From dd69942a22f62c03cd9429450466166e6245ec26 Mon Sep 17 00:00:00 2001 From: Michael Fero Date: Fri, 19 Apr 2019 10:26:14 -0400 Subject: [PATCH 01/27] Updating libuv version for *nix builds --- build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.yaml b/build.yaml index 8fb707fff..305851cb9 100644 --- a/build.yaml +++ b/build.yaml @@ -19,7 +19,7 @@ os: - centos/7-64/cpp - osx/high-sierra env: - LIBUV_VERSION: 1.26.0 + LIBUV_VERSION: 1.28.0 build: - script: | . ./cpp-driver/.build.sh From e6e3c59a859ee78a0c943dbb23de5460545504d2 Mon Sep 17 00:00:00 2001 From: Fero Date: Thu, 25 Apr 2019 13:29:24 -0400 Subject: [PATCH 02/27] CPP-766 - Allow RPM packages to be built on Amazon Linux (#230) --- cpp-driver/packaging/cassandra-cpp-driver.spec | 4 ++++ packaging/dse-cpp-driver.spec | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cpp-driver/packaging/cassandra-cpp-driver.spec b/cpp-driver/packaging/cassandra-cpp-driver.spec index 20e78927e..18ad5a07b 100644 --- a/cpp-driver/packaging/cassandra-cpp-driver.spec +++ b/cpp-driver/packaging/cassandra-cpp-driver.spec @@ -1,4 +1,6 @@ +%if 0%{!?amzn} %define distnum %(/usr/lib/rpm/redhat/dist.sh --distnum) +%endif Name: cassandra-cpp-driver Epoch: 1 @@ -14,9 +16,11 @@ Source1: cassandra.pc.in Source2: cassandra_static.pc.in BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +%if 0%{?distnum} %if %{distnum} == 5 BuildRequires: buildsys-macros >= 5 %endif +%endif BuildRequires: cmake >= 2.6.4 BuildRequires: libuv-devel >= %{libuv_version} BuildRequires: openssl-devel >= 0.9.8e diff --git a/packaging/dse-cpp-driver.spec b/packaging/dse-cpp-driver.spec index bad3a68a7..c1fd7715c 100644 --- a/packaging/dse-cpp-driver.spec +++ b/packaging/dse-cpp-driver.spec @@ -1,4 +1,6 @@ +%if 0%{!?amzn} %define distnum %(/usr/lib/rpm/redhat/dist.sh --distnum) +%endif Name: dse-cpp-driver Epoch: 1 @@ -14,9 +16,11 @@ Source1: dse.pc.in Source2: dse_static.pc.in BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +%if 0%{?distnum} %if %{distnum} == 5 BuildRequires: buildsys-macros >= 5 %endif +%endif BuildRequires: cmake >= 2.6.4 BuildRequires: libuv-devel >= %{libuv_version} BuildRequires: openssl-devel >= 0.9.8e From 53354e980cfa4ce5b3f9af43245fbe7aef8db80a Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Mon, 29 Apr 2019 15:53:28 -0400 Subject: [PATCH 03/27] CPP-764 - Move internal components from `namespace cass` to `namespace datastax::internal` (#233) --- .../gtests/src/integration/driver_utils.cpp | 31 +- cpp-driver/gtests/src/integration/logger.cpp | 11 +- .../policies/ignore_retry_policy.hpp | 16 +- .../policies/next_host_retry_policy.hpp | 16 +- .../gtests/src/integration/rest_client.cpp | 6 +- .../gtests/src/integration/shared_ptr.hpp | 10 +- .../simulacron/simulacron_cluster.cpp | 8 +- .../tests/test_null_string_params.cpp | 6 +- .../src/integration/tests/test_session.cpp | 8 +- .../gtests/src/unit/event_loop_test.hpp | 13 +- cpp-driver/gtests/src/unit/main.cpp | 9 +- cpp-driver/gtests/src/unit/mockssandra.cpp | 64 +-- cpp-driver/gtests/src/unit/mockssandra.hpp | 30 +- .../gtests/src/unit/test_token_map_utils.hpp | 174 ++++--- .../gtests/src/unit/tests/test_address.cpp | 14 +- .../gtests/src/unit/tests/test_async.cpp | 15 +- .../gtests/src/unit/tests/test_atomic.cpp | 10 +- .../src/unit/tests/test_class_type_parser.cpp | 181 +++---- .../gtests/src/unit/tests/test_cluster.cpp | 9 +- .../gtests/src/unit/tests/test_connection.cpp | 3 +- .../unit/tests/test_control_connection.cpp | 4 +- .../src/unit/tests/test_copy_on_write.cpp | 15 +- .../src/unit/tests/test_cql_type_parser.cpp | 134 ++--- .../gtests/src/unit/tests/test_data_type.cpp | 41 +- .../gtests/src/unit/tests/test_decoder.cpp | 56 ++- .../gtests/src/unit/tests/test_encode.cpp | 2 +- .../gtests/src/unit/tests/test_event_loop.cpp | 35 +- .../src/unit/tests/test_exec_profile.cpp | 225 ++++----- .../gtests/src/unit/tests/test_future.cpp | 32 +- .../gtests/src/unit/tests/test_get_time.cpp | 10 +- .../gtests/src/unit/tests/test_hash_table.cpp | 23 +- .../src/unit/tests/test_load_balancing.cpp | 462 +++++++++--------- .../src/unit/tests/test_loop_watcher.cpp | 27 +- cpp-driver/gtests/src/unit/tests/test_md5.cpp | 4 +- .../gtests/src/unit/tests/test_metadata.cpp | 30 +- .../gtests/src/unit/tests/test_metrics.cpp | 46 +- .../src/unit/tests/test_micro_timer.cpp | 3 +- .../src/unit/tests/test_name_resolver.cpp | 7 +- .../gtests/src/unit/tests/test_pool.cpp | 3 +- .../gtests/src/unit/tests/test_random.cpp | 8 +- .../unit/tests/test_replication_strategy.cpp | 170 +++---- .../src/unit/tests/test_request_processor.cpp | 9 +- .../gtests/src/unit/tests/test_resolver.cpp | 10 +- .../src/unit/tests/test_retry_policies.cpp | 21 +- .../src/unit/tests/test_routing_key.cpp | 58 ++- .../src/unit/tests/test_scoped_lock.cpp | 18 +- .../src/unit/tests/test_serialization.cpp | 44 +- .../gtests/src/unit/tests/test_session.cpp | 153 +++--- .../src/unit/tests/test_session_base.cpp | 91 ++-- .../src/unit/tests/test_small_vector.cpp | 4 +- .../gtests/src/unit/tests/test_socket.cpp | 20 +- .../src/unit/tests/test_startup_options.cpp | 78 +-- .../gtests/src/unit/tests/test_statement.cpp | 38 +- .../src/unit/tests/test_stream_manager.cpp | 8 +- .../gtests/src/unit/tests/test_string_ref.cpp | 46 +- .../src/unit/tests/test_tcp_connector.cpp | 6 +- .../gtests/src/unit/tests/test_timer.cpp | 7 +- .../src/unit/tests/test_timestamp_gen.cpp | 26 +- .../gtests/src/unit/tests/test_token.cpp | 192 ++++---- .../gtests/src/unit/tests/test_token_map.cpp | 156 +++--- .../gtests/src/unit/tests/test_tracing.cpp | 34 +- .../gtests/src/unit/tests/test_utils.cpp | 30 +- .../gtests/src/unit/tests/test_uuids.cpp | 11 +- .../gtests/src/unit/tests/test_value.cpp | 28 +- .../src/unit/tests/test_wait_for_handler.cpp | 3 +- cpp-driver/gtests/src/unit/uint128.hpp | 6 +- cpp-driver/gtests/src/unit/unit.cpp | 30 +- cpp-driver/gtests/src/unit/unit.hpp | 24 +- cpp-driver/src/abstract_data.cpp | 4 +- cpp-driver/src/abstract_data.hpp | 8 +- cpp-driver/src/address.cpp | 7 +- cpp-driver/src/address.hpp | 14 +- cpp-driver/src/aligned_storage.hpp | 5 +- cpp-driver/src/allocated.cpp | 4 +- cpp-driver/src/allocated.hpp | 4 +- cpp-driver/src/allocator.hpp | 4 +- cpp-driver/src/async.cpp | 4 +- cpp-driver/src/async.hpp | 6 +- cpp-driver/src/atomic.hpp | 1 - cpp-driver/src/atomic/atomic_boost.hpp | 4 +- cpp-driver/src/atomic/atomic_intrinsics.hpp | 4 +- .../src/atomic/atomic_intrinsics_gcc.hpp | 4 +- .../src/atomic/atomic_intrinsics_msvc.hpp | 4 +- cpp-driver/src/atomic/atomic_std.hpp | 4 +- cpp-driver/src/auth.cpp | 11 +- cpp-driver/src/auth.hpp | 6 +- cpp-driver/src/auth_requests.cpp | 4 +- cpp-driver/src/auth_requests.hpp | 4 +- cpp-driver/src/auth_responses.cpp | 8 +- cpp-driver/src/auth_responses.hpp | 4 +- cpp-driver/src/batch_request.cpp | 15 +- cpp-driver/src/batch_request.hpp | 6 +- cpp-driver/src/blacklist_dc_policy.cpp | 4 +- cpp-driver/src/blacklist_dc_policy.hpp | 4 +- cpp-driver/src/blacklist_policy.cpp | 4 +- cpp-driver/src/blacklist_policy.hpp | 4 +- cpp-driver/src/buffer.hpp | 24 +- cpp-driver/src/callback.hpp | 4 +- cpp-driver/src/cluster.cpp | 11 +- cpp-driver/src/cluster.hpp | 4 +- cpp-driver/src/cluster_config.cpp | 69 +-- cpp-driver/src/cluster_config.hpp | 6 +- cpp-driver/src/cluster_connector.cpp | 10 +- cpp-driver/src/cluster_connector.hpp | 9 +- cpp-driver/src/collection.cpp | 41 +- cpp-driver/src/collection.hpp | 9 +- cpp-driver/src/collection_iterator.cpp | 4 +- cpp-driver/src/collection_iterator.hpp | 4 +- cpp-driver/src/config.cpp | 4 +- cpp-driver/src/config.hpp | 4 +- cpp-driver/src/connection.cpp | 9 +- cpp-driver/src/connection.hpp | 4 +- cpp-driver/src/connection_pool.cpp | 5 +- cpp-driver/src/connection_pool.hpp | 4 +- cpp-driver/src/connection_pool_connector.cpp | 5 +- cpp-driver/src/connection_pool_connector.hpp | 6 +- cpp-driver/src/connection_pool_manager.cpp | 5 +- cpp-driver/src/connection_pool_manager.hpp | 4 +- .../connection_pool_manager_initializer.cpp | 5 +- .../connection_pool_manager_initializer.hpp | 6 +- cpp-driver/src/connector.cpp | 9 +- cpp-driver/src/connector.hpp | 6 +- cpp-driver/src/control_connection.cpp | 9 +- cpp-driver/src/control_connection.hpp | 4 +- cpp-driver/src/control_connector.cpp | 9 +- cpp-driver/src/control_connector.hpp | 6 +- cpp-driver/src/copy_on_write_ptr.hpp | 4 +- cpp-driver/src/data_type.cpp | 129 +++-- cpp-driver/src/data_type.hpp | 8 +- cpp-driver/src/data_type_parser.cpp | 5 +- cpp-driver/src/data_type_parser.hpp | 4 +- cpp-driver/src/dc_aware_policy.cpp | 10 +- cpp-driver/src/dc_aware_policy.hpp | 6 +- cpp-driver/src/decoder.cpp | 12 +- cpp-driver/src/decoder.hpp | 76 +-- cpp-driver/src/delayed_connector.cpp | 5 +- cpp-driver/src/delayed_connector.hpp | 6 +- cpp-driver/src/dense_hash_map.hpp | 8 +- cpp-driver/src/dense_hash_set.hpp | 8 +- cpp-driver/src/deque.hpp | 8 +- cpp-driver/src/driver_info.cpp | 4 +- cpp-driver/src/driver_info.hpp | 4 +- cpp-driver/src/encode.cpp | 12 +- cpp-driver/src/encode.hpp | 5 +- cpp-driver/src/error_response.cpp | 10 +- cpp-driver/src/error_response.hpp | 6 +- cpp-driver/src/event_loop.cpp | 5 +- cpp-driver/src/event_loop.hpp | 4 +- cpp-driver/src/event_response.cpp | 4 +- cpp-driver/src/event_response.hpp | 4 +- cpp-driver/src/execute_request.cpp | 4 +- cpp-driver/src/execute_request.hpp | 4 +- cpp-driver/src/execution_profile.cpp | 39 +- cpp-driver/src/execution_profile.hpp | 6 +- cpp-driver/src/fixed_allocator.hpp | 4 +- cpp-driver/src/fixnl.sh | 11 + cpp-driver/src/future.cpp | 68 ++- cpp-driver/src/future.hpp | 6 +- cpp-driver/src/get_time-mac.cpp | 5 +- cpp-driver/src/get_time-unix.cpp | 6 +- cpp-driver/src/get_time-win.cpp | 5 +- cpp-driver/src/get_time.hpp | 4 +- cpp-driver/src/hash.hpp | 4 +- cpp-driver/src/hash_table.hpp | 6 +- cpp-driver/src/histogram_wrapper.hpp | 4 +- cpp-driver/src/host.cpp | 9 +- cpp-driver/src/host.hpp | 4 +- cpp-driver/src/host_targeting_policy.cpp | 10 +- cpp-driver/src/host_targeting_policy.hpp | 6 +- cpp-driver/src/iterator.cpp | 31 +- cpp-driver/src/iterator.hpp | 6 +- cpp-driver/src/json.hpp | 30 +- cpp-driver/src/latency_aware_policy.cpp | 6 +- cpp-driver/src/latency_aware_policy.hpp | 4 +- cpp-driver/src/list.hpp | 4 +- cpp-driver/src/list_policy.cpp | 6 +- cpp-driver/src/list_policy.hpp | 5 +- cpp-driver/src/load_balancing.hpp | 8 +- cpp-driver/src/logger.cpp | 14 +- cpp-driver/src/logger.hpp | 8 +- cpp-driver/src/loop_watcher.hpp | 6 +- cpp-driver/src/map.hpp | 8 +- cpp-driver/src/map_iterator.cpp | 4 +- cpp-driver/src/map_iterator.hpp | 4 +- cpp-driver/src/md5.cpp | 4 +- cpp-driver/src/md5.hpp | 4 +- cpp-driver/src/memory.cpp | 9 +- cpp-driver/src/memory.hpp | 4 +- cpp-driver/src/metadata.cpp | 91 ++-- cpp-driver/src/metadata.hpp | 40 +- cpp-driver/src/metrics.hpp | 4 +- cpp-driver/src/micro_timer.cpp | 4 +- cpp-driver/src/micro_timer.hpp | 6 +- cpp-driver/src/monitor_reporting.cpp | 4 +- cpp-driver/src/monitor_reporting.hpp | 4 +- cpp-driver/src/mpmc_queue.hpp | 4 +- cpp-driver/src/murmur3.cpp | 5 +- cpp-driver/src/murmur3.hpp | 4 +- cpp-driver/src/name_resolver.hpp | 6 +- cpp-driver/src/options_request.hpp | 4 +- cpp-driver/src/pooled_connection.cpp | 5 +- cpp-driver/src/pooled_connection.hpp | 4 +- cpp-driver/src/prepare_all_handler.cpp | 5 +- cpp-driver/src/prepare_all_handler.hpp | 4 +- cpp-driver/src/prepare_host_handler.cpp | 5 +- cpp-driver/src/prepare_host_handler.hpp | 6 +- cpp-driver/src/prepare_request.cpp | 4 +- cpp-driver/src/prepare_request.hpp | 4 +- cpp-driver/src/prepared.cpp | 22 +- cpp-driver/src/prepared.hpp | 6 +- cpp-driver/src/protocol.cpp | 4 +- cpp-driver/src/protocol.hpp | 4 +- cpp-driver/src/query_request.cpp | 5 +- cpp-driver/src/query_request.hpp | 4 +- cpp-driver/src/random.cpp | 6 +- cpp-driver/src/random.hpp | 5 +- cpp-driver/src/ready_response.hpp | 4 +- cpp-driver/src/ref_counted.hpp | 4 +- cpp-driver/src/register_request.cpp | 5 +- cpp-driver/src/register_request.hpp | 4 +- cpp-driver/src/request.cpp | 8 +- cpp-driver/src/request.hpp | 6 +- cpp-driver/src/request_callback.cpp | 5 +- cpp-driver/src/request_callback.hpp | 4 +- cpp-driver/src/request_handler.cpp | 10 +- cpp-driver/src/request_handler.hpp | 4 +- cpp-driver/src/request_processor.cpp | 10 +- cpp-driver/src/request_processor.hpp | 6 +- .../src/request_processor_initializer.cpp | 10 +- .../src/request_processor_initializer.hpp | 6 +- cpp-driver/src/resolver.hpp | 8 +- cpp-driver/src/response.cpp | 5 +- cpp-driver/src/response.hpp | 4 +- cpp-driver/src/result_iterator.hpp | 4 +- cpp-driver/src/result_metadata.cpp | 6 +- cpp-driver/src/result_metadata.hpp | 4 +- cpp-driver/src/result_response.cpp | 16 +- cpp-driver/src/result_response.hpp | 6 +- cpp-driver/src/retry_policy.cpp | 21 +- cpp-driver/src/retry_policy.hpp | 7 +- cpp-driver/src/ring_buffer.cpp | 6 +- cpp-driver/src/ring_buffer.hpp | 6 +- cpp-driver/src/round_robin_policy.cpp | 6 +- cpp-driver/src/round_robin_policy.hpp | 4 +- cpp-driver/src/row.cpp | 11 +- cpp-driver/src/row.hpp | 6 +- cpp-driver/src/row_iterator.hpp | 4 +- cpp-driver/src/schema_agreement_handler.cpp | 5 +- cpp-driver/src/schema_agreement_handler.hpp | 4 +- cpp-driver/src/scoped_lock.hpp | 4 +- cpp-driver/src/scoped_ptr.hpp | 4 +- cpp-driver/src/serialization.hpp | 4 +- cpp-driver/src/session.cpp | 37 +- cpp-driver/src/session.hpp | 6 +- cpp-driver/src/session_base.cpp | 10 +- cpp-driver/src/session_base.hpp | 9 +- cpp-driver/src/set.hpp | 8 +- cpp-driver/src/small_dense_hash_map.hpp | 4 +- cpp-driver/src/small_vector.hpp | 4 +- cpp-driver/src/socket.cpp | 5 +- cpp-driver/src/socket.hpp | 6 +- cpp-driver/src/socket_connector.cpp | 9 +- cpp-driver/src/socket_connector.hpp | 6 +- cpp-driver/src/speculative_execution.hpp | 4 +- cpp-driver/src/spin_lock.hpp | 4 +- cpp-driver/src/spsc_queue.hpp | 4 +- cpp-driver/src/ssl.cpp | 10 +- cpp-driver/src/ssl.hpp | 6 +- cpp-driver/src/ssl/ring_buffer_bio.cpp | 6 +- cpp-driver/src/ssl/ring_buffer_bio.hpp | 6 +- cpp-driver/src/ssl/ssl_no_impl.cpp | 24 +- cpp-driver/src/ssl/ssl_no_impl.hpp | 5 +- cpp-driver/src/ssl/ssl_openssl_impl.cpp | 6 +- cpp-driver/src/ssl/ssl_openssl_impl.hpp | 4 +- cpp-driver/src/stack.hpp | 4 +- cpp-driver/src/startup_request.cpp | 5 +- cpp-driver/src/startup_request.hpp | 4 +- cpp-driver/src/statement.cpp | 100 ++-- cpp-driver/src/statement.hpp | 6 +- cpp-driver/src/stream_manager.hpp | 4 +- cpp-driver/src/string.hpp | 22 +- cpp-driver/src/string_ref.cpp | 5 +- cpp-driver/src/string_ref.hpp | 18 +- cpp-driver/src/supported_response.cpp | 4 +- cpp-driver/src/supported_response.hpp | 4 +- cpp-driver/src/tcp_connector.hpp | 6 +- cpp-driver/src/testing.cpp | 14 +- cpp-driver/src/testing.hpp | 4 +- cpp-driver/src/third_party/curl/hostcheck.hpp | 1 - cpp-driver/src/timer.cpp | 4 +- cpp-driver/src/timer.hpp | 6 +- cpp-driver/src/timestamp_generator.cpp | 16 +- cpp-driver/src/timestamp_generator.hpp | 7 +- cpp-driver/src/token_aware_policy.cpp | 6 +- cpp-driver/src/token_aware_policy.hpp | 4 +- cpp-driver/src/token_map.cpp | 5 +- cpp-driver/src/token_map.hpp | 6 +- cpp-driver/src/token_map_impl.cpp | 5 +- cpp-driver/src/token_map_impl.hpp | 10 +- cpp-driver/src/tracing_data_handler.cpp | 5 +- cpp-driver/src/tracing_data_handler.hpp | 4 +- cpp-driver/src/tuple.cpp | 35 +- cpp-driver/src/tuple.hpp | 9 +- cpp-driver/src/types.hpp | 4 +- cpp-driver/src/user_type_field_iterator.cpp | 4 +- cpp-driver/src/user_type_field_iterator.hpp | 4 +- cpp-driver/src/user_type_value.cpp | 44 +- cpp-driver/src/user_type_value.hpp | 6 +- cpp-driver/src/utils.cpp | 4 +- cpp-driver/src/utils.hpp | 7 +- cpp-driver/src/uuids.cpp | 15 +- cpp-driver/src/uuids.hpp | 6 +- cpp-driver/src/value.cpp | 21 +- cpp-driver/src/value.hpp | 6 +- cpp-driver/src/vector.hpp | 8 +- cpp-driver/src/wait_for_handler.cpp | 11 +- cpp-driver/src/wait_for_handler.hpp | 4 +- cpp-driver/src/whitelist_dc_policy.cpp | 4 +- cpp-driver/src/whitelist_dc_policy.hpp | 4 +- cpp-driver/src/whitelist_policy.cpp | 4 +- cpp-driver/src/whitelist_policy.hpp | 4 +- .../integration_tests/src/policy_tools.cpp | 6 +- .../integration_tests/src/test_config.cpp | 20 +- .../src/test_control_connection.cpp | 4 +- .../src/test_latency_aware_policy.cpp | 10 +- .../src/test_prepare_on_up_or_add_host.cpp | 4 +- .../src/test_prepared_batch.cpp | 4 +- .../src/test_prepared_existing.cpp | 6 +- .../src/test_speculative_execution_policy.cpp | 20 +- .../integration_tests/src/test_timestamps.cpp | 17 +- .../src/test_token_aware_policy.cpp | 8 +- src/client_insights.cpp | 277 +++++------ src/client_insights.hpp | 38 +- src/cluster_config.cpp | 36 +- src/collection.cpp | 6 +- src/date_range.cpp | 102 ++-- src/date_range.hpp | 6 +- src/driver_info.cpp | 4 +- src/dse_auth.cpp | 64 +-- src/dse_auth.hpp | 38 +- src/graph.cpp | 107 ++-- src/graph.hpp | 69 ++- src/line_string.cpp | 24 +- src/line_string.hpp | 18 +- src/point.hpp | 4 +- src/polygon.cpp | 27 +- src/polygon.hpp | 18 +- src/protocol.cpp | 5 +- src/serialization.hpp | 12 +- src/statement.cpp | 10 +- src/tuple.cpp | 10 +- src/user_type_value.cpp | 14 +- src/validate.hpp | 6 +- src/value.cpp | 49 +- src/wkt.cpp | 6 +- src/wkt.hpp | 1 - src/wkt.rl | 2 +- tests/src/integration/embedded_ads.hpp | 8 +- tests/src/unit/main.cpp | 11 +- tests/src/unit/tests/test_client_insights.cpp | 317 ++++++------ tests/src/unit/tests/test_graph_object.cpp | 25 +- tests/src/unit/tests/test_line_string.cpp | 22 +- tests/src/unit/tests/test_polygon.cpp | 20 +- .../src/unit/tests/test_protocol_version.cpp | 2 +- 364 files changed, 3541 insertions(+), 3375 deletions(-) create mode 100755 cpp-driver/src/fixnl.sh diff --git a/cpp-driver/gtests/src/integration/driver_utils.cpp b/cpp-driver/gtests/src/integration/driver_utils.cpp index 3c0ba2cfa..8ceabc4e4 100644 --- a/cpp-driver/gtests/src/integration/driver_utils.cpp +++ b/cpp-driver/gtests/src/integration/driver_utils.cpp @@ -24,15 +24,18 @@ #include "request_handler.hpp" #include "statement.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + std::vector test::driver::internals::Utils::attempted_hosts( CassFuture* future) { std::vector attempted_hosts; if (future) { - cass::Future* cass_future = static_cast(future); - if (cass_future->type() == cass::Future::FUTURE_TYPE_RESPONSE) { - cass::ResponseFuture* response = static_cast(cass_future); - cass::AddressVec attempted_addresses = response->attempted_addresses(); - for (cass::AddressVec::iterator iterator = attempted_addresses.begin(); + Future* cass_future = static_cast(future); + if (cass_future->type() == Future::FUTURE_TYPE_RESPONSE) { + ResponseFuture* response = static_cast(cass_future); + AddressVec attempted_addresses = response->attempted_addresses(); + for (AddressVec::iterator iterator = attempted_addresses.begin(); iterator != attempted_addresses.end(); ++iterator) { attempted_hosts.push_back(iterator->to_string().c_str()); } @@ -48,9 +51,9 @@ unsigned int test::driver::internals::Utils::connect_timeout(CassCluster* cluste std::string test::driver::internals::Utils::contact_points(CassCluster* cluster) { std::string contact_points; - const cass::ContactPointList& contact_points_list = + const ContactPointList& contact_points_list = cluster->config().contact_points(); - for (cass::ContactPointList::const_iterator it = contact_points_list.begin(); + for (ContactPointList::const_iterator it = contact_points_list.begin(); it != contact_points_list.end(); ++it) { if (contact_points.size() > 0) { contact_points.push_back(','); @@ -61,18 +64,18 @@ std::string test::driver::internals::Utils::contact_points(CassCluster* cluster) } std::string test::driver::internals::Utils::driver_name() { - return cass::driver_name(); + return datastax::internal::driver_name(); } std::string test::driver::internals::Utils::driver_version() { - return cass::driver_version(); + return datastax::internal::driver_version(); } std::string test::driver::internals::Utils::host(CassFuture* future) { if (future) { - cass::Future* cass_future = static_cast(future); - if (cass_future->type() == cass::Future::FUTURE_TYPE_RESPONSE) { - return static_cast(cass_future)->address().to_string().c_str(); + Future* cass_future = static_cast(future); + if (cass_future->type() == Future::FUTURE_TYPE_RESPONSE) { + return static_cast(cass_future)->address().to_string().c_str(); } } return ""; @@ -80,7 +83,7 @@ std::string test::driver::internals::Utils::host(CassFuture* future) { int64_t test::driver::internals::Utils::murmur3_hash( const std::string& value) { - return cass::MurmurHash3_x64_128(value.data(), value.size(), 0); + return MurmurHash3_x64_128(value.data(), value.size(), 0); } int test::driver::internals::Utils::port(CassCluster* cluster) { @@ -90,7 +93,7 @@ int test::driver::internals::Utils::port(CassCluster* cluster) { void test::driver::internals::Utils::set_record_attempted_hosts( CassStatement* statement, bool enable) { if (statement) { - static_cast(statement) + static_cast(statement) ->set_record_attempted_addresses(enable); } } diff --git a/cpp-driver/gtests/src/integration/logger.cpp b/cpp-driver/gtests/src/integration/logger.cpp index 6db09bbb4..d9d5ed4d7 100644 --- a/cpp-driver/gtests/src/integration/logger.cpp +++ b/cpp-driver/gtests/src/integration/logger.cpp @@ -25,6 +25,7 @@ #include #include +using namespace datastax::internal; using namespace test::driver; #define LOGGER_DIRECTORY "log" @@ -75,12 +76,12 @@ void Logger::initialize(const std::string& test_case, const std::string& test_na } void Logger::add_critera(const std::string& criteria) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); search_criteria_.push_back(criteria); } void test::driver::Logger::clear_critera() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); search_criteria_.clear(); } @@ -90,7 +91,7 @@ size_t Logger::count() { void Logger::log(const CassLogMessage* log, void* data) { Logger* logger = static_cast(data); - cass::ScopedMutex lock(&(logger->mutex_)); + ScopedMutex lock(&(logger->mutex_)); // Get the log message std::string message = log->message; @@ -133,13 +134,13 @@ void Logger::log(const CassLogMessage* log, void* data) { } void test::driver::Logger::reset() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); search_criteria_.clear(); count_ = 0; } void test::driver::Logger::reset_count() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); count_ = 0; } diff --git a/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp b/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp index 6f928466a..983978a29 100644 --- a/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp +++ b/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp @@ -27,10 +27,10 @@ namespace driver { /** * Retry policy that will create an ignore decision for retry */ -class IgnoreRetryPolicy : public cass::DefaultRetryPolicy { +class IgnoreRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { public: IgnoreRetryPolicy() - : cass::DefaultRetryPolicy() { } + : datastax::internal::core::DefaultRetryPolicy() { } /** * Create an instance of the retry policy for use with the driver @@ -38,12 +38,12 @@ class IgnoreRetryPolicy : public cass::DefaultRetryPolicy { * @return Driver ready retry policy */ static ::test::driver::RetryPolicy policy() { - cass::RetryPolicy* policy = new IgnoreRetryPolicy(); + datastax::internal::core::RetryPolicy* policy = new IgnoreRetryPolicy(); policy->inc_ref(); return CassRetryPolicy::to(policy); } - RetryDecision on_read_timeout(const cass::Request* request, + RetryDecision on_read_timeout(const datastax::internal::core::Request* request, CassConsistency cl, int received, int required, @@ -51,7 +51,7 @@ class IgnoreRetryPolicy : public cass::DefaultRetryPolicy { int num_retries) const { return RetryDecision::ignore(); } - RetryDecision on_write_timeout(const cass::Request* request, + RetryDecision on_write_timeout(const datastax::internal::core::Request* request, CassConsistency cl, int received, int required, @@ -59,16 +59,16 @@ class IgnoreRetryPolicy : public cass::DefaultRetryPolicy { int num_retries) const { return RetryDecision::ignore(); } - virtual RetryDecision on_unavailable(const cass::Request* request, + virtual RetryDecision on_unavailable(const datastax::internal::core::Request* request, CassConsistency cl, int required, int alive, int num_retries) const { return RetryDecision::ignore(); } - virtual RetryDecision on_request_error(const cass::Request* request, + virtual RetryDecision on_request_error(const datastax::internal::core::Request* request, CassConsistency cl, - const cass::ErrorResponse* error, + const datastax::internal::core::ErrorResponse* error, int num_retries) const { return RetryDecision::ignore(); } diff --git a/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp b/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp index 8974ecbf1..0ebf05eaa 100644 --- a/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp +++ b/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp @@ -27,10 +27,10 @@ namespace driver { /** * Retry policy that will retry the statement on the next host */ -class NextHostRetryPolicy : public cass::DefaultRetryPolicy { +class NextHostRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { public: NextHostRetryPolicy() - : cass::DefaultRetryPolicy() { } + : datastax::internal::core::DefaultRetryPolicy() { } /** * Create an instance of the retry policy for use with the driver @@ -38,12 +38,12 @@ class NextHostRetryPolicy : public cass::DefaultRetryPolicy { * @return Driver ready retry policy */ static ::test::driver::RetryPolicy policy() { - cass::RetryPolicy* policy = new NextHostRetryPolicy(); + datastax::internal::core::RetryPolicy* policy = new NextHostRetryPolicy(); policy->inc_ref(); return CassRetryPolicy::to(policy); } - RetryDecision on_read_timeout(const cass::Request* request, + RetryDecision on_read_timeout(const datastax::internal::core::Request* request, CassConsistency cl, int received, int required, @@ -51,7 +51,7 @@ class NextHostRetryPolicy : public cass::DefaultRetryPolicy { int num_retries) const { return RetryDecision::retry_next_host(cl); } - RetryDecision on_write_timeout(const cass::Request* request, + RetryDecision on_write_timeout(const datastax::internal::core::Request* request, CassConsistency cl, int received, int required, @@ -59,16 +59,16 @@ class NextHostRetryPolicy : public cass::DefaultRetryPolicy { int num_retries) const { return RetryDecision::retry_next_host(cl); } - virtual RetryDecision on_unavailable(const cass::Request* request, + virtual RetryDecision on_unavailable(const datastax::internal::core::Request* request, CassConsistency cl, int required, int alive, int num_retries) const { return RetryDecision::retry_next_host(cl); } - virtual RetryDecision on_request_error(const cass::Request* request, + virtual RetryDecision on_request_error(const datastax::internal::core::Request* request, CassConsistency cl, - const cass::ErrorResponse* error, + const datastax::internal::core::ErrorResponse* error, int num_retries) const { return RetryDecision::retry_next_host(cl); } diff --git a/cpp-driver/gtests/src/integration/rest_client.cpp b/cpp-driver/gtests/src/integration/rest_client.cpp index a50a2febb..f7e380c56 100644 --- a/cpp-driver/gtests/src/integration/rest_client.cpp +++ b/cpp-driver/gtests/src/integration/rest_client.cpp @@ -25,6 +25,8 @@ #define HTTP_EOL "\r\n" #define OUTPUT_BUFFER_SIZE 10240ul +using namespace datastax::internal::core; + // Static initializations uv_buf_t RestClient::write_buf_; uv_write_t RestClient::write_req_; @@ -62,8 +64,8 @@ const Response RestClient::send_request(const Request& request) { http_request.loop = &loop; // Create the IPv4 socket address - const cass::Address address(request.address.c_str(), - static_cast(request.port)); + const Address address(request.address.c_str(), + static_cast(request.port)); // Initialize the client TCP request uv_tcp_t tcp; diff --git a/cpp-driver/gtests/src/integration/shared_ptr.hpp b/cpp-driver/gtests/src/integration/shared_ptr.hpp index 7174bf2f2..ac202786c 100644 --- a/cpp-driver/gtests/src/integration/shared_ptr.hpp +++ b/cpp-driver/gtests/src/integration/shared_ptr.hpp @@ -27,8 +27,8 @@ struct StdDeleter { /** * Reference counted objects container */ -template > -class ObjectRef : public cass::RefCounted< ObjectRef > { +template > +class ObjectRef : public datastax::internal::RefCounted< ObjectRef > { public: ObjectRef(T* ptr) : ptr_(ptr) {} @@ -56,14 +56,14 @@ class ObjectRef : public cass::RefCounted< ObjectRef > { /** * Shared pointer for object references */ -template > +template > class SharedPtr { public: SharedPtr(T* ptr = NULL) : object_(NULL) { if (ptr) { ObjectRef* object_ref = new ObjectRef(ptr); - object_ = cass::SharedRefPtr >(object_ref); + object_ = datastax::internal::SharedRefPtr >(object_ref); } } @@ -101,7 +101,7 @@ class SharedPtr { /** * Object reference */ - cass::SharedRefPtr > object_; + datastax::internal::SharedRefPtr > object_; }; #endif // __SHARED_PTR_HPP__ diff --git a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp index 24c0dcbaa..2de4967a0 100644 --- a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp +++ b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp @@ -39,6 +39,8 @@ #define MAX_TOKEN static_cast(INT64_MAX) - 1 #define DATA_CENTER_PREFIX "dc" +using datastax::internal::ScopedMutex; + // Initialize the mutex, running status, thread, and default data center nodes uv_mutex_t test::SimulacronCluster::mutex_; bool test::SimulacronCluster::is_ready_ = false; @@ -275,7 +277,7 @@ void test::SimulacronCluster::remove_primed_queries(unsigned int node /*= 0*/) { void test::SimulacronCluster::handle_exit(uv_process_t* process, int64_t error_code, int term_signal) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); TEST_LOG("Process " << process->pid << " Terminated: " << error_code); uv_close(reinterpret_cast(process), NULL); } @@ -283,7 +285,7 @@ void test::SimulacronCluster::handle_exit(uv_process_t* process, void test::SimulacronCluster::handle_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); buffer->base = new char[OUTPUT_BUFFER_SIZE]; buffer->len = OUTPUT_BUFFER_SIZE; } @@ -352,7 +354,7 @@ void test::SimulacronCluster::handle_thread_create(void* arg) { void test::SimulacronCluster::handle_read(uv_stream_t* stream, ssize_t buffer_length, const uv_buf_t* buffer) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); if (buffer_length > 0) { // Process the buffer and log it std::string message(buffer->base, buffer_length); diff --git a/cpp-driver/gtests/src/integration/tests/test_null_string_params.cpp b/cpp-driver/gtests/src/integration/tests/test_null_string_params.cpp index f02c1a243..63543abe1 100644 --- a/cpp-driver/gtests/src/integration/tests/test_null_string_params.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_null_string_params.cpp @@ -27,6 +27,8 @@ // Name of materialized view used in this test file. #define VIEW_NAME "my_view" +using namespace datastax::internal::core; + /** * Null string api args test, without initially creating a connection. */ @@ -672,8 +674,8 @@ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, UserTypeFunctions) { */ CASSANDRA_INTEGRATION_TEST_F(SchemaNullStringApiArgsTest, MiscellaneousFunctions) { CHECK_VERSION(2.2.0); - cass::ResultResponse response; - cass::Row r(&response); + ResultResponse response; + datastax::internal::core::Row r(&response); CassRow* row = CassRow::to(&r); EXPECT_EQ(NULL, cass_row_get_column_by_name(row, NULL)); diff --git a/cpp-driver/gtests/src/integration/tests/test_session.cpp b/cpp-driver/gtests/src/integration/tests/test_session.cpp index 238775303..835c80019 100644 --- a/cpp-driver/gtests/src/integration/tests/test_session.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_session.cpp @@ -24,6 +24,8 @@ #define EVENT_MAXIMUM_WAIT_TIME_MS 5000 #define EVENT_WAIT_FOR_NAP_MS 100 +using namespace datastax::internal; + class SessionTest : public Integration { public: typedef std::pair Event; @@ -42,7 +44,7 @@ class SessionTest : public Integration { } void check_event(CassHostListenerEvent expected_event, short expected_node) { - cass::ScopedMutex l(&mutex_); + ScopedMutex l(&mutex_); std::stringstream expected_address; expected_address << ccm_->get_ip_prefix() << expected_node; Event event = events_.front(); @@ -61,11 +63,11 @@ class SessionTest : public Integration { protected: size_t event_count() { - cass::ScopedMutex l(&mutex_); + ScopedMutex l(&mutex_); return events_.size(); } void add_event(CassHostListenerEvent event, CassInet inet) { - cass::ScopedMutex l(&mutex_); + ScopedMutex l(&mutex_); char address[CASS_INET_STRING_LENGTH]; cass_inet_string(inet, address); diff --git a/cpp-driver/gtests/src/unit/event_loop_test.hpp b/cpp-driver/gtests/src/unit/event_loop_test.hpp index 19986222b..d6254a363 100644 --- a/cpp-driver/gtests/src/unit/event_loop_test.hpp +++ b/cpp-driver/gtests/src/unit/event_loop_test.hpp @@ -20,9 +20,12 @@ #include "unit.hpp" #include "event_loop.hpp" +using datastax::internal::core::Future; +using datastax::internal::core::EventLoop; + class EventLoopTest : public Unit { public: - EventLoopTest(const cass::String& thread_name) + EventLoopTest(const datastax::String& thread_name) :thread_name_(thread_name) { } virtual void SetUp() { @@ -54,15 +57,15 @@ class EventLoopTest : public Unit { * @param outage_plan The outage plan to execute. * @return Generic future instance. */ - cass::Future::Ptr execute_outage_plan(OutagePlan* outage_plan) { - cass::Future::Ptr future(new cass::Future(cass::Future::FUTURE_TYPE_GENERIC)); + Future::Ptr execute_outage_plan(OutagePlan* outage_plan) { + Future::Ptr future(new Future(Future::FUTURE_TYPE_GENERIC)); add_task(new ExecuteOutagePlan(outage_plan, future)); return future; } private: - cass::EventLoop event_loop_; - cass::String thread_name_; + EventLoop event_loop_; + datastax::String thread_name_; }; #endif // EVENT_LOOP_TEST_HPP diff --git a/cpp-driver/gtests/src/unit/main.cpp b/cpp-driver/gtests/src/unit/main.cpp index 679fa129b..cbfbe5e6f 100644 --- a/cpp-driver/gtests/src/unit/main.cpp +++ b/cpp-driver/gtests/src/unit/main.cpp @@ -20,6 +20,9 @@ #include "string.hpp" #include "ssl.hpp" +using datastax::String; +using datastax::internal::core::SslContextFactory; + #if defined(_WIN32) && defined(_DEBUG) # ifdef USE_VISUAL_LEAK_DETECTOR # include @@ -132,7 +135,7 @@ class BootstrapListener : public testing::EmptyTestEventListener { << CASS_VERSION_MAJOR << "." << CASS_VERSION_MINOR << "." << CASS_VERSION_PATCH; - if (!cass::String(CASS_VERSION_SUFFIX).empty()) { + if (!String(CASS_VERSION_SUFFIX).empty()) { std::cout << "-" << CASS_VERSION_SUFFIX; } std::cout << std::endl; @@ -144,11 +147,11 @@ class BootstrapListener : public testing::EmptyTestEventListener { } void OnTestStart(const testing::TestInfo& test_information) { - cass::SslContextFactory::init(); + SslContextFactory::init(); } void OnTestEnd(const testing::TestInfo& test_information) { - cass::SslContextFactory::cleanup(); + SslContextFactory::cleanup(); } }; diff --git a/cpp-driver/gtests/src/unit/mockssandra.cpp b/cpp-driver/gtests/src/unit/mockssandra.cpp index e48375ec4..b0b3ca2ce 100644 --- a/cpp-driver/gtests/src/unit/mockssandra.cpp +++ b/cpp-driver/gtests/src/unit/mockssandra.cpp @@ -29,9 +29,11 @@ # include "winsock.h" #endif -using cass::Memory; -using cass::ScopedMutex; -using cass::OStringStream; +using datastax::internal::bind_callback; +using datastax::internal::Memory; +using datastax::internal::ScopedMutex; +using datastax::internal::OStringStream; +using datastax::internal::core::UuidGen; #define SSL_BUF_SIZE 8192 #define CASSANDRA_VERSION "3.11.4" @@ -439,7 +441,7 @@ bool ServerConnection::use_ssl(const String& key, return true; } -using cass::Task; +using datastax::internal::core::Task; class RunListen : public Task { public: @@ -1013,7 +1015,7 @@ static String encode_header(int8_t version, int8_t flags, int16_t stream, int8_t } encode_int32(len, &header); if (flags & FLAG_TRACING) { - cass::UuidGen gen; + UuidGen gen; CassUuid tracing_id; gen.generate_random(&tracing_id); encode_uuid(tracing_id, &header); @@ -1072,7 +1074,7 @@ void Collection::encode(int protocol_version, String* output) const { Value::Value() : type_(NUL) { } -Value::Value(const cass::String& value) +Value::Value(const String& value) : type_(VALUE) , value_(new String(value)) { } @@ -1109,12 +1111,12 @@ void Value::encode(int protocol_version, String* output) const { } } -Row::Builder& Row::Builder::text(const cass::String& text) { +Row::Builder& Row::Builder::text(const String& text) { values_.push_back(Value(text)); return *this; } -Row::Builder& Row::Builder::inet(const cass::Address& inet) { +Row::Builder& Row::Builder::inet(const Address& inet) { String value; uint8_t buf[16]; uint8_t len = inet.to_inet(buf); @@ -1137,7 +1139,7 @@ Row::Builder& Row::Builder::collection(const Collection& collection) { return *this; } -void Row::encode(int protocol_version, cass::String* output) const { +void Row::encode(int protocol_version, String* output) const { for (Vector::const_iterator it = values_.begin(), end = values_.end(); it != end; ++it) { it->encode(protocol_version, output); @@ -1283,12 +1285,12 @@ Action::Builder& Action::Builder::system_traces() { return execute(new SystemTraces()); } -Action::Builder& Action::Builder::use_keyspace(const cass::String& keyspace) { +Action::Builder& Action::Builder::use_keyspace(const String& keyspace) { return execute((new UseKeyspace(keyspace))); } -Action::Builder& Action::Builder::plaintext_auth(const cass::String& username, - const cass::String& password) { +Action::Builder& Action::Builder::plaintext_auth(const String& username, + const String& password) { return execute((new PlaintextAuth(username, password))); } @@ -1324,15 +1326,15 @@ Action* Action::Builder::build() { return first_.release(); } -Action::PredicateBuilder Action::Builder::is_address(const cass::Address& address) { +Action::PredicateBuilder Action::Builder::is_address(const Address& address) { return PredicateBuilder(execute(new IsAddress(address))); } -Action::PredicateBuilder Action::Builder::is_address(const cass::String& address, int port) { +Action::PredicateBuilder Action::Builder::is_address(const String& address, int port) { return PredicateBuilder(execute(new IsAddress(Address(address, port)))); } -Action::PredicateBuilder Action::Builder::is_query(const cass::String& query) { +Action::PredicateBuilder Action::Builder::is_query(const String& query) { return PredicateBuilder(execute(new IsQuery(query))); } @@ -1362,7 +1364,7 @@ void Request::write(int8_t opcode, const String& body) { write(stream_, opcode, body); } -void Request::write(int16_t stream, int8_t opcode, const cass::String& body) { +void Request::write(int16_t stream, int8_t opcode, const String& body) { client_->write(encode_header(version_, flags_, stream, opcode, body.size()) + body); } @@ -1377,7 +1379,7 @@ void Request::wait(uint64_t timeout, const Action* action) { inc_ref(); timer_action_ = action; timer_.start(client_->server()->loop(), timeout, - cass::bind_callback(&Request::on_timeout, this)); + bind_callback(&Request::on_timeout, this)); } void Request::close() { @@ -1999,7 +2001,7 @@ void ClientConnection::on_read(const char* data, size_t len) { handler_.decode(this, data, len); } -Event::Event(const cass::String& event_body) +Event::Event(const String& event_body) : event_body_(event_body) { } void Event::run(internal::ServerConnection* server_connection) { @@ -2024,7 +2026,7 @@ Event::Ptr TopologyChangeEvent::removed_node(const Address& address) { return Ptr(new TopologyChangeEvent(REMOVED_NODE, address)); } -cass::String TopologyChangeEvent::encode(TopologyChangeEvent::Type type, const cass::Address& address) { +String TopologyChangeEvent::encode(TopologyChangeEvent::Type type, const Address& address) { String body; encode_string("TOPOLOGY_CHANGE", &body); switch(type) { @@ -2046,7 +2048,7 @@ Event::Ptr StatusChangeEvent::up(const Address& address) { return Ptr(new StatusChangeEvent(UP, address)); } -Event::Ptr StatusChangeEvent::down(const cass::Address& address) { +Event::Ptr StatusChangeEvent::down(const Address& address) { return Ptr(new StatusChangeEvent(DOWN, address)); } @@ -2104,9 +2106,9 @@ Event::Ptr SchemaChangeEvent::aggregate(SchemaChangeEvent::Type type, args_types)); } -cass::String SchemaChangeEvent::encode(SchemaChangeEvent::Target target, SchemaChangeEvent::Type type, - const cass::String& keyspace_name, const cass::String& target_name, - const Vector& arg_types) { +String SchemaChangeEvent::encode(SchemaChangeEvent::Target target, SchemaChangeEvent::Type type, + const String& keyspace_name, const String& target_name, + const Vector& arg_types) { String body; encode_string("SCHEMA_CHANGE", &body); switch (type) { @@ -2189,7 +2191,7 @@ int Cluster::start_all(EventLoopGroup* event_loop_group) { return 0; } -void Cluster::start_all_async(cass::EventLoopGroup* event_loop_group) { +void Cluster::start_all_async(EventLoopGroup* event_loop_group) { for (size_t i = 0; i < servers_.size(); ++i) { Server& server = servers_[i]; server.connection->listen(event_loop_group); @@ -2220,7 +2222,7 @@ int Cluster::start(EventLoopGroup* event_loop_group, size_t node) { return server.connection->wait_listen(); } -void Cluster::start_async(cass::EventLoopGroup* event_loop_group, size_t node) { +void Cluster::start_async(EventLoopGroup* event_loop_group, size_t node) { if (node < 1 || node > servers_.size()) { return; } @@ -2245,7 +2247,7 @@ void Cluster::stop_async(size_t node) { server.connection->close(); } -int Cluster::add(cass::EventLoopGroup* event_loop_group, size_t node) { +int Cluster::add(EventLoopGroup* event_loop_group, size_t node) { if (node < 1 || node > servers_.size()) { return -1; } @@ -2328,9 +2330,9 @@ Address Ipv4AddressGenerator::next() { return Address(buf, port_); } -Host::Host(const cass::Address& address, - const cass::String& dc, - const cass::String& rack, +Host::Host(const Address& address, + const String& dc, + const String& rack, MT19937_64& token_rng, int num_tokens) : address(address) @@ -2346,7 +2348,7 @@ Host::Host(const cass::Address& address, } SimpleEventLoopGroup::SimpleEventLoopGroup(size_t num_threads) - : cass::RoundRobinEventLoopGroup(num_threads) { + : RoundRobinEventLoopGroup(num_threads) { int rc = init("mockssandra"); UNUSED_(rc); assert(rc == 0 && "Unable to initialize simple event loop"); @@ -2368,7 +2370,7 @@ SimpleRequestHandlerBuilder::SimpleRequestHandlerBuilder() on(OPCODE_QUERY).system_local().system_peers().empty_rows_result(1); } -AuthRequestHandlerBuilder::AuthRequestHandlerBuilder(const cass::String& username, +AuthRequestHandlerBuilder::AuthRequestHandlerBuilder(const String& username, const String& password) : SimpleRequestHandlerBuilder() { on(mockssandra::OPCODE_STARTUP) diff --git a/cpp-driver/gtests/src/unit/mockssandra.hpp b/cpp-driver/gtests/src/unit/mockssandra.hpp index 913f2b87e..42eda0dec 100644 --- a/cpp-driver/gtests/src/unit/mockssandra.hpp +++ b/cpp-driver/gtests/src/unit/mockssandra.hpp @@ -43,17 +43,19 @@ #define CLIENT_OPTIONS_QUERY "client.options" -using cass::Address; -using cass::EventLoop; -using cass::EventLoopGroup; -using cass::List; -using cass::String; -using cass::Task; -using cass::Timer; -using cass::Vector; -using cass::RefCounted; -using cass::SharedRefPtr; -using cass::ScopedPtr; +using datastax::String; +using datastax::internal::Atomic; +using datastax::internal::List; +using datastax::internal::Vector; +using datastax::internal::RefCounted; +using datastax::internal::SharedRefPtr; +using datastax::internal::ScopedPtr; +using datastax::internal::core::Address; +using datastax::internal::core::EventLoop; +using datastax::internal::core::EventLoopGroup; +using datastax::internal::core::RoundRobinEventLoopGroup; +using datastax::internal::core::Task; +using datastax::internal::core::Timer; namespace mockssandra { @@ -1222,7 +1224,7 @@ class Cluster { void stop(size_t node); void stop_async(size_t node); - int add(cass::EventLoopGroup* event_loop_group, size_t node); + int add(EventLoopGroup* event_loop_group, size_t node); void remove(size_t node); const Host& host(const Address& address) const; @@ -1251,7 +1253,7 @@ class Cluster { Host host; internal::ServerConnection::Ptr connection; - cass::Atomic is_removed; + Atomic is_removed; }; typedef Vector Servers; @@ -1265,7 +1267,7 @@ class Cluster { MT19937_64 token_rng_; }; -class SimpleEventLoopGroup : public cass::RoundRobinEventLoopGroup { +class SimpleEventLoopGroup : public RoundRobinEventLoopGroup { public: SimpleEventLoopGroup(size_t num_threads = 1); ~SimpleEventLoopGroup(); diff --git a/cpp-driver/gtests/src/unit/test_token_map_utils.hpp b/cpp-driver/gtests/src/unit/test_token_map_utils.hpp index 9b46ee83e..179f26069 100644 --- a/cpp-driver/gtests/src/unit/test_token_map_utils.hpp +++ b/cpp-driver/gtests/src/unit/test_token_map_utils.hpp @@ -26,6 +26,20 @@ #define CASS_PROTOCOL_VERSION 3 +using datastax::String; +using datastax::internal::OStringStream; +using datastax::internal::core::Address; +using datastax::internal::core::ByteOrderedPartitioner; +using datastax::internal::core::DataType; +using datastax::internal::core::Decoder; +using datastax::internal::core::CollectionType; +using datastax::internal::core::Host; +using datastax::internal::core::VersionNumber; +using datastax::internal::core::Murmur3Partitioner; +using datastax::internal::core::RandomPartitioner; +using datastax::internal::core::ResultResponse; +using datastax::internal::core::TokenMap; + class BufferBuilder { public: char* data() const { @@ -38,7 +52,7 @@ class BufferBuilder { template void append(T value) { - cass::String buffer(size_of(value), 0); + String buffer(size_of(value), 0); encode(&buffer[0], value); buffer_.append(buffer); } @@ -49,7 +63,7 @@ class BufferBuilder { append(value); } - void append_string(const cass::String& str) { + void append_string(const String& str) { append(str.size()); append(str); } @@ -73,43 +87,43 @@ class BufferBuilder { return sizeof(int64_t); } - static size_t size_of(const cass::String& value) { + static size_t size_of(const String& value) { return value.size(); } static void encode(char* buf, uint16_t value) { - cass::encode_uint16(buf, value); + datastax::internal::encode_uint16(buf, value); } static void encode(char* buf, int32_t value) { - cass::encode_int32(buf, value); + datastax::internal::encode_int32(buf, value); } static void encode(char* buf, int64_t value) { - cass::encode_int64(buf, value); + datastax::internal::encode_int64(buf, value); } - static void encode(char* buf, const cass::String& value) { + static void encode(char* buf, const String& value) { memcpy(buf, value.data(), value.size()); } private: - cass::String buffer_; + String buffer_; }; -typedef cass::Map ReplicationMap; +typedef datastax::internal::Map ReplicationMap; struct ColumnMetadata { - ColumnMetadata(const cass::String& name, const cass::DataType::ConstPtr& data_type) + ColumnMetadata(const String& name, const DataType::ConstPtr& data_type) : name(name) , data_type(data_type) { } - cass::String name; - cass::DataType::ConstPtr data_type; + String name; + DataType::ConstPtr data_type; }; -typedef cass::Vector ColumnMetadataVec; -typedef cass::Vector TokenVec; -typedef cass::Vector Murmur3TokenVec; +typedef datastax::internal::Vector ColumnMetadataVec; +typedef datastax::internal::Vector TokenVec; +typedef datastax::internal::Vector Murmur3TokenVec; class RowResultResponseBuilder : protected BufferBuilder { public: @@ -122,7 +136,7 @@ class RowResultResponseBuilder : protected BufferBuilder { append_string("table"); for (ColumnMetadataVec::const_iterator i = column_metadata.begin(), - end = column_metadata.end(); i != end; ++i) { + end = column_metadata.end(); i != end; ++i) { append_column_metadata(*i); } @@ -130,9 +144,9 @@ class RowResultResponseBuilder : protected BufferBuilder { append(0); // Row count (updated later) } - void append_keyspace_row_v3(const cass::String& keyspace_name, + void append_keyspace_row_v3(const String& keyspace_name, const ReplicationMap& replication) { - append_value(keyspace_name); + append_value(keyspace_name); size_t size = sizeof(int32_t); for (ReplicationMap::const_iterator i = replication.begin(), @@ -145,33 +159,33 @@ class RowResultResponseBuilder : protected BufferBuilder { append(replication.size()); // Element count for (ReplicationMap::const_iterator i = replication.begin(), end = replication.end(); i != end; ++i) { - append_value(i->first); - append_value(i->second); + append_value(i->first); + append_value(i->second); } ++row_count_; } - void append_keyspace_row_v3(const cass::String& keyspace_name, - const cass::String& strategy_class, - const cass::String& strategy_options) { - append_value(keyspace_name); - append_value(strategy_class); - append_value(strategy_options); + void append_keyspace_row_v3(const String& keyspace_name, + const String& strategy_class, + const String& strategy_options) { + append_value(keyspace_name); + append_value(strategy_class); + append_value(strategy_options); ++row_count_; } void append_local_peers_row_v3(const TokenVec& tokens, - const cass::String& partitioner, - const cass::String& dc, - const cass::String& rack, - const cass::String& release_version) { - append_value(rack); - append_value(dc); - append_value(release_version); + const String& partitioner, + const String& dc, + const String& rack, + const String& release_version) { + append_value(rack); + append_value(dc); + append_value(release_version); if (!partitioner.empty()) { - append_value(partitioner); + append_value(partitioner); } size_t size = sizeof(int32_t); @@ -184,7 +198,7 @@ class RowResultResponseBuilder : protected BufferBuilder { append(tokens.size()); // Element count for (TokenVec::const_iterator i = tokens.begin(), end = tokens.end(); i != end; ++i) { - append_value(*i); + append_value(*i); } ++row_count_; @@ -195,17 +209,17 @@ class RowResultResponseBuilder : protected BufferBuilder { append_data_type(metadata.data_type); } - void append_data_type(const cass::DataType::ConstPtr& data_type) { + void append_data_type(const DataType::ConstPtr& data_type) { append(data_type->value_type()); switch (data_type->value_type()) { case CASS_VALUE_TYPE_LIST: case CASS_VALUE_TYPE_SET: - append_data_type(cass::CollectionType::ConstPtr(data_type)->types()[0]); + append_data_type(CollectionType::ConstPtr(data_type)->types()[0]); break; case CASS_VALUE_TYPE_MAP: - append_data_type(cass::CollectionType::ConstPtr(data_type)->types()[0]); - append_data_type(cass::CollectionType::ConstPtr(data_type)->types()[1]); + append_data_type(CollectionType::ConstPtr(data_type)->types()[0]); + append_data_type(CollectionType::ConstPtr(data_type)->types()[1]); break; case CASS_VALUE_TYPE_TUPLE: case CASS_VALUE_TYPE_UDT: @@ -216,34 +230,34 @@ class RowResultResponseBuilder : protected BufferBuilder { } } - cass::ResultResponse* finish() { + ResultResponse* finish() { encode_at(row_count_index_, row_count_); - cass::Decoder decoder(data(), size(), CASS_PROTOCOL_VERSION); + Decoder decoder(data(), size(), CASS_PROTOCOL_VERSION); result_response_.decode(decoder); return &result_response_; } private: - cass::ResultResponse result_response_; + ResultResponse result_response_; size_t row_count_index_; int32_t row_count_; }; -inline cass::String to_string(const cass::Murmur3Partitioner::Token& token) { - cass::OStringStream ss; +inline String to_string(const Murmur3Partitioner::Token& token) { + OStringStream ss; ss << token; return ss.str(); } -inline cass::String to_string(const cass::RandomPartitioner::Token& token) { +inline String to_string(const RandomPartitioner::Token& token) { numeric::uint128_t r(token.lo); r |= (numeric::uint128_t(token.hi) << 64); return r.to_string(); } -inline cass::String to_string(const cass::ByteOrderedPartitioner::Token& token) { - cass::String s; - for (cass::ByteOrderedPartitioner::Token::const_iterator it = token.begin(), +inline String to_string(const ByteOrderedPartitioner::Token& token) { + String s; + for (ByteOrderedPartitioner::Token::const_iterator it = token.begin(), end = token.end(); it != end; ++it) { s.push_back(static_cast(*it)); } @@ -272,55 +286,55 @@ inline TokenVec murmur3_tokens(const Murmur3TokenVec& murmur3_tokens) { return tokens; } -inline void add_keyspace_simple(const cass::String& keyspace_name, +inline void add_keyspace_simple(const String& keyspace_name, size_t replication_factor, - cass::TokenMap* token_map) { + TokenMap* token_map) { - cass::DataType::ConstPtr varchar_data_type(new cass::DataType(CASS_VALUE_TYPE_VARCHAR)); + DataType::ConstPtr varchar_data_type(new DataType(CASS_VALUE_TYPE_VARCHAR)); ColumnMetadataVec column_metadata; column_metadata.push_back(ColumnMetadata("keyspace_name", varchar_data_type)); - column_metadata.push_back(ColumnMetadata("replication", cass::CollectionType::map(varchar_data_type, varchar_data_type, true))); + column_metadata.push_back(ColumnMetadata("replication", CollectionType::map(varchar_data_type, varchar_data_type, true))); RowResultResponseBuilder builder(column_metadata); ReplicationMap replication; replication["class"] = CASS_SIMPLE_STRATEGY; - cass::OStringStream ss; + OStringStream ss; ss << replication_factor; replication["replication_factor"] = ss.str(); builder.append_keyspace_row_v3(keyspace_name, replication); builder.finish(); - token_map->add_keyspaces(cass::VersionNumber(3, 0, 0), builder.finish()); + token_map->add_keyspaces(VersionNumber(3, 0, 0), builder.finish()); } -inline void add_keyspace_network_topology(const cass::String& keyspace_name, +inline void add_keyspace_network_topology(const String& keyspace_name, ReplicationMap& replication, - cass::TokenMap* token_map) { + TokenMap* token_map) { - cass::DataType::ConstPtr varchar_data_type(new cass::DataType(CASS_VALUE_TYPE_VARCHAR)); + DataType::ConstPtr varchar_data_type(new DataType(CASS_VALUE_TYPE_VARCHAR)); ColumnMetadataVec column_metadata; column_metadata.push_back(ColumnMetadata("keyspace_name", varchar_data_type)); - column_metadata.push_back(ColumnMetadata("replication", cass::CollectionType::map(varchar_data_type, varchar_data_type, true))); + column_metadata.push_back(ColumnMetadata("replication", CollectionType::map(varchar_data_type, varchar_data_type, true))); RowResultResponseBuilder builder(column_metadata); replication["class"] = CASS_NETWORK_TOPOLOGY_STRATEGY; builder.append_keyspace_row_v3(keyspace_name, replication); builder.finish(); - token_map->add_keyspaces(cass::VersionNumber(3, 0, 0), builder.finish()); + token_map->add_keyspaces(VersionNumber(3, 0, 0), builder.finish()); } -inline cass::Host::Ptr create_host(const cass::Address& address, - const TokenVec& tokens, - const cass::String& partitioner = "", - const cass::String& dc = "dc", - const cass::String& rack = "rack", - const cass::String& release_version = "3.11") { - cass::Host::Ptr host(new cass::Host(address)); +inline Host::Ptr create_host(const Address& address, + const TokenVec& tokens, + const String& partitioner = "", + const String& dc = "dc", + const String& rack = "rack", + const String& release_version = "3.11") { + Host::Ptr host(new Host(address)); - cass::DataType::ConstPtr varchar_data_type(new cass::DataType(CASS_VALUE_TYPE_VARCHAR)); + DataType::ConstPtr varchar_data_type(new DataType(CASS_VALUE_TYPE_VARCHAR)); ColumnMetadataVec column_metadata; column_metadata.push_back(ColumnMetadata("data_center", varchar_data_type)); @@ -329,7 +343,7 @@ inline cass::Host::Ptr create_host(const cass::Address& address, if (!partitioner.empty()) { column_metadata.push_back(ColumnMetadata("partitioner", varchar_data_type)); } - column_metadata.push_back(ColumnMetadata("tokens", cass::CollectionType::list(varchar_data_type, true))); + column_metadata.push_back(ColumnMetadata("tokens", CollectionType::list(varchar_data_type, true))); RowResultResponseBuilder builder(column_metadata); builder.append_local_peers_row_v3(tokens, partitioner, dc, rack, release_version); @@ -339,27 +353,27 @@ inline cass::Host::Ptr create_host(const cass::Address& address, return host; } -inline cass::Host::Ptr create_host(const cass::String& address, - const TokenVec& tokens, - const cass::String& partitioner = "", - const cass::String& dc = "dc", - const cass::String& rack = "rack", - const cass::String& release_version = "3.11") { - return create_host(cass::Address(address, 9042), tokens, partitioner, dc, rack, release_version); +inline Host::Ptr create_host(const String& address, + const TokenVec& tokens, + const String& partitioner = "", + const String& dc = "dc", + const String& rack = "rack", + const String& release_version = "3.11") { + return create_host(Address(address, 9042), tokens, partitioner, dc, rack, release_version); } -inline cass::RandomPartitioner::Token create_random_token(const cass::String& s) { - cass::RandomPartitioner::Token token; +inline RandomPartitioner::Token create_random_token(const String& s) { + RandomPartitioner::Token token; numeric::uint128_t i(s); token.lo = (i & numeric::uint128_t("0xFFFFFFFFFFFFFFFF")).to_base_type(); token.hi = (i >> 64).to_base_type(); return token; } -inline cass::ByteOrderedPartitioner::Token create_byte_ordered_token(const cass::String& s) { - cass::ByteOrderedPartitioner::Token token; - for (cass::String::const_iterator i = s.begin(), +inline ByteOrderedPartitioner::Token create_byte_ordered_token(const String& s) { + ByteOrderedPartitioner::Token token; + for (String::const_iterator i = s.begin(), end = s.end(); i != end; ++i) { token.push_back(static_cast(*i)); } diff --git a/cpp-driver/gtests/src/unit/tests/test_address.cpp b/cpp-driver/gtests/src/unit/tests/test_address.cpp index 2be844338..c318445c5 100644 --- a/cpp-driver/gtests/src/unit/tests/test_address.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_address.cpp @@ -18,14 +18,16 @@ #include "address.hpp" +using datastax::internal::core::Address; + TEST(AddressUnitTest, CompareIPv4) { - EXPECT_GT(cass::Address("255.255.255.255", 9042).compare(cass::Address("0.0.0.0", 9042)), 0); - EXPECT_LT(cass::Address("0.0.0.0", 9042).compare(cass::Address("255.255.255.255", 9042)), 0); - EXPECT_EQ(cass::Address("1.2.3.4", 9042).compare(cass::Address("1.2.3.4", 9042)), 0); + EXPECT_GT(Address("255.255.255.255", 9042).compare(Address("0.0.0.0", 9042)), 0); + EXPECT_LT(Address("0.0.0.0", 9042).compare(Address("255.255.255.255", 9042)), 0); + EXPECT_EQ(Address("1.2.3.4", 9042).compare(Address("1.2.3.4", 9042)), 0); } TEST(AddressUnitTest, CompareIPv6) { - EXPECT_GT(cass::Address("0.0.0.0", 1).compare(cass::Address("0.0.0.0", 0), true), 0); - EXPECT_LT(cass::Address("0.0.0.0", 0).compare(cass::Address("0.0.0.0", 1), true), 0); - EXPECT_EQ(cass::Address("0.0.0.0", 0).compare(cass::Address("0.0.0.0", 1), false), 0); + EXPECT_GT(Address("0.0.0.0", 1).compare(Address("0.0.0.0", 0), true), 0); + EXPECT_LT(Address("0.0.0.0", 0).compare(Address("0.0.0.0", 1), true), 0); + EXPECT_EQ(Address("0.0.0.0", 0).compare(Address("0.0.0.0", 1), false), 0); } diff --git a/cpp-driver/gtests/src/unit/tests/test_async.cpp b/cpp-driver/gtests/src/unit/tests/test_async.cpp index a21d482dd..7dd112066 100644 --- a/cpp-driver/gtests/src/unit/tests/test_async.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_async.cpp @@ -19,6 +19,9 @@ #include "async.hpp" #include "callback.hpp" +using datastax::internal::core::Async; +using datastax::internal::bind_callback; + class AsyncUnitTest : public LoopTest { public: AsyncUnitTest() @@ -27,14 +30,14 @@ class AsyncUnitTest : public LoopTest { bool is_callback_called() { return is_callback_called_; } protected: - void start(cass::Async* async) { + void start(Async* async) { ASSERT_EQ(0, async->start(loop(), - cass::bind_callback(&AsyncUnitTest::on_async, - this))); + bind_callback(&AsyncUnitTest::on_async, + this))); } private: - void on_async(cass::Async* async) { + void on_async(Async* async) { is_callback_called_ = true; async->close_handle(); } @@ -44,7 +47,7 @@ class AsyncUnitTest : public LoopTest { }; TEST_F(AsyncUnitTest, Simple) { - cass::Async async; + Async async; ASSERT_FALSE(async.is_running()); start(&async); @@ -62,7 +65,7 @@ TEST_F(AsyncUnitTest, Simple) { } TEST_F(AsyncUnitTest, NotStarted) { - cass::Async async; + Async async; ASSERT_FALSE(async.is_running()); ASSERT_FALSE(is_callback_called()); diff --git a/cpp-driver/gtests/src/unit/tests/test_atomic.cpp b/cpp-driver/gtests/src/unit/tests/test_atomic.cpp index 50910ddde..22d2ce59d 100644 --- a/cpp-driver/gtests/src/unit/tests/test_atomic.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_atomic.cpp @@ -21,6 +21,8 @@ #include #include +using datastax::internal::Atomic; + enum Enum { ONE, TWO, THREE }; @@ -35,7 +37,7 @@ void test_atomic_integer() { const T zero = static_cast(0); const T one = static_cast(1); - cass::Atomic i(zero); + Atomic i(zero); EXPECT_EQ(i.load(), zero); @@ -86,7 +88,7 @@ TEST(AtomicUnitTest, Integers) { } TEST(AtomicUnitTest, Enumeration) { - cass::Atomic e(ONE); + Atomic e(ONE); EXPECT_EQ(e.load(), ONE); @@ -116,7 +118,7 @@ TEST(AtomicUnitTest, Enumeration) { TEST(AtomicUnitTest, Pointer) { Object one, two; - cass::Atomic p(&one); + Atomic p(&one); EXPECT_EQ(p.load(), &one); @@ -145,7 +147,7 @@ TEST(AtomicUnitTest, Pointer) { } TEST(AtomicUnitTest, Boolean) { - cass::Atomic b(false); + Atomic b(false); EXPECT_EQ(b.load(), false); diff --git a/cpp-driver/gtests/src/unit/tests/test_class_type_parser.cpp b/cpp-driver/gtests/src/unit/tests/test_class_type_parser.cpp index 3627721ea..1d4a097af 100644 --- a/cpp-driver/gtests/src/unit/tests/test_class_type_parser.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_class_type_parser.cpp @@ -18,22 +18,25 @@ #include "data_type_parser.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + TEST(ClassTypeParserUnitTest, Simple) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - data_type = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.InetAddressType", cache); + data_type = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.InetAddressType", cache); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_INET); - data_type = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type)", cache); + data_type = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type)", cache); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TEXT); - data_type = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type)", cache); + data_type = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type)", cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); - cass::CollectionType::ConstPtr collection - = static_cast(data_type); + CollectionType::ConstPtr collection + = static_cast(data_type); ASSERT_EQ(collection->types().size(), 1u); EXPECT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_TEXT); } @@ -41,58 +44,58 @@ TEST(ClassTypeParserUnitTest, Simple) { TEST(ClassTypeParserUnitTest, Invalid) { cass_log_set_level(CASS_LOG_DISABLED); - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; // Premature end of string - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah,", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah,", cache)); // Empty - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType()", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType()", cache)); // Invalid hex - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah,ZZZZ", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(blah,ZZZZ", cache)); // Missing ':' - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(" - "foo,61646472657373," - "737472656574org.apache.cassandra.db.marshal.UTF8Type)", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(" + "foo,61646472657373," + "737472656574org.apache.cassandra.db.marshal.UTF8Type)", cache)); // Premature end of string - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type", cache)); - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.UTF8Type,", cache)); // Empty - EXPECT_FALSE(cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType()", cache)); + EXPECT_FALSE(DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType()", cache)); } TEST(ClassTypeParserUnitTest, UserDefinedType) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::DataType::ConstPtr data_type - = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(" - "foo,61646472657373," - "737472656574:org.apache.cassandra.db.marshal.UTF8Type," - "7a6970636f6465:org.apache.cassandra.db.marshal.Int32Type," - "70686f6e6573:org.apache.cassandra.db.marshal.SetType(" - "org.apache.cassandra.db.marshal.UserType(foo,70686f6e65,6e616d65:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))", - cache); + DataType::ConstPtr data_type + = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.UserType(" + "foo,61646472657373," + "737472656574:org.apache.cassandra.db.marshal.UTF8Type," + "7a6970636f6465:org.apache.cassandra.db.marshal.Int32Type," + "70686f6e6573:org.apache.cassandra.db.marshal.SetType(" + "org.apache.cassandra.db.marshal.UserType(foo,70686f6e65,6e616d65:org.apache.cassandra.db.marshal.UTF8Type,6e756d626572:org.apache.cassandra.db.marshal.UTF8Type)))", + cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_UDT); // Check external UDT - cass::UserType::ConstPtr udt(data_type); + UserType::ConstPtr udt(data_type); EXPECT_EQ(udt->keyspace(), "foo"); EXPECT_EQ(udt->type_name(), "address"); ASSERT_EQ(udt->fields().size(), 3u); - cass::UserType::FieldVec::const_iterator i; + UserType::FieldVec::const_iterator i; i = udt->fields().begin(); @@ -109,15 +112,15 @@ TEST(ClassTypeParserUnitTest, UserDefinedType) { EXPECT_EQ(i->name, "phones"); ASSERT_EQ(i->type->value_type(), CASS_VALUE_TYPE_SET); - cass::CollectionType::ConstPtr collection - = static_cast(i->type); + CollectionType::ConstPtr collection + = static_cast(i->type); ASSERT_EQ(collection->types().size(), 1u); ASSERT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_UDT); // Check internal UDT - udt = static_cast(collection->types()[0]); + udt = static_cast(collection->types()[0]); EXPECT_EQ(udt->keyspace(), "foo"); EXPECT_EQ(udt->type_name(), "phone"); @@ -135,17 +138,17 @@ TEST(ClassTypeParserUnitTest, UserDefinedType) { } TEST(ClassTypeParserUnitTest, Tuple) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::DataType::ConstPtr data_type - = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.TupleType(" - "org.apache.cassandra.db.marshal.Int32Type," - "org.apache.cassandra.db.marshal.UTF8Type," - "org.apache.cassandra.db.marshal.FloatType)", cache); + DataType::ConstPtr data_type + = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.TupleType(" + "org.apache.cassandra.db.marshal.Int32Type," + "org.apache.cassandra.db.marshal.UTF8Type," + "org.apache.cassandra.db.marshal.FloatType)", cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TUPLE); - cass::TupleType::ConstPtr tuple = static_cast(data_type); + TupleType::ConstPtr tuple = static_cast(data_type); ASSERT_EQ(tuple->types().size(), 3u); @@ -155,19 +158,19 @@ TEST(ClassTypeParserUnitTest, Tuple) { } TEST(ClassTypeParserUnitTest, NestedCollections) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::DataType::ConstPtr data_type - = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.MapType(" - "org.apache.cassandra.db.marshal.UTF8Type," - "org.apache.cassandra.db.marshal.FrozenType(" - "org.apache.cassandra.db.marshal.MapType(" - "org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.Int32Type)))", cache); + DataType::ConstPtr data_type + = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.MapType(" + "org.apache.cassandra.db.marshal.UTF8Type," + "org.apache.cassandra.db.marshal.FrozenType(" + "org.apache.cassandra.db.marshal.MapType(" + "org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.Int32Type)))", cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_MAP); - cass::CollectionType::ConstPtr collection - = static_cast(data_type); + CollectionType::ConstPtr collection + = static_cast(data_type); ASSERT_EQ(collection->types().size(), 2u); @@ -175,8 +178,8 @@ TEST(ClassTypeParserUnitTest, NestedCollections) { ASSERT_EQ(collection->types()[1]->value_type(), CASS_VALUE_TYPE_MAP); - cass::CollectionType::ConstPtr nested_collection - = static_cast(collection->types()[1]); + CollectionType::ConstPtr nested_collection + = static_cast(collection->types()[1]); ASSERT_EQ(nested_collection->types().size(), 2u); EXPECT_EQ(nested_collection->types()[0]->value_type(), CASS_VALUE_TYPE_INT); @@ -184,12 +187,12 @@ TEST(ClassTypeParserUnitTest, NestedCollections) { } TEST(ClassTypeParserUnitTest, Composite) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::SharedRefPtr result - = cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" - "org.apache.cassandra.db.marshal.AsciiType," - "org.apache.cassandra.db.marshal.Int32Type)", cache); + SharedRefPtr result + = DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" + "org.apache.cassandra.db.marshal.AsciiType," + "org.apache.cassandra.db.marshal.Int32Type)", cache); EXPECT_TRUE(result->is_composite()); @@ -205,10 +208,10 @@ TEST(ClassTypeParserUnitTest, Composite) { } TEST(ClassTypeParserUnitTest, NotComposite) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::SharedRefPtr result - = cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.InetAddressType", cache); + SharedRefPtr result + = DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.InetAddressType", cache); ASSERT_EQ(result->types().size(), 1u); EXPECT_EQ(result->types()[0]->value_type(), CASS_VALUE_TYPE_INET); @@ -218,12 +221,12 @@ TEST(ClassTypeParserUnitTest, NotComposite) { } TEST(ClassTypeParserUnitTest, CompositeWithReversedType) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::SharedRefPtr result - = cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" - "org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType)," - "org.apache.cassandra.db.marshal.Int32Type)", cache); + SharedRefPtr result + = DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" + "org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType)," + "org.apache.cassandra.db.marshal.Int32Type)", cache); EXPECT_TRUE(result->is_composite()); @@ -239,17 +242,17 @@ TEST(ClassTypeParserUnitTest, CompositeWithReversedType) { } TEST(ClassTypeParserUnitTest, CompositeWithCollections) { - cass::SimpleDataTypeCache cache; - - cass::SharedRefPtr result - = cass::DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" - "org.apache.cassandra.db.marshal.Int32Type, " - "org.apache.cassandra.db.marshal.UTF8Type," - "org.apache.cassandra.db.marshal.ColumnToCollectionType(" - "6162:org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.Int32Type)," - "4A4b4C4D4e4F:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)," - "6A6b6C6D6e6F:org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.UTF8Type, org.apache.cassandra.db.marshal.LongType)" - "))", cache); + SimpleDataTypeCache cache; + + SharedRefPtr result + = DataTypeClassNameParser::parse_with_composite("org.apache.cassandra.db.marshal.CompositeType(" + "org.apache.cassandra.db.marshal.Int32Type, " + "org.apache.cassandra.db.marshal.UTF8Type," + "org.apache.cassandra.db.marshal.ColumnToCollectionType(" + "6162:org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.Int32Type)," + "4A4b4C4D4e4F:org.apache.cassandra.db.marshal.SetType(org.apache.cassandra.db.marshal.UTF8Type)," + "6A6b6C6D6e6F:org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.UTF8Type, org.apache.cassandra.db.marshal.LongType)" + "))", cache); EXPECT_TRUE(result->is_composite()); @@ -263,47 +266,47 @@ TEST(ClassTypeParserUnitTest, CompositeWithCollections) { ASSERT_EQ(result->collections().size(), 3u); - cass::ParseResult::CollectionMap::const_iterator i; + ParseResult::CollectionMap::const_iterator i; i = result->collections().find("ab"); - cass::CollectionType::ConstPtr collection; + CollectionType::ConstPtr collection; ASSERT_NE(i, result->collections().end()); ASSERT_EQ(i->second->value_type(), CASS_VALUE_TYPE_LIST); - collection = static_cast(i->second); + collection = static_cast(i->second); ASSERT_EQ(collection->types().size(), 1u); EXPECT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_INT); i = result->collections().find("JKLMNO"); ASSERT_NE(i, result->collections().end()); EXPECT_EQ(i->second->value_type(), CASS_VALUE_TYPE_SET); - collection = static_cast(i->second); + collection = static_cast(i->second); ASSERT_EQ(collection->types().size(), 1u); EXPECT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_TEXT); i = result->collections().find("jklmno"); ASSERT_NE(i, result->collections().end()); EXPECT_EQ(i->second->value_type(), CASS_VALUE_TYPE_MAP); - collection = static_cast(i->second); + collection = static_cast(i->second); ASSERT_EQ(collection->types().size(), 2u); EXPECT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_TEXT); EXPECT_EQ(collection->types()[1]->value_type(), CASS_VALUE_TYPE_BIGINT); } TEST(ClassTypeParserUnitTest, Frozen) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - data_type = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type))", cache); + data_type = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type))", cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); EXPECT_TRUE(data_type->is_frozen()); - data_type = cass::DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type)))", cache); + data_type = DataTypeClassNameParser::parse_one("org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.FrozenType(org.apache.cassandra.db.marshal.ListType(org.apache.cassandra.db.marshal.UTF8Type)))", cache); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); EXPECT_FALSE(data_type->is_frozen()); - cass::CollectionType::ConstPtr collection - = static_cast(data_type); + CollectionType::ConstPtr collection + = static_cast(data_type); ASSERT_EQ(collection->types().size(), 1u); EXPECT_EQ(collection->types()[0]->value_type(), CASS_VALUE_TYPE_LIST); EXPECT_TRUE(collection->types()[0]->is_frozen()); diff --git a/cpp-driver/gtests/src/unit/tests/test_cluster.cpp b/cpp-driver/gtests/src/unit/tests/test_cluster.cpp index 8338d6876..9d2973628 100644 --- a/cpp-driver/gtests/src/unit/tests/test_cluster.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_cluster.cpp @@ -20,19 +20,20 @@ #include "cluster_connector.hpp" #include "ref_counted.hpp" -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; class ClusterUnitTest : public EventLoopTest { public: ClusterUnitTest() : EventLoopTest("ClusterUnitTest") { } - class Future : public cass::Future { + class Future : public core::Future { public: typedef SharedRefPtr Ptr; Future() - : cass::Future(FUTURE_TYPE_GENERIC) { } + : core::Future(FUTURE_TYPE_GENERIC) { } ~Future() { if (cluster_) { @@ -237,7 +238,7 @@ class ClusterUnitTest : public EventLoopTest { virtual void on_reconnect(Cluster* cluster) { // Trigger an ADD event right after cluster connection. simple_cluster_.event( - mockssandra::TopologyChangeEvent::new_node(cass::Address("127.0.0.2", 9042))); + mockssandra::TopologyChangeEvent::new_node(Address("127.0.0.2", 9042))); } virtual void on_host_up(const Host::Ptr& host) { event_future_->set(); } diff --git a/cpp-driver/gtests/src/unit/tests/test_connection.cpp b/cpp-driver/gtests/src/unit/tests/test_connection.cpp index 22e5db413..cfeae404c 100644 --- a/cpp-driver/gtests/src/unit/tests/test_connection.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_connection.cpp @@ -27,7 +27,8 @@ #undef STATUS_TIMEOUT #endif -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; class ConnectionUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_control_connection.cpp b/cpp-driver/gtests/src/unit/tests/test_control_connection.cpp index 50c214e3d..b063df638 100644 --- a/cpp-driver/gtests/src/unit/tests/test_control_connection.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_control_connection.cpp @@ -23,7 +23,9 @@ #undef STATUS_TIMEOUT #endif -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; + using mockssandra::SchemaChangeEvent; using mockssandra::StatusChangeEvent; using mockssandra::TopologyChangeEvent; diff --git a/cpp-driver/gtests/src/unit/tests/test_copy_on_write.cpp b/cpp-driver/gtests/src/unit/tests/test_copy_on_write.cpp index 1b183dde9..a2494a1d0 100644 --- a/cpp-driver/gtests/src/unit/tests/test_copy_on_write.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_copy_on_write.cpp @@ -22,22 +22,25 @@ #include "string.hpp" #include "vector.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + TEST(CopyOnWriteUnitTest, Simple) { - cass::Vector* ptr = new cass::Vector(); - cass::CopyOnWritePtr > vec(ptr); + Vector* ptr = new Vector(); + CopyOnWritePtr > vec(ptr); // Only a single reference so no copy should be made - EXPECT_EQ(static_cast >&>(vec).operator->(), ptr); + EXPECT_EQ(static_cast >&>(vec).operator->(), ptr); vec->push_back(1); - EXPECT_EQ(static_cast >&>(vec).operator->(), ptr); + EXPECT_EQ(static_cast >&>(vec).operator->(), ptr); // Make const reference to object - const cass::CopyOnWritePtr > const_vec(vec); + const CopyOnWritePtr > const_vec(vec); EXPECT_EQ((*const_vec)[0], 1); EXPECT_EQ(const_vec.operator->(), ptr); // Force copy to be made vec->push_back(2); - EXPECT_NE(static_cast >&>(vec).operator->(), ptr); + EXPECT_NE(static_cast >&>(vec).operator->(), ptr); EXPECT_EQ(const_vec.operator->(), ptr); } diff --git a/cpp-driver/gtests/src/unit/tests/test_cql_type_parser.cpp b/cpp-driver/gtests/src/unit/tests/test_cql_type_parser.cpp index 57bdcdfdb..300eaf976 100644 --- a/cpp-driver/gtests/src/unit/tests/test_cql_type_parser.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_cql_type_parser.cpp @@ -18,111 +18,113 @@ #include "data_type_parser.hpp" +using namespace datastax::internal::core; + TEST(CqlTypeParserUnitTest, Simple) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); - data_type = cass::DataTypeCqlNameParser::parse("ascii", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("ascii", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_ASCII); - data_type = cass::DataTypeCqlNameParser::parse("bigint", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("bigint", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_BIGINT); - data_type = cass::DataTypeCqlNameParser::parse("blob", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("blob", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_BLOB); - data_type = cass::DataTypeCqlNameParser::parse("boolean", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("boolean", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_BOOLEAN); - data_type = cass::DataTypeCqlNameParser::parse("counter", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("counter", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_COUNTER); - data_type = cass::DataTypeCqlNameParser::parse("date", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("date", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_DATE); - data_type = cass::DataTypeCqlNameParser::parse("decimal", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("decimal", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_DECIMAL); - data_type = cass::DataTypeCqlNameParser::parse("double", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("double", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_DOUBLE); - data_type = cass::DataTypeCqlNameParser::parse("float", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("float", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_FLOAT); - data_type = cass::DataTypeCqlNameParser::parse("inet", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("inet", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_INET); - data_type = cass::DataTypeCqlNameParser::parse("int", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("int", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_INT); - data_type = cass::DataTypeCqlNameParser::parse("smallint", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("smallint", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_SMALL_INT); - data_type = cass::DataTypeCqlNameParser::parse("time", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("time", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TIME); - data_type = cass::DataTypeCqlNameParser::parse("timestamp", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("timestamp", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TIMESTAMP); - data_type = cass::DataTypeCqlNameParser::parse("timeuuid", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("timeuuid", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TIMEUUID); - data_type = cass::DataTypeCqlNameParser::parse("tinyint", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("tinyint", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TINY_INT); - data_type = cass::DataTypeCqlNameParser::parse("text", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("text", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TEXT); - data_type = cass::DataTypeCqlNameParser::parse("uuid", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("uuid", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_UUID); - data_type = cass::DataTypeCqlNameParser::parse("varchar", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("varchar", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_VARCHAR); - data_type = cass::DataTypeCqlNameParser::parse("varint", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("varint", cache, &keyspace); EXPECT_EQ(data_type->value_type(), CASS_VALUE_TYPE_VARINT); } TEST(CqlTypeParserUnitTest, Collections) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); - data_type = cass::DataTypeCqlNameParser::parse("list", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("list", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); - cass::CollectionType::ConstPtr list = static_cast(data_type); + CollectionType::ConstPtr list = static_cast(data_type); ASSERT_EQ(list->types().size(), 1u); EXPECT_EQ(list->types()[0]->value_type(), CASS_VALUE_TYPE_INT); - data_type = cass::DataTypeCqlNameParser::parse("set", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("set", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_SET); - cass::CollectionType::ConstPtr set = static_cast(data_type); + CollectionType::ConstPtr set = static_cast(data_type); ASSERT_EQ(set->types().size(), 1u); EXPECT_EQ(set->types()[0]->value_type(), CASS_VALUE_TYPE_INT); - data_type = cass::DataTypeCqlNameParser::parse("map", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("map", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_MAP); - cass::CollectionType::ConstPtr map = static_cast(data_type); + CollectionType::ConstPtr map = static_cast(data_type); ASSERT_EQ(map->types().size(), 2u); EXPECT_EQ(map->types()[0]->value_type(), CASS_VALUE_TYPE_INT); EXPECT_EQ(map->types()[1]->value_type(), CASS_VALUE_TYPE_TEXT); } TEST(CqlTypeParserUnitTest, Tuple) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); - data_type = cass::DataTypeCqlNameParser::parse("tuple", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("tuple", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_TUPLE); - cass::CollectionType::ConstPtr tuple = static_cast(data_type); + CollectionType::ConstPtr tuple = static_cast(data_type); ASSERT_EQ(tuple->types().size(), 3u); EXPECT_EQ(tuple->types()[0]->value_type(), CASS_VALUE_TYPE_INT); EXPECT_EQ(tuple->types()[1]->value_type(), CASS_VALUE_TYPE_BIGINT); @@ -130,18 +132,18 @@ TEST(CqlTypeParserUnitTest, Tuple) { } TEST(CqlTypeParserUnitTest, UserDefinedType) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); EXPECT_TRUE(keyspace.user_types().empty()); - data_type = cass::DataTypeCqlNameParser::parse("type1", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("type1", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_UDT); - cass::UserType::ConstPtr udt = static_cast(data_type); + UserType::ConstPtr udt = static_cast(data_type); EXPECT_EQ(udt->type_name(), "type1"); EXPECT_EQ(udt->keyspace(), "keyspace1"); @@ -149,25 +151,25 @@ TEST(CqlTypeParserUnitTest, UserDefinedType) { } TEST(CqlTypeParserUnitTest, Frozen) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); { - data_type = cass::DataTypeCqlNameParser::parse("frozen>", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("frozen>", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); - cass::CollectionType::ConstPtr list = static_cast(data_type); + CollectionType::ConstPtr list = static_cast(data_type); ASSERT_EQ(list->types().size(), 1u); EXPECT_TRUE(list->is_frozen()); EXPECT_EQ(list->types()[0]->value_type(), CASS_VALUE_TYPE_INT); } { - data_type = cass::DataTypeCqlNameParser::parse("list>>", cache, &keyspace); + data_type = DataTypeCqlNameParser::parse("list>>", cache, &keyspace); ASSERT_EQ(data_type->value_type(), CASS_VALUE_TYPE_LIST); - cass::CollectionType::ConstPtr list = static_cast(data_type); + CollectionType::ConstPtr list = static_cast(data_type); ASSERT_EQ(list->types().size(), 1u); EXPECT_FALSE(list->is_frozen()); @@ -177,30 +179,30 @@ TEST(CqlTypeParserUnitTest, Frozen) { } TEST(CqlTypeParserUnitTest, Invalid) { - cass::DataType::ConstPtr data_type; + DataType::ConstPtr data_type; - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::KeyspaceMetadata keyspace("keyspace1"); + KeyspaceMetadata keyspace("keyspace1"); // Invalid number of parameters - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("list<>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("set<>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("map<>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("tuple<>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("list<>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("set<>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("map<>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("tuple<>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("list", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("set", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("map", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("map", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("list", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("set", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("map", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("map", cache, &keyspace)); // Invalid brackets - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("list<", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("list>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("<>", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("<", cache, &keyspace)); - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse(">", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("list<", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("list>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("<>", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("<", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse(">", cache, &keyspace)); // Empty - EXPECT_FALSE(cass::DataTypeCqlNameParser::parse("", cache, &keyspace)); + EXPECT_FALSE(DataTypeCqlNameParser::parse("", cache, &keyspace)); } diff --git a/cpp-driver/gtests/src/unit/tests/test_data_type.cpp b/cpp-driver/gtests/src/unit/tests/test_data_type.cpp index 6f3154e9d..8ad948438 100644 --- a/cpp-driver/gtests/src/unit/tests/test_data_type.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_data_type.cpp @@ -22,6 +22,9 @@ #include #include +using namespace datastax; +using namespace datastax::internal::core; + class DataTypeWrapper { public: DataTypeWrapper(CassDataType* data_type) @@ -54,10 +57,10 @@ TEST(DataTypeUnitTest, KeyspaceAndTypeName) { size_t name_length; ASSERT_EQ(cass_data_type_keyspace(data_type, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "keyspace1"); + EXPECT_EQ(String(name, name_length), "keyspace1"); ASSERT_EQ(cass_data_type_type_name(data_type, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "type_name1"); + EXPECT_EQ(String(name, name_length), "type_name1"); } // Invalid type @@ -94,7 +97,7 @@ TEST(DataTypeUnitTest, ClassName) { size_t name_length; ASSERT_EQ(cass_data_type_class_name(data_type, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "class_name1"); + EXPECT_EQ(String(name, name_length), "class_name1"); } // Invalid type @@ -129,7 +132,7 @@ TEST(DataTypeUnitTest, FromExisting) { size_t name_length; ASSERT_EQ(cass_data_type_class_name(data_type_copy, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "class_name1"); + EXPECT_EQ(String(name, name_length), "class_name1"); } // From an existing tuple @@ -193,10 +196,10 @@ TEST(DataTypeUnitTest, FromExisting) { size_t name_length; ASSERT_EQ(cass_data_type_keyspace(data_type_copy, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "keyspace1"); + EXPECT_EQ(String(name, name_length), "keyspace1"); ASSERT_EQ(cass_data_type_type_name(data_type_copy, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "type_name1"); + EXPECT_EQ(String(name, name_length), "type_name1"); } } @@ -368,20 +371,20 @@ TEST(DataTypeUnitTest, CheckSubValueType) { size_t name_length; ASSERT_EQ(cass_data_type_sub_type_name(data_type, 0, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "field1"); + EXPECT_EQ(String(name, name_length), "field1"); ASSERT_EQ(cass_data_type_sub_type_name(data_type, 1, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "field2"); + EXPECT_EQ(String(name, name_length), "field2"); ASSERT_EQ(cass_data_type_sub_type_name(data_type, 2, &name, &name_length), CASS_OK); - EXPECT_EQ(cass::String(name, name_length), "field3"); + EXPECT_EQ(String(name, name_length), "field3"); } } TEST(DataTypeUnitTest, CheckValueTypeByClass) { #define XX_VALUE_TYPE(name, type, cql, klass) \ EXPECT_TRUE(strlen(klass) == 0 || \ - cass::ValueTypes::by_class(klass) == name); \ + ValueTypes::by_class(klass) == name); \ CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) #undef XX_VALUE_TYPE @@ -389,9 +392,9 @@ TEST(DataTypeUnitTest, CheckValueTypeByClass) { TEST(DataTypeUnitTest, CheckValueTypeByClassCaseInsensitive) { #define XX_VALUE_TYPE(name, type, cql, klass) { \ - cass::String upper(klass); \ + String upper(klass); \ std::transform(upper.begin(), upper.end(), upper.begin(), toupper); \ - EXPECT_TRUE(upper.empty() || cass::ValueTypes::by_class(upper) == name); \ + EXPECT_TRUE(upper.empty() || ValueTypes::by_class(upper) == name); \ } CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) @@ -401,7 +404,7 @@ TEST(DataTypeUnitTest, CheckValueTypeByClassCaseInsensitive) { TEST(DataTypeUnitTest, CheckValueTypesByCql) { #define XX_VALUE_TYPE(name, type, cql, klass) \ EXPECT_TRUE(strlen(cql) == 0 || \ - cass::ValueTypes::by_cql(cql) == name); \ + ValueTypes::by_cql(cql) == name); \ CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) #undef XX_VALUE_TYPE @@ -409,9 +412,9 @@ TEST(DataTypeUnitTest, CheckValueTypesByCql) { TEST(DataTypeUnitTest, CheckValueTypesByCqlCasInsensitive) { #define XX_VALUE_TYPE(name, type, cql, klass) { \ - cass::String upper(cql); \ + String upper(cql); \ std::transform(upper.begin(), upper.end(), upper.begin(), toupper); \ - EXPECT_TRUE(upper.empty() || cass::ValueTypes::by_cql(upper) == name); \ + EXPECT_TRUE(upper.empty() || ValueTypes::by_cql(upper) == name); \ } CASS_VALUE_TYPE_MAPPING(XX_VALUE_TYPE) @@ -419,11 +422,11 @@ TEST(DataTypeUnitTest, CheckValueTypesByCqlCasInsensitive) { } TEST(DataTypeUnitTest, SimpleDataTypeCache) { - cass::SimpleDataTypeCache cache; + SimpleDataTypeCache cache; - cass::DataType::ConstPtr by_class = cache.by_class("org.apache.cassandra.db.marshal.AsciiType"); - cass::DataType::ConstPtr by_cql = cache.by_cql("ascii"); - cass::DataType::ConstPtr by_value_type = cache.by_value_type(CASS_VALUE_TYPE_ASCII); + DataType::ConstPtr by_class = cache.by_class("org.apache.cassandra.db.marshal.AsciiType"); + DataType::ConstPtr by_cql = cache.by_cql("ascii"); + DataType::ConstPtr by_value_type = cache.by_value_type(CASS_VALUE_TYPE_ASCII); EXPECT_EQ(by_class->value_type(), CASS_VALUE_TYPE_ASCII); EXPECT_EQ(by_cql->value_type(), CASS_VALUE_TYPE_ASCII); diff --git a/cpp-driver/gtests/src/unit/tests/test_decoder.cpp b/cpp-driver/gtests/src/unit/tests/test_decoder.cpp index b1048cd0a..84ed0f52d 100644 --- a/cpp-driver/gtests/src/unit/tests/test_decoder.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_decoder.cpp @@ -19,15 +19,19 @@ #include "decoder.hpp" #include "logger.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + // Testing decoder class to expose protected testing methods -class TestDecoder : public cass::Decoder { +class TestDecoder : public Decoder { public: TestDecoder(const char* input, size_t length, - cass::ProtocolVersion protocol_version = cass::ProtocolVersion::highest_supported()) - : cass::Decoder(input, length, protocol_version) { } + ProtocolVersion protocol_version = ProtocolVersion::highest_supported()) + : Decoder(input, length, protocol_version) { } - inline const char* buffer() const { return cass::Decoder::buffer(); } - inline size_t remaining() const { return cass::Decoder::remaining(); } + inline const char* buffer() const { return Decoder::buffer(); } + inline size_t remaining() const { return Decoder::remaining(); } }; class DecoderUnitTest : public testing::Test { @@ -36,7 +40,7 @@ class DecoderUnitTest : public testing::Test { failure_logged_ = false; warning_logged_ = false; cass_log_set_level(CASS_LOG_WARN); - cass::Logger::set_callback(DecoderUnitTest::log, NULL); + Logger::set_callback(DecoderUnitTest::log, NULL); } static void log(const CassLogMessage* message, void* data) { @@ -470,7 +474,7 @@ TEST_F(DecoderUnitTest, DecodeStringRef) { const char input[17] = { 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 17); - cass::StringRef value; + StringRef value; // SUCCESS ASSERT_TRUE(decoder.decode_string(&value)); @@ -542,7 +546,7 @@ TEST_F(DecoderUnitTest, DecodeBytesRef) { const char input[21] = { 0, 0, 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 0, 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 21); - cass::StringRef value; + StringRef value; // SUCCESS ASSERT_TRUE(decoder.decode_bytes(&value)); @@ -568,7 +572,7 @@ TEST_F(DecoderUnitTest, DecodeInetAddress) { const char input[30] = { 4, 127, 0, 0, 1, 0, 0, 35, 82, // 127.0.0.1:9042 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 35, 82 }; // [::1]:9042 TestDecoder decoder(input, 30); - cass::Address value; + Address value; // SUCCESS ASSERT_TRUE(decoder.decode_inet(&value)); @@ -596,14 +600,14 @@ TEST_F(DecoderUnitTest, DecodeInetStruct) { ASSERT_EQ(17ul, decoder.remaining()); for (int i = 0; i < value.address_length; ++i) { uint8_t byte = 0; - cass::decode_byte(&input[i + 1], byte); + decode_byte(&input[i + 1], byte); ASSERT_EQ(byte, value.address[i]); } ASSERT_TRUE(decoder.decode_inet(&value)); ASSERT_EQ(0ul, decoder.remaining()); for (int i = 0; i < value.address_length; ++i) { uint8_t byte = 0; - cass::decode_byte(&input[i + 6], byte); + decode_byte(&input[i + 6], byte); ASSERT_EQ(byte, value.address[i]); } @@ -624,7 +628,7 @@ TEST_F(DecoderUnitTest, AsInetIPv4) { ASSERT_EQ(4ul, decoder.remaining()); for (int j = 0; j < value.address_length; ++j) { uint8_t byte = 0; - cass::decode_byte(&input[j], byte); + decode_byte(&input[j], byte); ASSERT_EQ(byte, value.address[j]); } } @@ -643,7 +647,7 @@ TEST_F(DecoderUnitTest, AsInetIPv6) { ASSERT_EQ(16ul, decoder.remaining()); for (int j = 0; j < value.address_length; ++j) { uint8_t byte = 0; - cass::decode_byte(&input[j], byte); + decode_byte(&input[j], byte); ASSERT_EQ(byte, value.address[j]); } } @@ -657,7 +661,7 @@ TEST_F(DecoderUnitTest, DecodeStringMap) { 0, 8, 108, 97, 110, 103, 117, 97, 103, 101, // key = language 0, 5, 67, 47, 67, 43, 43 }; // value = C/C++ TestDecoder decoder(input, 38); - cass::Map value; + Map value; // SUCCESS ASSERT_TRUE(decoder.decode_string_map(value)); @@ -677,7 +681,7 @@ TEST_F(DecoderUnitTest, DecodeStringlistVector) { 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 19); - cass::Vector value; + Vector value; // SUCCESS ASSERT_TRUE(decoder.decode_stringlist(value)); @@ -697,7 +701,7 @@ TEST_F(DecoderUnitTest, DecodeStringlistStringRefVec) { 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 19); - cass::StringRefVec value; + StringRefVec value; // SUCCESS ASSERT_TRUE(decoder.decode_stringlist(value)); @@ -719,7 +723,7 @@ TEST_F(DecoderUnitTest, AsStringlist) { 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 19); - cass::StringRefVec value; + StringRefVec value; // SUCCESS for (int i = 0; i < 10; ++i) { @@ -752,14 +756,14 @@ TEST_F(DecoderUnitTest, DecodeStringMultiMap) { 0, 6, 80, 121, 116, 104, 111, 110, // Python 0, 4, 82, 117, 98, 121 }; // Ruby TestDecoder decoder(input, 58); - cass::Map > value; + Map > value; // SUCCESS ASSERT_TRUE(decoder.decode_string_multimap(value)); ASSERT_EQ(&input[58], decoder.buffer()); ASSERT_EQ(0ul, decoder.remaining()); ASSERT_EQ(1ul, value.size()); - cass::Vector values = value["drivers"]; + Vector values = value["drivers"]; ASSERT_EQ(7ul, values.size()); ASSERT_STREQ("C/C++", std::string(values[0].data(), values[0].size()).c_str()); @@ -841,7 +845,7 @@ TEST_F(DecoderUnitTest, AsDecimal) { ASSERT_EQ(8ul, decoder.remaining()); for (size_t j = 0; j < value_size; ++j) { uint8_t byte = 0; - cass::decode_byte(&input[j + sizeof(int32_t)], byte); + decode_byte(&input[j + sizeof(int32_t)], byte); ASSERT_EQ(byte, value[j]); } } @@ -890,7 +894,7 @@ TEST_F(DecoderUnitTest, DecodeCustomPayload) { 0, 8, 68, 97, 116, 97, 83, 116, 97, 120, // DataStax 0, 0, 0, 5, 67, 47, 67, 43, 43 }; // C/C++ TestDecoder decoder(input, 21); - cass::CustomPayloadVec value; + CustomPayloadVec value; // SUCCESS ASSERT_TRUE(decoder.decode_custom_payload(value)); @@ -912,7 +916,7 @@ TEST_F(DecoderUnitTest, DecodeCustomPayload) { TEST_F(DecoderUnitTest, DecodeFailures) { const char input[4] = { 0, 0, 0, 42 }; TestDecoder decoder(input, 4, 1); - cass::FailureVec value; + FailureVec value; int32_t value_size = 0; // SUCCESS @@ -933,7 +937,7 @@ TEST_F(DecoderUnitTest, DecodeFailuresWithVector) { 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // [::1] [02] 0, 2 }; TestDecoder decoder(input, 30, 5); - cass::FailureVec value; + FailureVec value; int32_t value_size = 0; // SUCCESS @@ -943,13 +947,13 @@ TEST_F(DecoderUnitTest, DecodeFailuresWithVector) { ASSERT_EQ(2, value_size); for (int i = 0; i < value[0].endpoint.address_length; ++i) { uint8_t byte; - cass::decode_byte(&input[i + 5], byte); + decode_byte(&input[i + 5], byte); ASSERT_EQ(byte, value[0].endpoint.address[i]); } ASSERT_EQ(1ul, value[0].failurecode); for (int i = 0; i < value[1].endpoint.address_length; ++i) { uint8_t byte; - cass::decode_byte(&input[i + 12], byte); + decode_byte(&input[i + 12], byte); ASSERT_EQ(byte, value[1].endpoint.address[i]); } ASSERT_EQ(2ul, value[1].failurecode); @@ -1008,7 +1012,7 @@ TEST_F(DecoderUnitTest, DecodeWarnings) { 0, 16, 87, 97, 114, 110, 105, 110, 103, 32, 78, 117, 109, 98, 101, 114, 32, 49, // Warning Number 1 0, 16, 87, 97, 114, 110, 105, 110, 103, 32, 78, 117, 109, 98, 101, 114, 32, 50 }; // Warning Number 2 TestDecoder decoder(input, 38); - cass::WarningVec value; + WarningVec value; // SUCCESS ASSERT_TRUE(decoder.decode_warnings(value)); diff --git a/cpp-driver/gtests/src/unit/tests/test_encode.cpp b/cpp-driver/gtests/src/unit/tests/test_encode.cpp index 81c71fea5..fc5b9f29a 100644 --- a/cpp-driver/gtests/src/unit/tests/test_encode.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_encode.cpp @@ -20,7 +20,7 @@ #include -using namespace cass; +using namespace datastax::internal::core; TEST(EncodeDurationUnitTest, Base) { CassDuration value(0, 0, 0); diff --git a/cpp-driver/gtests/src/unit/tests/test_event_loop.cpp b/cpp-driver/gtests/src/unit/tests/test_event_loop.cpp index 94b0d70bf..32c466d74 100644 --- a/cpp-driver/gtests/src/unit/tests/test_event_loop.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_event_loop.cpp @@ -20,45 +20,48 @@ #include "event_loop.hpp" #include "test_utils.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + class EventLoopUnitTest : public testing::Test { public: - class MarkTaskCompleted : public cass::Task { + class MarkTaskCompleted : public Task { public: MarkTaskCompleted(EventLoopUnitTest* event_loop_unit_test) : event_loop_unit_test_(event_loop_unit_test) { } - virtual void run(cass::EventLoop* event_loop) { + virtual void run(EventLoop* event_loop) { event_loop_unit_test_->mark_task_completed(); } private: EventLoopUnitTest* event_loop_unit_test_; }; - class MarkIsRunningOn : public cass::Task { + class MarkIsRunningOn : public Task { public: MarkIsRunningOn(EventLoopUnitTest* event_loop_unit_test, - cass::EventLoop* event_loop) + EventLoop* event_loop) : event_loop_unit_test_(event_loop_unit_test) , event_loop_(event_loop) { } - virtual void run(cass::EventLoop* event_loop) { + virtual void run(EventLoop* event_loop) { event_loop_unit_test_->set_is_running_on(event_loop_->is_running_on()); } private: EventLoopUnitTest * event_loop_unit_test_; - cass::EventLoop* event_loop_; + EventLoop* event_loop_; }; - class StartIoTime : public cass::Task { + class StartIoTime : public Task { public: - virtual void run(cass::EventLoop* event_loop) { + virtual void run(EventLoop* event_loop) { event_loop->maybe_start_io_time(); } }; - class SetIoTimeElapsed : public cass::Task { + class SetIoTimeElapsed : public Task { public: SetIoTimeElapsed(EventLoopUnitTest* event_loop_unit_test) : event_loop_unit_test_(event_loop_unit_test) { } - virtual void run(cass::EventLoop* event_loop) { + virtual void run(EventLoop* event_loop) { event_loop_unit_test_->set_io_time_elapsed(event_loop->io_time_elapsed()); } private: @@ -86,7 +89,7 @@ class EventLoopUnitTest : public testing::Test { uint64_t io_time_elapsed_; }; -class TestEventLoop : public cass::EventLoop { +class TestEventLoop : public EventLoop { public: TestEventLoop() : is_on_run_completed_(false) @@ -100,12 +103,12 @@ class TestEventLoop : public cass::EventLoop { void on_after_run() { is_after_run_completed_ = true; } private: - cass::Atomic is_on_run_completed_; + Atomic is_on_run_completed_; bool is_after_run_completed_; }; TEST_F(EventLoopUnitTest, ExecuteTask) { - cass::EventLoop event_loop; + EventLoop event_loop; ASSERT_EQ(0, event_loop.init("EventLoopUnitTest::ExecuteTask")); ASSERT_STREQ("EventLoopUnitTest::ExecuteTask", event_loop.name().c_str()); ASSERT_EQ(0, event_loop.run()); @@ -119,7 +122,7 @@ TEST_F(EventLoopUnitTest, ExecuteTask) { } TEST_F(EventLoopUnitTest, ThreadRunningOn) { - cass::EventLoop event_loop; + EventLoop event_loop; ASSERT_EQ(0, event_loop.init("EventLoopUnitTest::ThreadRunningOn")); ASSERT_STREQ("EventLoopUnitTest::ThreadRunningOn", event_loop.name().c_str()); ASSERT_EQ(0, event_loop.run()); @@ -133,14 +136,14 @@ TEST_F(EventLoopUnitTest, ThreadRunningOn) { } TEST_F(EventLoopUnitTest, ThreadNotRunningOn) { - cass::EventLoop event_loop; + EventLoop event_loop; ASSERT_EQ(0, event_loop.init("EventLoopUnitTest::ThreadNotRunningOn (EventLoop 1)")); ASSERT_STREQ("EventLoopUnitTest::ThreadNotRunningOn (EventLoop 1)", event_loop.name().c_str()); ASSERT_EQ(0, event_loop.run()); ASSERT_FALSE(is_running_on()); - cass::EventLoop event_loop_2; + EventLoop event_loop_2; ASSERT_EQ(0, event_loop_2.init("EventLoopUnitTest::ThreadNotRunningOn (EventLoop 2)")); ASSERT_STREQ("EventLoopUnitTest::ThreadNotRunningOn (EventLoop 2)", event_loop_2.name().c_str()); ASSERT_EQ(0, event_loop_2.run()); diff --git a/cpp-driver/gtests/src/unit/tests/test_exec_profile.cpp b/cpp-driver/gtests/src/unit/tests/test_exec_profile.cpp index 9d7bcc447..ad29cc852 100644 --- a/cpp-driver/gtests/src/unit/tests/test_exec_profile.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_exec_profile.cpp @@ -17,12 +17,15 @@ #include "config.hpp" -bool execution_profile(const cass::Config& config, - const cass::String& name, - cass::ExecutionProfile& profile) { +using namespace datastax; +using namespace datastax::internal::core; + +bool execution_profile(const Config& config, + const String& name, + ExecutionProfile& profile) { // Handle profile lookup - const cass::ExecutionProfile::Map& profiles = config.profiles(); - cass::ExecutionProfile::Map::const_iterator it = profiles.find(name); + const ExecutionProfile::Map& profiles = config.profiles(); + ExecutionProfile::Map::const_iterator it = profiles.find(name); if (it != profiles.end()) { profile = it->second; return true; @@ -31,14 +34,14 @@ bool execution_profile(const cass::Config& config, } TEST(ExecutionProfileUnitTest, Consistency) { - cass::ExecutionProfile profile; + ExecutionProfile profile; ASSERT_EQ(CASS_CONSISTENCY_UNKNOWN, profile.consistency()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(CASS_DEFAULT_CONSISTENCY, profile_lookup.consistency()); ASSERT_EQ(CASS_DEFAULT_CONSISTENCY, @@ -46,14 +49,14 @@ TEST(ExecutionProfileUnitTest, Consistency) { } TEST(ExecutionProfileUnitTest, SerialConsistency) { - cass::ExecutionProfile profile; + ExecutionProfile profile; ASSERT_EQ(CASS_CONSISTENCY_UNKNOWN, profile.serial_consistency()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(CASS_DEFAULT_SERIAL_CONSISTENCY, profile_lookup.serial_consistency()); ASSERT_EQ(CASS_DEFAULT_SERIAL_CONSISTENCY, @@ -61,14 +64,14 @@ TEST(ExecutionProfileUnitTest, SerialConsistency) { } TEST(ExecutionProfileUnitTest, RequestTimeout) { - cass::ExecutionProfile profile; + ExecutionProfile profile; ASSERT_EQ(CASS_UINT64_MAX, profile.request_timeout_ms()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(CASS_DEFAULT_REQUEST_TIMEOUT_MS, profile_lookup.request_timeout_ms()); ASSERT_EQ(CASS_DEFAULT_REQUEST_TIMEOUT_MS, @@ -76,7 +79,7 @@ TEST(ExecutionProfileUnitTest, RequestTimeout) { } TEST(ExecutionProfileUnitTest, NullLoadBalancingPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; profile.build_load_balancing_policy(); ASSERT_TRUE(!profile.load_balancing_policy()); @@ -86,13 +89,13 @@ TEST(ExecutionProfileUnitTest, NullLoadBalancingPolicy) { // by the request processor init method now. The last assertion in // the test is invalid making the whole test invalid. TEST(ExecutionProfileUnitTest, DISABLED_ClusterLoadBalancingPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(copy_config.default_profile().load_balancing_policy().get(), profile_lookup.load_balancing_policy().get()); @@ -102,29 +105,29 @@ TEST(ExecutionProfileUnitTest, DISABLED_ClusterLoadBalancingPolicy) { // by the request processor init method now The last assertion in // the test is invalid making the whole test invalid. TEST(ExecutionProfileUnitTest, DISABLED_ClusterLoadBalancingPolicies) { - cass::ExecutionProfile profile_1; - profile_1.set_load_balancing_policy(new cass::DCAwarePolicy()); - cass::ExecutionProfile profile_2; - cass::ExecutionProfile profile_3; - profile_3.set_load_balancing_policy(new cass::RoundRobinPolicy()); + ExecutionProfile profile_1; + profile_1.set_load_balancing_policy(new DCAwarePolicy()); + ExecutionProfile profile_2; + ExecutionProfile profile_3; + profile_3.set_load_balancing_policy(new RoundRobinPolicy()); - cass::Config config; + Config config; config.set_execution_profile("profile_1", &profile_1); config.set_execution_profile("profile_2", &profile_2); config.set_execution_profile("profile_3", &profile_3); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_1_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_1_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_1", profile_1_lookup)); - cass::ExecutionProfile profile_2_lookup; + ExecutionProfile profile_2_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_2", profile_2_lookup)); - cass::ExecutionProfile profile_3_lookup; + ExecutionProfile profile_3_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_3", profile_3_lookup)); - const cass::LoadBalancingPolicy* profile_1_lbp = + const LoadBalancingPolicy* profile_1_lbp = profile_1_lookup.load_balancing_policy().get(); - const cass::LoadBalancingPolicy* profile_2_lbp = + const LoadBalancingPolicy* profile_2_lbp = profile_2_lookup.load_balancing_policy().get(); - const cass::LoadBalancingPolicy* profile_3_lbp = + const LoadBalancingPolicy* profile_3_lbp = profile_3_lookup.load_balancing_policy().get(); EXPECT_NE(profile_1_lbp, profile_2_lbp); EXPECT_NE(profile_2_lbp, profile_3_lbp); @@ -134,18 +137,18 @@ TEST(ExecutionProfileUnitTest, DISABLED_ClusterLoadBalancingPolicies) { } TEST(ExecutionProfileUnitTest, Blacklist) { - cass::ExecutionProfile profile; - cass::explode(cass::String("0.0.0.0, 0.0.0.2, 0.0.0.4"), profile.blacklist()); + ExecutionProfile profile; + explode(String("0.0.0.0, 0.0.0.2, 0.0.0.4"), profile.blacklist()); ASSERT_EQ(3u, profile.blacklist().size()); ASSERT_STREQ("0.0.0.0", profile.blacklist().at(0).c_str()); ASSERT_STREQ("0.0.0.2", profile.blacklist().at(1).c_str()); ASSERT_STREQ("0.0.0.4", profile.blacklist().at(2).c_str()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(profile.blacklist().size(), profile_lookup.blacklist().size()); ASSERT_STREQ(profile.blacklist().at(0).c_str(), @@ -158,18 +161,18 @@ TEST(ExecutionProfileUnitTest, Blacklist) { } TEST(ExecutionProfileUnitTest, BlacklistDC) { - cass::ExecutionProfile profile; - cass::explode(cass::String("dc1, dc3, dc5"), profile.blacklist_dc()); + ExecutionProfile profile; + explode(String("dc1, dc3, dc5"), profile.blacklist_dc()); ASSERT_EQ(3u, profile.blacklist_dc().size()); ASSERT_STREQ("dc1", profile.blacklist_dc().at(0).c_str()); ASSERT_STREQ("dc3", profile.blacklist_dc().at(1).c_str()); ASSERT_STREQ("dc5", profile.blacklist_dc().at(2).c_str()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(profile.blacklist_dc().size(), profile_lookup.blacklist_dc().size()); ASSERT_STREQ(profile.blacklist_dc().at(0).c_str(), @@ -182,18 +185,18 @@ TEST(ExecutionProfileUnitTest, BlacklistDC) { } TEST(ExecutionProfileUnitTest, Whitelist) { - cass::ExecutionProfile profile; - cass::explode(cass::String("0.0.0.0, 0.0.0.2, 0.0.0.4"), profile.whitelist()); + ExecutionProfile profile; + explode(String("0.0.0.0, 0.0.0.2, 0.0.0.4"), profile.whitelist()); ASSERT_EQ(3u, profile.whitelist().size()); ASSERT_STREQ("0.0.0.0", profile.whitelist().at(0).c_str()); ASSERT_STREQ("0.0.0.2", profile.whitelist().at(1).c_str()); ASSERT_STREQ("0.0.0.4", profile.whitelist().at(2).c_str()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(profile.whitelist().size(), profile_lookup.whitelist().size()); ASSERT_STREQ(profile.whitelist().at(0).c_str(), @@ -206,18 +209,18 @@ TEST(ExecutionProfileUnitTest, Whitelist) { } TEST(ExecutionProfileUnitTest, WhitelistDC) { - cass::ExecutionProfile profile; - cass::explode(cass::String("dc1, dc3, dc5"), profile.whitelist_dc()); + ExecutionProfile profile; + explode(String("dc1, dc3, dc5"), profile.whitelist_dc()); ASSERT_EQ(3u, profile.whitelist_dc().size()); ASSERT_STREQ("dc1", profile.whitelist_dc().at(0).c_str()); ASSERT_STREQ("dc3", profile.whitelist_dc().at(1).c_str()); ASSERT_STREQ("dc5", profile.whitelist_dc().at(2).c_str()); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(profile.whitelist_dc().size(), profile_lookup.whitelist_dc().size()); ASSERT_STREQ(profile.whitelist_dc().at(0).c_str(), @@ -230,75 +233,75 @@ TEST(ExecutionProfileUnitTest, WhitelistDC) { } TEST(ExecutionProfileUnitTest, LatencyAware) { - cass::ExecutionProfile profile; + ExecutionProfile profile; profile.set_latency_aware_routing(true); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_FALSE(copy_config.default_profile().latency_aware()); ASSERT_TRUE(profile_lookup.latency_aware()); } TEST(ExecutionProfileUnitTest, TokenAware) { - cass::ExecutionProfile profile; + ExecutionProfile profile; profile.set_token_aware_routing(false); - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_TRUE(copy_config.default_profile().token_aware_routing()); ASSERT_FALSE(profile_lookup.token_aware_routing()); } TEST(ExecutionProfileUnitTest, NullRetryPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; ASSERT_TRUE(!profile.retry_policy()); } TEST(ExecutionProfileUnitTest, ClusterRetryPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; - cass::Config config; + Config config; config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_EQ(copy_config.default_profile().retry_policy().get(), profile_lookup.retry_policy().get()); } TEST(ExecutionProfileUnitTest, ClusterRetryPolicies) { - cass::ExecutionProfile profile_1; - profile_1.set_retry_policy(new cass::FallthroughRetryPolicy()); - cass::ExecutionProfile profile_2; - cass::ExecutionProfile profile_3; - profile_3.set_retry_policy(new cass::DefaultRetryPolicy()); + ExecutionProfile profile_1; + profile_1.set_retry_policy(new FallthroughRetryPolicy()); + ExecutionProfile profile_2; + ExecutionProfile profile_3; + profile_3.set_retry_policy(new DefaultRetryPolicy()); - cass::Config config; + Config config; config.set_execution_profile("profile_1", &profile_1); config.set_execution_profile("profile_2", &profile_2); config.set_execution_profile("profile_3", &profile_3); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_1_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_1_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_1", profile_1_lookup)); - cass::ExecutionProfile profile_2_lookup; + ExecutionProfile profile_2_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_2", profile_2_lookup)); - cass::ExecutionProfile profile_3_lookup; + ExecutionProfile profile_3_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_3", profile_3_lookup)); - const cass::RetryPolicy* profile_1_retry_policy = + const RetryPolicy* profile_1_retry_policy = profile_1_lookup.retry_policy().get(); - const cass::RetryPolicy* profile_2_retry_policy = + const RetryPolicy* profile_2_retry_policy = profile_2_lookup.retry_policy().get(); - const cass::RetryPolicy* profile_3_retry_policy = + const RetryPolicy* profile_3_retry_policy = profile_3_lookup.retry_policy().get(); EXPECT_NE(profile_1_retry_policy, profile_2_retry_policy); EXPECT_NE(profile_2_retry_policy, profile_3_retry_policy); @@ -308,19 +311,19 @@ TEST(ExecutionProfileUnitTest, ClusterRetryPolicies) { } TEST(ExecutionProfileUnitTest, NullSpeculativeExecutionPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; ASSERT_TRUE(!profile.speculative_execution_policy()); } TEST(ExecutionProfileUnitTest, ClusterSpeculativeExecutionPolicy) { - cass::ExecutionProfile profile; + ExecutionProfile profile; - cass::Config config; - config.set_speculative_execution_policy(new cass::NoSpeculativeExecutionPolicy()); + Config config; + config.set_speculative_execution_policy(new NoSpeculativeExecutionPolicy()); config.set_execution_profile("profile", &profile); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile", profile_lookup)); ASSERT_NE(copy_config.default_profile().speculative_execution_policy().get(), profile_lookup.speculative_execution_policy().get()); @@ -329,32 +332,32 @@ TEST(ExecutionProfileUnitTest, ClusterSpeculativeExecutionPolicy) { } TEST(ExecutionProfileUnitTest, ClusterSpeculativeExecutionPolicies) { - cass::ExecutionProfile profile_1; - profile_1.set_speculative_execution_policy(new cass::ConstantSpeculativeExecutionPolicy(1, 2)); - cass::ExecutionProfile profile_2; - cass::ExecutionProfile profile_3; - profile_3.set_speculative_execution_policy(new cass::NoSpeculativeExecutionPolicy()); - - cass::Config config; - config.set_speculative_execution_policy(new cass::ConstantSpeculativeExecutionPolicy(3, 4)); + ExecutionProfile profile_1; + profile_1.set_speculative_execution_policy(new ConstantSpeculativeExecutionPolicy(1, 2)); + ExecutionProfile profile_2; + ExecutionProfile profile_3; + profile_3.set_speculative_execution_policy(new NoSpeculativeExecutionPolicy()); + + Config config; + config.set_speculative_execution_policy(new ConstantSpeculativeExecutionPolicy(3, 4)); config.set_execution_profile("profile_1", &profile_1); config.set_execution_profile("profile_2", &profile_2); config.set_execution_profile("profile_3", &profile_3); - cass::Config copy_config = config.new_instance(); - cass::ExecutionProfile profile_1_lookup; + Config copy_config = config.new_instance(); + ExecutionProfile profile_1_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_1", profile_1_lookup)); - cass::ExecutionProfile profile_2_lookup; + ExecutionProfile profile_2_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_2", profile_2_lookup)); - cass::ExecutionProfile profile_3_lookup; + ExecutionProfile profile_3_lookup; ASSERT_TRUE(execution_profile(copy_config, "profile_3", profile_3_lookup)); - const cass::SpeculativeExecutionPolicy* profile_1_speculative_execution_policy = + const SpeculativeExecutionPolicy* profile_1_speculative_execution_policy = profile_1_lookup.speculative_execution_policy().get(); - const cass::SpeculativeExecutionPolicy* profile_2_speculative_execution_policy = + const SpeculativeExecutionPolicy* profile_2_speculative_execution_policy = profile_2_lookup.speculative_execution_policy().get(); - const cass::SpeculativeExecutionPolicy* profile_3_speculative_execution_policy = + const SpeculativeExecutionPolicy* profile_3_speculative_execution_policy = profile_3_lookup.speculative_execution_policy().get(); - const cass::SpeculativeExecutionPolicy* config_speculative_execution_policy = + const SpeculativeExecutionPolicy* config_speculative_execution_policy = copy_config.default_profile().speculative_execution_policy().get(); EXPECT_NE(profile_1_speculative_execution_policy, profile_2_speculative_execution_policy); @@ -368,13 +371,13 @@ TEST(ExecutionProfileUnitTest, ClusterSpeculativeExecutionPolicies) { typeid(profile_2_speculative_execution_policy)); ASSERT_EQ(typeid(config_speculative_execution_policy), typeid(profile_1_speculative_execution_policy)); - ASSERT_EQ(dynamic_cast(config_speculative_execution_policy)->constant_delay_ms_, - dynamic_cast(profile_2_speculative_execution_policy)->constant_delay_ms_); - ASSERT_EQ(dynamic_cast(config_speculative_execution_policy)->max_speculative_executions_, - dynamic_cast(profile_2_speculative_execution_policy)->max_speculative_executions_); - ASSERT_NE(dynamic_cast(config_speculative_execution_policy)->constant_delay_ms_, - dynamic_cast(profile_1_speculative_execution_policy)->constant_delay_ms_); - ASSERT_NE(dynamic_cast(config_speculative_execution_policy)->max_speculative_executions_, - dynamic_cast(profile_1_speculative_execution_policy)->max_speculative_executions_); + ASSERT_EQ(dynamic_cast(config_speculative_execution_policy)->constant_delay_ms_, + dynamic_cast(profile_2_speculative_execution_policy)->constant_delay_ms_); + ASSERT_EQ(dynamic_cast(config_speculative_execution_policy)->max_speculative_executions_, + dynamic_cast(profile_2_speculative_execution_policy)->max_speculative_executions_); + ASSERT_NE(dynamic_cast(config_speculative_execution_policy)->constant_delay_ms_, + dynamic_cast(profile_1_speculative_execution_policy)->constant_delay_ms_); + ASSERT_NE(dynamic_cast(config_speculative_execution_policy)->max_speculative_executions_, + dynamic_cast(profile_1_speculative_execution_policy)->max_speculative_executions_); } diff --git a/cpp-driver/gtests/src/unit/tests/test_future.cpp b/cpp-driver/gtests/src/unit/tests/test_future.cpp index 21e1fb563..37a20cae8 100644 --- a/cpp-driver/gtests/src/unit/tests/test_future.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_future.cpp @@ -23,8 +23,10 @@ #define DELAY_MS 500 // 500 milliseconds +using datastax::internal::core::Future; + void on_timeout_set_future(uv_timer_t* handle) { - cass::Future* future = static_cast(handle->data); + Future* future = static_cast(handle->data); future->set(); uv_close(reinterpret_cast(handle), NULL); } @@ -35,30 +37,30 @@ void on_future_callback(CassFuture* future, void* data) { } void start_timer(void* arg) { - cass::Future* future = static_cast(arg); + Future* future = static_cast(arg); test::Utils::msleep(DELAY_MS); future->set(); } TEST(FutureUnitTest, Types) { - cass::Future generic(cass::Future::FUTURE_TYPE_GENERIC); - cass::Future session(cass::Future::FUTURE_TYPE_SESSION); - cass::Future response(cass::Future::FUTURE_TYPE_RESPONSE); + Future generic(Future::FUTURE_TYPE_GENERIC); + Future session(Future::FUTURE_TYPE_SESSION); + Future response(Future::FUTURE_TYPE_RESPONSE); - ASSERT_EQ(cass::Future::FUTURE_TYPE_GENERIC, generic.type()); - ASSERT_EQ(cass::Future::FUTURE_TYPE_SESSION, session.type()); - ASSERT_EQ(cass::Future::FUTURE_TYPE_RESPONSE, response.type()); + ASSERT_EQ(Future::FUTURE_TYPE_GENERIC, generic.type()); + ASSERT_EQ(Future::FUTURE_TYPE_SESSION, session.type()); + ASSERT_EQ(Future::FUTURE_TYPE_RESPONSE, response.type()); } TEST(FutureUnitTest, Ready) { - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); ASSERT_FALSE(future.ready()); future.set(); ASSERT_TRUE(future.ready()); } TEST(FutureUnitTest, Wait) { - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); uv_thread_t thread; ASSERT_EQ(0, uv_thread_create(&thread, start_timer, &future)); @@ -69,7 +71,7 @@ TEST(FutureUnitTest, Wait) { } TEST(FutureUnitTest, WaitFor) { - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); uv_thread_t thread; ASSERT_EQ(0, uv_thread_create(&thread, start_timer, &future)); @@ -85,7 +87,7 @@ TEST(FutureUnitTest, WaitFor) { } TEST(FutureUnitTest, Error) { - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); future.set_error(CASS_ERROR_LIB_BAD_PARAMS, "FutureUnitTest error message"); ASSERT_TRUE(future.ready()); ASSERT_TRUE(future.error()); @@ -95,7 +97,7 @@ TEST(FutureUnitTest, Error) { TEST(FutureUnitTest, Callback) { bool is_future_callback_called = false; - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); ASSERT_TRUE(future.set_callback(&on_future_callback, &is_future_callback_called)); ASSERT_FALSE(is_future_callback_called); @@ -105,14 +107,14 @@ TEST(FutureUnitTest, Callback) { } TEST(FutureUnitTest, CallbackAlreadyAssigned) { - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); ASSERT_TRUE(future.set_callback(&on_future_callback, NULL)); ASSERT_FALSE(future.set_callback(&on_future_callback, NULL)); } TEST(FutureUnitTest, CallbackAfterFutureIsSet) { bool is_future_callback_called = false; - cass::Future future(cass::Future::FUTURE_TYPE_GENERIC); + Future future(Future::FUTURE_TYPE_GENERIC); ASSERT_FALSE(is_future_callback_called); future.set(); diff --git a/cpp-driver/gtests/src/unit/tests/test_get_time.cpp b/cpp-driver/gtests/src/unit/tests/test_get_time.cpp index d1830d7d7..fc6f2caeb 100644 --- a/cpp-driver/gtests/src/unit/tests/test_get_time.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_get_time.cpp @@ -19,20 +19,22 @@ #include "test_utils.hpp" #include "get_time.hpp" +using datastax::internal::get_time_monotonic_ns; + TEST(GetTimeUnitTest, Monotonic) { - uint64_t prev = cass::get_time_monotonic_ns(); + uint64_t prev = get_time_monotonic_ns(); for (int i = 0; i < 100; ++i) { - uint64_t current = cass::get_time_monotonic_ns(); + uint64_t current = get_time_monotonic_ns(); EXPECT_GE(current, prev); prev = current; } } TEST(GetTimeUnitTest, MonotonicDuration) { - uint64_t start = cass::get_time_monotonic_ns(); + uint64_t start = get_time_monotonic_ns(); test::Utils::msleep(1000); // 1 second - uint64_t elapsed = cass::get_time_monotonic_ns() - start; + uint64_t elapsed = get_time_monotonic_ns() - start; EXPECT_GE(elapsed, static_cast(NANOSECONDS_PER_SECOND)); EXPECT_LE(elapsed, static_cast(2 * NANOSECONDS_PER_SECOND)); } diff --git a/cpp-driver/gtests/src/unit/tests/test_hash_table.cpp b/cpp-driver/gtests/src/unit/tests/test_hash_table.cpp index 95fed87a0..0e6b0c2c8 100644 --- a/cpp-driver/gtests/src/unit/tests/test_hash_table.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_hash_table.cpp @@ -18,20 +18,23 @@ #include "hash_table.hpp" -struct TestEntry : cass::HashTableEntry { - TestEntry(const cass::String& name) +using namespace datastax; +using namespace datastax::internal::core; + +struct TestEntry : HashTableEntry { + TestEntry(const String& name) : name(name) { } - cass::String name; + String name; }; TEST(HashTableUnitTests, Simple) { - cass::CaseInsensitiveHashTable ht(4); + CaseInsensitiveHashTable ht(4); ht.add(TestEntry("abc")); ht.add(TestEntry("def")); ht.add(TestEntry("123")); ht.add(TestEntry("456")); - cass::IndexVec indices; + IndexVec indices; EXPECT_GT(ht.get_indices("abc", &indices), 0u); EXPECT_EQ(indices[0], 0u); @@ -49,12 +52,12 @@ TEST(HashTableUnitTests, Simple) { } TEST(HashTableUnitTests, CaseSensitivity) { - cass::CaseInsensitiveHashTable ht(4); + CaseInsensitiveHashTable ht(4); ht.add(TestEntry("abc")); ht.add(TestEntry("def")); ht.add(TestEntry("DEF")); - cass::IndexVec indices; + IndexVec indices; EXPECT_GT(ht.get_indices("aBc", &indices), 0u); EXPECT_EQ(indices[0], 0u); @@ -77,15 +80,15 @@ TEST(HashTableUnitTests, CaseSensitivity) { } TEST(HashTableUnitTests, Resize) { - cass::CaseInsensitiveHashTable ht(0); + CaseInsensitiveHashTable ht(0); for (int i = 0; i < 26; ++i) { - cass::String s; + String s; s.push_back('a' + i); ht.add(TestEntry(s)); } - cass::IndexVec indices; + IndexVec indices; EXPECT_GT(ht.get_indices("a", &indices), 0u); EXPECT_EQ(indices[0], 0u); diff --git a/cpp-driver/gtests/src/unit/tests/test_load_balancing.cpp b/cpp-driver/gtests/src/unit/tests/test_load_balancing.cpp index aed8fbece..0472f8753 100644 --- a/cpp-driver/gtests/src/unit/tests/test_load_balancing.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_load_balancing.cpp @@ -38,33 +38,37 @@ #include -const cass::String LOCAL_DC = "local"; -const cass::String REMOTE_DC = "remote"; -const cass::String BACKUP_DC = "backup"; +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; -#define VECTOR_FROM(t, a) cass::Vector(a, a + sizeof(a)/sizeof(a[0])) +const String LOCAL_DC = "local"; +const String REMOTE_DC = "remote"; +const String BACKUP_DC = "backup"; -cass::Address addr_for_sequence(size_t i) { +#define VECTOR_FROM(t, a) Vector(a, a + sizeof(a)/sizeof(a[0])) + +Address addr_for_sequence(size_t i) { char temp[64]; sprintf(temp, "%d.%d.%d.%d", static_cast(i & 0xFF), static_cast((i >> 8) & 0xFF), static_cast((i >> 16) & 0xFF), static_cast((i >> 24) & 0xFF)); - return cass::Address(temp, 9042); + return Address(temp, 9042); } -cass::SharedRefPtr host_for_addr(const cass::Address addr, - const cass::String& rack = "rack", - const cass::String& dc = "dc") { - cass::SharedRefPtrhost(new cass::Host(addr)); +SharedRefPtr host_for_addr(const Address addr, + const String& rack = "rack", + const String& dc = "dc") { + SharedRefPtrhost(new Host(addr)); host->set_rack_and_dc(rack, dc); return host; } -void populate_hosts(size_t count, const cass::String& rack, - const cass::String& dc, cass::HostMap* hosts) { - cass::Address addr; +void populate_hosts(size_t count, const String& rack, + const String& dc, HostMap* hosts) { + Address addr; size_t first = hosts->size() + 1; for (size_t i = first; i < first+count; ++i) { addr = addr_for_sequence(i); @@ -72,9 +76,9 @@ void populate_hosts(size_t count, const cass::String& rack, } } -void verify_sequence(cass::QueryPlan* qp, const cass::Vector& sequence) { - cass::Address received; - for (cass::Vector::const_iterator it = sequence.begin(); +void verify_sequence(QueryPlan* qp, const Vector& sequence) { + Address received; + for (Vector::const_iterator it = sequence.begin(); it!= sequence.end(); ++it) { ASSERT_TRUE(qp->compute_next(&received)); @@ -83,13 +87,13 @@ void verify_sequence(cass::QueryPlan* qp, const cass::Vector& sequence) EXPECT_FALSE(qp->compute_next(&received)); } -typedef cass::Map QueryCounts; +typedef Map QueryCounts; -QueryCounts run_policy(cass::LoadBalancingPolicy& policy, int count) { +QueryCounts run_policy(LoadBalancingPolicy& policy, int count) { QueryCounts counts; for (int i = 0; i < 12; ++i) { - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); - cass::Host::Ptr host(qp->compute_next()); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + Host::Ptr host(qp->compute_next()); if (host) { counts[host->address()] += 1; } @@ -98,11 +102,11 @@ QueryCounts run_policy(cass::LoadBalancingPolicy& policy, int count) { } void verify_dcs(const QueryCounts& counts, - const cass::HostMap& hosts, - const cass::String& expected_dc) { + const HostMap& hosts, + const String& expected_dc) { for (QueryCounts::const_iterator it = counts.begin(), end = counts.end(); it != end; ++it) { - cass::HostMap::const_iterator host_it = hosts.find(it->first); + HostMap::const_iterator host_it = hosts.find(it->first); ASSERT_NE(host_it, hosts.end()); EXPECT_EQ(expected_dc, host_it->second->dc()); } @@ -115,14 +119,14 @@ void verify_query_counts(const QueryCounts& counts, int expected_count) { } } -struct RunPeriodicTask : public cass::EventLoop { - RunPeriodicTask(cass::LatencyAwarePolicy* policy) +struct RunPeriodicTask : public EventLoop { + RunPeriodicTask(LatencyAwarePolicy* policy) : policy(policy) { async.data = this; } int init() { - int rc = cass::EventLoop::init(); + int rc = EventLoop::init(); if (rc != 0) return rc; rc = uv_async_init(loop(), &async, on_async); if (rc != 0) return rc; @@ -142,7 +146,7 @@ struct RunPeriodicTask : public cass::EventLoop { } uv_async_t async; - cass::LatencyAwarePolicy* policy; + LatencyAwarePolicy* policy; }; // Latency-aware utility functions @@ -155,7 +159,7 @@ uint64_t calculate_moving_average(uint64_t first_latency_ns, const uint64_t min_measured = 15LL; const uint64_t threshold_to_account = (30LL * min_measured) / 100LL; - cass::Host host(cass::Address("0.0.0.0", 9042)); + Host host(Address("0.0.0.0", 9042)); host.enable_latency_tracking(scale, min_measured); for (uint64_t i = 0; i < threshold_to_account; ++i) { @@ -169,82 +173,82 @@ uint64_t calculate_moving_average(uint64_t first_latency_ns, while (uv_hrtime() - start < time_between_ns) {} host.update_latency(second_latency_ns); - cass::TimestampedAverage current = host.get_current_average(); + TimestampedAverage current = host.get_current_average(); return current.average; } void test_dc_aware_policy(size_t local_count, size_t remote_count) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(local_count, "rack", LOCAL_DC, &hosts); populate_hosts(remote_count, "rack", REMOTE_DC, &hosts); - cass::DCAwarePolicy policy(LOCAL_DC, remote_count, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, remote_count, false); + policy.init(SharedRefPtr(), hosts, NULL); const size_t total_hosts = local_count + remote_count; - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); - cass::Vector seq(total_hosts); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + Vector seq(total_hosts); for (size_t i = 0; i < total_hosts; ++i) seq[i] = i + 1; verify_sequence(qp.get(), seq); } TEST(RoundRobinLoadBalancingUnitTest, Simple) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(2, "rack", "dc", &hosts); - cass::RoundRobinPolicy policy; - policy.init(cass::SharedRefPtr(), hosts, NULL); + RoundRobinPolicy policy; + policy.init(SharedRefPtr(), hosts, NULL); // start on first elem - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); const size_t seq1[] = {1, 2}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); // rotate starting element - cass::ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); const size_t seq2[] = {2, 1}; verify_sequence(qp2.get(), VECTOR_FROM(size_t, seq2)); // back around - cass::ScopedPtr qp3(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp3(policy.new_query_plan("ks", NULL, NULL)); verify_sequence(qp3.get(), VECTOR_FROM(size_t, seq1)); } TEST(RoundRobinLoadBalancingUnitTest, OnAdd) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(2, "rack", "dc", &hosts); - cass::RoundRobinPolicy policy; - policy.init(cass::SharedRefPtr(), hosts, NULL); + RoundRobinPolicy policy; + policy.init(SharedRefPtr(), hosts, NULL); // baseline - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); const size_t seq1[] = {1, 2}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); const size_t seq_new = 5; - cass::Address addr_new = addr_for_sequence(seq_new); - cass::SharedRefPtr host = host_for_addr(addr_new); + Address addr_new = addr_for_sequence(seq_new); + SharedRefPtr host = host_for_addr(addr_new); policy.on_host_added(host); policy.on_host_up(host); - cass::ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); const size_t seq2[] = {2, seq_new, 1}; verify_sequence(qp2.get(), VECTOR_FROM(size_t, seq2)); } TEST(RoundRobinLoadBalancingUnitTest, OnRemove) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", "dc", &hosts); - cass::RoundRobinPolicy policy; - policy.init(cass::SharedRefPtr(), hosts, NULL); + RoundRobinPolicy policy; + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); - cass::SharedRefPtr host = hosts.begin()->second; + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + SharedRefPtr host = hosts.begin()->second; policy.on_host_removed(host); - cass::ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp2(policy.new_query_plan("ks", NULL, NULL)); // Both should not have the removed host const size_t seq1[] = {2, 3}; @@ -255,15 +259,15 @@ TEST(RoundRobinLoadBalancingUnitTest, OnRemove) { } TEST(RoundRobinLoadBalancingUnitTest, OnUpAndDown) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", "dc", &hosts); - cass::RoundRobinPolicy policy; - policy.init(cass::SharedRefPtr(), hosts, NULL); + RoundRobinPolicy policy; + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp_before1(policy.new_query_plan("ks", NULL, NULL)); - cass::ScopedPtr qp_before2(policy.new_query_plan("ks", NULL, NULL)); - cass::SharedRefPtr host = hosts.begin()->second; + ScopedPtr qp_before1(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp_before2(policy.new_query_plan("ks", NULL, NULL)); + SharedRefPtr host = hosts.begin()->second; // 'before' qp both have the down host // Ahead of set_down, it will be returned @@ -282,8 +286,8 @@ TEST(RoundRobinLoadBalancingUnitTest, OnUpAndDown) { // host is added to the list, but not 'up' policy.on_host_up(host); - cass::ScopedPtr qp_after1(policy.new_query_plan("ks", NULL, NULL)); - cass::ScopedPtr qp_after2(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp_after1(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp_after2(policy.new_query_plan("ks", NULL, NULL)); policy.on_host_down(host->address()); // 1 is dynamically excluded from plan @@ -301,11 +305,11 @@ TEST(RoundRobinLoadBalancingUnitTest, OnUpAndDown) { } TEST(RoundRobinLoadBalancingUnitTest, VerifyEqualDistribution) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", "dc", &hosts); - cass::RoundRobinPolicy policy; - policy.init(cass::SharedRefPtr(), hosts, NULL); + RoundRobinPolicy policy; + policy.init(SharedRefPtr(), hosts, NULL); { // All nodes QueryCounts counts(run_policy(policy, 12)); @@ -340,31 +344,31 @@ TEST(RoundRobinLoadBalancingUnitTest, VerifyEqualDistribution) { TEST(DatacenterAwareLoadBalancingUnitTest, SomeDatacenterLocalUnspecified) { const size_t total_hosts = 3; - cass::HostMap hosts; + HostMap hosts; populate_hosts(total_hosts, "rack", LOCAL_DC, &hosts); - cass::Host* h = hosts.begin()->second.get(); + Host* h = hosts.begin()->second.get(); h->set_rack_and_dc("", ""); - cass::DCAwarePolicy policy(LOCAL_DC, 1, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 1, false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); const size_t seq[] = {2, 3, 1}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } TEST(DatacenterAwareLoadBalancingUnitTest, SingleLocalDown) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", LOCAL_DC, &hosts); - cass::SharedRefPtr target_host = hosts.begin()->second; + SharedRefPtr target_host = hosts.begin()->second; populate_hosts(1, "rack", REMOTE_DC, &hosts); - cass::DCAwarePolicy policy(LOCAL_DC, 1, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 1, false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan - cass::ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan + ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan + ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan policy.on_host_down(target_host->address()); { @@ -380,17 +384,17 @@ TEST(DatacenterAwareLoadBalancingUnitTest, SingleLocalDown) { } TEST(DatacenterAwareLoadBalancingUnitTest, AllLocalRemovedReturned) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(1, "rack", LOCAL_DC, &hosts); - cass::SharedRefPtr target_host = hosts.begin()->second; + SharedRefPtr target_host = hosts.begin()->second; populate_hosts(1, "rack", REMOTE_DC, &hosts); - cass::DCAwarePolicy policy(LOCAL_DC, 1, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 1, false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan + ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan policy.on_host_down(target_host->address()); - cass::ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan + ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan { const size_t seq[] = {2}; @@ -401,7 +405,7 @@ TEST(DatacenterAwareLoadBalancingUnitTest, AllLocalRemovedReturned) { policy.on_host_up(target_host); // make sure we get the local node first after on_up - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); { const size_t seq[] = {1, 2}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); @@ -409,18 +413,18 @@ TEST(DatacenterAwareLoadBalancingUnitTest, AllLocalRemovedReturned) { } TEST(DatacenterAwareLoadBalancingUnitTest, RemoteRemovedReturned) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(1, "rack", LOCAL_DC, &hosts); populate_hosts(1, "rack", REMOTE_DC, &hosts); - cass::Address target_addr("2.0.0.0", 9042); - cass::SharedRefPtr target_host = hosts[target_addr]; + Address target_addr("2.0.0.0", 9042); + SharedRefPtr target_host = hosts[target_addr]; - cass::DCAwarePolicy policy(LOCAL_DC, 1, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 1, false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan + ScopedPtr qp_before(policy.new_query_plan("ks", NULL, NULL));// has down host ptr in plan policy.on_host_down(target_host->address()); - cass::ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan + ScopedPtr qp_after(policy.new_query_plan("ks", NULL, NULL));// should not have down host ptr in plan { const size_t seq[] = {1}; @@ -431,7 +435,7 @@ TEST(DatacenterAwareLoadBalancingUnitTest, RemoteRemovedReturned) { policy.on_host_up(target_host); // make sure we get both nodes, correct order after - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); { const size_t seq[] = {1, 2}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); @@ -439,16 +443,16 @@ TEST(DatacenterAwareLoadBalancingUnitTest, RemoteRemovedReturned) { } TEST(DatacenterAwareLoadBalancingUnitTest, UsedHostsPerDatacenter) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", LOCAL_DC, &hosts); populate_hosts(3, "rack", REMOTE_DC, &hosts); for (size_t used_hosts = 0; used_hosts < 4; ++used_hosts) { - cass::DCAwarePolicy policy(LOCAL_DC, used_hosts, false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, used_hosts, false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); - cass::Vector seq; + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + Vector seq; size_t index = 0; seq.reserve(3 + used_hosts); @@ -470,24 +474,24 @@ TEST(DatacenterAwareLoadBalancingUnitTest, UsedHostsPerDatacenter) { } TEST(DatacenterAwareLoadBalancingUnitTest, AllowRemoteDatacentersForLocalConsistencyLevel) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", LOCAL_DC, &hosts); populate_hosts(3, "rack", REMOTE_DC, &hosts); { // Not allowing remote DCs for local CLs bool allow_remote_dcs_for_local_cl = false; - cass::DCAwarePolicy policy(LOCAL_DC, 3, !allow_remote_dcs_for_local_cl); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 3, !allow_remote_dcs_for_local_cl); + policy.init(SharedRefPtr(), hosts, NULL); // Set local CL - cass::QueryRequest::Ptr request(new cass::QueryRequest("", 0)); + QueryRequest::Ptr request(new QueryRequest("", 0)); request->set_consistency(CASS_CONSISTENCY_LOCAL_ONE); - cass::SharedRefPtr request_handler( - new cass::RequestHandler(request, cass::ResponseFuture::Ptr())); + SharedRefPtr request_handler( + new RequestHandler(request, ResponseFuture::Ptr())); // Check for only local hosts are used - cass::ScopedPtr qp(policy.new_query_plan("ks", request_handler.get(), NULL)); + ScopedPtr qp(policy.new_query_plan("ks", request_handler.get(), NULL)); const size_t seq[] = {1, 2, 3}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } @@ -495,61 +499,61 @@ TEST(DatacenterAwareLoadBalancingUnitTest, AllowRemoteDatacentersForLocalConsist { // Allowing remote DCs for local CLs bool allow_remote_dcs_for_local_cl = true; - cass::DCAwarePolicy policy(LOCAL_DC, 3, !allow_remote_dcs_for_local_cl); - policy.init(cass::SharedRefPtr(), hosts, NULL); + DCAwarePolicy policy(LOCAL_DC, 3, !allow_remote_dcs_for_local_cl); + policy.init(SharedRefPtr(), hosts, NULL); // Set local CL - cass::QueryRequest::Ptr request(new cass::QueryRequest("", 0)); + QueryRequest::Ptr request(new QueryRequest("", 0)); request->set_consistency(CASS_CONSISTENCY_LOCAL_QUORUM); - cass::SharedRefPtr request_handler( - new cass::RequestHandler(request, cass::ResponseFuture::Ptr())); + SharedRefPtr request_handler( + new RequestHandler(request, ResponseFuture::Ptr())); // Check for only local hosts are used - cass::ScopedPtr qp(policy.new_query_plan("ks", request_handler.get(), NULL)); + ScopedPtr qp(policy.new_query_plan("ks", request_handler.get(), NULL)); const size_t seq[] = {1, 2, 3, 4, 5, 6}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } } TEST(DatacenterAwareLoadBalancingUnitTest, StartWithEmptyLocalDatacenter) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(1, "rack", REMOTE_DC, &hosts); populate_hosts(3, "rack", LOCAL_DC, &hosts); // Set local DC using connected host { - cass::DCAwarePolicy policy("", 0, false); - policy.init(hosts[cass::Address("2.0.0.0", 9042)], hosts, NULL); + DCAwarePolicy policy("", 0, false); + policy.init(hosts[Address("2.0.0.0", 9042)], hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); const size_t seq[] = {2, 3, 4}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } // Set local DC using first host with non-empty DC { - cass::DCAwarePolicy policy("", 0, false); - policy.init(cass::SharedRefPtr( - new cass::Host(cass::Address("0.0.0.0", 9042))), hosts, NULL); + DCAwarePolicy policy("", 0, false); + policy.init(SharedRefPtr( + new Host(Address("0.0.0.0", 9042))), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); const size_t seq[] = {1}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } } -cass::Vector single_token(int64_t token) { - cass::OStringStream ss; +Vector single_token(int64_t token) { + OStringStream ss; ss << token; - return cass::Vector(1, ss.str()); + return Vector(1, ss.str()); } TEST(DatacenterAwareLoadBalancingUnitTest, VerifyEqualDistributionLocalDc) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", LOCAL_DC, &hosts); populate_hosts(3, "rack", REMOTE_DC, &hosts); - cass::DCAwarePolicy policy("", 0, false); + DCAwarePolicy policy("", 0, false); policy.init(hosts.begin()->second, hosts, NULL); { // All local nodes @@ -588,16 +592,16 @@ TEST(DatacenterAwareLoadBalancingUnitTest, VerifyEqualDistributionLocalDc) { } TEST(DatacenterAwareLoadBalancingUnitTest, VerifyEqualDistributionRemoteDc) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack", LOCAL_DC, &hosts); populate_hosts(3, "rack", REMOTE_DC, &hosts); - cass::DCAwarePolicy policy("", 3, false); // Allow all remote DC nodes + DCAwarePolicy policy("", 3, false); // Allow all remote DC nodes policy.init(hosts.begin()->second, hosts, NULL); - cass::Host::Ptr remote_dc_node1; + Host::Ptr remote_dc_node1; { // Mark down all local nodes - cass::HostMap::iterator it = hosts.begin(); + HostMap::iterator it = hosts.begin(); for (int i = 0; i < 3; ++i) { policy.on_host_down(it->first); it++; @@ -642,8 +646,8 @@ TEST(DatacenterAwareLoadBalancingUnitTest, VerifyEqualDistributionRemoteDc) { TEST(TokenAwareLoadBalancingUnitTest, Simple) { const int64_t num_hosts = 4; - cass::HostMap hosts; - cass::TokenMap::Ptr token_map(cass::TokenMap::from_partitioner(cass::Murmur3Partitioner::name())); + HostMap hosts; + TokenMap::Ptr token_map(TokenMap::from_partitioner(Murmur3Partitioner::name())); // Tokens // 1.0.0.0 -4611686018427387905 @@ -652,14 +656,14 @@ TEST(TokenAwareLoadBalancingUnitTest, Simple) { // 4.0.0.0 9223372036854775804 const uint64_t partition_size = CASS_UINT64_MAX / num_hosts; - cass::Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; + Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; for (size_t i = 1; i <= num_hosts; ++i) { - cass::Host::Ptr host(create_host(addr_for_sequence(i), - single_token(token), - cass::Murmur3Partitioner::name().to_string(), - "rack1", - LOCAL_DC)); + Host::Ptr host(create_host(addr_for_sequence(i), + single_token(token), + Murmur3Partitioner::name().to_string(), + "rack1", + LOCAL_DC)); hosts[host->address()] = host; token_map->add_host(host); @@ -669,28 +673,28 @@ TEST(TokenAwareLoadBalancingUnitTest, Simple) { add_keyspace_simple("test", 3, token_map.get()); token_map->build(); - cass::TokenAwarePolicy policy(new cass::RoundRobinPolicy(), false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + TokenAwarePolicy policy(new RoundRobinPolicy(), false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::QueryRequest::Ptr request(new cass::QueryRequest("", 1)); + QueryRequest::Ptr request(new QueryRequest("", 1)); const char* value = "kjdfjkldsdjkl"; // hash: 9024137376112061887 - request->set(0, cass::CassString(value, strlen(value))); + request->set(0, CassString(value, strlen(value))); request->add_key_index(0); - cass::SharedRefPtr request_handler( - new cass::RequestHandler(request, cass::ResponseFuture::Ptr())); + SharedRefPtr request_handler( + new RequestHandler(request, ResponseFuture::Ptr())); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 4, 1, 2, 3 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } // Bring down the first host - cass::HostMap::iterator curr_host_it = hosts.begin(); // 1.0.0.0 + HostMap::iterator curr_host_it = hosts.begin(); // 1.0.0.0 policy.on_host_down(curr_host_it->second->address()); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 4, 2, 3 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } @@ -703,7 +707,7 @@ TEST(TokenAwareLoadBalancingUnitTest, Simple) { policy.on_host_down(curr_host_it->second->address()); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 1, 2, 3 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } @@ -711,9 +715,9 @@ TEST(TokenAwareLoadBalancingUnitTest, Simple) { TEST(TokenAwareLoadBalancingUnitTest, NetworkTopology) { const size_t num_hosts = 7; - cass::HostMap hosts; + HostMap hosts; - cass::TokenMap::Ptr token_map(cass::TokenMap::from_partitioner(cass::Murmur3Partitioner::name())); + TokenMap::Ptr token_map(TokenMap::from_partitioner(Murmur3Partitioner::name())); // Tokens // 1.0.0.0 local -6588122883467697006 @@ -725,14 +729,14 @@ TEST(TokenAwareLoadBalancingUnitTest, NetworkTopology) { // 7.0.0.0 local 9223372036854775806 const uint64_t partition_size = CASS_UINT64_MAX / num_hosts; - cass::Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; + Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; for (size_t i = 1; i <= num_hosts; ++i) { - cass::Host::Ptr host(create_host(addr_for_sequence(i), - single_token(token), - cass::Murmur3Partitioner::name().to_string(), - "rack1", - i % 2 == 0 ? REMOTE_DC : LOCAL_DC)); + Host::Ptr host(create_host(addr_for_sequence(i), + single_token(token), + Murmur3Partitioner::name().to_string(), + "rack1", + i % 2 == 0 ? REMOTE_DC : LOCAL_DC)); hosts[host->address()] = host; token_map->add_host(host); @@ -745,28 +749,28 @@ TEST(TokenAwareLoadBalancingUnitTest, NetworkTopology) { add_keyspace_network_topology("test", replication, token_map.get()); token_map->build(); - cass::TokenAwarePolicy policy(new cass::DCAwarePolicy(LOCAL_DC, num_hosts / 2, false), false); - policy.init(cass::SharedRefPtr(), hosts, NULL); + TokenAwarePolicy policy(new DCAwarePolicy(LOCAL_DC, num_hosts / 2, false), false); + policy.init(SharedRefPtr(), hosts, NULL); - cass::QueryRequest::Ptr request(new cass::QueryRequest("", 1)); + QueryRequest::Ptr request(new QueryRequest("", 1)); const char* value = "abc"; // hash: -5434086359492102041 - request->set(0, cass::CassString(value, strlen(value))); + request->set(0, CassString(value, strlen(value))); request->add_key_index(0); - cass::SharedRefPtr request_handler( - new cass::RequestHandler(request, cass::ResponseFuture::Ptr())); + SharedRefPtr request_handler( + new RequestHandler(request, ResponseFuture::Ptr())); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 3, 5, 7, 1, 4, 6, 2 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } // Bring down the first host - cass::HostMap::iterator curr_host_it = hosts.begin(); // 1.0.0.0 + HostMap::iterator curr_host_it = hosts.begin(); // 1.0.0.0 policy.on_host_down(curr_host_it->second->address()); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 3, 5, 7, 4, 6, 2 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } @@ -778,18 +782,18 @@ TEST(TokenAwareLoadBalancingUnitTest, NetworkTopology) { policy.on_host_down(curr_host_it->second->address()); { - cass::ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(policy.new_query_plan("test", request_handler.get(), token_map.get())); const size_t seq[] = { 5, 7, 1, 6, 2, 4 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq)); } } TEST(TokenAwareLoadBalancingUnitTest, ShuffleReplicas) { - cass::Random random; + Random random; const int64_t num_hosts = 4; - cass::HostMap hosts; - cass::TokenMap::Ptr token_map(cass::TokenMap::from_partitioner(cass::Murmur3Partitioner::name())); + HostMap hosts; + TokenMap::Ptr token_map(TokenMap::from_partitioner(Murmur3Partitioner::name())); // Tokens // 1.0.0.0 -4611686018427387905 @@ -798,14 +802,14 @@ TEST(TokenAwareLoadBalancingUnitTest, ShuffleReplicas) { // 4.0.0.0 9223372036854775804 const uint64_t partition_size = CASS_UINT64_MAX / num_hosts; - cass::Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; + Murmur3Partitioner::Token token = CASS_INT64_MIN + partition_size; for (size_t i = 1; i <= num_hosts; ++i) { - cass::Host::Ptr host(create_host(addr_for_sequence(i), - single_token(token), - cass::Murmur3Partitioner::name().to_string(), - "rack1", - LOCAL_DC)); + Host::Ptr host(create_host(addr_for_sequence(i), + single_token(token), + Murmur3Partitioner::name().to_string(), + "rack1", + LOCAL_DC)); hosts[host->address()] = host; token_map->add_host(host); @@ -815,26 +819,26 @@ TEST(TokenAwareLoadBalancingUnitTest, ShuffleReplicas) { add_keyspace_simple("test", 3, token_map.get()); token_map->build(); - cass::QueryRequest::Ptr request(new cass::QueryRequest("", 1)); + QueryRequest::Ptr request(new QueryRequest("", 1)); const char* value = "kjdfjkldsdjkl"; // hash: 9024137376112061887 - request->set(0, cass::CassString(value, strlen(value))); + request->set(0, CassString(value, strlen(value))); request->add_key_index(0); - cass::SharedRefPtr request_handler( - new cass::RequestHandler(request, cass::ResponseFuture::Ptr())); + SharedRefPtr request_handler( + new RequestHandler(request, ResponseFuture::Ptr())); - cass::HostVec not_shuffled; + HostVec not_shuffled; { - cass::TokenAwarePolicy policy(new cass::RoundRobinPolicy(), false); // Not shuffled - policy.init(cass::SharedRefPtr(), hosts, &random); - cass::ScopedPtr qp1(policy.new_query_plan("test", request_handler.get(), token_map.get())); + TokenAwarePolicy policy(new RoundRobinPolicy(), false); // Not shuffled + policy.init(SharedRefPtr(), hosts, &random); + ScopedPtr qp1(policy.new_query_plan("test", request_handler.get(), token_map.get())); for (int i = 0; i < num_hosts; ++i) { not_shuffled.push_back(qp1->compute_next()); } // Verify that not shuffled will repeat the same order - cass::HostVec not_shuffled_again; - cass::ScopedPtr qp2(policy.new_query_plan("test", request_handler.get(), token_map.get())); + HostVec not_shuffled_again; + ScopedPtr qp2(policy.new_query_plan("test", request_handler.get(), token_map.get())); for (int i = 0; i < num_hosts; ++i) { not_shuffled_again.push_back(qp2->compute_next()); } @@ -843,11 +847,11 @@ TEST(TokenAwareLoadBalancingUnitTest, ShuffleReplicas) { // Verify that the shuffle setting does indeed shuffle the replicas { - cass::TokenAwarePolicy shuffle_policy(new cass::RoundRobinPolicy(), true); // Shuffled - shuffle_policy.init(cass::SharedRefPtr(), hosts, &random); + TokenAwarePolicy shuffle_policy(new RoundRobinPolicy(), true); // Shuffled + shuffle_policy.init(SharedRefPtr(), hosts, &random); - cass::HostVec shuffled_previous; - cass::ScopedPtr qp(shuffle_policy.new_query_plan("test", request_handler.get(), token_map.get())); + HostVec shuffled_previous; + ScopedPtr qp(shuffle_policy.new_query_plan("test", request_handler.get(), token_map.get())); for (int i = 0; i < num_hosts; ++i) { shuffled_previous.push_back(qp->compute_next()); } @@ -855,11 +859,11 @@ TEST(TokenAwareLoadBalancingUnitTest, ShuffleReplicas) { int count; const int max_iterations = num_hosts * num_hosts; for (count = 0; count < max_iterations; ++count) { - cass::ScopedPtr qp(shuffle_policy.new_query_plan("test", request_handler.get(), token_map.get())); + ScopedPtr qp(shuffle_policy.new_query_plan("test", request_handler.get(), token_map.get())); - cass::HostVec shuffled; + HostVec shuffled; for (int j = 0; j < num_hosts; ++j) { - cass::Host::Ptr host(qp->compute_next()); + Host::Ptr host(qp->compute_next()); EXPECT_GT(std::count(not_shuffled.begin(), not_shuffled.end(), host), 0); shuffled.push_back(host); } @@ -879,10 +883,10 @@ TEST(LatencyAwareLoadBalancingUnitTest, ThreadholdToAccount) { const uint64_t threshold_to_account = (30LL * min_measured) / 100LL; const uint64_t one_ms = 1000000LL; // 1 ms in ns - cass::Host host(cass::Address("0.0.0.0", 9042)); + Host host(Address("0.0.0.0", 9042)); host.enable_latency_tracking(scale, min_measured); - cass::TimestampedAverage current = host.get_current_average(); + TimestampedAverage current = host.get_current_average(); for (uint64_t i = 0; i < threshold_to_account; ++i) { host.update_latency(one_ms); current = host.get_current_average(); @@ -926,7 +930,7 @@ TEST(LatencyAwareLoadBalancingUnitTest, DISABLED_Simple) { // Disabled: See http #else TEST(LatencyAwareLoadBalancingUnitTest, Simple) { #endif - cass::LatencyAwarePolicy::Settings settings; + LatencyAwarePolicy::Settings settings; // Disable min_measured settings.min_measured = 0L; @@ -938,22 +942,22 @@ TEST(LatencyAwareLoadBalancingUnitTest, Simple) { settings.retry_period_ns = 1000LL * 1000LL * 1000L; const int64_t num_hosts = 4; - cass::HostMap hosts; + HostMap hosts; populate_hosts(num_hosts, "rack1", LOCAL_DC, &hosts); - cass::LatencyAwarePolicy policy(new cass::RoundRobinPolicy(), settings); - policy.init(cass::SharedRefPtr(), hosts, NULL); + LatencyAwarePolicy policy(new RoundRobinPolicy(), settings); + policy.init(SharedRefPtr(), hosts, NULL); // Record some latencies with 100 ns being the minimum - for (cass::HostMap::iterator i = hosts.begin(); i != hosts.end(); ++i) { + for (HostMap::iterator i = hosts.begin(); i != hosts.end(); ++i) { i->second->enable_latency_tracking(settings.scale_ns, settings.min_measured); } - hosts[cass::Address("1.0.0.0", 9042)]->update_latency(100); - hosts[cass::Address("4.0.0.0", 9042)]->update_latency(150); + hosts[Address("1.0.0.0", 9042)]->update_latency(100); + hosts[Address("4.0.0.0", 9042)]->update_latency(150); // Hosts 2 and 3 will exceed the exclusion threshold - hosts[cass::Address("2.0.0.0", 9042)]->update_latency(201); - hosts[cass::Address("3.0.0.0", 9042)]->update_latency(1000); + hosts[Address("2.0.0.0", 9042)]->update_latency(201); + hosts[Address("3.0.0.0", 9042)]->update_latency(1000); // Verify we don't have a current minimum average EXPECT_EQ(policy.min_average(), -1); @@ -974,7 +978,7 @@ TEST(LatencyAwareLoadBalancingUnitTest, Simple) { // 1 and 4 are under the minimum, but 2 and 3 will be skipped { - cass::ScopedPtr qp(policy.new_query_plan("", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("", NULL, NULL)); const size_t seq1[] = {1, 4, 2, 3}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); } @@ -984,7 +988,7 @@ TEST(LatencyAwareLoadBalancingUnitTest, Simple) { // After waiting no hosts should be skipped (notice 2 and 3 tried first) { - cass::ScopedPtr qp(policy.new_query_plan("", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("", NULL, NULL)); const size_t seq1[] = {2, 3, 4, 1}; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); } @@ -995,16 +999,16 @@ TEST(LatencyAwareLoadBalancingUnitTest, DISABLED_MinAverageUnderMinMeasured) { / #else TEST(LatencyAwareLoadBalancingUnitTest, MinAverageUnderMinMeasured) { #endif - cass::LatencyAwarePolicy::Settings settings; + LatencyAwarePolicy::Settings settings; const int64_t num_hosts = 4; - cass::HostMap hosts; + HostMap hosts; populate_hosts(num_hosts, "rack1", LOCAL_DC, &hosts); - cass::LatencyAwarePolicy policy(new cass::RoundRobinPolicy(), settings); - policy.init(cass::SharedRefPtr(), hosts, NULL); + LatencyAwarePolicy policy(new RoundRobinPolicy(), settings); + policy.init(SharedRefPtr(), hosts, NULL); int count = 1; - for (cass::HostMap::iterator i = hosts.begin(); i != hosts.end(); ++i) { + for (HostMap::iterator i = hosts.begin(); i != hosts.end(); ++i) { i->second->enable_latency_tracking(settings.scale_ns, settings.min_measured); i->second->update_latency(100 * count++); } @@ -1029,82 +1033,82 @@ TEST(LatencyAwareLoadBalancingUnitTest, MinAverageUnderMinMeasured) { TEST(WhitelistLoadBalancingUnitTest, Hosts) { const int64_t num_hosts = 100; - cass::HostMap hosts; + HostMap hosts; populate_hosts(num_hosts, "rack1", LOCAL_DC, &hosts); - cass::ContactPointList whitelist_hosts; + ContactPointList whitelist_hosts; whitelist_hosts.push_back("37.0.0.0"); whitelist_hosts.push_back("83.0.0.0"); - cass::WhitelistPolicy policy(new cass::RoundRobinPolicy(), whitelist_hosts); - policy.init(cass::SharedRefPtr(), hosts, NULL); + WhitelistPolicy policy(new RoundRobinPolicy(), whitelist_hosts); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); // Verify only hosts 37 and 83 are computed in the query plan const size_t seq1[] = { 37, 83 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); // The query plan should now be exhausted - cass::Address next_address; + Address next_address; ASSERT_FALSE(qp.get()->compute_next(&next_address)); } TEST(WhitelistLoadBalancingUnitTest, Datacenters) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack1", LOCAL_DC, &hosts); populate_hosts(3, "rack1", BACKUP_DC, &hosts); populate_hosts(3, "rack1", REMOTE_DC, &hosts); - cass::DcList whitelist_dcs; + DcList whitelist_dcs; whitelist_dcs.push_back(LOCAL_DC); whitelist_dcs.push_back(REMOTE_DC); - cass::WhitelistDCPolicy policy(new cass::RoundRobinPolicy(), whitelist_dcs); - policy.init(cass::SharedRefPtr(), hosts, NULL); + WhitelistDCPolicy policy(new RoundRobinPolicy(), whitelist_dcs); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); // Verify only hosts LOCAL_DC and REMOTE_DC are computed in the query plan const size_t seq1[] = { 1, 2, 3, 7, 8, 9 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); // The query plan should now be exhausted - cass::Address next_address; + Address next_address; ASSERT_FALSE(qp.get()->compute_next(&next_address)); } TEST(BlacklistLoadBalancingUnitTest, Hosts) { const int64_t num_hosts = 5; - cass::HostMap hosts; + HostMap hosts; populate_hosts(num_hosts, "rack1", LOCAL_DC, &hosts); - cass::ContactPointList blacklist_hosts; + ContactPointList blacklist_hosts; blacklist_hosts.push_back("2.0.0.0"); blacklist_hosts.push_back("3.0.0.0"); - cass::BlacklistPolicy policy(new cass::RoundRobinPolicy(), blacklist_hosts); - policy.init(cass::SharedRefPtr(), hosts, NULL); + BlacklistPolicy policy(new RoundRobinPolicy(), blacklist_hosts); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); // Verify only hosts 1, 4 and 5 are computed in the query plan const size_t seq1[] = { 1, 4, 5 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); // The query plan should now be exhausted - cass::Address next_address; + Address next_address; ASSERT_FALSE(qp.get()->compute_next(&next_address)); } TEST(BlacklistLoadBalancingUnitTest, Datacenters) { - cass::HostMap hosts; + HostMap hosts; populate_hosts(3, "rack1", LOCAL_DC, &hosts); populate_hosts(3, "rack1", BACKUP_DC, &hosts); populate_hosts(3, "rack1", REMOTE_DC, &hosts); - cass::DcList blacklist_dcs; + DcList blacklist_dcs; blacklist_dcs.push_back(LOCAL_DC); blacklist_dcs.push_back(REMOTE_DC); - cass::BlacklistDCPolicy policy(new cass::RoundRobinPolicy(), blacklist_dcs); - policy.init(cass::SharedRefPtr(), hosts, NULL); + BlacklistDCPolicy policy(new RoundRobinPolicy(), blacklist_dcs); + policy.init(SharedRefPtr(), hosts, NULL); - cass::ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); + ScopedPtr qp(policy.new_query_plan("ks", NULL, NULL)); // Verify only hosts from BACKUP_DC are computed in the query plan const size_t seq1[] = { 4, 5, 6 }; verify_sequence(qp.get(), VECTOR_FROM(size_t, seq1)); // The query plan should now be exhausted - cass::Address next_address; + Address next_address; ASSERT_FALSE(qp.get()->compute_next(&next_address)); } diff --git a/cpp-driver/gtests/src/unit/tests/test_loop_watcher.cpp b/cpp-driver/gtests/src/unit/tests/test_loop_watcher.cpp index 3cf6ea83a..cd75abf26 100644 --- a/cpp-driver/gtests/src/unit/tests/test_loop_watcher.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_loop_watcher.cpp @@ -18,6 +18,9 @@ #include "loop_watcher.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + class LoopWatcherUnitTest : public LoopTest { public: LoopWatcherUnitTest() @@ -28,23 +31,23 @@ class LoopWatcherUnitTest : public LoopTest { bool is_prepare_callback_called() { return is_prepare_callback_called_; } protected: - void start(cass::Check* check) { + void start(Check* check) { ASSERT_EQ(0, check->start(loop(), - cass::bind_callback(&LoopWatcherUnitTest::on_check, - this))); + bind_callback(&LoopWatcherUnitTest::on_check, + this))); } - void start(cass::Prepare* prepare) { + void start(Prepare* prepare) { ASSERT_EQ(0, prepare->start(loop(), - cass::bind_callback(&LoopWatcherUnitTest::on_prepare, - this))); + bind_callback(&LoopWatcherUnitTest::on_prepare, + this))); } private: - void on_check(cass::Check* check) { + void on_check(Check* check) { is_check_callback_called_ = true; check->close_handle(); } - void on_prepare(cass::Prepare* prepare) { + void on_prepare(Prepare* prepare) { is_prepare_callback_called_ = true; prepare->close_handle(); } @@ -55,7 +58,7 @@ class LoopWatcherUnitTest : public LoopTest { }; TEST_F(LoopWatcherUnitTest, Check) { - cass::Check check; + Check check; ASSERT_FALSE(check.is_running()); start(&check); @@ -69,7 +72,7 @@ TEST_F(LoopWatcherUnitTest, Check) { } TEST_F(LoopWatcherUnitTest, CheckNotStarted) { - cass::Prepare check; + Prepare check; ASSERT_FALSE(check.is_running()); ASSERT_FALSE(is_check_callback_called()); @@ -80,7 +83,7 @@ TEST_F(LoopWatcherUnitTest, CheckNotStarted) { } TEST_F(LoopWatcherUnitTest, Prepare) { - cass::Prepare prepare; + Prepare prepare; ASSERT_FALSE(prepare.is_running()); start(&prepare); @@ -94,7 +97,7 @@ TEST_F(LoopWatcherUnitTest, Prepare) { } TEST_F(LoopWatcherUnitTest, PrepareNotStarted) { - cass::Prepare prepare; + Prepare prepare; ASSERT_FALSE(prepare.is_running()); ASSERT_FALSE(is_prepare_callback_called()); diff --git a/cpp-driver/gtests/src/unit/tests/test_md5.cpp b/cpp-driver/gtests/src/unit/tests/test_md5.cpp index 71c1a3f45..936ae06b4 100644 --- a/cpp-driver/gtests/src/unit/tests/test_md5.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_md5.cpp @@ -18,6 +18,8 @@ #include "md5.hpp" +using datastax::internal::Md5; + static bool hash_equal(uint8_t* hash, const char* hash_str) { const char* p = hash_str; for (size_t i = 0; i < 16; ++i) { @@ -32,7 +34,7 @@ static bool hash_equal(uint8_t* hash, const char* hash_str) { } static bool check_hash(const char* data, const char* hash_str) { - cass::Md5 m; + Md5 m; m.update(reinterpret_cast(data), strlen(data)); uint8_t hash[16]; m.final(hash); diff --git a/cpp-driver/gtests/src/unit/tests/test_metadata.cpp b/cpp-driver/gtests/src/unit/tests/test_metadata.cpp index ad7950a82..7ecab1960 100644 --- a/cpp-driver/gtests/src/unit/tests/test_metadata.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_metadata.cpp @@ -18,17 +18,21 @@ #include "result_metadata.hpp" -cass::SharedRefPtr create_metadata(const char* column_names[]) { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + +SharedRefPtr create_metadata(const char* column_names[]) { size_t count = 0; while (column_names[count] != NULL) { count++; } - cass::ResultMetadata::Ptr metadata( - new cass::ResultMetadata(count, - cass::RefBuffer::Ptr())); + ResultMetadata::Ptr metadata( + new ResultMetadata(count, + RefBuffer::Ptr())); for (size_t i = 0; column_names[i] != NULL; ++i) { - cass::ColumnDefinition def; - def.name = cass::StringRef(column_names[i]); + ColumnDefinition def; + def.name = StringRef(column_names[i]); def.index = i; metadata->add(def); } @@ -38,10 +42,10 @@ cass::SharedRefPtr create_metadata(const char* column_name TEST(ResultMetadataUnitTest, Simple) { const char* column_names[] = { "abc", "def", "xyz", NULL }; - cass::SharedRefPtr metadata(create_metadata(column_names)); + SharedRefPtr metadata(create_metadata(column_names)); for (size_t i = 0; column_names[i] != NULL; ++i) { - cass::IndexVec indices; + IndexVec indices; size_t count = metadata->get_indices(column_names[i], &indices); EXPECT_EQ(count, 1u); EXPECT_GT(indices.size(), 0u); @@ -51,11 +55,11 @@ TEST(ResultMetadataUnitTest, Simple) { TEST(ResultMetadataUnitTest, CaseSensitive) { const char* column_names[] = { "a", "A", "abc", "Abc", "ABc", "ABC", "aBc", "aBC", "abC", NULL }; - cass::SharedRefPtr metadata(create_metadata(column_names)); + SharedRefPtr metadata(create_metadata(column_names)); for (size_t i = 0; column_names[i] != NULL; ++i) { - cass::IndexVec indices; - cass::String name; + IndexVec indices; + String name; name.push_back('"'); name.append(column_names[i]); name.push_back('"'); @@ -66,13 +70,13 @@ TEST(ResultMetadataUnitTest, CaseSensitive) { } { - cass::IndexVec indices; + IndexVec indices; size_t count = metadata->get_indices("a", &indices); EXPECT_EQ(count, 2u); } { - cass::IndexVec indices; + IndexVec indices; size_t count = metadata->get_indices("abc", &indices); EXPECT_EQ(count, 7u); } diff --git a/cpp-driver/gtests/src/unit/tests/test_metrics.cpp b/cpp-driver/gtests/src/unit/tests/test_metrics.cpp index bc04e21d6..5ef808d56 100644 --- a/cpp-driver/gtests/src/unit/tests/test_metrics.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_metrics.cpp @@ -25,9 +25,11 @@ #define NUM_THREADS 2 #define NUM_ITERATIONS 100 +using datastax::internal::core::Metrics; + struct CounterThreadArgs { uv_thread_t thread; - cass::Metrics::Counter* counter; + Metrics::Counter* counter; }; void counter_thread(void* data) { @@ -40,7 +42,7 @@ void counter_thread(void* data) { struct HistogramThreadArgs { uv_thread_t thread; uint64_t id; - cass::Metrics::Histogram* histogram; + Metrics::Histogram* histogram; }; void histogram_thread(void* data) { @@ -52,7 +54,7 @@ void histogram_thread(void* data) { struct MeterThreadArgs { uv_thread_t thread; - cass::Metrics::Meter* meter; + Metrics::Meter* meter; }; void meter_thread(void* data) { @@ -66,8 +68,8 @@ void meter_thread(void* data) { } TEST(MetricsUnitTest, Counter) { - cass::Metrics::ThreadState thread_state(1); - cass::Metrics::Counter counter(&thread_state); + Metrics::ThreadState thread_state(1); + Metrics::Counter counter(&thread_state); EXPECT_EQ(counter.sum(), 0); @@ -85,8 +87,8 @@ TEST(MetricsUnitTest, Counter) { TEST(MetricsUnitTest, CounterWithThreads) { CounterThreadArgs args[NUM_THREADS]; - cass::Metrics::ThreadState thread_state(NUM_THREADS); - cass::Metrics::Counter counter(&thread_state); + Metrics::ThreadState thread_state(NUM_THREADS); + Metrics::Counter counter(&thread_state); for (int i = 0; i < NUM_THREADS; ++i) { args[i].counter = &counter; @@ -101,14 +103,14 @@ TEST(MetricsUnitTest, CounterWithThreads) { } TEST(MetricsUnitTest, Histogram) { - cass::Metrics::ThreadState thread_state(1); - cass::Metrics::Histogram histogram(&thread_state); + Metrics::ThreadState thread_state(1); + Metrics::Histogram histogram(&thread_state); for (uint64_t i = 1; i <= 100; ++i) { histogram.record_value(i); } - cass::Metrics::Histogram::Snapshot snapshot; + Metrics::Histogram::Snapshot snapshot; histogram.get_snapshot(&snapshot); EXPECT_EQ(snapshot.min, 1); @@ -124,10 +126,10 @@ TEST(MetricsUnitTest, Histogram) { } TEST(MetricsUnitTest, HistogramEmpty) { - cass::Metrics::ThreadState thread_state(1); - cass::Metrics::Histogram histogram(&thread_state); + Metrics::ThreadState thread_state(1); + Metrics::Histogram histogram(&thread_state); - cass::Metrics::Histogram::Snapshot snapshot; + Metrics::Histogram::Snapshot snapshot; histogram.get_snapshot(&snapshot); EXPECT_EQ(snapshot.min, 0); @@ -145,8 +147,8 @@ TEST(MetricsUnitTest, HistogramEmpty) { TEST(MetricsUnitTest, HistogramWithThreads) { HistogramThreadArgs args[NUM_THREADS]; - cass::Metrics::ThreadState thread_state(NUM_THREADS); - cass::Metrics::Histogram histogram(&thread_state); + Metrics::ThreadState thread_state(NUM_THREADS); + Metrics::Histogram histogram(&thread_state); for (int i = 0; i < NUM_THREADS; ++i) { args[i].histogram = &histogram; @@ -158,7 +160,7 @@ TEST(MetricsUnitTest, HistogramWithThreads) { uv_thread_join(&args[i].thread); } - cass::Metrics::Histogram::Snapshot snapshot; + Metrics::Histogram::Snapshot snapshot; histogram.get_snapshot(&snapshot); EXPECT_EQ(snapshot.min, 1); @@ -173,8 +175,8 @@ TEST(MetricsUnitTest, HistogramWithThreads) { } TEST(MetricsUnitTest, Meter) { - cass::Metrics::ThreadState thread_state(1); - cass::Metrics::Meter meter(&thread_state); + Metrics::ThreadState thread_state(1); + Metrics::Meter meter(&thread_state); // ~10 requests a second (Needs to run for at least 5 seconds) for (int i = 0; i < 51; ++i) { @@ -202,8 +204,8 @@ TEST(MetricsUnitTest, Meter) { } TEST(MetricsUnitTest, MeterSpeculative) { - cass::Metrics::ThreadState thread_state(1); - cass::Metrics::Meter meter(&thread_state); + Metrics::ThreadState thread_state(1); + Metrics::Meter meter(&thread_state); // Emulate a situation where for a total of 60 requests sent on the wire, // where 15 are unique requests and 45 are dups (speculative executions). @@ -224,8 +226,8 @@ TEST(MetricsUnitTest, MeterSpeculative) { TEST(MetricsUnitTest, MeterWithThreads) { MeterThreadArgs args[NUM_THREADS]; - cass::Metrics::ThreadState thread_state(NUM_THREADS); - cass::Metrics::Meter meter(&thread_state); + Metrics::ThreadState thread_state(NUM_THREADS); + Metrics::Meter meter(&thread_state); for (int i = 0; i < NUM_THREADS; ++i) { args[i].meter = &meter; diff --git a/cpp-driver/gtests/src/unit/tests/test_micro_timer.cpp b/cpp-driver/gtests/src/unit/tests/test_micro_timer.cpp index fa7e14441..6652d5b20 100644 --- a/cpp-driver/gtests/src/unit/tests/test_micro_timer.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_micro_timer.cpp @@ -18,7 +18,8 @@ #include "loop_test.hpp" -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; class MicroTimerUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_name_resolver.cpp b/cpp-driver/gtests/src/unit/tests/test_name_resolver.cpp index 7a28e1ad9..6e8a01026 100644 --- a/cpp-driver/gtests/src/unit/tests/test_name_resolver.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_name_resolver.cpp @@ -25,11 +25,8 @@ #define RESOLVE_TIMEOUT 2000 -using cass::Address; -using cass::bind_callback; -using cass::Memory; -using cass::NameResolver; -using cass::String; +using namespace datastax; +using namespace datastax::internal::core; class NameResolverUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_pool.cpp b/cpp-driver/gtests/src/unit/tests/test_pool.cpp index 57649f1c9..eb6b8ad98 100644 --- a/cpp-driver/gtests/src/unit/tests/test_pool.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_pool.cpp @@ -18,7 +18,8 @@ #include "ssl.hpp" #define NUM_NODES 3u -using namespace cass; + +using namespace datastax::internal::core; class PoolUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_random.cpp b/cpp-driver/gtests/src/unit/tests/test_random.cpp index 00d7d0bff..91c747a79 100644 --- a/cpp-driver/gtests/src/unit/tests/test_random.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_random.cpp @@ -20,6 +20,8 @@ #include "third_party/hdr_histogram/hdr_histogram.hpp" #include "vector.hpp" +using namespace datastax::internal; + // 626 of the first numbers generated with the default seed of 5489LL using boost::mt19937_64 uint64_t random_numbers[] = { 14514284786278117030ULL,4620546740167642908ULL,13109570281517897720ULL,17462938647148434322ULL,355488278567739596ULL,7469126240319926998ULL,4635995468481642529ULL,418970542659199878ULL, @@ -103,7 +105,7 @@ uint64_t random_numbers[] = { 12329720415526259303ULL,5557519966701086911ULL }; TEST(RandomUnitTest, RandomShuffle) { - cass::Random r; + Random r; const int num_elements = 8; const int max_iterations = num_elements * num_elements; @@ -117,7 +119,7 @@ TEST(RandomUnitTest, RandomShuffle) { int count; for (count = 0; count < max_iterations; ++count) { std::vector copy(previous); - cass::random_shuffle(copy.begin(), copy.end(), &r); + random_shuffle(copy.begin(), copy.end(), &r); if (copy != previous) { break; } @@ -135,7 +137,7 @@ TEST(RandomUnitTest, RandomSeed) { int count; // Keep trying while seed equals previous value for (count = 0; count < max_iterations; ++count) { - uint64_t seed = cass::get_random_seed(previous); + uint64_t seed = get_random_seed(previous); if (seed != previous) { previous = seed; break; diff --git a/cpp-driver/gtests/src/unit/tests/test_replication_strategy.cpp b/cpp-driver/gtests/src/unit/tests/test_replication_strategy.cpp index 06d176047..5f5fa08fd 100644 --- a/cpp-driver/gtests/src/unit/tests/test_replication_strategy.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_replication_strategy.cpp @@ -21,17 +21,21 @@ #include "string.hpp" #include "vector.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + namespace { -static const cass::CopyOnWriteHostVec NO_REPLICAS(NULL); +static const CopyOnWriteHostVec NO_REPLICAS(NULL); template struct MockTokenMap { - typedef typename cass::ReplicationStrategy::Token Token; - typedef typename cass::ReplicationStrategy::TokenHost TokenHost; - typedef typename cass::ReplicationStrategy::TokenHostVec TokenHostVec; - typedef typename cass::ReplicationStrategy::TokenReplicas TokenReplicas; - typedef typename cass::ReplicationStrategy::TokenReplicasVec TokenReplicasVec; + typedef typename ReplicationStrategy::Token Token; + typedef typename ReplicationStrategy::TokenHost TokenHost; + typedef typename ReplicationStrategy::TokenHostVec TokenHostVec; + typedef typename ReplicationStrategy::TokenReplicas TokenReplicas; + typedef typename ReplicationStrategy::TokenReplicasVec TokenReplicasVec; struct TokenReplicasCompare { bool operator()(const TokenReplicas& lhs, const TokenReplicas& rhs) const { @@ -39,70 +43,70 @@ struct MockTokenMap { } }; - cass::HostSet hosts; - cass::IdGenerator dc_ids; - cass::IdGenerator rack_ids; + HostSet hosts; + IdGenerator dc_ids; + IdGenerator rack_ids; - cass::ReplicationStrategy strategy; + ReplicationStrategy strategy; TokenHostVec tokens; TokenReplicasVec replicas; - cass::DatacenterMap datacenters; + DatacenterMap datacenters; void init_simple_strategy(size_t replication_factor) { - cass::DataType::ConstPtr varchar_data_type(new cass::DataType(CASS_VALUE_TYPE_VARCHAR)); + DataType::ConstPtr varchar_data_type(new DataType(CASS_VALUE_TYPE_VARCHAR)); ColumnMetadataVec column_metadata; column_metadata.push_back(ColumnMetadata("keyspace_name", varchar_data_type)); - column_metadata.push_back(ColumnMetadata("replication", cass::CollectionType::map(varchar_data_type, varchar_data_type, true))); + column_metadata.push_back(ColumnMetadata("replication", CollectionType::map(varchar_data_type, varchar_data_type, true))); RowResultResponseBuilder builder(column_metadata); ReplicationMap replication; replication["class"] = CASS_SIMPLE_STRATEGY; - cass::OStringStream ss; + OStringStream ss; ss << replication_factor; replication["replication_factor"] = ss.str(); builder.append_keyspace_row_v3("ks1", replication); builder.finish(); - cass::ResultIterator iterator(builder.finish()); + ResultIterator iterator(builder.finish()); EXPECT_TRUE(iterator.next()); - strategy.init(dc_ids, cass::VersionNumber(3, 0, 0), iterator.row()); + strategy.init(dc_ids, VersionNumber(3, 0, 0), iterator.row()); } void init_network_topology_strategy(ReplicationMap& replication) { - cass::DataType::ConstPtr varchar_data_type(new cass::DataType(CASS_VALUE_TYPE_VARCHAR)); + DataType::ConstPtr varchar_data_type(new DataType(CASS_VALUE_TYPE_VARCHAR)); ColumnMetadataVec column_metadata; column_metadata.push_back(ColumnMetadata("keyspace_name", varchar_data_type)); - column_metadata.push_back(ColumnMetadata("replication", cass::CollectionType::map(varchar_data_type, varchar_data_type, true))); + column_metadata.push_back(ColumnMetadata("replication", CollectionType::map(varchar_data_type, varchar_data_type, true))); RowResultResponseBuilder builder(column_metadata); replication["class"] = CASS_NETWORK_TOPOLOGY_STRATEGY; builder.append_keyspace_row_v3("ks1", replication); builder.finish(); - cass::ResultIterator iterator(builder.finish()); + ResultIterator iterator(builder.finish()); EXPECT_TRUE(iterator.next()); - strategy.init(dc_ids, cass::VersionNumber(3, 0, 0), iterator.row()); + strategy.init(dc_ids, VersionNumber(3, 0, 0), iterator.row()); } void add_token(Token token, - const cass::String& address, - const cass::String& rack = "", - const cass::String& dc = "") { + const String& address, + const String& rack = "", + const String& dc = "") { tokens.push_back(TokenHost(token, create_host(address, rack, dc))); } void build_replicas() { std::sort(tokens.begin(), tokens.end()); // We assume sorted tokens - cass::build_datacenters(hosts, datacenters); + build_datacenters(hosts, datacenters); strategy.build_replicas(tokens, datacenters, replicas); } - const cass::CopyOnWriteHostVec& find_hosts(Token token) { + const CopyOnWriteHostVec& find_hosts(Token token) { typename TokenReplicasVec::const_iterator i = std::lower_bound(replicas.begin(), replicas.end(), TokenReplicas(token, NO_REPLICAS), TokenReplicasCompare()); @@ -112,13 +116,13 @@ struct MockTokenMap { return NO_REPLICAS; } - cass::Host* create_host(const cass::String& address, - const cass::String& rack = "", - const cass::String& dc = "") { - cass::Host::Ptr host(new cass::Host(cass::Address(address, 9042))); + Host* create_host(const String& address, + const String& rack = "", + const String& dc = "") { + Host::Ptr host(new Host(Address(address, 9042))); host->set_rack_and_dc(rack, dc); host->set_rack_and_dc_ids(rack_ids.get(rack), dc_ids.get(dc)); - cass::HostSet::iterator i = hosts.find(host); + HostSet::iterator i = hosts.find(host); if (i != hosts.end()) { return i->get(); } else { @@ -128,11 +132,11 @@ struct MockTokenMap { } }; -void check_host(const cass::SharedRefPtr& host, - const cass::String& ip, - const cass::String& rack = "", - const cass::String& dc = "") { - EXPECT_EQ(host->address(), cass::Address(ip, 9042)); +void check_host(const SharedRefPtr& host, + const String& ip, + const String& rack = "", + const String& dc = "") { + EXPECT_EQ(host->address(), Address(ip, 9042)); EXPECT_EQ(host->rack(), rack); EXPECT_EQ(host->dc(), dc); } @@ -141,14 +145,14 @@ void check_host(const cass::SharedRefPtr& host, TEST(ReplicationStrategyUnitTest, Simple) { - MockTokenMap token_map; + MockTokenMap token_map; token_map.init_simple_strategy(3); - MockTokenMap::Token t1 = 0; - MockTokenMap::Token t2 = 100; - MockTokenMap::Token t3 = 200; - MockTokenMap::Token t4 = 300; + MockTokenMap::Token t1 = 0; + MockTokenMap::Token t2 = 100; + MockTokenMap::Token t3 = 200; + MockTokenMap::Token t4 = 300; token_map.add_token(t1, "1.0.0.1"); token_map.add_token(t2, "1.0.0.2"); @@ -158,7 +162,7 @@ TEST(ReplicationStrategyUnitTest, Simple) token_map.build_replicas(); { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.1"); check_host((*hosts)[1], "1.0.0.2"); @@ -166,21 +170,21 @@ TEST(ReplicationStrategyUnitTest, Simple) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); check_host((*hosts)[0], "1.0.0.2"); check_host((*hosts)[1], "1.0.0.3"); check_host((*hosts)[2], "1.0.0.4"); } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); check_host((*hosts)[0], "1.0.0.3"); check_host((*hosts)[1], "1.0.0.4"); check_host((*hosts)[2], "1.0.0.1"); } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); check_host((*hosts)[0], "1.0.0.4"); check_host((*hosts)[1], "1.0.0.1"); check_host((*hosts)[2], "1.0.0.2"); @@ -189,7 +193,7 @@ TEST(ReplicationStrategyUnitTest, Simple) TEST(ReplicationStrategyUnitTest, NetworkTopology) { - MockTokenMap token_map; + MockTokenMap token_map; ReplicationMap replication; replication["dc1"] = "2"; @@ -197,20 +201,20 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) token_map.init_network_topology_strategy(replication); - MockTokenMap::Token t1 = 0; - MockTokenMap::Token t2 = 100; - MockTokenMap::Token t3 = 200; - MockTokenMap::Token t4 = 300; + MockTokenMap::Token t1 = 0; + MockTokenMap::Token t2 = 100; + MockTokenMap::Token t3 = 200; + MockTokenMap::Token t4 = 300; token_map.add_token(t1, "1.0.0.1", "rack1", "dc1"); token_map.add_token(t2, "1.0.0.2", "rack1", "dc1"); token_map.add_token(t3, "1.0.0.3", "rack2", "dc1"); token_map.add_token(t4, "1.0.0.4", "rack2", "dc1"); - MockTokenMap::Token t5 = 400; - MockTokenMap::Token t6 = 500; - MockTokenMap::Token t7 = 600; - MockTokenMap::Token t8 = 700; + MockTokenMap::Token t5 = 400; + MockTokenMap::Token t6 = 500; + MockTokenMap::Token t7 = 600; + MockTokenMap::Token t8 = 700; token_map.add_token(t5, "2.0.0.1", "rack1", "dc2"); token_map.add_token(t6, "2.0.0.2", "rack1", "dc2"); @@ -220,7 +224,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) token_map.build_replicas(); { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "1.0.0.1", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.3", "rack2", "dc1"); @@ -229,7 +233,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "1.0.0.2", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.3", "rack2", "dc1"); @@ -238,7 +242,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "1.0.0.3", "rack2", "dc1"); check_host((*hosts)[1], "2.0.0.1", "rack1", "dc2"); @@ -247,7 +251,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "1.0.0.4", "rack2", "dc1"); check_host((*hosts)[1], "2.0.0.1", "rack1", "dc2"); @@ -256,7 +260,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t5); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t5); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "2.0.0.1", "rack1", "dc2"); check_host((*hosts)[1], "2.0.0.3", "rack2", "dc2"); @@ -265,7 +269,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t6); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t6); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "2.0.0.2", "rack1", "dc2"); check_host((*hosts)[1], "2.0.0.3", "rack2", "dc2"); @@ -274,7 +278,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t7); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t7); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "2.0.0.3", "rack2", "dc2"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); @@ -283,7 +287,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t8); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t8); ASSERT_TRUE(hosts && hosts->size() == 4); check_host((*hosts)[0], "2.0.0.4", "rack2", "dc2"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); @@ -294,7 +298,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopology) TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) { - MockTokenMap token_map; + MockTokenMap token_map; ReplicationMap replication; replication["dc1"] = "2"; @@ -302,17 +306,17 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) token_map.init_network_topology_strategy(replication); - MockTokenMap::Token t1 = 100; - MockTokenMap::Token t2 = 200; - MockTokenMap::Token t3 = 300; + MockTokenMap::Token t1 = 100; + MockTokenMap::Token t2 = 200; + MockTokenMap::Token t3 = 300; token_map.add_token(t1, "1.0.0.1", "rack1", "dc1"); token_map.add_token(t2, "1.0.0.2", "rack1", "dc1"); token_map.add_token(t3, "1.0.0.3", "rack1", "dc1"); - MockTokenMap::Token t4 = 400; - MockTokenMap::Token t5 = 500; - MockTokenMap::Token t6 = 600; + MockTokenMap::Token t4 = 400; + MockTokenMap::Token t5 = 500; + MockTokenMap::Token t6 = 600; token_map.add_token(t4, "2.0.0.1", "rack1", "dc2"); token_map.add_token(t5, "2.0.0.2", "rack1", "dc2"); @@ -321,7 +325,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) token_map.build_replicas(); { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.1", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.2", "rack1", "dc1"); @@ -329,7 +333,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.2", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.3", "rack1", "dc1"); @@ -337,7 +341,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.3", "rack1", "dc1"); check_host((*hosts)[1], "2.0.0.1", "rack1", "dc2"); @@ -345,7 +349,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "2.0.0.1", "rack1", "dc2"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); @@ -353,7 +357,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t5); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t5); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "2.0.0.2", "rack1", "dc2"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); @@ -361,7 +365,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t6); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t6); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "2.0.0.3", "rack1", "dc2"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); @@ -371,17 +375,17 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologySameRack) TEST(ReplicationStrategyUnitTest, NetworkTopologyNotEnoughRacks) { - MockTokenMap token_map; + MockTokenMap token_map; ReplicationMap replication; replication["dc1"] = "3"; token_map.init_network_topology_strategy(replication); - MockTokenMap::Token t1 = 100; - MockTokenMap::Token t2 = 200; - MockTokenMap::Token t3 = 300; - MockTokenMap::Token t4 = 400; + MockTokenMap::Token t1 = 100; + MockTokenMap::Token t2 = 200; + MockTokenMap::Token t3 = 300; + MockTokenMap::Token t4 = 400; token_map.add_token(t1, "1.0.0.1", "rack1", "dc1"); token_map.add_token(t2, "1.0.0.2", "rack1", "dc1"); @@ -391,7 +395,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologyNotEnoughRacks) token_map.build_replicas(); { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t1); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.1", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.4", "rack2", "dc1"); @@ -399,7 +403,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologyNotEnoughRacks) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t2); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.2", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.4", "rack2", "dc1"); @@ -407,7 +411,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologyNotEnoughRacks) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t3); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.3", "rack1", "dc1"); check_host((*hosts)[1], "1.0.0.4", "rack2", "dc1"); @@ -415,7 +419,7 @@ TEST(ReplicationStrategyUnitTest, NetworkTopologyNotEnoughRacks) } { - const cass::CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); + const CopyOnWriteHostVec& hosts = token_map.find_hosts(t4); ASSERT_TRUE(hosts && hosts->size() == 3); check_host((*hosts)[0], "1.0.0.4", "rack2", "dc1"); check_host((*hosts)[1], "1.0.0.1", "rack1", "dc1"); diff --git a/cpp-driver/gtests/src/unit/tests/test_request_processor.cpp b/cpp-driver/gtests/src/unit/tests/test_request_processor.cpp index 716a223b3..7674d1488 100644 --- a/cpp-driver/gtests/src/unit/tests/test_request_processor.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_request_processor.cpp @@ -24,7 +24,8 @@ #define NUM_NODES 3 -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; class RequestProcessorUnitTest : public EventLoopTest { public: @@ -57,12 +58,12 @@ class RequestProcessorUnitTest : public EventLoopTest { << response_future->error()->message;; } - class Future : public cass::Future { + class Future : public core::Future { public: typedef SharedRefPtr Ptr; Future() - : cass::Future(FUTURE_TYPE_GENERIC) { } + : core::Future(FUTURE_TYPE_GENERIC) { } ~Future() { if (processor_) { @@ -594,7 +595,7 @@ TEST_F(RequestProcessorUnitTest, RollingRestart) { ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_FALSE(connect_future->error()); RequestProcessor::Ptr processor(connect_future->processor()); - cass::Future::Ptr outage_future = execute_outage_plan(&outage_plan); + Future::Ptr outage_future = execute_outage_plan(&outage_plan); while (!outage_future->wait_for(1000)) { // 1 millisecond wait try_request(processor, WAIT_FOR_TIME * 3); // Increase wait time for chaotic tests diff --git a/cpp-driver/gtests/src/unit/tests/test_resolver.cpp b/cpp-driver/gtests/src/unit/tests/test_resolver.cpp index 2969261fa..37225d5ef 100644 --- a/cpp-driver/gtests/src/unit/tests/test_resolver.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_resolver.cpp @@ -21,13 +21,9 @@ #define RESOLVE_TIMEOUT 2000 -using cass::Address; -using cass::AddressVec; -using cass::bind_callback; -using cass::MultiResolver; -using cass::Memory; -using cass::Resolver; -using cass::String; +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; class ResolverUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_retry_policies.cpp b/cpp-driver/gtests/src/unit/tests/test_retry_policies.cpp index bad5f58fc..051d1f680 100644 --- a/cpp-driver/gtests/src/unit/tests/test_retry_policies.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_retry_policies.cpp @@ -18,8 +18,10 @@ #include "retry_policy.hpp" -typedef cass::RetryPolicy RetryPolicy; -typedef cass::RetryPolicy::RetryDecision RetryDecision; +using namespace datastax::internal; +using namespace datastax::internal::core; + +typedef RetryPolicy::RetryDecision RetryDecision; void check_decision(RetryDecision decision, RetryDecision::Type type, @@ -30,8 +32,7 @@ void check_decision(RetryDecision decision, EXPECT_EQ(decision.retry_current_host(), retry_current_host); } - -void check_default(cass::RetryPolicy& policy) { +void check_default(RetryPolicy& policy) { // Read timeout { // Retry because data wasn't present @@ -86,13 +87,13 @@ void check_default(cass::RetryPolicy& policy) { TEST(RetryPoliciesUnitTest, DefaultPolicy) { - cass::DefaultRetryPolicy policy; + DefaultRetryPolicy policy; check_default(policy); } TEST(RetryPoliciesUnitTest, Downgrading) { - cass::DowngradingConsistencyRetryPolicy policy; + DowngradingConsistencyRetryPolicy policy; // Read timeout { @@ -190,7 +191,7 @@ TEST(RetryPoliciesUnitTest, Downgrading) TEST(RetryPoliciesUnitTest, Fallthrough) { - cass::FallthroughRetryPolicy policy; + FallthroughRetryPolicy policy; // Always fail @@ -212,9 +213,9 @@ TEST(RetryPoliciesUnitTest, Fallthrough) TEST(RetryPoliciesUnitTest, Logging) { - cass::SharedRefPtr policy( - new cass::DefaultRetryPolicy()); - cass::LoggingRetryPolicy logging_policy(policy); + SharedRefPtr policy( + new DefaultRetryPolicy()); + LoggingRetryPolicy logging_policy(policy); cass_log_set_level(CASS_LOG_INFO); check_default(logging_policy); } diff --git a/cpp-driver/gtests/src/unit/tests/test_routing_key.cpp b/cpp-driver/gtests/src/unit/tests/test_routing_key.cpp index 36d94baaf..76b7a9524 100644 --- a/cpp-driver/gtests/src/unit/tests/test_routing_key.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_routing_key.cpp @@ -21,6 +21,10 @@ #include "string.hpp" #include "token_map.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + // The java-driver was used as a reference for the hash value // below. @@ -29,7 +33,7 @@ struct RoutingKeyUnitTest : public Unit { }; TEST_F(RoutingKeyUnitTest, Single) { { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); CassUuid uuid; ASSERT_EQ(cass_uuid_from_string("d8775a70-6ea4-11e4-9fa7-0db22d2a6140", &uuid), CASS_OK); @@ -37,77 +41,77 @@ TEST_F(RoutingKeyUnitTest, Single) query.set(0, uuid); query.add_key_index(0); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, 6739078495667776670); } { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); cass_int32_t value = 123456789; query.set(0, value); query.add_key_index(0); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, -567416363967733925); } { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); cass_int64_t value = 123456789; query.set(0, value); query.add_key_index(0); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, 5616923877423390342); } { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); query.set(0, cass_true); query.add_key_index(0); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, 8849112093580131862); } { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); const char* value = "abcdefghijklmnop"; - query.set(0, cass::CassString(value, strlen(value))); + query.set(0, CassString(value, strlen(value))); query.add_key_index(0); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, -4266531025627334877); } } TEST_F(RoutingKeyUnitTest, EmptyAndNull) { - cass::QueryRequest query("", 1); + QueryRequest query("", 1); - cass::String routing_key; + String routing_key; EXPECT_FALSE(query.get_routing_key(&routing_key)); - query.set(0, cass::CassNull()); + query.set(0, CassNull()); query.add_key_index(0); EXPECT_FALSE(query.get_routing_key(&routing_key)); @@ -116,7 +120,7 @@ TEST_F(RoutingKeyUnitTest, EmptyAndNull) TEST_F(RoutingKeyUnitTest, Composite) { { - cass::QueryRequest query("", 3); + QueryRequest query("", 3); CassUuid uuid; ASSERT_EQ(cass_uuid_from_string("d8775a70-6ea4-11e4-9fa7-0db22d2a6140", &uuid), CASS_OK); @@ -128,18 +132,18 @@ TEST_F(RoutingKeyUnitTest, Composite) query.add_key_index(1); const char* value = "abcdefghijklmnop"; - query.set(2, cass::CassString(value, strlen(value))); + query.set(2, CassString(value, strlen(value))); query.add_key_index(2); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, 3838437721532426513); } { - cass::QueryRequest query("", 3); + QueryRequest query("", 3); query.set(0, cass_false); query.add_key_index(0); @@ -148,13 +152,13 @@ TEST_F(RoutingKeyUnitTest, Composite) query.add_key_index(1); const char* value = "xyz"; - query.set(2, cass::CassString(value, strlen(value))); + query.set(2, CassString(value, strlen(value))); query.add_key_index(2); - cass::String routing_key; + String routing_key; EXPECT_TRUE(query.get_routing_key(&routing_key)); - int64_t hash = cass::MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); + int64_t hash = MurmurHash3_x64_128(routing_key.data(), routing_key.size(), 0); EXPECT_EQ(hash, 4466051201071860026); } } diff --git a/cpp-driver/gtests/src/unit/tests/test_scoped_lock.cpp b/cpp-driver/gtests/src/unit/tests/test_scoped_lock.cpp index d7635a579..ca2146337 100644 --- a/cpp-driver/gtests/src/unit/tests/test_scoped_lock.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_scoped_lock.cpp @@ -18,6 +18,10 @@ #include "scoped_lock.hpp" +using datastax::internal::ScopedMutex; +using datastax::internal::ScopedReadLock; +using datastax::internal::ScopedWriteLock; + struct MutexData { MutexData(uv_mutex_t* mutex) : mutex(mutex) @@ -60,7 +64,7 @@ TEST(ScopedLockUnitTest, ScopedMutex) { MutexData mutex_data(&mutex); { - cass::ScopedMutex lock(&mutex); + ScopedMutex lock(&mutex); uv_thread_t thread; uv_thread_create(&thread, on_mutex_trylock, &mutex_data); @@ -77,7 +81,7 @@ TEST(ScopedLockUnitTest, ScopedMutexDefaultUnlocked) { MutexData mutex_data(&mutex); { - cass::ScopedMutex lock(&mutex, false); + ScopedMutex lock(&mutex, false); uv_thread_t thread; uv_thread_create(&thread, on_mutex_trylock, &mutex_data); @@ -94,7 +98,7 @@ TEST(ScopedLockUnitTest, ScopedReadLock) { RwlockData rwlock_data(&rwlock); { - cass::ScopedReadLock rl(&rwlock); + ScopedReadLock rl(&rwlock); uv_thread_t thread; uv_thread_create(&thread, on_rwlock_trywrlock, &rwlock_data); // Lock for writing to force busy for write @@ -111,7 +115,7 @@ TEST(ScopedLockUnitTest, ScopedReadLockDefaultUnlocked) { RwlockData rwlock_data(&rwlock); { - cass::ScopedReadLock rl(&rwlock, false); + ScopedReadLock rl(&rwlock, false); uv_thread_t thread; uv_thread_create(&thread, on_rwlock_trywrlock, &rwlock_data); @@ -128,7 +132,7 @@ TEST(ScopedLockUnitTest, ScopedWriteLock) { RwlockData rwlock_data(&rwlock); { - cass::ScopedWriteLock wl(&rwlock); + ScopedWriteLock wl(&rwlock); uv_thread_t thread; uv_thread_create(&thread, on_rwlock_trywrlock, &rwlock_data); @@ -145,7 +149,7 @@ TEST(ScopedLockUnitTest, ScopedWriteLockDefaultUnlocked) { RwlockData rwlock_data(&rwlock); { - cass::ScopedWriteLock wl(&rwlock, false); + ScopedWriteLock wl(&rwlock, false); uv_thread_t thread; uv_thread_create(&thread, on_rwlock_trywrlock, &rwlock_data); @@ -162,7 +166,7 @@ TEST(ScopedLockUnitTest, ScopedWriteLockBusy) { RwlockData rwlock_data(&rwlock); { - cass::ScopedWriteLock wl(&rwlock); + ScopedWriteLock wl(&rwlock); uv_thread_t thread; uv_thread_create(&thread, on_rwlock_tryrdlock, &rwlock_data); // Lock for reading to force busy for read diff --git a/cpp-driver/gtests/src/unit/tests/test_serialization.cpp b/cpp-driver/gtests/src/unit/tests/test_serialization.cpp index 5aee9095a..4cba7c315 100644 --- a/cpp-driver/gtests/src/unit/tests/test_serialization.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_serialization.cpp @@ -19,18 +19,20 @@ #include "serialization.hpp" #include "buffer.hpp" +using namespace datastax::internal; + TEST(SerializationTest, DecodeZigZag) { - ASSERT_EQ(1LL << 63, cass::decode_zig_zag((long) -1)); + ASSERT_EQ(1LL << 63, decode_zig_zag((long) -1)); } TEST(SerializationTest, DecodeByte) { const char input[2] = { -1, 0 }; uint8_t value = 0; - const char* pos = cass::decode_byte(&input[0], value); + const char* pos = decode_byte(&input[0], value); ASSERT_EQ(&input[1], pos); ASSERT_EQ(std::numeric_limits::max(), value); - pos = cass::decode_byte(pos, value); + pos = decode_byte(pos, value); ASSERT_EQ(std::numeric_limits::min(), value); } @@ -38,10 +40,10 @@ TEST(SerializationTest, DecodeInt8) { const char input[2] = { -128, 127 }; int8_t value = 0; - const char* pos = cass::decode_int8(&input[0], value); + const char* pos = decode_int8(&input[0], value); ASSERT_EQ(&input[1], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_int8(pos, value); + pos = decode_int8(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -50,10 +52,10 @@ TEST(SerializationTest, DecodeUInt16) { 0, 0 }; uint16_t value = 0; - const char* pos = cass::decode_uint16(&input[0], value); + const char* pos = decode_uint16(&input[0], value); ASSERT_EQ(&input[2], pos); ASSERT_EQ(std::numeric_limits::max(), value); - pos = cass::decode_uint16(pos, value); + pos = decode_uint16(pos, value); ASSERT_EQ(std::numeric_limits::min(), value); } @@ -63,10 +65,10 @@ TEST(SerializationTest, DecodeInt16) { int16_t value = 0; // SUCCESS - const char *pos = cass::decode_int16(&input[0], value); + const char *pos = decode_int16(&input[0], value); ASSERT_EQ(&input[2], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_int16(pos, value); + pos = decode_int16(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -75,10 +77,10 @@ TEST(SerializationTest, DecodeUInt32) { 0, 0, 0, 0 }; uint32_t value = 0; - const char* pos = cass::decode_uint32(&input[0], value); + const char* pos = decode_uint32(&input[0], value); ASSERT_EQ(&input[4], pos); ASSERT_EQ(std::numeric_limits::max(), value); - pos = cass::decode_uint32(pos, value); + pos = decode_uint32(pos, value); ASSERT_EQ(std::numeric_limits::min(), value); } @@ -87,10 +89,10 @@ TEST(SerializationTest, DecodeInt32) { 127, -1, -1, -1 }; int32_t value = 0; - const char *pos = cass::decode_int32(&input[0], value); + const char *pos = decode_int32(&input[0], value); ASSERT_EQ(&input[4], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_int32(pos, value); + pos = decode_int32(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -99,10 +101,10 @@ TEST(SerializationTest, DecodeInt64) { 127, -1, -1, -1, -1, -1, -1, -1 }; int64_t value = 0; - const char *pos = cass::decode_int64(&input[0], value); + const char *pos = decode_int64(&input[0], value); ASSERT_EQ(&input[8], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_int64(pos, value); + pos = decode_int64(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -111,10 +113,10 @@ TEST(SerializationTest, DecodeFloat) { 127, 127, -1, -1 }; float value = 0; - const char *pos = cass::decode_float(&input[0], value); + const char *pos = decode_float(&input[0], value); ASSERT_EQ(&input[4], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_float(pos, value); + pos = decode_float(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -123,10 +125,10 @@ TEST(SerializationTest, DecodeDouble) { 127, -17, -1, -1, -1, -1, -1, -1 }; double value = 0; - const char *pos = cass::decode_double(&input[0], value); + const char *pos = decode_double(&input[0], value); ASSERT_EQ(&input[8], pos); ASSERT_EQ(std::numeric_limits::min(), value); - pos = cass::decode_double(pos, value); + pos = decode_double(pos, value); ASSERT_EQ(std::numeric_limits::max(), value); } @@ -135,11 +137,11 @@ TEST(SerializationTest, DecodeUuid) { 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0 }; CassUuid value; - const char *pos = cass::decode_uuid(&input[0], &value); + const char *pos = decode_uuid(&input[0], &value); ASSERT_EQ(&input[16], pos); ASSERT_EQ(std::numeric_limits::max(), value.clock_seq_and_node); ASSERT_EQ(std::numeric_limits::max(), value.time_and_version); - pos = cass::decode_uuid(pos, &value); + pos = decode_uuid(pos, &value); ASSERT_EQ(std::numeric_limits::min(), value.clock_seq_and_node); ASSERT_EQ(std::numeric_limits::min(), value.time_and_version); } diff --git a/cpp-driver/gtests/src/unit/tests/test_session.cpp b/cpp-driver/gtests/src/unit/tests/test_session.cpp index 082686e93..c15dc7dbb 100644 --- a/cpp-driver/gtests/src/unit/tests/test_session.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_session.cpp @@ -22,6 +22,9 @@ #define NUM_THREADS 2 // Number of threads to execute queries using a session #define OUTAGE_PLAN_DELAY 250 // Reduced delay to incorporate larger outage plan +using namespace datastax::internal; +using namespace datastax::internal::core; + class SessionUnitTest : public EventLoopTest { public: SessionUnitTest() @@ -44,7 +47,7 @@ class SessionUnitTest : public EventLoopTest { outage_plan->stop_node(1, OUTAGE_PLAN_DELAY); } - void query_on_threads(cass::Session* session) { + void query_on_threads(Session* session) { uv_thread_t threads[NUM_THREADS]; for (int i = 0; i < NUM_THREADS; ++i) { ASSERT_EQ(0, uv_thread_create(&threads[i], query, session)); @@ -54,24 +57,24 @@ class SessionUnitTest : public EventLoopTest { } } - static void connect(const cass::Config& config, - cass::Session* session, + static void connect(const Config& config, + Session* session, uint64_t wait_for_time_us = WAIT_FOR_TIME) { - cass::Future::Ptr connect_future(session->connect(config)); + Future::Ptr connect_future(session->connect(config)); ASSERT_TRUE(connect_future->wait_for(wait_for_time_us)) << "Timed out waiting for session to connect"; ASSERT_FALSE(connect_future->error()) << cass_error_desc(connect_future->error()->code) << ": " << connect_future->error()->message; } - static void connect(cass::Session* session, - cass::SslContext* ssl_context = NULL, + static void connect(Session* session, + SslContext* ssl_context = NULL, uint64_t wait_for_time_us = WAIT_FOR_TIME, size_t num_nodes = 3) { - cass::Config config; + Config config; config.set_reconnect_wait_time(100); // Faster reconnect time to handle cluster starts and stops for (size_t i = 1; i <= num_nodes; ++i) { - cass::OStringStream ss; + OStringStream ss; ss << "127.0.0." << i; config.contact_points().push_back(ss.str()); } @@ -81,20 +84,20 @@ class SessionUnitTest : public EventLoopTest { connect(config, session, wait_for_time_us); } - static void close(cass::Session* session, + static void close(Session* session, uint64_t wait_for_time_us = WAIT_FOR_TIME) { - cass::Future::Ptr close_future(session->close()); + Future::Ptr close_future(session->close()); ASSERT_TRUE(close_future->wait_for(wait_for_time_us)) << "Timed out waiting for session to close"; ASSERT_FALSE(close_future->error()) << cass_error_desc(close_future->error()->code) << ": " << close_future->error()->message; } - static void query(cass::Session* session) { - cass::QueryRequest::Ptr request(new cass::QueryRequest("blah", 0)); + static void query(Session* session) { + QueryRequest::Ptr request(new QueryRequest("blah", 0)); request->set_is_idempotent(true); - cass::Future::Ptr future = session->execute(request, NULL); + Future::Ptr future = session->execute(request, NULL); ASSERT_TRUE(future->wait_for(WAIT_FOR_TIME)) << "Timed out executing query"; ASSERT_FALSE(future->error()) << cass_error_desc(future->error()->code) << ": " @@ -103,11 +106,11 @@ class SessionUnitTest : public EventLoopTest { // uv_thread_create static void query(void* arg) { - cass::Session* session = static_cast(arg); + Session* session = static_cast(arg); query(session); } - class HostEventFuture : public cass::Future { + class HostEventFuture : public Future { public: typedef SharedRefPtr Ptr; @@ -122,12 +125,12 @@ class SessionUnitTest : public EventLoopTest { typedef std::pair Event; HostEventFuture() - : cass::Future(cass::Future::FUTURE_TYPE_GENERIC) { } + : Future(Future::FUTURE_TYPE_GENERIC) { } Type type() { return event_.first; } void set_event(Type type, const Address& host) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); if (!is_set()) { event_ = Event(type, host); internal_set(lock); @@ -135,7 +138,7 @@ class SessionUnitTest : public EventLoopTest { } Event wait_for_event(uint64_t timeout_us) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); return internal_wait_for(lock, timeout_us) ? event_ : Event(INVALID, Address()); } @@ -144,9 +147,9 @@ class SessionUnitTest : public EventLoopTest { Event event_; }; - class TestHostListener : public cass::DefaultHostListener { + class TestHostListener : public DefaultHostListener { public: - typedef cass::SharedRefPtr Ptr; + typedef SharedRefPtr Ptr; TestHostListener() { events_.push_back( @@ -159,19 +162,19 @@ class SessionUnitTest : public EventLoopTest { uv_mutex_destroy(&mutex_); } - virtual void on_host_up(const cass::Host::Ptr& host) { + virtual void on_host_up(const Host::Ptr& host) { push_back(HostEventFuture::START_NODE, host); } - virtual void on_host_down(const cass::Host::Ptr& host) { + virtual void on_host_down(const Host::Ptr& host) { push_back(HostEventFuture::STOP_NODE, host); } - virtual void on_host_added(const cass::Host::Ptr& host) { + virtual void on_host_added(const Host::Ptr& host) { push_back(HostEventFuture::ADD_NODE, host); } - virtual void on_host_removed(const cass::Host::Ptr& host) { + virtual void on_host_removed(const Host::Ptr& host) { push_back(HostEventFuture::REMOVE_NODE, host); } @@ -182,26 +185,26 @@ class SessionUnitTest : public EventLoopTest { } size_t event_count() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); size_t count = events_.size(); return events_.front()->ready() ? count : count - 1; } private: - typedef cass::Deque EventQueue; + typedef Deque EventQueue; HostEventFuture::Ptr front() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); return events_.front(); } void pop_front() { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); events_.pop_front(); } - void push_back(HostEventFuture::Type type, const cass::Host::Ptr& host) { - cass::ScopedMutex lock(&mutex_); + void push_back(HostEventFuture::Type type, const Host::Ptr& host) { + ScopedMutex lock(&mutex_); events_.back()->set_event(type, host->address()); events_.push_back( HostEventFuture::Ptr( @@ -215,10 +218,10 @@ class SessionUnitTest : public EventLoopTest { }; TEST_F(SessionUnitTest, ExecuteQueryNotConnected) { - cass::QueryRequest::Ptr request(new cass::QueryRequest("blah", 0)); + QueryRequest::Ptr request(new QueryRequest("blah", 0)); - cass::Session session; - cass::Future::Ptr future = session.execute(request, NULL); + Session session; + Future::Ptr future = session.execute(request, NULL); ASSERT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, future->error()->code); } @@ -232,11 +235,11 @@ TEST_F(SessionUnitTest, InvalidKeyspace) { mockssandra::SimpleCluster cluster(builder.build()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); - cass::Session session; + Session session; - cass::Future::Ptr connect_future(session.connect(config, "invalid")); + Future::Ptr connect_future(session.connect(config, "invalid")); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); ASSERT_EQ(CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE, connect_future->error()->code); @@ -247,15 +250,15 @@ TEST_F(SessionUnitTest, InvalidDataCenter) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); - config.set_load_balancing_policy(new cass::DCAwarePolicy( + config.set_load_balancing_policy(new DCAwarePolicy( "invalid_data_center", 0, false)); - cass::Session session; + Session session; - cass::Future::Ptr connect_future(session.connect(config)); + Future::Ptr connect_future(session.connect(config)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); ASSERT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, connect_future->error()->code); @@ -267,16 +270,16 @@ TEST_F(SessionUnitTest, InvalidLocalAddress) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.set_local_address(Address("1.1.1.1", PORT)); // Invalid config.contact_points().push_back("127.0.0.1"); - config.set_load_balancing_policy(new cass::DCAwarePolicy( + config.set_load_balancing_policy(new DCAwarePolicy( "invalid_data_center", 0, false)); - cass::Session session; + Session session; - cass::Future::Ptr connect_future(session.connect(config, "invalid")); + Future::Ptr connect_future(session.connect(config, "invalid")); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); ASSERT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, connect_future->error()->code); @@ -287,7 +290,7 @@ TEST_F(SessionUnitTest, ExecuteQueryReusingSession) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; for (int i = 0; i < 2; ++i) { connect(&session); query(&session); @@ -297,10 +300,10 @@ TEST_F(SessionUnitTest, ExecuteQueryReusingSession) { TEST_F(SessionUnitTest, ExecuteQueryReusingSessionUsingSsl) { mockssandra::SimpleCluster cluster(simple()); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; for (int i = 0; i < 2; ++i) { connect(&session, ssl_context.get()); query(&session); @@ -315,8 +318,8 @@ TEST_F(SessionUnitTest, ExecuteQueryReusingSessionChaotic) { OutagePlan outage_plan(loop(), &cluster); populate_outage_plan(&outage_plan); - cass::Session session; - cass::Future::Ptr outage_future = execute_outage_plan(&outage_plan); + Session session; + Future::Ptr outage_future = execute_outage_plan(&outage_plan); while (!outage_future->wait_for(1000)) { // 1 millisecond wait connect(&session, NULL, WAIT_FOR_TIME * 3, 4); query(&session); @@ -326,14 +329,14 @@ TEST_F(SessionUnitTest, ExecuteQueryReusingSessionChaotic) { TEST_F(SessionUnitTest, ExecuteQueryReusingSessionUsingSslChaotic) { mockssandra::SimpleCluster cluster(simple(), 4); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ASSERT_EQ(cluster.start_all(), 0); OutagePlan outage_plan(loop(), &cluster); populate_outage_plan(&outage_plan); - cass::Session session; - cass::Future::Ptr outage_future = execute_outage_plan(&outage_plan); + Session session; + Future::Ptr outage_future = execute_outage_plan(&outage_plan); while (!outage_future->wait_for(1000)) { // 1 millisecond wait connect(&session, ssl_context.get(), WAIT_FOR_TIME * 3, 4); query(&session); @@ -345,13 +348,13 @@ TEST_F(SessionUnitTest, ExecuteQueryWithCompleteOutage) { mockssandra::SimpleCluster cluster(simple(), 3); ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session); // Full outage cluster.stop_all(); - cass::QueryRequest::Ptr request(new cass::QueryRequest("blah", 0)); - cass::Future::Ptr future = session.execute(request, NULL); + QueryRequest::Ptr request(new QueryRequest("blah", 0)); + Future::Ptr future = session.execute(request, NULL); ASSERT_TRUE(future->wait_for(WAIT_FOR_TIME)); ASSERT_TRUE(future->error()); EXPECT_TRUE(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE == future->error()->code || @@ -369,7 +372,7 @@ TEST_F(SessionUnitTest, ExecuteQueryWithCompleteOutageSpinDown) { mockssandra::SimpleCluster cluster(simple(), 3); ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session); // Spin down nodes while querying @@ -381,8 +384,8 @@ TEST_F(SessionUnitTest, ExecuteQueryWithCompleteOutageSpinDown) { cluster.stop(2); // Full outage - cass::QueryRequest::Ptr request(new cass::QueryRequest("blah", 0)); - cass::Future::Ptr future = session.execute(request, NULL); + QueryRequest::Ptr request(new QueryRequest("blah", 0)); + Future::Ptr future = session.execute(request, NULL); ASSERT_TRUE(future->wait_for(WAIT_FOR_TIME)); ASSERT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, future->error()->code); @@ -398,7 +401,7 @@ TEST_F(SessionUnitTest, ExecuteQueryWithThreads) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session); query_on_threads(&session); close(&session); @@ -406,10 +409,10 @@ TEST_F(SessionUnitTest, ExecuteQueryWithThreads) { TEST_F(SessionUnitTest, ExecuteQueryWithThreadsUsingSsl) { mockssandra::SimpleCluster cluster(simple()); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session, ssl_context.get()); query_on_threads(&session); close(&session); @@ -419,13 +422,13 @@ TEST_F(SessionUnitTest, ExecuteQueryWithThreadsChaotic) { mockssandra::SimpleCluster cluster(simple(), 4); ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session); OutagePlan outage_plan(loop(), &cluster); populate_outage_plan(&outage_plan); - cass::Future::Ptr outage_future = execute_outage_plan(&outage_plan); + Future::Ptr outage_future = execute_outage_plan(&outage_plan); while (!outage_future->wait_for(1000)) { // 1 millisecond wait query_on_threads(&session); } @@ -435,16 +438,16 @@ TEST_F(SessionUnitTest, ExecuteQueryWithThreadsChaotic) { TEST_F(SessionUnitTest, ExecuteQueryWithThreadsUsingSslChaotic) { mockssandra::SimpleCluster cluster(simple(), 4); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ASSERT_EQ(cluster.start_all(), 0); - cass::Session session; + Session session; connect(&session, ssl_context.get()); OutagePlan outage_plan(loop(), &cluster); populate_outage_plan(&outage_plan); - cass::Future::Ptr outage_future = execute_outage_plan(&outage_plan); + Future::Ptr outage_future = execute_outage_plan(&outage_plan); while (!outage_future->wait_for(1000)) { // 1 millisecond wait query_on_threads(&session); } @@ -458,12 +461,12 @@ TEST_F(SessionUnitTest, HostListener) { TestHostListener::Ptr listener(new TestHostListener()); - cass::Config config; + Config config; config.set_reconnect_wait_time(100); // Reconnect immediately config.contact_points().push_back("127.0.0.2"); config.set_host_listener(listener); - cass::Session session; + Session session; connect(config, &session); { // Initial nodes available from peers table @@ -526,12 +529,12 @@ TEST_F(SessionUnitTest, HostListenerDCAwareLocal) { TestHostListener::Ptr listener(new TestHostListener()); - cass::Config config; + Config config; config.set_reconnect_wait_time(100); // Reconnect immediately config.contact_points().push_back("127.0.0.1"); config.set_host_listener(listener); - cass::Session session; + Session session; connect(config, &session); { // Initial nodes available from peers table @@ -568,16 +571,16 @@ TEST_F(SessionUnitTest, HostListenerDCAwareRemote) { TestHostListener::Ptr listener(new TestHostListener()); - cass::Config config; + Config config; config.set_reconnect_wait_time(100); // Reconnect immediately config.contact_points().push_back("127.0.0.1"); - config.set_load_balancing_policy(new cass::DCAwarePolicy( + config.set_load_balancing_policy(new DCAwarePolicy( "dc1", 1, false)); config.set_host_listener(listener); - cass::Session session; + Session session; connect(config, &session); { // Initial nodes available from peers table @@ -620,12 +623,12 @@ TEST_F(SessionUnitTest, HostListenerNodeDown) { TestHostListener::Ptr listener(new TestHostListener()); - cass::Config config; + Config config; config.set_reconnect_wait_time(100); // Reconnect immediately config.contact_points().push_back("127.0.0.1"); config.set_host_listener(listener); - cass::Session session; + Session session; connect(config, &session); { // Initial nodes available from peers table diff --git a/cpp-driver/gtests/src/unit/tests/test_session_base.cpp b/cpp-driver/gtests/src/unit/tests/test_session_base.cpp index 4e99aad36..97d35b1f2 100644 --- a/cpp-driver/gtests/src/unit/tests/test_session_base.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_session_base.cpp @@ -22,37 +22,40 @@ #define KEYSPACE "datastax" -class TestSessionBase : public cass::SessionBase { +using namespace datastax; +using namespace datastax::internal::core; + +class TestSessionBase : public SessionBase { public: TestSessionBase() : connected_(0) , failed_(0) , closed_(0) { } - virtual void on_host_up(const cass::Host::Ptr& host) { } - virtual void on_host_down(const cass::Host::Ptr& host) { } - virtual void on_host_added(const cass::Host::Ptr& host) { } - virtual void on_host_removed(const cass::Host::Ptr& host) { } - virtual void on_token_map_updated(const cass::TokenMap::Ptr& token_map) { } + virtual void on_host_up(const Host::Ptr& host) { } + virtual void on_host_down(const Host::Ptr& host) { } + virtual void on_host_added(const Host::Ptr& host) { } + virtual void on_host_removed(const Host::Ptr& host) { } + virtual void on_token_map_updated(const TokenMap::Ptr& token_map) { } int connected() { return connected_; } int failed() { return failed_; } int closed() { return closed_; } protected: - virtual void on_connect(const cass::Host::Ptr& connected_host, - cass::ProtocolVersion protocol_version, - const cass::HostMap& hosts, - const cass::TokenMap::Ptr& token_map) { + virtual void on_connect(const Host::Ptr& connected_host, + ProtocolVersion protocol_version, + const HostMap& hosts, + const TokenMap::Ptr& token_map) { ++connected_; ASSERT_STREQ("127.0.0.1", connected_host->address_string().c_str()); - ASSERT_EQ(cass::ProtocolVersion(PROTOCOL_VERSION), protocol_version); + ASSERT_EQ(ProtocolVersion(PROTOCOL_VERSION), protocol_version); ASSERT_EQ(1u, hosts.size()); ASSERT_EQ(state(), SESSION_STATE_CONNECTING); notify_connected(); } - virtual void on_connect_failed(CassError code, const cass::String& message) { + virtual void on_connect_failed(CassError code, const String& message) { ++failed_; ASSERT_EQ(state(), SESSION_STATE_CONNECTING); notify_connect_failed(code, message); @@ -77,13 +80,13 @@ TEST_F(SessionBaseUnitTest, Simple) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); - ASSERT_EQ(session_base.state(), cass::SessionBase::SESSION_STATE_CONNECTED); + ASSERT_EQ(session_base.state(), SessionBase::SESSION_STATE_CONNECTED); EXPECT_STREQ(KEYSPACE, session_base.connect_keyspace().c_str()); EXPECT_NE(&session_base.config(), &config); EXPECT_TRUE(session_base.random() != NULL); @@ -101,14 +104,14 @@ TEST_F(SessionBaseUnitTest, SimpleEmptyKeyspaceWithoutRandom) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); config.set_use_randomized_contact_points(false); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config)); + Future::Ptr connect_future(session_base.connect(config)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); - ASSERT_EQ(session_base.state(), cass::SessionBase::SESSION_STATE_CONNECTED); + ASSERT_EQ(session_base.state(), SessionBase::SESSION_STATE_CONNECTED); EXPECT_TRUE(session_base.connect_keyspace().empty()); EXPECT_NE(&session_base.config(), &config); EXPECT_TRUE(session_base.random() == NULL); @@ -124,17 +127,17 @@ TEST_F(SessionBaseUnitTest, SimpleEmptyKeyspaceWithoutRandom) { TEST_F(SessionBaseUnitTest, Ssl) { mockssandra::SimpleCluster cluster(simple()); - cass::ConnectionSettings settings(use_ssl(&cluster)); + ConnectionSettings settings(use_ssl(&cluster)); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); config.set_ssl_context(settings.socket_settings.ssl_context.get()); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); - ASSERT_EQ(session_base.state(), cass::SessionBase::SESSION_STATE_CONNECTED); + ASSERT_EQ(session_base.state(), SessionBase::SESSION_STATE_CONNECTED); EXPECT_STREQ(KEYSPACE, session_base.connect_keyspace().c_str()); EXPECT_NE(&session_base.config(), &config); EXPECT_TRUE(session_base.random() != NULL); @@ -152,13 +155,13 @@ TEST_F(SessionBaseUnitTest, SimpleInvalidContactPointsIp) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.set_use_randomized_contact_points(false); config.contact_points().push_back("123.456.789.012"); config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_STREQ(KEYSPACE, session_base.connect_keyspace().c_str()); EXPECT_NE(&session_base.config(), &config); @@ -177,12 +180,12 @@ TEST_F(SessionBaseUnitTest, SimpleInvalidContactPointsHostname) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("doesnotexist.dne"); config.contact_points().push_back("localhost"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_STREQ(KEYSPACE, session_base.connect_keyspace().c_str()); EXPECT_NE(&session_base.config(), &config); @@ -203,11 +206,11 @@ TEST_F(SessionBaseUnitTest, InvalidProtocol) { mockssandra::SimpleCluster cluster(builder.build()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_LIB_UNABLE_TO_DETERMINE_PROTOCOL, connect_future->error()->code); EXPECT_EQ(0, session_base.connected()); @@ -220,14 +223,14 @@ TEST_F(SessionBaseUnitTest, SslError) { use_ssl(&cluster); ASSERT_EQ(cluster.start_all(), 0); - cass::SslContext::Ptr invalid_ssl_context(cass::SslContextFactory::create()); + SslContext::Ptr invalid_ssl_context(SslContextFactory::create()); invalid_ssl_context->set_verify_flags(CASS_SSL_VERIFY_PEER_CERT); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); config.set_ssl_context(invalid_ssl_context.get()); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_SSL_INVALID_PEER_CERT, connect_future->error()->code); EXPECT_EQ(0, session_base.connected()); @@ -239,12 +242,12 @@ TEST_F(SessionBaseUnitTest, Auth) { mockssandra::SimpleCluster cluster(auth()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); config.set_credentials("cassandra", "cassandra"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_FALSE(connect_future->error()); EXPECT_EQ(1, session_base.connected()); @@ -261,11 +264,11 @@ TEST_F(SessionBaseUnitTest, BadCredentials) { mockssandra::SimpleCluster cluster(auth()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_SERVER_BAD_CREDENTIALS, connect_future->error()->code); EXPECT_EQ(0, session_base.connected()); @@ -274,11 +277,11 @@ TEST_F(SessionBaseUnitTest, BadCredentials) { } TEST_F(SessionBaseUnitTest, NoHostsAvailable) { - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE, connect_future->error()->code); EXPECT_EQ(0, session_base.connected()); @@ -290,12 +293,12 @@ TEST_F(SessionBaseUnitTest, ConnectWhenAlreadyConnected) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; { - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(1, session_base.connected()); EXPECT_EQ(0, session_base.failed()); @@ -303,7 +306,7 @@ TEST_F(SessionBaseUnitTest, ConnectWhenAlreadyConnected) { } {// Attempt second session connection - cass::Future::Ptr connect_future(session_base.connect(config, "")); + Future::Ptr connect_future(session_base.connect(config, "")); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_LIB_UNABLE_TO_CONNECT, connect_future->error()->code); EXPECT_EQ(1, session_base.connected()); @@ -321,11 +324,11 @@ TEST_F(SessionBaseUnitTest, CloseWhenAlreadyClosed) { mockssandra::SimpleCluster cluster(simple()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.contact_points().push_back("127.0.0.1"); TestSessionBase session_base; - cass::Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); + Future::Ptr connect_future(session_base.connect(config, KEYSPACE)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(1, session_base.connected()); EXPECT_EQ(0, session_base.failed()); @@ -337,7 +340,7 @@ TEST_F(SessionBaseUnitTest, CloseWhenAlreadyClosed) { EXPECT_EQ(1, session_base.closed()); // Attempt second session close - cass::Future::Ptr close_future(session_base.close()); + Future::Ptr close_future(session_base.close()); ASSERT_TRUE(close_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_LIB_UNABLE_TO_CLOSE, close_future->error()->code); EXPECT_EQ(1, session_base.connected()); @@ -351,7 +354,7 @@ TEST_F(SessionBaseUnitTest, CloseWhenNotConnected) { TestSessionBase session_base; - cass::Future::Ptr close_future(session_base.close()); + Future::Ptr close_future(session_base.close()); ASSERT_TRUE(close_future->wait_for(WAIT_FOR_TIME)); EXPECT_EQ(CASS_ERROR_LIB_UNABLE_TO_CLOSE, close_future->error()->code); EXPECT_EQ(0, session_base.connected()); diff --git a/cpp-driver/gtests/src/unit/tests/test_small_vector.cpp b/cpp-driver/gtests/src/unit/tests/test_small_vector.cpp index 5d215fd44..0261cc3b7 100644 --- a/cpp-driver/gtests/src/unit/tests/test_small_vector.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_small_vector.cpp @@ -18,9 +18,11 @@ #include "small_vector.hpp" +using datastax::internal::SmallVector; + TEST(SmallVectorUnitTest, Simple) { - cass::SmallVector vec; + SmallVector vec; EXPECT_EQ(vec.fixed().data.address(), vec.data()); EXPECT_EQ(vec.fixed().is_used, true); diff --git a/cpp-driver/gtests/src/unit/tests/test_socket.cpp b/cpp-driver/gtests/src/unit/tests/test_socket.cpp index c17182647..335f31e50 100644 --- a/cpp-driver/gtests/src/unit/tests/test_socket.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_socket.cpp @@ -24,7 +24,9 @@ #define SSL_VERIFY_PEER_DNS_ABSOLUTE_HOSTNAME SSL_VERIFY_PEER_DNS_RELATIVE_HOSTNAME "." #define SSL_VERIFY_PEER_DNS_IP_ADDRESS "127.254.254.254" -using namespace cass; +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; class TestSocketHandler : public SocketHandler { public: @@ -174,7 +176,7 @@ TEST_F(SocketUnitTest, Simple) { String result; SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_connected, &result))); + bind_callback(on_socket_connected, &result))); connector->connect(loop()); @@ -190,7 +192,7 @@ TEST_F(SocketUnitTest, Ssl) { String result; SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_connected, &result))); + bind_callback(on_socket_connected, &result))); connector->with_settings(settings) @@ -204,7 +206,7 @@ TEST_F(SocketUnitTest, Ssl) { TEST_F(SocketUnitTest, Refused) { bool is_refused = false; SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_refused, &is_refused))); + bind_callback(on_socket_refused, &is_refused))); connector->connect(loop()); uv_run(loop(), UV_RUN_DEFAULT); @@ -223,7 +225,7 @@ TEST_F(SocketUnitTest, SslClose) { bool is_closed = false; for (size_t i = 0; i < 10; ++i) { SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_closed, &is_closed))); + bind_callback(on_socket_closed, &is_closed))); connector ->with_settings(settings) @@ -244,7 +246,7 @@ TEST_F(SocketUnitTest, Cancel) { bool is_canceled = false; for (size_t i = 0; i < 10; ++i) { SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_canceled, &is_canceled))); + bind_callback(on_socket_canceled, &is_canceled))); connector->connect(loop()); connectors.push_back(connector); } @@ -271,7 +273,7 @@ TEST_F(SocketUnitTest, SslCancel) { bool is_canceled = false; for (size_t i = 0; i < 10; ++i) { SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_canceled, &is_canceled))); + bind_callback(on_socket_canceled, &is_canceled))); connector->with_settings(settings) ->connect(loop()); connectors.push_back(connector); @@ -297,7 +299,7 @@ TEST_F(SocketUnitTest, SslVerifyIdentity) { String result; SocketConnector::Ptr connector(new SocketConnector(Address("127.0.0.1", 8888), - cass::bind_callback(on_socket_connected, &result))); + bind_callback(on_socket_connected, &result))); connector->with_settings(settings) ->connect(loop()); @@ -330,7 +332,7 @@ TEST_F(SocketUnitTest, SslVerifyIdentityDns) { String result; SocketConnector::Ptr connector(new SocketConnector(Address(SSL_VERIFY_PEER_DNS_IP_ADDRESS, 8888), - cass::bind_callback(on_socket_connected, &result))); + bind_callback(on_socket_connected, &result))); connector->with_settings(settings) ->connect(loop()); diff --git a/cpp-driver/gtests/src/unit/tests/test_startup_options.cpp b/cpp-driver/gtests/src/unit/tests/test_startup_options.cpp index d7007cb74..b509c69b5 100644 --- a/cpp-driver/gtests/src/unit/tests/test_startup_options.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_startup_options.cpp @@ -24,9 +24,13 @@ #define APPLICATION_NAME "DataStax C/C++ Test Harness" #define APPLICATION_VERSION "1.0.0" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + inline bool operator==(const CassUuid& rhs, const CassUuid& lhs) { return rhs.clock_seq_and_node == lhs.clock_seq_and_node && - rhs.time_and_version == lhs.time_and_version; + rhs.time_and_version == lhs.time_and_version; } inline bool operator!=(const CassUuid& rhs, const CassUuid& lhs) { @@ -40,46 +44,46 @@ class StartupRequestUnitTest : public Unit { Unit::TearDown(); } - cass::Session& session() { return session_; } - const cass::String& client_id() const { return client_id_; } - cass::Config& config() { return config_; } + Session& session() { return session_; } + const String& client_id() const { return client_id_; } + Config& config() { return config_; } const mockssandra::RequestHandler* simple_with_client_options() { mockssandra::SimpleRequestHandlerBuilder builder; builder.on(mockssandra::OPCODE_QUERY) - .system_local() - .system_peers() - .client_options() // Allow for fake query to get client options - .empty_rows_result(1); + .system_local() + .system_peers() + .client_options() // Allow for fake query to get client options + .empty_rows_result(1); return builder.build(); } void connect() { config_.contact_points().push_back("127.0.0.1"); - cass::Future::Ptr connect_future(session_.connect(config_)); + internal::core::Future::Ptr connect_future(session_.connect(config_)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)) << "Timed out waiting for session to connect"; ASSERT_FALSE(connect_future->error()) - << cass_error_desc(connect_future->error()->code) << ": " - << connect_future->error()->message; + << cass_error_desc(connect_future->error()->code) << ": " + << connect_future->error()->message; char client_id[CASS_UUID_STRING_LENGTH]; cass_uuid_string(session_.client_id(), client_id); client_id_ = client_id; } - cass::Map client_options() { - cass::SharedRefPtr request(new cass::QueryRequest(CLIENT_OPTIONS_QUERY, 0)); - cass::ResponseFuture::Ptr future = static_cast(session_.execute(request, NULL)); + Map client_options() { + SharedRefPtr request(new QueryRequest(CLIENT_OPTIONS_QUERY, 0)); + ResponseFuture::Ptr future = static_cast(session_.execute(request, NULL)); EXPECT_TRUE(future->wait_for(WAIT_FOR_TIME)) << "Timed out executing query"; EXPECT_FALSE(future->error()) - << cass_error_desc(future->error()->code) << ": " - << future->error()->message; + << cass_error_desc(future->error()->code) << ": " + << future->error()->message; - cass::Map options; - cass::ResultResponse::Ptr response = static_cast(future->response()); - const cass::Row row = response->first_row(); + Map options; + ResultResponse::Ptr response = static_cast(future->response()); + const Row row = response->first_row(); for (size_t i = 0; i < row.values.size(); ++i) { - cass::String key = response->metadata()->get_column_definition(i).name.to_string(); - cass::String value = row.values[i].decoder().as_string(); + String key = response->metadata()->get_column_definition(i).name.to_string(); + String value = row.values[i].decoder().as_string(); options[key] = value; } @@ -87,9 +91,9 @@ class StartupRequestUnitTest : public Unit { } private: - cass::Config config_; - cass::Session session_; - cass::String client_id_; + Config config_; + Session session_; + String client_id_; }; TEST_F(StartupRequestUnitTest, Standard) { @@ -97,13 +101,13 @@ TEST_F(StartupRequestUnitTest, Standard) { ASSERT_EQ(cluster.start_all(), 0); connect(); - cass::Map options = client_options(); + Map options = client_options(); ASSERT_EQ(4u, options.size()); ASSERT_EQ(client_id(), options["CLIENT_ID"]); ASSERT_EQ(CASS_DEFAULT_CQL_VERSION, options["CQL_VERSION"]); - ASSERT_EQ(cass::driver_name(), options["DRIVER_NAME"]); - ASSERT_EQ(cass::driver_version(), options["DRIVER_VERSION"]); + ASSERT_EQ(driver_name(), options["DRIVER_NAME"]); + ASSERT_EQ(driver_version(), options["DRIVER_VERSION"]); } TEST_F(StartupRequestUnitTest, EnableNoCompact) { @@ -112,13 +116,13 @@ TEST_F(StartupRequestUnitTest, EnableNoCompact) { config().set_no_compact(true); connect(); - cass::Map options = client_options(); + Map options = client_options(); ASSERT_EQ(5u, options.size()); ASSERT_EQ(client_id(), options["CLIENT_ID"]); ASSERT_EQ(CASS_DEFAULT_CQL_VERSION, options["CQL_VERSION"]); - ASSERT_EQ(cass::driver_name(), options["DRIVER_NAME"]); - ASSERT_EQ(cass::driver_version(), options["DRIVER_VERSION"]); + ASSERT_EQ(driver_name(), options["DRIVER_NAME"]); + ASSERT_EQ(driver_version(), options["DRIVER_VERSION"]); ASSERT_EQ("true", options["NO_COMPACT"]); } @@ -129,15 +133,15 @@ TEST_F(StartupRequestUnitTest, Application) { config().set_application_name(APPLICATION_NAME); config().set_application_version(APPLICATION_VERSION); connect(); - cass::Map options = client_options(); + Map options = client_options(); ASSERT_EQ(6u, options.size()); ASSERT_EQ(APPLICATION_NAME, options["APPLICATION_NAME"]); ASSERT_EQ(APPLICATION_VERSION, options["APPLICATION_VERSION"]); ASSERT_EQ(client_id(), options["CLIENT_ID"]); ASSERT_EQ(CASS_DEFAULT_CQL_VERSION, options["CQL_VERSION"]); - ASSERT_EQ(cass::driver_name(), options["DRIVER_NAME"]); - ASSERT_EQ(cass::driver_version(), options["DRIVER_VERSION"]); + ASSERT_EQ(driver_name(), options["DRIVER_NAME"]); + ASSERT_EQ(driver_version(), options["DRIVER_VERSION"]); } TEST_F(StartupRequestUnitTest, SetClientId) { @@ -155,11 +159,11 @@ TEST_F(StartupRequestUnitTest, SetClientId) { CassUuid current_client_id = session().client_id(); ASSERT_EQ(assigned_client_id, current_client_id); ASSERT_NE(generated_client_id, current_client_id); - cass::Map options = client_options(); + Map options = client_options(); ASSERT_EQ(4u, options.size()); ASSERT_EQ("03398c99-c635-4fad-b30a-3b2c49f785c2", options["CLIENT_ID"]); ASSERT_EQ(CASS_DEFAULT_CQL_VERSION, options["CQL_VERSION"]); - ASSERT_EQ(cass::driver_name(), options["DRIVER_NAME"]); - ASSERT_EQ(cass::driver_version(), options["DRIVER_VERSION"]); -} \ No newline at end of file + ASSERT_EQ(driver_name(), options["DRIVER_NAME"]); + ASSERT_EQ(driver_version(), options["DRIVER_VERSION"]); +} diff --git a/cpp-driver/gtests/src/unit/tests/test_statement.cpp b/cpp-driver/gtests/src/unit/tests/test_statement.cpp index 7149f197c..51f018287 100644 --- a/cpp-driver/gtests/src/unit/tests/test_statement.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_statement.cpp @@ -21,6 +21,8 @@ #include "session.hpp" #include "constants.hpp" +using namespace datastax::internal::core; + class StatementUnitTest : public Unit { public: void TearDown() { @@ -28,11 +30,11 @@ class StatementUnitTest : public Unit { Unit::TearDown(); } - void connect(const cass::Config& config = cass::Config()) { - cass::Config temp(config); + void connect(const Config& config = Config()) { + Config temp(config); temp.contact_points().push_back("127.0.0.1"); temp.contact_points().push_back("127.0.0.2"); // At least one more host (in case node 1 is down) - cass::Future::Ptr connect_future(session.connect(temp)); + Future::Ptr connect_future(session.connect(temp)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)) << "Timed out waiting for session to connect"; ASSERT_FALSE(connect_future->error()) @@ -40,23 +42,23 @@ class StatementUnitTest : public Unit { << connect_future->error()->message; } - void get_rpc_address(const cass::Response::Ptr& response, cass::Address* output) { + void get_rpc_address(const Response::Ptr& response, Address* output) { ASSERT_TRUE(response); ASSERT_EQ(response->opcode(), CQL_OPCODE_RESULT); - cass::ResultResponse::Ptr result(response); + ResultResponse::Ptr result(response); - const cass::Value* value = result->first_row().get_by_name("rpc_address"); + const Value* value = result->first_row().get_by_name("rpc_address"); ASSERT_TRUE(value); ASSERT_EQ(value->value_type(), CASS_VALUE_TYPE_INET); CassInet inet; ASSERT_TRUE(value->decoder().as_inet(value->size(), &inet)); - ASSERT_TRUE(cass::Address::from_inet(inet.address, inet.address_length, 9042, output)); + ASSERT_TRUE(Address::from_inet(inet.address, inet.address_length, 9042, output)); } - cass::Session session; + Session session; }; TEST_F(StatementUnitTest, SetHost) { @@ -68,15 +70,15 @@ TEST_F(StatementUnitTest, SetHost) { mockssandra::Ipv4AddressGenerator gen; for (int i = 0; i < 2; ++i) { - cass::Address expected_host(gen.next()); + Address expected_host(gen.next()); - cass::Statement::Ptr request(new cass::QueryRequest(SELECT_LOCAL, 0)); + Statement::Ptr request(new QueryRequest(SELECT_LOCAL, 0)); request->set_host(expected_host); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); - cass::Address actual_host; + Address actual_host; get_rpc_address(future->response(), &actual_host); EXPECT_EQ(expected_host, actual_host); @@ -89,12 +91,12 @@ TEST_F(StatementUnitTest, SetHostWithInvalidPort) { connect(); - cass::Address expected_host(cass::Address("127.0.0.1", 8888)); // Invalid port + Address expected_host(Address("127.0.0.1", 8888)); // Invalid port - cass::Statement::Ptr request(new cass::QueryRequest(SELECT_LOCAL, 0)); + Statement::Ptr request(new QueryRequest(SELECT_LOCAL, 0)); request->set_host(expected_host); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->error()); @@ -109,12 +111,12 @@ TEST_F(StatementUnitTest, SetHostWhereHostIsDown) { connect(); - cass::Address expected_host(cass::Address("127.0.0.1", 9042)); + Address expected_host(Address("127.0.0.1", 9042)); - cass::Statement::Ptr request(new cass::QueryRequest(SELECT_LOCAL, 0)); + Statement::Ptr request(new QueryRequest(SELECT_LOCAL, 0)); request->set_host(expected_host); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->error()); diff --git a/cpp-driver/gtests/src/unit/tests/test_stream_manager.cpp b/cpp-driver/gtests/src/unit/tests/test_stream_manager.cpp index 56e238948..e7c08c7b0 100644 --- a/cpp-driver/gtests/src/unit/tests/test_stream_manager.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_stream_manager.cpp @@ -18,14 +18,16 @@ #include "stream_manager.hpp" +using datastax::internal::core::StreamManager; + TEST(StreamManagerUnitTest, MaxStreams) { - ASSERT_EQ(cass::StreamManager().max_streams(), 32768u); + ASSERT_EQ(StreamManager().max_streams(), 32768u); } TEST(StreamManagerUnitTest, Simple) { - cass::StreamManager streams; + StreamManager streams; for (size_t i = 0; i < streams.max_streams(); ++i) { int stream = streams.acquire(i); @@ -53,7 +55,7 @@ TEST(StreamManagerUnitTest, Simple) TEST(StreamManagerUnitTest, Release) { - cass::StreamManager streams; + StreamManager streams; for (size_t i = 0; i < streams.max_streams(); ++i) { int stream = streams.acquire(i); diff --git a/cpp-driver/gtests/src/unit/tests/test_string_ref.cpp b/cpp-driver/gtests/src/unit/tests/test_string_ref.cpp index f9692dbac..3af5388d7 100644 --- a/cpp-driver/gtests/src/unit/tests/test_string_ref.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_string_ref.cpp @@ -18,10 +18,12 @@ #include "string_ref.hpp" +using datastax::StringRef; + TEST(StringRefUnitTest, Compare) { const char* value = "abc"; - cass::StringRef s(value); + StringRef s(value); // Equals EXPECT_EQ(s.compare(s), 0); @@ -30,87 +32,87 @@ TEST(StringRefUnitTest, Compare) // Not equals EXPECT_NE(s, "xyz"); - EXPECT_NE(s, cass::StringRef("xyz")); + EXPECT_NE(s, StringRef("xyz")); // Case insensitive EXPECT_TRUE(s.iequals("ABC")); - EXPECT_TRUE(cass::iequals(s, "ABC")); + EXPECT_TRUE(iequals(s, "ABC")); } TEST(StringRefUnitTest, Empty) { - cass::StringRef s; + StringRef s; EXPECT_TRUE(s.empty()); EXPECT_EQ(s, ""); EXPECT_NE(s, "abc"); - EXPECT_TRUE(cass::starts_with(s, "")); - EXPECT_TRUE(cass::ends_with(s, "")); + EXPECT_TRUE(starts_with(s, "")); + EXPECT_TRUE(ends_with(s, "")); - EXPECT_FALSE(cass::starts_with(s, "abc")); - EXPECT_FALSE(cass::ends_with(s, "abc")); + EXPECT_FALSE(starts_with(s, "abc")); + EXPECT_FALSE(ends_with(s, "abc")); } TEST(StringRefUnitTest, Substr) { - cass::StringRef s("abcxyz"); + StringRef s("abcxyz"); // Full string EXPECT_EQ(s.substr(0, s.length()), s); // Exceeds length EXPECT_EQ(s.substr(0, s.length() + 1), s); - EXPECT_EQ(s.substr(0, cass::StringRef::npos), s); + EXPECT_EQ(s.substr(0, StringRef::npos), s); // More tests in "starts_with" and "ends_with" } TEST(StringRefUnitTest, Find) { - cass::StringRef s("abcxyz"); + StringRef s("abcxyz"); EXPECT_EQ(s.find(""), 0u); EXPECT_EQ(s.find("abc"), 0u); EXPECT_EQ(s.find("xyz"), 3u); EXPECT_EQ(s.find("z"), 5u); - EXPECT_EQ(s.find("invalid"), cass::StringRef::npos); - EXPECT_EQ(s.find("abcxyza"), cass::StringRef::npos); + EXPECT_EQ(s.find("invalid"), StringRef::npos); + EXPECT_EQ(s.find("abcxyza"), StringRef::npos); EXPECT_EQ(s.find(""), 0u); - EXPECT_EQ(cass::StringRef("").find(""), 0u); + EXPECT_EQ(StringRef("").find(""), 0u); } TEST(StringRefUnitTest, StartsWith) { - cass::StringRef s("abcxyz"); + StringRef s("abcxyz"); // Various lengths for (size_t i = 0; i < s.length(); ++i) { - EXPECT_TRUE(cass::starts_with(s, s.substr(0, i))); + EXPECT_TRUE(starts_with(s, s.substr(0, i))); } // Does not start with - EXPECT_FALSE(cass::starts_with(s, "xyz")); + EXPECT_FALSE(starts_with(s, "xyz")); // Too long - EXPECT_FALSE(cass::starts_with(s, "abcxyzabcxyz")); + EXPECT_FALSE(starts_with(s, "abcxyzabcxyz")); } TEST(StringRefUnitTest, EndsWith) { - cass::StringRef s("abcxyz"); + StringRef s("abcxyz"); // Various lengths for (size_t i = 0; i < s.length(); ++i) { - EXPECT_TRUE(cass::ends_with(s, s.substr(i, cass::StringRef::npos))); + EXPECT_TRUE(ends_with(s, s.substr(i, StringRef::npos))); } // Does not end with - EXPECT_FALSE(cass::ends_with(s, "abc")); + EXPECT_FALSE(ends_with(s, "abc")); // Too long - EXPECT_FALSE(cass::ends_with(s, "abcxyzabcxyz")); + EXPECT_FALSE(ends_with(s, "abcxyzabcxyz")); } diff --git a/cpp-driver/gtests/src/unit/tests/test_tcp_connector.cpp b/cpp-driver/gtests/src/unit/tests/test_tcp_connector.cpp index 726f7c1ca..59beb2fdd 100644 --- a/cpp-driver/gtests/src/unit/tests/test_tcp_connector.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_tcp_connector.cpp @@ -19,10 +19,8 @@ #include "callback.hpp" #include "tcp_connector.hpp" -using cass::Address; -using cass::bind_callback; -using cass::Memory; -using cass::TcpConnector; +using namespace datastax::internal; +using namespace datastax::internal::core; class TcpConnectorUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/tests/test_timer.cpp b/cpp-driver/gtests/src/unit/tests/test_timer.cpp index 492172b84..b3e4e278a 100644 --- a/cpp-driver/gtests/src/unit/tests/test_timer.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_timer.cpp @@ -18,7 +18,8 @@ #include "timer.hpp" -using namespace cass; +using datastax::internal::bind_callback; +using datastax::internal::core::Timer; class TimerUnitTest : public LoopTest { public: @@ -86,7 +87,7 @@ class TimerUnitTest : public LoopTest { Timer timer; restart_timer_.start(loop(), 10, - bind_callback(&TimerUnitTest::on_timer_once, this)); + bind_callback(&TimerUnitTest::on_timer_once, this)); timer.start(loop(), 1, bind_callback(&TimerUnitTest::on_timer_restart, this)); @@ -124,7 +125,7 @@ class TimerUnitTest : public LoopTest { restart_timer_.stop(); } else { restart_timer_.start(loop(), 10, - bind_callback(&TimerUnitTest::on_timer_once, this)); + bind_callback(&TimerUnitTest::on_timer_once, this)); timer->start(loop(), 1, bind_callback(&TimerUnitTest::on_timer_restart, this)); diff --git a/cpp-driver/gtests/src/unit/tests/test_timestamp_gen.cpp b/cpp-driver/gtests/src/unit/tests/test_timestamp_gen.cpp index f1bbdad89..412d3a056 100644 --- a/cpp-driver/gtests/src/unit/tests/test_timestamp_gen.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_timestamp_gen.cpp @@ -21,10 +21,14 @@ #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + static void clock_skew_log_callback(const CassLogMessage* message, void* data) { - cass::String msg(message->message); + String msg(message->message); int* counter = reinterpret_cast(data); - if (msg.find("Clock skew detected") != cass::String::npos) { + if (msg.find("Clock skew detected") != String::npos) { (*counter)++; } } @@ -36,16 +40,16 @@ class TimestampGenUnitTest : public Unit { uint64_t duration_ms) { const int NUM_TIMESTAMPS_PER_ITERATION = 1000; - cass::MonotonicTimestampGenerator gen(warning_threshold_us, - warning_interval_ms); + MonotonicTimestampGenerator gen(warning_threshold_us, + warning_interval_ms); int timestamp_count = 0; int warn_count = 0; - cass::Logger::set_log_level(CASS_LOG_WARN); - cass::Logger::set_callback(clock_skew_log_callback, &warn_count); + Logger::set_log_level(CASS_LOG_WARN); + Logger::set_callback(clock_skew_log_callback, &warn_count); - uint64_t start = cass::get_time_since_epoch_ms(); + uint64_t start = get_time_since_epoch_ms(); uint64_t elapsed; do { @@ -58,7 +62,7 @@ class TimestampGenUnitTest : public Unit { timestamp_count++; } - elapsed = cass::get_time_since_epoch_ms() - start; + elapsed = get_time_since_epoch_ms() - start; } while (elapsed < duration_ms); // We can generate at most 1,000,000 timestamps in a second. If we exceed @@ -68,7 +72,7 @@ class TimestampGenUnitTest : public Unit { if (timestamp_rate <= 1000000.0 || elapsed * MICROSECONDS_PER_MILLISECOND <= warning_threshold_us) { fprintf(stderr, "Warning: The test may not have exceeded the timestamp " \ - "generator's maximum rate."); + "generator's maximum rate."); } EXPECT_GT(warn_count, 0); @@ -79,13 +83,13 @@ class TimestampGenUnitTest : public Unit { TEST_F(TimestampGenUnitTest, Server) { - cass::ServerSideTimestampGenerator gen; + ServerSideTimestampGenerator gen; EXPECT_EQ(gen.next(), CASS_INT64_MIN); } TEST_F(TimestampGenUnitTest, Monotonic) { - cass::MonotonicTimestampGenerator gen; + MonotonicTimestampGenerator gen; int64_t prev = gen.next(); for (int i = 0; i < 100; ++i) { diff --git a/cpp-driver/gtests/src/unit/tests/test_token.cpp b/cpp-driver/gtests/src/unit/tests/test_token.cpp index 7b97547b7..b900c0907 100644 --- a/cpp-driver/gtests/src/unit/tests/test_token.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_token.cpp @@ -23,9 +23,13 @@ #include #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + namespace { -cass::String to_string(cass::RandomPartitioner::Token token) { +String to_string(RandomPartitioner::Token token) { return numeric::uint128_t(token.lo, token.hi).to_string(); } @@ -38,10 +42,10 @@ TEST(TokenUnitTest, RandomAbs) uint8_t digest[16] = { }; digest[0] = 0x80; - cass::RandomPartitioner::Token token; - token.hi = cass::RandomPartitioner::encode(digest); - token.lo = cass::RandomPartitioner::encode(digest + 8); - token = cass::RandomPartitioner::abs(token); + RandomPartitioner::Token token; + token.hi = RandomPartitioner::encode(digest); + token.lo = RandomPartitioner::encode(digest + 8); + token = RandomPartitioner::abs(token); EXPECT_EQ(to_string(token), "170141183460469231731687303715884105728"); @@ -53,10 +57,10 @@ TEST(TokenUnitTest, RandomAbs) digest[0] = 0x80; digest[15] = 0x01; - cass::RandomPartitioner::Token token; - token.hi = cass::RandomPartitioner::encode(digest); - token.lo = cass::RandomPartitioner::encode(digest + 8); - token = cass::RandomPartitioner::abs(token); + RandomPartitioner::Token token; + token.hi = RandomPartitioner::encode(digest); + token.lo = RandomPartitioner::encode(digest + 8); + token = RandomPartitioner::abs(token); EXPECT_EQ(to_string(token), "170141183460469231731687303715884105727"); } @@ -73,10 +77,10 @@ TEST(TokenUnitTest, RandomAbs) digest[6] = 0xFF; digest[7] = 0xFF; - cass::RandomPartitioner::Token token; - token.hi = cass::RandomPartitioner::encode(digest); - token.lo = cass::RandomPartitioner::encode(digest + 8); - token = cass::RandomPartitioner::abs(token); + RandomPartitioner::Token token; + token.hi = RandomPartitioner::encode(digest); + token.lo = RandomPartitioner::encode(digest + 8); + token = RandomPartitioner::abs(token); EXPECT_EQ(to_string(token), "18446744073709551616"); } @@ -85,10 +89,10 @@ TEST(TokenUnitTest, RandomAbs) { uint8_t digest[16] = { }; - cass::RandomPartitioner::Token token; - token.hi = cass::RandomPartitioner::encode(digest); - token.lo = cass::RandomPartitioner::encode(digest + 8); - token = cass::RandomPartitioner::abs(token); + RandomPartitioner::Token token; + token.hi = RandomPartitioner::encode(digest); + token.lo = RandomPartitioner::encode(digest + 8); + token = RandomPartitioner::abs(token); EXPECT_EQ(numeric::uint128_t(token.lo, token.hi).to_string(), "0"); } @@ -113,10 +117,10 @@ TEST(TokenUnitTest, RandomAbs) digest[14] = 0xFF; digest[15] = 0xFF; - cass::RandomPartitioner::Token token; - token.hi = cass::RandomPartitioner::encode(digest); - token.lo = cass::RandomPartitioner::encode(digest + 8); - token = cass::RandomPartitioner::abs(token); + RandomPartitioner::Token token; + token.hi = RandomPartitioner::encode(digest); + token.lo = RandomPartitioner::encode(digest + 8); + token = RandomPartitioner::abs(token); EXPECT_EQ(to_string(token), "170141183460469231731687303715884105727"); } @@ -126,23 +130,23 @@ TEST(TokenUnitTest, RandomLessThan) { // 'hi' is the same and 'lo' is less than { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 0 { uint8_t digest[16] = { }; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 1 { uint8_t digest[16] = { }; digest[15] = 0x01; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_TRUE(t1 < t2); @@ -150,25 +154,25 @@ TEST(TokenUnitTest, RandomLessThan) // 'lo' is the same and 'hi' is less than { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 36893488147419103232 { uint8_t digest[16] = { }; digest[7] = 0x02; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_TRUE(t1 < t2); @@ -176,25 +180,25 @@ TEST(TokenUnitTest, RandomLessThan) // Absolute value of negative values { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: -170141183460469231731687303715884105727 { uint8_t digest[16] = { }; digest[0] = 0x80; digest[15] = 0x01; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: -170141183460469231731687303715884105728 { uint8_t digest[16] = { }; digest[0] = 0x80; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_TRUE(t1 < t2); @@ -202,24 +206,24 @@ TEST(TokenUnitTest, RandomLessThan) // Same value { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_FALSE(t1 < t2); @@ -227,20 +231,20 @@ TEST(TokenUnitTest, RandomLessThan) // Zero { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; { uint8_t digest[16] = { }; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } { uint8_t digest[16] = { }; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_FALSE(t1 < t2); @@ -251,24 +255,24 @@ TEST(TokenUnitTest, RandomEqual) { // Same value { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_TRUE(t1 == t2); @@ -276,20 +280,20 @@ TEST(TokenUnitTest, RandomEqual) // Zero { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; { uint8_t digest[16] = { }; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } { uint8_t digest[16] = { }; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_TRUE(t1 == t2); @@ -297,23 +301,23 @@ TEST(TokenUnitTest, RandomEqual) // 'hi' is the same and 'lo' is less than { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 0 { uint8_t digest[16] = { }; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 1 { uint8_t digest[16] = { }; digest[15] = 0x01; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_FALSE(t1 == t2); @@ -321,25 +325,25 @@ TEST(TokenUnitTest, RandomEqual) // 'lo' is the same and 'hi' is less than { - cass::RandomPartitioner::Token t1, t2; + RandomPartitioner::Token t1, t2; // Two's complement: 18446744073709551616 { uint8_t digest[16] = { }; digest[7] = 0x01; - t1.hi = cass::RandomPartitioner::encode(digest); - t1.lo = cass::RandomPartitioner::encode(digest + 8); - t1 = cass::RandomPartitioner::abs(t1); + t1.hi = RandomPartitioner::encode(digest); + t1.lo = RandomPartitioner::encode(digest + 8); + t1 = RandomPartitioner::abs(t1); } // Two's complement: 36893488147419103232 { uint8_t digest[16] = { }; digest[7] = 0x02; - t2.hi = cass::RandomPartitioner::encode(digest); - t2.lo = cass::RandomPartitioner::encode(digest + 8); - t2 = cass::RandomPartitioner::abs(t2); + t2.hi = RandomPartitioner::encode(digest); + t2.lo = RandomPartitioner::encode(digest + 8); + t2 = RandomPartitioner::abs(t2); } EXPECT_FALSE(t1 == t2); @@ -349,18 +353,18 @@ TEST(TokenUnitTest, RandomEqual) TEST(TokenUnitTest, RandomHash) { // Sampled using: SELECT token(key) FROM sometable; - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("a")), "16955237001963240173058271559858726497"); - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("b")), "144992942750327304334463589818972416113"); - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("c")), "99079589977253916124855502156832923443"); - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("d")), "166860289390734216023086131251507064403"); - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("abc")), "148866708576779697295343134153845407886"); - EXPECT_EQ(to_string(cass::RandomPartitioner::hash("xyz")), "61893731502141497228477852773302439842"); + EXPECT_EQ(to_string(RandomPartitioner::hash("a")), "16955237001963240173058271559858726497"); + EXPECT_EQ(to_string(RandomPartitioner::hash("b")), "144992942750327304334463589818972416113"); + EXPECT_EQ(to_string(RandomPartitioner::hash("c")), "99079589977253916124855502156832923443"); + EXPECT_EQ(to_string(RandomPartitioner::hash("d")), "166860289390734216023086131251507064403"); + EXPECT_EQ(to_string(RandomPartitioner::hash("abc")), "148866708576779697295343134153845407886"); + EXPECT_EQ(to_string(RandomPartitioner::hash("xyz")), "61893731502141497228477852773302439842"); } TEST(TokenUnitTest, RandomFromString) { - EXPECT_EQ(to_string(cass::RandomPartitioner::from_string("0")), "0"); - EXPECT_EQ(to_string(cass::RandomPartitioner::from_string("1")), "1"); - EXPECT_EQ(to_string(cass::RandomPartitioner::from_string("170141183460469231731687303715884105727")), "170141183460469231731687303715884105727"); - EXPECT_EQ(to_string(cass::RandomPartitioner::from_string("170141183460469231731687303715884105728")), "170141183460469231731687303715884105728"); + EXPECT_EQ(to_string(RandomPartitioner::from_string("0")), "0"); + EXPECT_EQ(to_string(RandomPartitioner::from_string("1")), "1"); + EXPECT_EQ(to_string(RandomPartitioner::from_string("170141183460469231731687303715884105727")), "170141183460469231731687303715884105727"); + EXPECT_EQ(to_string(RandomPartitioner::from_string("170141183460469231731687303715884105728")), "170141183460469231731687303715884105728"); } diff --git a/cpp-driver/gtests/src/unit/tests/test_token_map.cpp b/cpp-driver/gtests/src/unit/tests/test_token_map.cpp index dfd031177..9a6062ada 100644 --- a/cpp-driver/gtests/src/unit/tests/test_token_map.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_token_map.cpp @@ -20,28 +20,32 @@ #include "map.hpp" #include "set.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + namespace { template struct TestTokenMap { - typedef typename cass::ReplicationStrategy::Token Token; - typedef cass::Map TokenHostMap; + typedef typename ReplicationStrategy::Token Token; + typedef Map TokenHostMap; TokenHostMap tokens; - cass::TokenMap::Ptr token_map; + TokenMap::Ptr token_map; TestTokenMap() - : token_map(cass::TokenMap::from_partitioner(Partitioner::name())) { } + : token_map(TokenMap::from_partitioner(Partitioner::name())) { } - void add_host(const cass::Host::Ptr& host) { - for (cass::Vector::const_iterator i = host->tokens().begin(), + void add_host(const Host::Ptr& host) { + for (Vector::const_iterator i = host->tokens().begin(), end = host->tokens().end(); i != end; ++i) { - const cass::String v(*i); + const String v(*i); tokens[Partitioner::from_string(*i)] = host; } } - void build(const cass::String& keyspace_name = "ks", size_t replication_factor = 3) { + void build(const String& keyspace_name = "ks", size_t replication_factor = 3) { add_keyspace_simple(keyspace_name, replication_factor, token_map.get()); for (typename TokenHostMap::const_iterator i = tokens.begin(), end = tokens.end(); i != end; ++i) { @@ -50,7 +54,7 @@ struct TestTokenMap { token_map->build(); } - const cass::Host::Ptr& get_replica(const cass::String& key) { + const Host::Ptr& get_replica(const String& key) { typename TokenHostMap::const_iterator i = tokens.upper_bound(Partitioner::hash(key)); if (i != tokens.end()) { return i->second; @@ -59,17 +63,17 @@ struct TestTokenMap { } } - void verify(const cass::String& keyspace_name = "ks") { - const cass::String keys[] = { "test", "abc", "def", "a", "b", "c", "d" }; + void verify(const String& keyspace_name = "ks") { + const String keys[] = { "test", "abc", "def", "a", "b", "c", "d" }; for (size_t i = 0; i < sizeof(keys)/sizeof(keys[0]); ++i) { - const cass::String& key = keys[i]; + const String& key = keys[i]; - const cass::CopyOnWriteHostVec& hosts = token_map->get_replicas(keyspace_name, key); + const CopyOnWriteHostVec& hosts = token_map->get_replicas(keyspace_name, key); ASSERT_TRUE(hosts); ASSERT_GT(hosts->size(), 0); - const cass::Host::Ptr& host = get_replica(key); + const Host::Ptr& host = get_replica(key); ASSERT_TRUE(host); EXPECT_EQ(hosts->front()->address(), host->address()); @@ -81,7 +85,7 @@ struct TestTokenMap { TEST(TokenMapUnitTest, Murmur3) { - TestTokenMap test_murmur3; + TestTokenMap test_murmur3; test_murmur3.add_host(create_host("1.0.0.1", single_token(CASS_INT64_MIN / 2))); test_murmur3.add_host(create_host("1.0.0.2", single_token(0))); @@ -93,7 +97,7 @@ TEST(TokenMapUnitTest, Murmur3) TEST(TokenMapUnitTest, Murmur3MultipleTokensPerHost) { - TestTokenMap test_murmur3; + TestTokenMap test_murmur3; const size_t tokens_per_host = 256; MT19937_64 rng; @@ -109,7 +113,7 @@ TEST(TokenMapUnitTest, Murmur3MultipleTokensPerHost) TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) { - TestTokenMap test_murmur3; + TestTokenMap test_murmur3; size_t num_dcs = 3; size_t num_racks = 3; @@ -119,7 +123,7 @@ TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) ReplicationMap replication; MT19937_64 rng; - cass::TokenMap* token_map = test_murmur3.token_map.get(); + TokenMap* token_map = test_murmur3.token_map.get(); // Populate tokens int host_count = 1; @@ -139,10 +143,10 @@ TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) sprintf(ip, "127.0.%d.%d", host_count / 255, host_count % 255); host_count++; - cass::Host::Ptr host(create_host(ip, - random_murmur3_tokens(rng, num_vnodes), - cass::Murmur3Partitioner::name().to_string(), - rack, dc)); + Host::Ptr host(create_host(ip, + random_murmur3_tokens(rng, num_vnodes), + Murmur3Partitioner::name().to_string(), + rack, dc)); test_murmur3.add_host(host); token_map->add_host(host); @@ -154,21 +158,21 @@ TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) add_keyspace_network_topology("ks1", replication, token_map); token_map->build(); - const cass::String keys[] = { "test", "abc", "def", "a", "b", "c", "d" }; + const String keys[] = { "test", "abc", "def", "a", "b", "c", "d" }; for (size_t i = 0; i < sizeof(keys)/sizeof(keys[0]); ++i) { - const cass::String& key = keys[i]; + const String& key = keys[i]; - const cass::CopyOnWriteHostVec& hosts = token_map->get_replicas("ks1", key); + const CopyOnWriteHostVec& hosts = token_map->get_replicas("ks1", key); ASSERT_TRUE(hosts && hosts->size() == replication_factor * num_dcs); - typedef cass::Map > DcRackMap; + typedef Map > DcRackMap; // Verify rack counts DcRackMap dc_racks; - for (cass::HostVec::const_iterator i = hosts->begin(), + for (HostVec::const_iterator i = hosts->begin(), end = hosts->end(); i != end; ++i) { - const cass::Host::Ptr& host = (*i); + const Host::Ptr& host = (*i); dc_racks[host->dc()].insert(host->rack()); } EXPECT_EQ(dc_racks.size(), num_dcs); @@ -179,7 +183,7 @@ TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) } // Verify replica - cass::Host::Ptr host = test_murmur3.get_replica(key); + Host::Ptr host = test_murmur3.get_replica(key); ASSERT_TRUE(host); EXPECT_EQ((*hosts)[0]->address(), host->address()); @@ -188,9 +192,9 @@ TEST(TokenMapUnitTest, Murmur3LargeNumberOfVnodes) TEST(TokenMapUnitTest, Random) { - cass::TokenMap::Ptr token_map(cass::TokenMap::from_partitioner(cass::RandomPartitioner::name())); + TokenMap::Ptr token_map(TokenMap::from_partitioner(RandomPartitioner::name())); - TestTokenMap test_random; + TestTokenMap test_random; test_random.add_host(create_host("1.0.0.1", single_token(create_random_token("42535295865117307932921825928971026432")))); // 2^127 / 4 test_random.add_host(create_host("1.0.0.2", single_token(create_random_token("85070591730234615865843651857942052864")))); // 2^127 / 2 @@ -202,9 +206,9 @@ TEST(TokenMapUnitTest, Random) TEST(TokenMapUnitTest, ByteOrdered) { - cass::TokenMap::Ptr token_map(cass::TokenMap::from_partitioner(cass::ByteOrderedPartitioner::name())); + TokenMap::Ptr token_map(TokenMap::from_partitioner(ByteOrderedPartitioner::name())); - TestTokenMap test_byte_ordered; + TestTokenMap test_byte_ordered; test_byte_ordered.add_host(create_host("1.0.0.1", single_token(create_byte_ordered_token("g")))); test_byte_ordered.add_host(create_host("1.0.0.2", single_token(create_byte_ordered_token("m")))); @@ -216,7 +220,7 @@ TEST(TokenMapUnitTest, ByteOrdered) TEST(TokenMapUnitTest, RemoveHost) { - TestTokenMap test_remove_host; + TestTokenMap test_remove_host; test_remove_host.add_host(create_host("1.0.0.1", single_token(CASS_INT64_MIN / 2))); test_remove_host.add_host(create_host("1.0.0.2", single_token(0))); @@ -225,43 +229,43 @@ TEST(TokenMapUnitTest, RemoveHost) test_remove_host.build("ks", 2); test_remove_host.verify(); - cass::TokenMap* token_map = test_remove_host.token_map.get(); + TokenMap* token_map = test_remove_host.token_map.get(); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 2); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.1", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.1", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.2", 9042)); } - TestTokenMap::TokenHostMap::iterator host_to_remove_it = test_remove_host.tokens.begin(); + TestTokenMap::TokenHostMap::iterator host_to_remove_it = test_remove_host.tokens.begin(); token_map->remove_host_and_build(host_to_remove_it->second); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 2); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.2", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.3", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.3", 9042)); } ++host_to_remove_it; token_map->remove_host_and_build(host_to_remove_it->second); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 1); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.3", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.3", 9042)); } ++host_to_remove_it; token_map->remove_host_and_build(host_to_remove_it->second); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("test", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("test", "abc"); EXPECT_FALSE(replicas); } @@ -269,7 +273,7 @@ TEST(TokenMapUnitTest, RemoveHost) TEST(TokenMapUnitTest, UpdateHost) { - TestTokenMap test_update_host; + TestTokenMap test_update_host; test_update_host.add_host(create_host("1.0.0.1", single_token(CASS_INT64_MIN / 2))); test_update_host.add_host(create_host("1.0.0.2", single_token(CASS_INT64_MIN / 4))); @@ -277,45 +281,45 @@ TEST(TokenMapUnitTest, UpdateHost) test_update_host.build("ks", 4); test_update_host.verify(); - cass::TokenMap* token_map = test_update_host.token_map.get(); + TokenMap* token_map = test_update_host.token_map.get(); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 2); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.1", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.1", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.2", 9042)); } { - cass::Host::Ptr host(create_host("1.0.0.3", single_token(0))); + Host::Ptr host(create_host("1.0.0.3", single_token(0))); test_update_host.add_host(host); token_map->update_host_and_build(host); } { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 3); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.1", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.2", 9042)); - EXPECT_EQ((*replicas)[2]->address(), cass::Address("1.0.0.3", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.1", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[2]->address(), Address("1.0.0.3", 9042)); } { - cass::Host::Ptr host(create_host("1.0.0.4", single_token(CASS_INT64_MAX / 2))); + Host::Ptr host(create_host("1.0.0.4", single_token(CASS_INT64_MAX / 2))); test_update_host.add_host(host); token_map->update_host_and_build(host); } { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 4); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.1", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.2", 9042)); - EXPECT_EQ((*replicas)[2]->address(), cass::Address("1.0.0.3", 9042)); - EXPECT_EQ((*replicas)[3]->address(), cass::Address("1.0.0.4", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.1", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[2]->address(), Address("1.0.0.3", 9042)); + EXPECT_EQ((*replicas)[3]->address(), Address("1.0.0.4", 9042)); } } @@ -331,7 +335,7 @@ TEST(TokenMapUnitTest, UpdateHost) */ TEST(TokenMapUnitTest, UpdateRemoveHostsMurmur3) { - cass::TokenMapImpl token_map; + TokenMapImpl token_map; // Add hosts and build token map Murmur3TokenVec tokens1; @@ -340,10 +344,10 @@ TEST(TokenMapUnitTest, UpdateRemoveHostsMurmur3) tokens1.push_back(1LL); tokens1.push_back(3LL); - cass::Host::Ptr host1(create_host("1.0.0.1", - murmur3_tokens(tokens1), - cass::Murmur3Partitioner::name().to_string(), - "rack1", "dc1")); + Host::Ptr host1(create_host("1.0.0.1", + murmur3_tokens(tokens1), + Murmur3Partitioner::name().to_string(), + "rack1", "dc1")); token_map.add_host(host1); @@ -353,10 +357,10 @@ TEST(TokenMapUnitTest, UpdateRemoveHostsMurmur3) tokens2.push_back(2LL); tokens2.push_back(4LL); - cass::Host::Ptr host2(create_host("1.0.0.2", - murmur3_tokens(tokens2), - cass::Murmur3Partitioner::name().to_string(), - "rack1", "dc2")); + Host::Ptr host2(create_host("1.0.0.2", + murmur3_tokens(tokens2), + Murmur3Partitioner::name().to_string(), + "rack1", "dc2")); token_map.add_host(host2); @@ -435,7 +439,7 @@ TEST(TokenMapUnitTest, UpdateRemoveHostsMurmur3) TEST(TokenMapUnitTest, DropKeyspace) { - TestTokenMap test_drop_keyspace; + TestTokenMap test_drop_keyspace; test_drop_keyspace.add_host(create_host("1.0.0.1", single_token(CASS_INT64_MIN / 2))); test_drop_keyspace.add_host(create_host("1.0.0.2", single_token(0))); @@ -444,20 +448,20 @@ TEST(TokenMapUnitTest, DropKeyspace) test_drop_keyspace.build("ks", 2); test_drop_keyspace.verify(); - cass::TokenMap* token_map = test_drop_keyspace.token_map.get(); + TokenMap* token_map = test_drop_keyspace.token_map.get(); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); ASSERT_TRUE(replicas && replicas->size() == 2); - EXPECT_EQ((*replicas)[0]->address(), cass::Address("1.0.0.1", 9042)); - EXPECT_EQ((*replicas)[1]->address(), cass::Address("1.0.0.2", 9042)); + EXPECT_EQ((*replicas)[0]->address(), Address("1.0.0.1", 9042)); + EXPECT_EQ((*replicas)[1]->address(), Address("1.0.0.2", 9042)); } token_map->drop_keyspace("ks"); { - const cass::CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); + const CopyOnWriteHostVec& replicas = token_map->get_replicas("ks", "abc"); EXPECT_FALSE(replicas); } diff --git a/cpp-driver/gtests/src/unit/tests/test_tracing.cpp b/cpp-driver/gtests/src/unit/tests/test_tracing.cpp index d1572398b..ceae06717 100644 --- a/cpp-driver/gtests/src/unit/tests/test_tracing.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_tracing.cpp @@ -20,6 +20,8 @@ #include "session.hpp" #include "tracing_data_handler.hpp" +using namespace datastax::internal::core; + class TracingUnitTest : public Unit { public: void TearDown() { @@ -27,10 +29,10 @@ class TracingUnitTest : public Unit { Unit::TearDown(); } - void connect(const cass::Config& config = cass::Config()) { - cass::Config temp(config); + void connect(const Config& config = Config()) { + Config temp(config); temp.contact_points().push_back("127.0.0.1"); - cass::Future::Ptr connect_future(session.connect(temp)); + Future::Ptr connect_future(session.connect(temp)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)) << "Timed out waiting for session to connect"; ASSERT_FALSE(connect_future->error()) @@ -38,7 +40,7 @@ class TracingUnitTest : public Unit { << connect_future->error()->message; } - cass::Session session; + Session session; }; TEST_F(TracingUnitTest, Simple) { @@ -53,10 +55,10 @@ TEST_F(TracingUnitTest, Simple) { connect(); - cass::Statement::Ptr request(new cass::QueryRequest("blah", 0)); + Statement::Ptr request(new QueryRequest("blah", 0)); request->set_tracing(true); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->response()); @@ -72,19 +74,19 @@ TEST_F(TracingUnitTest, DataNotAvailble) { .system_local() .system_peers() .is_query(SELECT_TRACES_SESSION) - .then(mockssandra::Action::Builder().empty_rows_result(0)) // Send back an empty row result + .then(mockssandra::Action::Builder().empty_rows_result(0)) // Send back an empty row result .empty_rows_result(1); mockssandra::SimpleCluster cluster(builder.build()); ASSERT_EQ(cluster.start_all(), 0); connect(); - cass::Statement::Ptr request(new cass::QueryRequest("blah", 0)); + Statement::Ptr request(new QueryRequest("blah", 0)); request->set_tracing(true); add_logging_critera("Tracing data not available after 15 ms"); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->response()); @@ -102,22 +104,22 @@ TEST_F(TracingUnitTest, RequestTimeout) { .system_local() .system_peers() .is_query(SELECT_TRACES_SESSION) - .then(mockssandra::Action::Builder().no_result()) // Don't send back a response + .then(mockssandra::Action::Builder().no_result()) // Don't send back a response .empty_rows_result(1); mockssandra::SimpleCluster cluster(builder.build()); ASSERT_EQ(cluster.start_all(), 0); - cass::Config config; + Config config; config.set_max_tracing_wait_time_ms(500); connect(config); - cass::Statement::Ptr request(new cass::QueryRequest("blah", 0)); + Statement::Ptr request(new QueryRequest("blah", 0)); request->set_request_timeout_ms(100); request->set_tracing(true); add_logging_critera("A query timeout occurred waiting for tracing data to become available"); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->response()); @@ -135,20 +137,20 @@ TEST_F(TracingUnitTest, QueryError) { .system_local() .system_peers() .is_query(SELECT_TRACES_SESSION) - .then(mockssandra::Action::Builder().error(mockssandra::ERROR_INVALID_QUERY, "Invalid query")) + .then(mockssandra::Action::Builder().error(mockssandra::ERROR_INVALID_QUERY, "Invalid query")) .empty_rows_result(1); mockssandra::SimpleCluster cluster(builder.build()); ASSERT_EQ(cluster.start_all(), 0); connect(); - cass::Statement::Ptr request(new cass::QueryRequest("blah", 0)); + Statement::Ptr request(new QueryRequest("blah", 0)); request->set_tracing(true); add_logging_critera("Chained error response 'Invalid query' (0x02002200) for query " "\"SELECT session_id FROM system_traces.sessions WHERE session_id = ?\""); - cass::ResponseFuture::Ptr future(session.execute(cass::Request::ConstPtr(request))); + ResponseFuture::Ptr future(session.execute(Request::ConstPtr(request))); future->wait(); ASSERT_TRUE(future->response()); diff --git a/cpp-driver/gtests/src/unit/tests/test_utils.cpp b/cpp-driver/gtests/src/unit/tests/test_utils.cpp index 2b9aad8c2..3e24e06bb 100644 --- a/cpp-driver/gtests/src/unit/tests/test_utils.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_utils.cpp @@ -22,49 +22,53 @@ #include #include +using datastax::String; +using datastax::internal::to_cql_id; +using datastax::internal::num_leading_zeros; + TEST(UtilsUnitTest, CqlId) { - cass::String s; + String s; // valid id s = "abc"; - EXPECT_EQ(cass::to_cql_id(s), cass::String("abc")); + EXPECT_EQ(to_cql_id(s), String("abc")); // test lower cassing s = "ABC"; - EXPECT_EQ(cass::to_cql_id(s), cass::String("abc")); + EXPECT_EQ(to_cql_id(s), String("abc")); // quoted s = "\"aBc\""; - EXPECT_EQ(cass::to_cql_id(s), cass::String("aBc")); + EXPECT_EQ(to_cql_id(s), String("aBc")); // invalid chars s = "!@#"; - EXPECT_EQ(cass::to_cql_id(s), cass::String("!@#")); + EXPECT_EQ(to_cql_id(s), String("!@#")); } TEST(UtilsUnitTest, EscapeId) { - cass::String s; + String s; s = "abc"; - EXPECT_EQ(cass::escape_id(s), cass::String("abc")); + EXPECT_EQ(escape_id(s), String("abc")); s = "aBc"; - EXPECT_EQ(cass::escape_id(s), cass::String("\"aBc\"")); + EXPECT_EQ(escape_id(s), String("\"aBc\"")); s = "\""; - EXPECT_EQ(cass::escape_id(s), cass::String("\"\"\"\"")); + EXPECT_EQ(escape_id(s), String("\"\"\"\"")); s = "a\"Bc"; - EXPECT_EQ(cass::escape_id(s), cass::String("\"a\"\"Bc\"")); + EXPECT_EQ(escape_id(s), String("\"a\"\"Bc\"")); } TEST(UtilsUnitTest, NumLeadingZeros) { - EXPECT_EQ(64u, cass::num_leading_zeros(0)); - EXPECT_EQ(0u, cass::num_leading_zeros(1LL << 63)); - EXPECT_EQ(0u, cass::num_leading_zeros(1LL << 63 | 1 << 5)); + EXPECT_EQ(64u, num_leading_zeros(0)); + EXPECT_EQ(0u, num_leading_zeros(1LL << 63)); + EXPECT_EQ(0u, num_leading_zeros(1LL << 63 | 1 << 5)); } TEST(UtilsUnitTest, NextPow2) diff --git a/cpp-driver/gtests/src/unit/tests/test_uuids.cpp b/cpp-driver/gtests/src/unit/tests/test_uuids.cpp index 9843c54f5..b273bc5c5 100644 --- a/cpp-driver/gtests/src/unit/tests/test_uuids.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_uuids.cpp @@ -24,6 +24,9 @@ #include #include +using namespace datastax; +using namespace datastax::internal::testing; + inline bool operator!=(const CassUuid& u1, const CassUuid& u2) { return u1.clock_seq_and_node != u2.clock_seq_and_node || u1.time_and_version != u2.time_and_version; @@ -39,7 +42,7 @@ TEST(UuidUnitTest, V1) for (int i = 0; i < 1000; ++i) { CassUuid uuid; - uint64_t curr_ts = cass::get_time_since_epoch_in_ms(); + uint64_t curr_ts = get_time_since_epoch_in_ms(); cass_uuid_gen_time(uuid_gen, &uuid); cass_uint64_t ts = cass_uuid_timestamp(uuid); @@ -64,7 +67,7 @@ TEST(UuidUnitTest, V1) TEST(UuidUnitTest, V1MinMax) { cass_uint64_t founded_ts = 1270080000; // April 2010 - cass_uint64_t curr_ts = cass::get_time_since_epoch_in_ms(); + cass_uint64_t curr_ts = get_time_since_epoch_in_ms(); CassUuid min_uuid_1; CassUuid min_uuid_2; @@ -132,14 +135,14 @@ TEST(UuidUnitTest, V4) TEST(UuidUnitTest, FromString) { CassUuid uuid; - const cass::String expected = "c3b54ca0-7b01-11e4-aea6-c30dd51eaa64"; + const String expected = "c3b54ca0-7b01-11e4-aea6-c30dd51eaa64"; char actual[CASS_UUID_STRING_LENGTH]; EXPECT_EQ(cass_uuid_from_string(expected.c_str(), &uuid), CASS_OK); cass_uuid_string(uuid, actual); EXPECT_EQ(expected, actual); - cass::String upper = expected; + String upper = expected; std::transform(upper.begin(), upper.end(), upper.begin(), toupper); EXPECT_EQ(cass_uuid_from_string(upper.c_str(), &uuid), CASS_OK); cass_uuid_string(uuid, actual); diff --git a/cpp-driver/gtests/src/unit/tests/test_value.cpp b/cpp-driver/gtests/src/unit/tests/test_value.cpp index 93cbded13..c38416fa9 100644 --- a/cpp-driver/gtests/src/unit/tests/test_value.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_value.cpp @@ -21,27 +21,29 @@ #include +using namespace datastax::internal::core; + // The following CassValue's are used in tests as "bad data". // Create a CassValue representing a text type. -static cass::DataType::ConstPtr s_text_type(new cass::DataType(CASS_VALUE_TYPE_TEXT)); -static cass::Value s_text_value_Value(s_text_type, cass::Decoder(NULL, 0)); +static DataType::ConstPtr s_text_type(new DataType(CASS_VALUE_TYPE_TEXT)); +static Value s_text_value_Value(s_text_type, Decoder(NULL, 0)); static CassValue* s_text_value = CassValue::to(&s_text_value_Value); // ST is simple-type name (e.g. int8 and the like) and T is the full type name (e.g. cass_int8_t, CassUuid, etc.). #define TEST_TYPE(ST, T, SLT) \ -TEST(ValueUnitTest, Bad##ST) \ + TEST(ValueUnitTest, Bad##ST) \ { \ T output; \ EXPECT_EQ(cass_value_get_##ST(s_text_value, &output), \ CASS_ERROR_LIB_INVALID_VALUE_TYPE); \ - cass::DataType::ConstPtr data_type(new cass::DataType(CASS_VALUE_TYPE_##SLT)); \ - cass::Value null_value(data_type); \ + DataType::ConstPtr data_type(new DataType(CASS_VALUE_TYPE_##SLT)); \ + Value null_value(data_type); \ EXPECT_EQ(cass_value_get_##ST(NULL, &output), \ CASS_ERROR_LIB_NULL_VALUE); \ EXPECT_EQ(cass_value_get_##ST(CassValue::to(&null_value), &output), \ CASS_ERROR_LIB_NULL_VALUE); \ - cass::Value invalid_value(data_type, cass::Decoder("", 0)); \ + Value invalid_value(data_type, Decoder("", 0)); \ EXPECT_EQ(cass_value_get_##ST(CassValue::to(&invalid_value), &output), \ CASS_ERROR_LIB_NOT_ENOUGH_DATA); \ } @@ -77,16 +79,16 @@ TEST(ValueUnitTest, BadString) TEST(ValueUnitTest, BadInet) { CassInet inet; - cass::DataType::ConstPtr data_type(new cass::DataType(CASS_VALUE_TYPE_INET)); + DataType::ConstPtr data_type(new DataType(CASS_VALUE_TYPE_INET)); EXPECT_EQ(cass_value_get_inet(NULL, &inet), CASS_ERROR_LIB_NULL_VALUE); - cass::Value null_value(data_type); + Value null_value(data_type); EXPECT_EQ(cass_value_get_inet(CassValue::to(&null_value), &inet), CASS_ERROR_LIB_NULL_VALUE); - cass::Value invalid_value(data_type, cass::Decoder("12345678901234567", 17)); + Value invalid_value(data_type, Decoder("12345678901234567", 17)); EXPECT_EQ(cass_value_get_inet(CassValue::to(&invalid_value), &inet), CASS_ERROR_LIB_INVALID_DATA); } @@ -98,8 +100,8 @@ TEST(ValueUnitTest, BadDuration) EXPECT_EQ(cass_value_get_duration(s_text_value, &months, &days, &nanos), CASS_ERROR_LIB_INVALID_VALUE_TYPE); - cass::DataType::ConstPtr data_type(new cass::DataType(CASS_VALUE_TYPE_DURATION)); - cass::Value invalid_value(data_type, cass::Decoder("", 0)); + DataType::ConstPtr data_type(new DataType(CASS_VALUE_TYPE_DURATION)); + Value invalid_value(data_type, Decoder("", 0)); EXPECT_EQ(cass_value_get_duration(CassValue::to(&invalid_value), &months, &days, &nanos), CASS_ERROR_LIB_NOT_ENOUGH_DATA); } @@ -112,8 +114,8 @@ TEST(ValueUnitTest, BadDecimal) EXPECT_EQ(cass_value_get_decimal(s_text_value, &varint, &varint_size, &scale), CASS_ERROR_LIB_INVALID_VALUE_TYPE); - cass::DataType::ConstPtr data_type(new cass::DataType(CASS_VALUE_TYPE_DECIMAL)); - cass::Value invalid_value(data_type, cass::Decoder("", 0)); + DataType::ConstPtr data_type(new DataType(CASS_VALUE_TYPE_DECIMAL)); + Value invalid_value(data_type, Decoder("", 0)); EXPECT_EQ(cass_value_get_decimal(CassValue::to(&invalid_value), &varint, &varint_size, &scale), CASS_ERROR_LIB_NOT_ENOUGH_DATA); } diff --git a/cpp-driver/gtests/src/unit/tests/test_wait_for_handler.cpp b/cpp-driver/gtests/src/unit/tests/test_wait_for_handler.cpp index 105f4c65f..3cce6484e 100644 --- a/cpp-driver/gtests/src/unit/tests/test_wait_for_handler.cpp +++ b/cpp-driver/gtests/src/unit/tests/test_wait_for_handler.cpp @@ -22,7 +22,8 @@ #include "wait_for_handler.hpp" #include "timer.hpp" -using namespace cass; +using namespace datastax::internal; +using namespace datastax::internal::core; class WaitForHandlerUnitTest : public LoopTest { public: diff --git a/cpp-driver/gtests/src/unit/uint128.hpp b/cpp-driver/gtests/src/unit/uint128.hpp index 529d74a34..3aab37dd0 100644 --- a/cpp-driver/gtests/src/unit/uint128.hpp +++ b/cpp-driver/gtests/src/unit/uint128.hpp @@ -96,7 +96,7 @@ class uint128 { uint128(base_type value) : lo(value), hi(0) {} uint128(base_type lo, base_type hi) : lo(lo), hi(hi) {} - uint128(const cass::String &sz) : lo(0), hi(0) { + uint128(const datastax::String &sz) : lo(0), hi(0) { // do we have at least one character? if(!sz.empty()) { @@ -104,7 +104,7 @@ class uint128 { int radix = 10; bool minus = false; - cass::String::const_iterator i = sz.begin(); + datastax::String::const_iterator i = sz.begin(); // check for minus sign, i suppose technically this should only apply // to base 10, but who says that -0x1 should be invalid? @@ -397,7 +397,7 @@ class uint128 { return lo; } - cass::String to_string(unsigned int radix = 10) const { + datastax::String to_string(unsigned int radix = 10) const { if(*this == 0) { return "0"; } diff --git a/cpp-driver/gtests/src/unit/unit.cpp b/cpp-driver/gtests/src/unit/unit.cpp index fe43f1075..6bef17a93 100644 --- a/cpp-driver/gtests/src/unit/unit.cpp +++ b/cpp-driver/gtests/src/unit/unit.cpp @@ -15,6 +15,10 @@ */ #include "unit.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + Unit::OutagePlan::Action::Action(Type type, size_t node, uint64_t delay_ms) : type(type) , node(node) @@ -45,7 +49,7 @@ void Unit::OutagePlan::remove_node(size_t node, uint64_t delay_ms /*= DEFAULT_OU action_it_ = actions_.begin(); } -void Unit::OutagePlan::run(cass::Future::Ptr future /*= cass::Future::Ptr()*/) { +void Unit::OutagePlan::run(core::Future::Ptr future /*= core::Future::Ptr()*/) { if (future) future_ = future; next(); } @@ -62,7 +66,7 @@ void Unit::OutagePlan::next() { if (!is_done()) { if (action_it_->delay_ms > 0 && loop_ != NULL) { ASSERT_EQ(0, timer_.start(loop_, action_it_->delay_ms, - cass::bind_callback(&OutagePlan::on_timeout, this))); + bind_callback(&OutagePlan::on_timeout, this))); } else { handle_timeout(); } @@ -100,13 +104,13 @@ void Unit::OutagePlan::handle_timeout() { Unit::Unit() : output_log_level_(CASS_LOG_DISABLED) , logging_criteria_count_(0) { - cass::Logger::set_log_level(CASS_LOG_TRACE); - cass::Logger::set_callback(on_log, this); + Logger::set_log_level(CASS_LOG_TRACE); + Logger::set_callback(on_log, this); } Unit::~Unit() { - cass::Logger::set_log_level(CASS_LOG_DISABLED); - cass::Logger::set_callback(NULL, NULL); + Logger::set_log_level(CASS_LOG_DISABLED); + Logger::set_callback(NULL, NULL); } void Unit::set_output_log_level(CassLogLevel output_log_level) { @@ -121,22 +125,22 @@ const mockssandra::RequestHandler* Unit::auth() { return mockssandra::AuthRequestHandlerBuilder().build(); } -cass::ConnectionSettings Unit::use_ssl(mockssandra::Cluster* cluster, - const cass::String& cn /*= ""*/) { - cass::SslContext::Ptr ssl_context(cass::SslContextFactory::create()); +ConnectionSettings Unit::use_ssl(mockssandra::Cluster* cluster, + const String& cn /*= ""*/) { + SslContext::Ptr ssl_context(SslContextFactory::create()); String cert = cluster->use_ssl(cn); EXPECT_FALSE(cert.empty()) << "Unable to enable SSL"; EXPECT_EQ(ssl_context->add_trusted_cert(cert.data(), cert.size()), CASS_OK); - cass::ConnectionSettings settings; + core::ConnectionSettings settings; settings.socket_settings.ssl_context = ssl_context; settings.socket_settings.hostname_resolution_enabled = true; return settings; } -void Unit::add_logging_critera(const cass::String& criteria) { +void Unit::add_logging_critera(const String& criteria) { logging_criteria_.push_back(criteria); } @@ -159,8 +163,8 @@ void Unit::on_log(const CassLogMessage* message, void* data) { } // Determine if the log message matches any of the criteria - for (Vector::const_iterator it = instance->logging_criteria_.begin(), - end = instance->logging_criteria_.end(); it != end; ++it) { + for (Vector::const_iterator it = instance->logging_criteria_.begin(), + end = instance->logging_criteria_.end(); it != end; ++it) { if (strstr(message->message, it->c_str()) != NULL) { instance->logging_criteria_count_.fetch_add(1); } diff --git a/cpp-driver/gtests/src/unit/unit.hpp b/cpp-driver/gtests/src/unit/unit.hpp index 7b390b63a..22de8b17f 100644 --- a/cpp-driver/gtests/src/unit/unit.hpp +++ b/cpp-driver/gtests/src/unit/unit.hpp @@ -66,7 +66,7 @@ class Unit : public testing::Test { size_t node; uint64_t delay_ms; }; - typedef cass::Vector Actions; + typedef datastax::internal::Vector Actions; /** * Constructor. @@ -110,7 +110,7 @@ class Unit : public testing::Test { * * @param future Future to set when outage plan is running. */ - void run(cass::Future::Ptr future = cass::Future::Ptr()); + void run(datastax::internal::core::Future::Ptr future = datastax::internal::core::Future::Ptr()); /** * Stop the outage plan; must be executed on the same thread that started @@ -138,14 +138,14 @@ class Unit : public testing::Test { Actions actions_; uv_loop_t* loop_; mockssandra::SimpleCluster* cluster_; - cass::Future::Ptr future_; + datastax::internal::core::Future::Ptr future_; }; public: class ExecuteOutagePlan : public Task { public: ExecuteOutagePlan(OutagePlan* outage_plan, - cass::Future::Ptr future) + datastax::internal::core::Future::Ptr future) : outage_plan_(outage_plan) , future_(future) { } virtual void run(EventLoop* event_loop) { @@ -153,13 +153,13 @@ class Unit : public testing::Test { } private: OutagePlan * outage_plan_; - cass::Future::Ptr future_; + datastax::internal::core::Future::Ptr future_; }; class StopOutagePlan : public Task { public: StopOutagePlan(OutagePlan* outage_plan, - cass::Future::Ptr future) + datastax::internal::core::Future::Ptr future) : outage_plan_(outage_plan) , future_(future) { } virtual void run(EventLoop* event_loop) { @@ -168,7 +168,7 @@ class Unit : public testing::Test { } private: OutagePlan * outage_plan_; - cass::Future::Ptr future_; + datastax::internal::core::Future::Ptr future_; }; public: @@ -211,15 +211,15 @@ class Unit : public testing::Test { * peer verification) * @return A connection settings object setup to use SSL. */ - cass::ConnectionSettings use_ssl(mockssandra::Cluster* cluster, - const cass::String& cn = ""); + datastax::internal::core::ConnectionSettings use_ssl(mockssandra::Cluster* cluster, + const datastax::String& cn = ""); /** * Add criteria to the search criteria for incoming log messages * * @param criteria Criteria to add */ - void add_logging_critera(const cass::String& criteria); + void add_logging_critera(const datastax::String& criteria); /** * Get the number of log messages that matched the search criteria * @@ -238,8 +238,8 @@ class Unit : public testing::Test { private: CassLogLevel output_log_level_; - cass::Vector logging_criteria_; - cass::Atomic logging_criteria_count_; + datastax::internal::Vector logging_criteria_; + datastax::internal::Atomic logging_criteria_count_; }; #endif // UNIT_TEST_HPP diff --git a/cpp-driver/src/abstract_data.cpp b/cpp-driver/src/abstract_data.cpp index 81f41f721..2038a28fd 100644 --- a/cpp-driver/src/abstract_data.cpp +++ b/cpp-driver/src/abstract_data.cpp @@ -22,7 +22,7 @@ #include "tuple.hpp" #include "user_type_value.hpp" -namespace cass { +using namespace datastax::internal::core; CassError AbstractData::set(size_t index, CassNull value) { CASS_CHECK_INDEX_AND_TYPE(index, value); @@ -119,5 +119,3 @@ Buffer AbstractData::Element::get_buffer() const { return buf_; } } - -} // namespace cass diff --git a/cpp-driver/src/abstract_data.hpp b/cpp-driver/src/abstract_data.hpp index b32745563..9ce52453b 100644 --- a/cpp-driver/src/abstract_data.hpp +++ b/cpp-driver/src/abstract_data.hpp @@ -33,7 +33,7 @@ if (rc != CASS_OK) return rc; \ } while(0) -namespace cass { +namespace datastax { namespace internal { namespace core { class Tuple; class UserTypeValue; @@ -54,7 +54,7 @@ class AbstractData : public Allocated { Element(CassNull value) : type_(NUL) - , buf_(cass::encode_with_length(value)) { } + , buf_(core::encode_with_length(value)) { } Element(const Buffer& buf) : type_(BUFFER) @@ -100,7 +100,7 @@ class AbstractData : public Allocated { #define SET_TYPE(Type) \ CassError set(size_t index, const Type value) { \ CASS_CHECK_INDEX_AND_TYPE(index, value); \ - elements_[index] = cass::encode_with_length(value); \ + elements_[index] = core::encode_with_length(value); \ return CASS_OK; \ } @@ -177,6 +177,6 @@ class AbstractData : public Allocated { DISALLOW_COPY_AND_ASSIGN(AbstractData); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/address.cpp b/cpp-driver/src/address.cpp index 0efd97e8c..6a08ca100 100644 --- a/cpp-driver/src/address.cpp +++ b/cpp-driver/src/address.cpp @@ -24,7 +24,8 @@ #include #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; const Address Address::EMPTY_KEY("0.0.0.0", 0); const Address Address::DELETED_KEY("0.0.0.0", 1); @@ -169,6 +170,8 @@ int Address::compare(const Address& a, bool with_port) const { return 0; } +namespace datastax { namespace internal { namespace core { + bool determine_address_for_peer_host(const Address& connected_address, const Value* peer_value, const Value* rpc_value, @@ -223,4 +226,4 @@ String determine_listen_address(const Address& address, const Row* row) { return ""; } -} // namespace cass +} } } // namespace datastax::internal::core diff --git a/cpp-driver/src/address.hpp b/cpp-driver/src/address.hpp index 94cf41403..7ebbc6ea4 100644 --- a/cpp-driver/src/address.hpp +++ b/cpp-driver/src/address.hpp @@ -27,7 +27,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Row; class Value; @@ -95,13 +95,13 @@ class Address : public Allocated { }; struct AddressHash { - std::size_t operator()(const cass::Address& a) const { + std::size_t operator()(const Address& a) const { if (a.family() == AF_INET) { - return cass::hash::fnv1a(reinterpret_cast(a.addr()), - sizeof(struct sockaddr_in)); + return hash::fnv1a(reinterpret_cast(a.addr()), + sizeof(struct sockaddr_in)); } else if (a.family() == AF_INET6) { - return cass::hash::fnv1a(reinterpret_cast(a.addr()), - sizeof(struct sockaddr_in6)); + return hash::fnv1a(reinterpret_cast(a.addr()), + sizeof(struct sockaddr_in6)); } return 0; } @@ -152,6 +152,6 @@ bool determine_address_for_peer_host(const Address& connected_address, String determine_listen_address(const Address& address, const Row* row); -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/aligned_storage.hpp b/cpp-driver/src/aligned_storage.hpp index 2c9b80f80..96c37254d 100644 --- a/cpp-driver/src/aligned_storage.hpp +++ b/cpp-driver/src/aligned_storage.hpp @@ -29,7 +29,7 @@ #error Unsupported compiler! #endif -namespace cass { +namespace datastax { namespace internal { // This allows for the allocation of memory that is of the same size and // alignment as a required by a non-POD, but is represented as a POD type (char). @@ -59,7 +59,6 @@ ALIGNED_STORAGE(64); #undef ALIGNED_STORAGE -} // namespace cass +} } // namespace datastax::internal #endif - diff --git a/cpp-driver/src/allocated.cpp b/cpp-driver/src/allocated.cpp index b2596f469..0df7fca9e 100644 --- a/cpp-driver/src/allocated.cpp +++ b/cpp-driver/src/allocated.cpp @@ -18,7 +18,7 @@ #include "memory.hpp" #include -namespace cass { +using namespace datastax::internal; void* Allocated::operator new(size_t size) { return Memory::malloc(size); @@ -35,5 +35,3 @@ void Allocated::operator delete(void* ptr) { void Allocated::operator delete[](void* ptr) { Memory::free(ptr); } - -} // namespace cass diff --git a/cpp-driver/src/allocated.hpp b/cpp-driver/src/allocated.hpp index 5c318aa83..5aa0d89e7 100644 --- a/cpp-driver/src/allocated.hpp +++ b/cpp-driver/src/allocated.hpp @@ -19,7 +19,7 @@ #include -namespace cass { +namespace datastax { namespace internal { class Allocated { public: @@ -36,6 +36,6 @@ template struct AllocatedT : public Allocated, public T { }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/allocator.hpp b/cpp-driver/src/allocator.hpp index 5c7deed4a..2df22832f 100644 --- a/cpp-driver/src/allocator.hpp +++ b/cpp-driver/src/allocator.hpp @@ -12,7 +12,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template class Allocator { @@ -64,6 +64,6 @@ class Allocator { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/async.cpp b/cpp-driver/src/async.cpp index 92c695929..1f5261c13 100644 --- a/cpp-driver/src/async.cpp +++ b/cpp-driver/src/async.cpp @@ -16,7 +16,7 @@ #include "async.hpp" -namespace cass { +using namespace datastax::internal::core; Async::Async() : handle_(NULL) { } @@ -60,5 +60,3 @@ void Async::on_async(uv_async_t* handle) { void Async::on_close(uv_handle_t* handle) { delete reinterpret_cast*>(handle); } - -} // namespace cass diff --git a/cpp-driver/src/async.hpp b/cpp-driver/src/async.hpp index 5949ece04..725c45c8c 100644 --- a/cpp-driver/src/async.hpp +++ b/cpp-driver/src/async.hpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A wrapper for uv_async. This is useful for signaling an event loop that's @@ -31,7 +31,7 @@ namespace cass { */ class Async { public: - typedef cass::Callback Callback; + typedef internal::Callback Callback; Async(); @@ -77,6 +77,6 @@ class Async { DISALLOW_COPY_AND_ASSIGN(Async); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/atomic.hpp b/cpp-driver/src/atomic.hpp index c10933239..3f96cf9aa 100644 --- a/cpp-driver/src/atomic.hpp +++ b/cpp-driver/src/atomic.hpp @@ -28,4 +28,3 @@ #endif #endif - diff --git a/cpp-driver/src/atomic/atomic_boost.hpp b/cpp-driver/src/atomic/atomic_boost.hpp index 28b8ac85e..202da4485 100644 --- a/cpp-driver/src/atomic/atomic_boost.hpp +++ b/cpp-driver/src/atomic/atomic_boost.hpp @@ -19,7 +19,7 @@ #include -namespace cass { +namespace datastax { namespace internal { enum MemoryOrder { MEMORY_ORDER_RELAXED = boost::memory_order_relaxed, @@ -72,6 +72,6 @@ inline void atomic_thread_fence(MemoryOrder order) { boost::atomic_thread_fence(static_cast(order)); } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/atomic/atomic_intrinsics.hpp b/cpp-driver/src/atomic/atomic_intrinsics.hpp index 19e243841..8a6c82a04 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics.hpp @@ -36,7 +36,7 @@ // Note: Please use the boost::atomic<> or std::atomic<> // implementations when possible. -namespace cass { +namespace datastax { namespace internal { enum MemoryOrder { MEMORY_ORDER_RELAXED = 0, @@ -47,7 +47,7 @@ enum MemoryOrder { MEMORY_ORDER_SEQ_CST = 14 // MEMORY_ORDER_ACQ_REL | 8 }; -} // namespace cass +} } // namespace datastax::internal #if defined(__GNUC__) #include "atomic_intrinsics_gcc.hpp" diff --git a/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp b/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp index cc88fbb9a..a9cea519b 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp @@ -33,7 +33,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template class Atomic { @@ -109,6 +109,6 @@ inline void atomic_thread_fence(MemoryOrder order) { } } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp b/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp index 0f7bbbda2..786cf4176 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp @@ -58,7 +58,7 @@ # define InterlockedCompareExchange64 _InterlockedCompareExchange64 #endif -namespace cass { +namespace datastax { namespace internal { namespace impl { @@ -469,6 +469,6 @@ inline void atomic_thread_fence(MemoryOrder order) { _ReadWriteBarrier(); } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/atomic/atomic_std.hpp b/cpp-driver/src/atomic/atomic_std.hpp index 4920c8a2d..2c8d69fdc 100644 --- a/cpp-driver/src/atomic/atomic_std.hpp +++ b/cpp-driver/src/atomic/atomic_std.hpp @@ -19,7 +19,7 @@ #include -namespace cass { +namespace datastax { namespace internal { enum MemoryOrder { MEMORY_ORDER_RELAXED = std::memory_order_relaxed, @@ -72,6 +72,6 @@ inline void atomic_thread_fence(MemoryOrder order) { std::atomic_thread_fence(static_cast(order)); } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/auth.cpp b/cpp-driver/src/auth.cpp index 6dbc92b01..74ccfbfb2 100644 --- a/cpp-driver/src/auth.cpp +++ b/cpp-driver/src/auth.cpp @@ -22,6 +22,9 @@ #include +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { void cass_authenticator_address(const CassAuthenticator* auth, @@ -50,7 +53,7 @@ void cass_authenticator_set_exchange_data(CassAuthenticator* auth, void* exchang } char* cass_authenticator_response(CassAuthenticator* auth, size_t size) { - cass::String* response = auth->response(); + String* response = auth->response(); if (response != NULL) { response->resize(size, 0); @@ -74,13 +77,11 @@ void cass_authenticator_set_error(CassAuthenticator* auth, void cass_authenticator_set_error_n(CassAuthenticator* auth, const char* message, size_t message_length) { - auth->set_error(cass::String(message, message_length)); + auth->set_error(String(message, message_length)); } } // extern "C" -namespace cass { - bool PlainTextAuthenticator::initial_response(String* response) { response->reserve(username_.size() + password_.size() + 2); response->push_back(0); @@ -151,5 +152,3 @@ bool ExternalAuthenticator::success(const String& token) { token.data(), token.size()); return error_.empty(); } - -} // namespace cass diff --git a/cpp-driver/src/auth.hpp b/cpp-driver/src/auth.hpp index d94b2521e..6adeeaf24 100644 --- a/cpp-driver/src/auth.hpp +++ b/cpp-driver/src/auth.hpp @@ -25,7 +25,7 @@ #include "ref_counted.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Authenticator : public RefCounted { public: @@ -174,8 +174,8 @@ class PlainTextAuthProvider : public AuthProvider { String password_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::ExternalAuthenticator, CassAuthenticator) +EXTERNAL_TYPE(datastax::internal::core::ExternalAuthenticator, CassAuthenticator) #endif diff --git a/cpp-driver/src/auth_requests.cpp b/cpp-driver/src/auth_requests.cpp index 4d28e763b..64179af27 100644 --- a/cpp-driver/src/auth_requests.cpp +++ b/cpp-driver/src/auth_requests.cpp @@ -16,7 +16,7 @@ #include "auth_requests.hpp" -namespace cass { +using namespace datastax::internal::core; int AuthResponseRequest::encode(ProtocolVersion version, RequestCallback* callback, BufferVec* bufs) const { // [bytes] @@ -28,5 +28,3 @@ int AuthResponseRequest::encode(ProtocolVersion version, RequestCallback* callba return length; } - -} // namespace cass diff --git a/cpp-driver/src/auth_requests.hpp b/cpp-driver/src/auth_requests.hpp index 69a47867b..b9afbc6bb 100644 --- a/cpp-driver/src/auth_requests.hpp +++ b/cpp-driver/src/auth_requests.hpp @@ -22,7 +22,7 @@ #include "ref_counted.hpp" #include "request.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class AuthResponseRequest : public Request { public: @@ -42,6 +42,6 @@ class AuthResponseRequest : public Request { Authenticator::Ptr auth_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/auth_responses.cpp b/cpp-driver/src/auth_responses.cpp index 542cefe07..5df0d896b 100644 --- a/cpp-driver/src/auth_responses.cpp +++ b/cpp-driver/src/auth_responses.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; bool AuthenticateResponse::decode(Decoder& decoder) { decoder.set_type("authentication"); @@ -30,7 +30,7 @@ bool AuthenticateResponse::decode(Decoder& decoder) { return true; } -bool cass::AuthChallengeResponse::decode(Decoder& decoder) { +bool AuthChallengeResponse::decode(Decoder& decoder) { decoder.set_type("authentication challenge"); StringRef token; @@ -40,7 +40,7 @@ bool cass::AuthChallengeResponse::decode(Decoder& decoder) { return true; } -bool cass::AuthSuccessResponse::decode(Decoder& decoder) { +bool AuthSuccessResponse::decode(Decoder& decoder) { decoder.set_type("authentication success"); StringRef token; @@ -49,5 +49,3 @@ bool cass::AuthSuccessResponse::decode(Decoder& decoder) { decoder.maybe_log_remaining(); return true; } - -} // namespace cass diff --git a/cpp-driver/src/auth_responses.hpp b/cpp-driver/src/auth_responses.hpp index 63980d92e..550896482 100644 --- a/cpp-driver/src/auth_responses.hpp +++ b/cpp-driver/src/auth_responses.hpp @@ -22,7 +22,7 @@ #include "string.hpp" #include "string_ref.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class AuthenticateResponse : public Response { public: @@ -63,6 +63,6 @@ class AuthSuccessResponse : public Response { String token_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/batch_request.cpp b/cpp-driver/src/batch_request.cpp index 29345596f..9cb07beb7 100644 --- a/cpp-driver/src/batch_request.cpp +++ b/cpp-driver/src/batch_request.cpp @@ -24,10 +24,13 @@ #include "serialization.hpp" #include "statement.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassBatch* cass_batch_new(CassBatchType type) { - cass::BatchRequest* batch = new cass::BatchRequest(type); + BatchRequest* batch = new BatchRequest(type); batch->inc_ref(); return CassBatch::to(batch); } @@ -43,7 +46,7 @@ CassError cass_batch_set_keyspace(CassBatch* batch, const char* keyspace) { CassError cass_batch_set_keyspace_n(CassBatch* batch, const char* keyspace, size_t keyspace_length) { - batch->set_keyspace(cass::String(keyspace, keyspace_length)); + batch->set_keyspace(String(keyspace, keyspace_length)); return CASS_OK; } @@ -111,17 +114,15 @@ CassError cass_batch_set_execution_profile_n(CassBatch* batch, const char* name, size_t name_length) { if (name_length > 0) { - batch->set_execution_profile_name(cass::String(name, name_length)); + batch->set_execution_profile_name(String(name, name_length)); } else { - batch->set_execution_profile_name(cass::String()); + batch->set_execution_profile_name(String()); } return CASS_OK; } } // extern "C" -namespace cass { - // Format: ...[][] // where: // is a [byte] @@ -251,5 +252,3 @@ bool BatchRequest::get_routing_key(String* routing_key) const { } return false; } - -} // namespace cass diff --git a/cpp-driver/src/batch_request.hpp b/cpp-driver/src/batch_request.hpp index b139c2884..2566735ba 100644 --- a/cpp-driver/src/batch_request.hpp +++ b/cpp-driver/src/batch_request.hpp @@ -27,7 +27,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ExecuteRequest; @@ -57,8 +57,8 @@ class BatchRequest : public RoutableRequest { StatementVec statements_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::BatchRequest, CassBatch) +EXTERNAL_TYPE(datastax::internal::core::BatchRequest, CassBatch) #endif diff --git a/cpp-driver/src/blacklist_dc_policy.cpp b/cpp-driver/src/blacklist_dc_policy.cpp index a05dcf022..7c47afb70 100644 --- a/cpp-driver/src/blacklist_dc_policy.cpp +++ b/cpp-driver/src/blacklist_dc_policy.cpp @@ -16,7 +16,7 @@ #include "blacklist_dc_policy.hpp" -namespace cass { +using namespace datastax::internal::core; bool BlacklistDCPolicy::is_valid_host(const Host::Ptr& host) const { const String& host_dc = host->dc(); @@ -28,5 +28,3 @@ bool BlacklistDCPolicy::is_valid_host(const Host::Ptr& host) const { } return true; } - -} // namespace cass diff --git a/cpp-driver/src/blacklist_dc_policy.hpp b/cpp-driver/src/blacklist_dc_policy.hpp index 42774b067..f2532c14d 100644 --- a/cpp-driver/src/blacklist_dc_policy.hpp +++ b/cpp-driver/src/blacklist_dc_policy.hpp @@ -22,7 +22,7 @@ #include "scoped_ptr.hpp" #include "list_policy.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class BlacklistDCPolicy : public ListPolicy { public: @@ -46,6 +46,6 @@ class BlacklistDCPolicy : public ListPolicy { DISALLOW_COPY_AND_ASSIGN(BlacklistDCPolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/blacklist_policy.cpp b/cpp-driver/src/blacklist_policy.cpp index 90f5c2531..2334d2c77 100644 --- a/cpp-driver/src/blacklist_policy.cpp +++ b/cpp-driver/src/blacklist_policy.cpp @@ -16,7 +16,7 @@ #include "blacklist_policy.hpp" -namespace cass { +using namespace datastax::internal::core; bool BlacklistPolicy::is_valid_host(const Host::Ptr& host) const { const String& host_address = host->address().to_string(false); @@ -29,5 +29,3 @@ bool BlacklistPolicy::is_valid_host(const Host::Ptr& host) const { } return true; } - -} // namespace cass diff --git a/cpp-driver/src/blacklist_policy.hpp b/cpp-driver/src/blacklist_policy.hpp index 545a32a99..2ece32df2 100644 --- a/cpp-driver/src/blacklist_policy.hpp +++ b/cpp-driver/src/blacklist_policy.hpp @@ -22,7 +22,7 @@ #include "scoped_ptr.hpp" #include "list_policy.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class BlacklistPolicy : public ListPolicy { public: @@ -46,6 +46,6 @@ class BlacklistPolicy : public ListPolicy { DISALLOW_COPY_AND_ASSIGN(BlacklistPolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/buffer.hpp b/cpp-driver/src/buffer.hpp index e4c4e124e..20bd93cfd 100644 --- a/cpp-driver/src/buffer.hpp +++ b/cpp-driver/src/buffer.hpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Buffer { public: @@ -70,55 +70,55 @@ class Buffer { size_t encode_byte(size_t offset, uint8_t value) { assert(offset + sizeof(uint8_t) <= static_cast(size_)); - cass::encode_byte(data() + offset, value); + internal::encode_byte(data() + offset, value); return offset + sizeof(uint8_t); } size_t encode_int8(size_t offset, int8_t value) { assert(offset + sizeof(int8_t) <= static_cast(size_)); - cass::encode_int8(data() + offset, value); + internal::encode_int8(data() + offset, value); return offset + sizeof(int8_t); } size_t encode_int16(size_t offset, int16_t value) { assert(offset + sizeof(int16_t) <= static_cast(size_)); - cass::encode_int16(data() + offset, value); + internal::encode_int16(data() + offset, value); return offset + sizeof(int16_t); } size_t encode_uint16(size_t offset, uint16_t value) { assert(offset + sizeof(uint16_t) <= static_cast(size_)); - cass::encode_uint16(data() + offset, value); + internal::encode_uint16(data() + offset, value); return offset + sizeof(uint16_t); } size_t encode_int32(size_t offset, int32_t value) { assert(offset + sizeof(int32_t) <= static_cast(size_)); - cass::encode_int32(data() + offset, value); + internal::encode_int32(data() + offset, value); return offset + sizeof(int32_t); } size_t encode_uint32(size_t offset, uint32_t value) { assert(offset + sizeof(uint32_t) <= static_cast(size_)); - cass::encode_uint32(data() + offset, value); + internal::encode_uint32(data() + offset, value); return offset + sizeof(uint32_t); } size_t encode_int64(size_t offset, int64_t value) { assert(offset + sizeof(int64_t) <= static_cast(size_)); - cass::encode_int64(data() + offset, value); + internal::encode_int64(data() + offset, value); return offset + sizeof(int64_t); } size_t encode_float(size_t offset, float value) { assert(offset + sizeof(float) <= static_cast(size_)); - cass::encode_float(data() + offset, value); + internal::encode_float(data() + offset, value); return offset + sizeof(float); } size_t encode_double(size_t offset, double value) { assert(offset + sizeof(double) <= static_cast(size_)); - cass::encode_double(data() + offset, value); + internal::encode_double(data() + offset, value); return offset + sizeof(double); } @@ -161,7 +161,7 @@ class Buffer { size_t encode_uuid(size_t offset, CassUuid value) { assert(offset + sizeof(CassUuid) <= static_cast(size_)); - cass::encode_uuid(data() + offset, value); + internal::encode_uuid(data() + offset, value); return offset + sizeof(CassUuid); } @@ -224,6 +224,6 @@ class Buffer { typedef Vector BufferVec; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/callback.hpp b/cpp-driver/src/callback.hpp index 2ff8786cb..8de616cef 100644 --- a/cpp-driver/src/callback.hpp +++ b/cpp-driver/src/callback.hpp @@ -23,7 +23,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { template class Callback { @@ -157,6 +157,6 @@ Callback bind_callback(R (*func)(Arg, D), const D& data) { return Callback(func, data, dummy); } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/cluster.cpp b/cpp-driver/src/cluster.cpp index 3c748fb85..2d8efcb67 100644 --- a/cpp-driver/src/cluster.cpp +++ b/cpp-driver/src/cluster.cpp @@ -25,7 +25,10 @@ #include "speculative_execution.hpp" #include "utils.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A task for initiating the cluster close process. @@ -132,6 +135,8 @@ class NopClusterListener : public ClusterListener { virtual void on_close(Cluster* cluster) { } }; +} } } // namespace datastax::internal::core + void ClusterEvent::process_event(const ClusterEvent& event, ClusterListener* listener) { switch(event.type) { @@ -409,7 +414,7 @@ void Cluster::update_token_map(const HostMap& hosts, // important for DC-aware). This method prevents connection pools from being // created to ignored hosts. bool Cluster::is_host_ignored(const Host::Ptr& host) const { - return cass::is_host_ignored(load_balancing_policies_, host); + return core::is_host_ignored(load_balancing_policies_, host); } void Cluster::schedule_reconnect() { @@ -817,5 +822,3 @@ void Cluster::on_close(ControlConnection* connection) { handle_close(); } } - -} // namespace cass diff --git a/cpp-driver/src/cluster.hpp b/cpp-driver/src/cluster.hpp index caadfef6e..8cd0496b9 100644 --- a/cpp-driver/src/cluster.hpp +++ b/cpp-driver/src/cluster.hpp @@ -28,7 +28,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Cluster; @@ -444,6 +444,6 @@ class Cluster : public RefCounted Timer monitor_reporting_timer_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/cluster_config.cpp b/cpp-driver/src/cluster_config.cpp index caece85db..14f75173f 100644 --- a/cpp-driver/src/cluster_config.cpp +++ b/cpp-driver/src/cluster_config.cpp @@ -16,10 +16,13 @@ #include "cluster_config.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassCluster* cass_cluster_new() { - return CassCluster::to(new cass::ClusterConfig()); + return CassCluster::to(new ClusterConfig()); } CassError cass_cluster_set_port(CassCluster* cluster, @@ -41,10 +44,10 @@ CassError cass_cluster_set_protocol_version(CassCluster* cluster, if (cluster->config().use_beta_protocol_version()) { LOG_ERROR("The protocol version is already set to the newest beta version %s " "and cannot be explicitly set.", - cass::ProtocolVersion::newest_beta().to_string().c_str()); + ProtocolVersion::newest_beta().to_string().c_str()); return CASS_ERROR_LIB_BAD_PARAMS; } else { - cass::ProtocolVersion version(protocol_version); + ProtocolVersion version(protocol_version); if (!version.is_valid()) { return CASS_ERROR_LIB_BAD_PARAMS; } @@ -56,8 +59,8 @@ CassError cass_cluster_set_protocol_version(CassCluster* cluster, CassError cass_cluster_set_use_beta_protocol_version(CassCluster* cluster, cass_bool_t enable) { cluster->config().set_use_beta_protocol_version(enable == cass_true); - cluster->config().set_protocol_version(enable ? cass::ProtocolVersion::newest_beta() - : cass::ProtocolVersion::highest_supported()); + cluster->config().set_protocol_version(enable ? ProtocolVersion::newest_beta() + : ProtocolVersion::highest_supported()); return CASS_OK; } @@ -115,8 +118,8 @@ CassError cass_cluster_set_contact_points_n(CassCluster* cluster, if (contact_points_length == 0) { cluster->config().contact_points().clear(); } else { - cass::explode(cass::String(contact_points, contact_points_length), - cluster->config().contact_points()); + explode(String(contact_points, contact_points_length), + cluster->config().contact_points()); } return CASS_OK; } @@ -248,12 +251,12 @@ void cass_cluster_set_credentials_n(CassCluster* cluster, size_t username_length, const char* password, size_t password_length) { - cluster->config().set_credentials(cass::String(username, username_length), - cass::String(password, password_length)); + cluster->config().set_credentials(String(username, username_length), + String(password, password_length)); } void cass_cluster_set_load_balance_round_robin(CassCluster* cluster) { - cluster->config().set_load_balancing_policy(new cass::RoundRobinPolicy()); + cluster->config().set_load_balancing_policy(new RoundRobinPolicy()); } CassError cass_cluster_set_load_balance_dc_aware(CassCluster* cluster, @@ -279,9 +282,9 @@ CassError cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster, return CASS_ERROR_LIB_BAD_PARAMS; } cluster->config().set_load_balancing_policy( - new cass::DCAwarePolicy(cass::String(local_dc, local_dc_length), - used_hosts_per_remote_dc, - !allow_remote_dcs_for_local_cl)); + new DCAwarePolicy(String(local_dc, local_dc_length), + used_hosts_per_remote_dc, + !allow_remote_dcs_for_local_cl)); return CASS_OK; } @@ -306,7 +309,7 @@ void cass_cluster_set_latency_aware_routing_settings(CassCluster* cluster, cass_uint64_t retry_period_ms, cass_uint64_t update_rate_ms, cass_uint64_t min_measured) { - cass::LatencyAwarePolicy::Settings settings; + LatencyAwarePolicy::Settings settings; settings.exclusion_threshold = exclusion_threshold; settings.scale_ns = scale_ms * 1000 * 1000; settings.retry_period_ns = retry_period_ms * 1000 * 1000; @@ -328,8 +331,8 @@ void cass_cluster_set_whitelist_filtering_n(CassCluster* cluster, if (hosts_length == 0) { cluster->config().default_profile().whitelist().clear(); } else { - cass::explode(cass::String(hosts, hosts_length), - cluster->config().default_profile().whitelist()); + explode(String(hosts, hosts_length), + cluster->config().default_profile().whitelist()); } } @@ -346,8 +349,8 @@ void cass_cluster_set_blacklist_filtering_n(CassCluster* cluster, if (hosts_length == 0) { cluster->config().default_profile().blacklist().clear(); } else { - cass::explode(cass::String(hosts, hosts_length), - cluster->config().default_profile().blacklist()); + explode(String(hosts, hosts_length), + cluster->config().default_profile().blacklist()); } } @@ -364,8 +367,8 @@ void cass_cluster_set_whitelist_dc_filtering_n(CassCluster* cluster, if (dcs_length == 0) { cluster->config().default_profile().whitelist_dc().clear(); } else { - cass::explode(cass::String(dcs, dcs_length), - cluster->config().default_profile().whitelist_dc()); + explode(String(dcs, dcs_length), + cluster->config().default_profile().whitelist_dc()); } } @@ -382,8 +385,8 @@ void cass_cluster_set_blacklist_dc_filtering_n(CassCluster* cluster, if (dcs_length == 0) { cluster->config().default_profile().blacklist_dc().clear(); } else { - cass::explode(cass::String(dcs, dcs_length), - cluster->config().default_profile().blacklist_dc()); + explode(String(dcs, dcs_length), + cluster->config().default_profile().blacklist_dc()); } } @@ -402,9 +405,9 @@ CassError cass_cluster_set_authenticator_callbacks(CassCluster* cluster, const CassAuthenticatorCallbacks* exchange_callbacks, CassAuthenticatorDataCleanupCallback cleanup_callback, void* data) { - cluster->config().set_auth_provider(cass::AuthProvider::Ptr( - new cass::ExternalAuthProvider(exchange_callbacks, - cleanup_callback, data))); + cluster->config().set_auth_provider(AuthProvider::Ptr( + new ExternalAuthProvider(exchange_callbacks, + cleanup_callback, data))); return CASS_OK; } @@ -452,14 +455,14 @@ CassError cass_cluster_set_constant_speculative_execution_policy(CassCluster* cl return CASS_ERROR_LIB_BAD_PARAMS; } cluster->config().set_speculative_execution_policy( - new cass::ConstantSpeculativeExecutionPolicy(constant_delay_ms, - max_speculative_executions)); + new ConstantSpeculativeExecutionPolicy(constant_delay_ms, + max_speculative_executions)); return CASS_OK; } CassError cass_cluster_set_no_speculative_execution_policy(CassCluster* cluster) { cluster->config().set_speculative_execution_policy( - new cass::NoSpeculativeExecutionPolicy()); + new NoSpeculativeExecutionPolicy()); return CASS_OK; } @@ -485,7 +488,7 @@ CassError cass_cluster_set_execution_profile_n(CassCluster* cluster, if (name_length == 0 || !profile) { return CASS_ERROR_LIB_BAD_PARAMS; } - cluster->config().set_execution_profile(cass::String(name, name_length), + cluster->config().set_execution_profile(String(name, name_length), profile); return CASS_OK; } @@ -510,10 +513,10 @@ CassError cass_cluster_set_local_address(CassCluster* cluster, CassError cass_cluster_set_local_address_n(CassCluster* cluster, const char* name, size_t name_length) { - cass::Address address; // default to AF_UNSPEC + Address address; // default to AF_UNSPEC if (name_length == 0 || name == NULL || - cass::Address::from_string(cass::String(name, name_length), 0, &address)) { + Address::from_string(String(name, name_length), 0, &address)) { cluster->config().set_local_address(address); } else { return CASS_ERROR_LIB_HOST_RESOLUTION; @@ -531,8 +534,8 @@ CassError cass_cluster_set_host_listener_callback(CassCluster* cluster, CassHostListenerCallback callback, void* data) { cluster->config().set_host_listener( - cass::DefaultHostListener::Ptr( - new cass::ExternalHostListener(callback, data))); + DefaultHostListener::Ptr( + new ExternalHostListener(callback, data))); return CASS_OK; } diff --git a/cpp-driver/src/cluster_config.hpp b/cpp-driver/src/cluster_config.hpp index 79a4062c8..6718c8ae0 100644 --- a/cpp-driver/src/cluster_config.hpp +++ b/cpp-driver/src/cluster_config.hpp @@ -23,7 +23,7 @@ #include "uv.h" -namespace cass { +namespace datastax { namespace internal { namespace core { class ClusterConfig : public Allocated { public: @@ -34,8 +34,8 @@ class ClusterConfig : public Allocated { Config config_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::ClusterConfig, CassCluster) +EXTERNAL_TYPE(datastax::internal::core::ClusterConfig, CassCluster) #endif diff --git a/cpp-driver/src/cluster_connector.cpp b/cpp-driver/src/cluster_connector.cpp index 3f2e1fe27..3c181c04b 100644 --- a/cpp-driver/src/cluster_connector.cpp +++ b/cpp-driver/src/cluster_connector.cpp @@ -20,7 +20,11 @@ #include "random.hpp" #include "round_robin_policy.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A task for running the connection process. @@ -54,6 +58,8 @@ class RunCancelCluster : public Task { ClusterConnector::Ptr connector_; }; +} } } // namespace datastax::internal::core + ClusterConnector::ClusterConnector(const ContactPointList& contact_points, ProtocolVersion protocol_version, const Callback& callback) @@ -343,5 +349,3 @@ void ClusterConnector::on_connect(ControlConnector* connector) { on_error(CLUSTER_ERROR_NO_HOSTS_AVAILABLE, connector->error_message()); } } - -} // namespace cass diff --git a/cpp-driver/src/cluster_connector.hpp b/cpp-driver/src/cluster_connector.hpp index 59f895665..4de29f8c3 100644 --- a/cpp-driver/src/cluster_connector.hpp +++ b/cpp-driver/src/cluster_connector.hpp @@ -21,9 +21,12 @@ #include "cluster.hpp" #include "resolver.hpp" -namespace cass { +namespace datastax { namespace internal { class Random; + +namespace core { + class Metrics; /** @@ -37,7 +40,7 @@ class ClusterConnector : public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum ClusterError { CLUSTER_OK, @@ -177,6 +180,6 @@ class ClusterConnector : public RefCounted { CassError ssl_error_code_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/collection.cpp b/cpp-driver/src/collection.cpp index 2fe6af848..a22e9fd2a 100644 --- a/cpp-driver/src/collection.cpp +++ b/cpp-driver/src/collection.cpp @@ -24,11 +24,14 @@ #include +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassCollection* cass_collection_new(CassCollectionType type, size_t item_count) { - cass::Collection* collection = new cass::Collection(type, item_count); + Collection* collection = new Collection(type, item_count); collection->inc_ref(); return CassCollection::to(collection); } @@ -38,9 +41,9 @@ CassCollection* cass_collection_new_from_data_type(const CassDataType* data_type if (!data_type->is_collection()) { return NULL; } - cass::Collection* collection - = new cass::Collection(cass::DataType::ConstPtr(data_type), - item_count); + Collection* collection + = new Collection(DataType::ConstPtr(data_type), + item_count); collection->inc_ref(); return CassCollection::to(collection); } @@ -54,11 +57,11 @@ const CassDataType* cass_collection_data_type(const CassCollection* collection) } #define CASS_COLLECTION_APPEND(Name, Params, Value) \ - CassError cass_collection_append_##Name(CassCollection* collection Params) { \ - return collection->append(Value); \ - } + CassError cass_collection_append_##Name(CassCollection* collection Params) { \ + return collection->append(Value); \ +} -CASS_COLLECTION_APPEND(null, ZERO_PARAMS_(), cass::CassNull()) +CASS_COLLECTION_APPEND(null, ZERO_PARAMS_(), CassNull()) CASS_COLLECTION_APPEND(int8, ONE_PARAM_(cass_int8_t value), value) CASS_COLLECTION_APPEND(int16, ONE_PARAM_(cass_int16_t value), value) CASS_COLLECTION_APPEND(int32, ONE_PARAM_(cass_int32_t value), value) @@ -74,33 +77,33 @@ CASS_COLLECTION_APPEND(tuple, ONE_PARAM_(const CassTuple* value), value) CASS_COLLECTION_APPEND(user_type, ONE_PARAM_(const CassUserType* value), value) CASS_COLLECTION_APPEND(bytes, TWO_PARAMS_(const cass_byte_t* value, size_t value_size), - cass::CassBytes(value, value_size)) + CassBytes(value, value_size)) CASS_COLLECTION_APPEND(decimal, THREE_PARAMS_(const cass_byte_t* varint, size_t varint_size, int scale), - cass::CassDecimal(varint, varint_size, scale)) + CassDecimal(varint, varint_size, scale)) CASS_COLLECTION_APPEND(duration, THREE_PARAMS_(cass_int32_t months, cass_int32_t days, cass_int64_t nanos), - cass::CassDuration(months, days, nanos)) + CassDuration(months, days, nanos)) #undef CASS_COLLECTION_APPEND CassError cass_collection_append_string(CassCollection* collection, const char* value) { - return collection->append(cass::CassString(value, SAFE_STRLEN(value))); + return collection->append(CassString(value, SAFE_STRLEN(value))); } CassError cass_collection_append_string_n(CassCollection* collection, const char* value, size_t value_length) { - return collection->append(cass::CassString(value, value_length)); + return collection->append(CassString(value, value_length)); } CassError cass_collection_append_custom(CassCollection* collection, const char* class_name, const cass_byte_t* value, size_t value_size) { - return collection->append(cass::CassCustom(cass::StringRef(class_name), - value, value_size)); + return collection->append(CassCustom(StringRef(class_name), + value, value_size)); } CassError cass_collection_append_custom_n(CassCollection* collection, @@ -108,14 +111,12 @@ CassError cass_collection_append_custom_n(CassCollection* collection, size_t class_name_length, const cass_byte_t* value, size_t value_size) { - return collection->append(cass::CassCustom(cass::StringRef(class_name, class_name_length), - value, value_size)); + return collection->append(CassCustom(StringRef(class_name, class_name_length), + value, value_size)); } } // extern "C" -namespace cass { - CassError Collection::append(CassNull value) { CASS_COLLECTION_CHECK_TYPE(value); items_.push_back(Buffer()); @@ -183,5 +184,3 @@ Buffer Collection::encode_with_length() const { encode_items(buf.data() + pos); return buf; } - -} // namespace cass diff --git a/cpp-driver/src/collection.hpp b/cpp-driver/src/collection.hpp index 21e5e646d..9bf5117d2 100644 --- a/cpp-driver/src/collection.hpp +++ b/cpp-driver/src/collection.hpp @@ -30,7 +30,7 @@ if (rc != CASS_OK) return rc; \ } while(0) -namespace cass { +namespace datastax { namespace internal { namespace core { class UserTypeValue; @@ -58,7 +58,7 @@ class Collection : public RefCounted { #define APPEND_TYPE(Type) \ CassError append(const Type value) { \ CASS_COLLECTION_CHECK_TYPE(value); \ - items_.push_back(cass::encode(value)); \ + items_.push_back(core::encode(value)); \ return CASS_OK; \ } @@ -135,9 +135,8 @@ class Collection : public RefCounted { DISALLOW_COPY_AND_ASSIGN(Collection); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Collection, CassCollection) +EXTERNAL_TYPE(datastax::internal::core::Collection, CassCollection) #endif - diff --git a/cpp-driver/src/collection_iterator.cpp b/cpp-driver/src/collection_iterator.cpp index 4a4c634d0..4497b4ab5 100644 --- a/cpp-driver/src/collection_iterator.cpp +++ b/cpp-driver/src/collection_iterator.cpp @@ -16,7 +16,7 @@ #include "collection_iterator.hpp" -namespace cass { +using namespace datastax::internal::core; bool CollectionIterator::next() { if (index_ + 1 >= count_) { @@ -45,5 +45,3 @@ bool TupleIterator::next() { current_ = next_++; return decoder_.decode_value(*current_, value_); } - -} // namespace cass diff --git a/cpp-driver/src/collection_iterator.hpp b/cpp-driver/src/collection_iterator.hpp index df17b084b..2217ff8db 100644 --- a/cpp-driver/src/collection_iterator.hpp +++ b/cpp-driver/src/collection_iterator.hpp @@ -22,7 +22,7 @@ #include "serialization.hpp" #include "value.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ValueIterator : public Iterator { public: @@ -78,6 +78,6 @@ class TupleIterator : public ValueIterator { DataType::Vec::const_iterator end_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/config.cpp b/cpp-driver/src/config.cpp index 6942221d2..8e7053f81 100644 --- a/cpp-driver/src/config.cpp +++ b/cpp-driver/src/config.cpp @@ -16,7 +16,7 @@ #include "config.hpp" -namespace cass { +using namespace datastax::internal::core; void Config::init_profiles() { // Initialize the profile settings (if needed) @@ -43,5 +43,3 @@ void Config::init_profiles() { } } } - -} // namespace cass diff --git a/cpp-driver/src/config.hpp b/cpp-driver/src/config.hpp index f38b6efee..588106c96 100644 --- a/cpp-driver/src/config.hpp +++ b/cpp-driver/src/config.hpp @@ -29,7 +29,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { void stderr_log_callback(const CassLogMessage* message, void* data); @@ -475,6 +475,6 @@ class Config { unsigned monitor_reporting_interval_secs_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connection.cpp b/cpp-driver/src/connection.cpp index e5ff80285..917d90cbe 100644 --- a/cpp-driver/src/connection.cpp +++ b/cpp-driver/src/connection.cpp @@ -21,7 +21,10 @@ #include "request.hpp" #include "result_response.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A request callback that handles heartbeats. @@ -96,6 +99,8 @@ void SslConnectionHandler::on_close() { connection_->on_close(); } +} } } // namespace datastax::internal::core + void RecordingConnectionListener::process_events(const EventResponse::Vec& events, ConnectionListener* listener) { for (EventResponse::Vec::const_iterator it = events.begin(), @@ -391,5 +396,3 @@ void Connection::on_terminate(Timer* timer) { "Terminating connection..."); defunct(); } - -} // namespace cass diff --git a/cpp-driver/src/connection.hpp b/cpp-driver/src/connection.hpp index 675705e1c..7543671e5 100644 --- a/cpp-driver/src/connection.hpp +++ b/cpp-driver/src/connection.hpp @@ -22,7 +22,7 @@ #ifndef __CASS_CONNECTION_HPP_INCLUDED__ #define __CASS_CONNECTION_HPP_INCLUDED__ -namespace cass { +namespace datastax { namespace internal { namespace core { class ResponseMessage; class EventResponse; @@ -255,6 +255,6 @@ class Connection : public RefCounted { Timer terminate_timer_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connection_pool.cpp b/cpp-driver/src/connection_pool.cpp index 37fc3e877..8d235b8a1 100644 --- a/cpp-driver/src/connection_pool.cpp +++ b/cpp-driver/src/connection_pool.cpp @@ -24,7 +24,8 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; static inline bool least_busy_comp(const PooledConnection::Ptr& a, const PooledConnection::Ptr& b) { @@ -274,5 +275,3 @@ void ConnectionPool::on_reconnect(DelayedConnector* connector) { } } } - -} // namespace cass diff --git a/cpp-driver/src/connection_pool.hpp b/cpp-driver/src/connection_pool.hpp index 9749a16a4..4869be938 100644 --- a/cpp-driver/src/connection_pool.hpp +++ b/cpp-driver/src/connection_pool.hpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class ConnectionPool; class ConnectionPoolConnector; @@ -245,6 +245,6 @@ class ConnectionPool : public RefCounted { DenseHashSet to_flush_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connection_pool_connector.cpp b/cpp-driver/src/connection_pool_connector.cpp index 9546adf3b..9bfc15da6 100644 --- a/cpp-driver/src/connection_pool_connector.cpp +++ b/cpp-driver/src/connection_pool_connector.cpp @@ -19,7 +19,8 @@ #include "event_loop.hpp" #include "metrics.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; ConnectionPoolConnector::ConnectionPoolConnector(const Host::Ptr& host, ProtocolVersion protocol_version, @@ -168,5 +169,3 @@ void ConnectionPoolConnector::on_connect(Connector* connector) { dec_ref(); } } - -} // namespace cass diff --git a/cpp-driver/src/connection_pool_connector.hpp b/cpp-driver/src/connection_pool_connector.hpp index 02bfbd531..d3ee49602 100644 --- a/cpp-driver/src/connection_pool_connector.hpp +++ b/cpp-driver/src/connection_pool_connector.hpp @@ -28,7 +28,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class ConnectionPoolManager; @@ -41,7 +41,7 @@ class ConnectionPoolConnector : public RefCounted { typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; /** * Constructor @@ -139,6 +139,6 @@ class ConnectionPoolConnector : public RefCounted { Metrics* metrics_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connection_pool_manager.cpp b/cpp-driver/src/connection_pool_manager.cpp index 78ede8736..c17365946 100644 --- a/cpp-driver/src/connection_pool_manager.cpp +++ b/cpp-driver/src/connection_pool_manager.cpp @@ -19,7 +19,8 @@ #include "scoped_lock.hpp" #include "utils.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; class NopConnectionPoolManagerListener : public ConnectionPoolManagerListener { public: @@ -228,5 +229,3 @@ void ConnectionPoolManager::on_connect(ConnectionPoolConnector* pool_connector) pool_connector->error_message()); } } - -} // namespace cass diff --git a/cpp-driver/src/connection_pool_manager.hpp b/cpp-driver/src/connection_pool_manager.hpp index caf2a8f3f..413850fe6 100644 --- a/cpp-driver/src/connection_pool_manager.hpp +++ b/cpp-driver/src/connection_pool_manager.hpp @@ -27,7 +27,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class EventLoop; @@ -209,6 +209,6 @@ class ConnectionPoolManager #endif }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connection_pool_manager_initializer.cpp b/cpp-driver/src/connection_pool_manager_initializer.cpp index a91925aa4..dda4bc098 100644 --- a/cpp-driver/src/connection_pool_manager_initializer.cpp +++ b/cpp-driver/src/connection_pool_manager_initializer.cpp @@ -16,7 +16,8 @@ #include "connection_pool_manager_initializer.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; ConnectionPoolManagerInitializer::ConnectionPoolManagerInitializer(ProtocolVersion protocol_version, const Callback& callback) @@ -146,5 +147,3 @@ void ConnectionPoolManagerInitializer::on_connect(ConnectionPoolConnector* pool_ dec_ref(); } } - -} // namespace cass diff --git a/cpp-driver/src/connection_pool_manager_initializer.hpp b/cpp-driver/src/connection_pool_manager_initializer.hpp index a29b2f57e..9b2b86b01 100644 --- a/cpp-driver/src/connection_pool_manager_initializer.hpp +++ b/cpp-driver/src/connection_pool_manager_initializer.hpp @@ -27,7 +27,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; class Metrics; @@ -42,7 +42,7 @@ class ConnectionPoolManagerInitializer public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; /** * Constructor @@ -155,6 +155,6 @@ class ConnectionPoolManagerInitializer ConnectionPoolSettings settings_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/connector.cpp b/cpp-driver/src/connector.cpp index 897fd4315..648027c61 100644 --- a/cpp-driver/src/connector.cpp +++ b/cpp-driver/src/connector.cpp @@ -36,7 +36,10 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A proxy request callback that handles the connection process. @@ -57,6 +60,8 @@ class StartupCallback : public SimpleRequestCallback { Connector* connector_; }; +} } } // namespace datastax::internal::core + StartupCallback::StartupCallback(Connector* connector, const Request::ConstPtr& request) : SimpleRequestCallback(request, connector->settings_.connect_timeout_ms) , connector_(connector) { } @@ -424,5 +429,3 @@ void Connector::on_timeout(Timer* timer) { socket_connector_->cancel(); if (connection_) connection_->close(); } - -} // namespace cass diff --git a/cpp-driver/src/connector.hpp b/cpp-driver/src/connector.hpp index bc8d1ef5e..82f4c1e18 100644 --- a/cpp-driver/src/connector.hpp +++ b/cpp-driver/src/connector.hpp @@ -22,7 +22,7 @@ #ifndef __CASS_CONNECTION_CONNECTOR_HPP_INCLUDED__ #define __CASS_CONNECTION_CONNECTOR_HPP_INCLUDED__ -namespace cass { +namespace datastax { namespace internal { namespace core { class AuthResponseRequest; class Config; @@ -69,7 +69,7 @@ class Connector typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum ConnectionError { CONNECTION_OK, @@ -241,6 +241,6 @@ class Connector ConnectionSettings settings_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/control_connection.cpp b/cpp-driver/src/control_connection.cpp index f3f380d92..938179d39 100644 --- a/cpp-driver/src/control_connection.cpp +++ b/cpp-driver/src/control_connection.cpp @@ -35,7 +35,10 @@ #include #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A class for handling a single query on behalf of the control connection. @@ -325,6 +328,8 @@ class NopControlConnectionListener virtual void on_close(ControlConnection* connection) { } }; +} } } // namespace datastax::internal::core + static NopControlConnectionListener nop_listener__; ControlConnection::ControlConnection(const Connection::Ptr& connection, @@ -836,5 +841,3 @@ void ControlConnection::on_event(const EventResponse::Ptr& response) { break; } } - -} // namespace cass diff --git a/cpp-driver/src/control_connection.hpp b/cpp-driver/src/control_connection.hpp index 6ddbc335c..392daf92f 100644 --- a/cpp-driver/src/control_connection.hpp +++ b/cpp-driver/src/control_connection.hpp @@ -55,7 +55,7 @@ #define SELECT_VIRTUAL_TABLES_40 "SELECT * FROM system_virtual_schema.tables" #define SELECT_VIRTUAL_COLUMNS_40 "SELECT * FROM system_virtual_schema.columns" -namespace cass { +namespace datastax { namespace internal { namespace core { class ChainedControlRequestCallback; class ControlRequestCallback; @@ -296,6 +296,6 @@ class ControlConnection : public RefCounted ControlConnectionListener* listener_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/control_connector.cpp b/cpp-driver/src/control_connector.cpp index cba5e0a50..6f660af15 100644 --- a/cpp-driver/src/control_connector.cpp +++ b/cpp-driver/src/control_connector.cpp @@ -17,7 +17,10 @@ #include "control_connector.hpp" #include "result_iterator.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A chained request callback that gets the cluster's hosts from the @@ -80,6 +83,8 @@ class SchemaConnectorRequestCallback : public ChainedRequestCallback { ControlConnector* connector_; }; +} } } // namespace datastax::internal::core + ControlConnectionSettings::ControlConnectionSettings() : use_schema(CASS_DEFAULT_USE_SCHEMA) , token_aware_routing(CASS_DEFAULT_TOKEN_AWARE_ROUTING) { } @@ -347,5 +352,3 @@ void ControlConnector::on_close(Connection* connection) { "Control connection closed prematurely"); } } - -} // namespace cass diff --git a/cpp-driver/src/control_connector.hpp b/cpp-driver/src/control_connector.hpp index bcee23854..e86ed3672 100644 --- a/cpp-driver/src/control_connector.hpp +++ b/cpp-driver/src/control_connector.hpp @@ -22,7 +22,7 @@ #include "ref_counted.hpp" #include "event_response.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class HostsConnectorRequestCallback; class Metrics; @@ -89,7 +89,7 @@ class ControlConnector : public RefCounted public: typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum ControlConnectionError { CONTROL_CONNECTION_OK, @@ -262,6 +262,6 @@ class ControlConnector : public RefCounted ControlConnectionSettings settings_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/copy_on_write_ptr.hpp b/cpp-driver/src/copy_on_write_ptr.hpp index 0b33d6512..e4c7012ca 100644 --- a/cpp-driver/src/copy_on_write_ptr.hpp +++ b/cpp-driver/src/copy_on_write_ptr.hpp @@ -21,7 +21,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { template class CopyOnWritePtr { @@ -91,6 +91,6 @@ class CopyOnWritePtr { SharedRefPtr ptr_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/data_type.cpp b/cpp-driver/src/data_type.cpp index bd318ba2f..f32f6a2b9 100644 --- a/cpp-driver/src/data_type.cpp +++ b/cpp-driver/src/data_type.cpp @@ -25,26 +25,29 @@ #include +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassDataType* cass_data_type_new(CassValueType type) { - cass::DataType* data_type = NULL; + DataType* data_type = NULL; switch (type) { case CASS_VALUE_TYPE_LIST: case CASS_VALUE_TYPE_SET: case CASS_VALUE_TYPE_TUPLE: case CASS_VALUE_TYPE_MAP: - data_type = new cass::CollectionType(type, false); + data_type = new CollectionType(type, false); data_type->inc_ref(); break; case CASS_VALUE_TYPE_UDT: - data_type = new cass::UserType(false); + data_type = new UserType(false); data_type->inc_ref(); break; case CASS_VALUE_TYPE_CUSTOM: - data_type = new cass::CustomType(); + data_type = new CustomType(); data_type->inc_ref(); break; @@ -54,7 +57,7 @@ CassDataType* cass_data_type_new(CassValueType type) { default: if (type < CASS_VALUE_TYPE_LAST_ENTRY) { - data_type = new cass::DataType(type); + data_type = new DataType(type); data_type->inc_ref(); } break; @@ -63,36 +66,36 @@ CassDataType* cass_data_type_new(CassValueType type) { } CassDataType* cass_data_type_new_from_existing(const CassDataType* data_type) { - cass::DataType::Ptr copy = data_type->copy(); + DataType::Ptr copy = data_type->copy(); copy->inc_ref(); return CassDataType::to(copy.get()); } CassDataType* cass_data_type_new_tuple(size_t item_count) { - cass::DataType* data_type - = new cass::CollectionType(CASS_VALUE_TYPE_TUPLE, item_count); + DataType* data_type + = new CollectionType(CASS_VALUE_TYPE_TUPLE, item_count); data_type->inc_ref(); return CassDataType::to(data_type); } CassDataType* cass_data_type_new_udt(size_t field_count) { - cass::DataType* data_type = new cass::UserType(field_count); + DataType* data_type = new UserType(field_count); data_type->inc_ref(); return CassDataType::to(data_type); } const CassDataType* cass_data_type_sub_data_type(const CassDataType* data_type, size_t index) { - const cass::DataType* sub_type = NULL; + const DataType* sub_type = NULL; if (data_type->is_collection() || data_type->is_tuple()) { - const cass::CompositeType* composite_type - = static_cast(data_type->from()); + const CompositeType* composite_type + = static_cast(data_type->from()); if (index < composite_type->types().size()) { sub_type = composite_type->types()[index].get(); } } else if (data_type->is_user_type()) { - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); if (index < user_type->fields().size()) { sub_type = user_type->fields()[index].type.get(); } @@ -113,11 +116,11 @@ const CassDataType* cass_data_type_sub_data_type_by_name_n(const CassDataType* d return NULL; } - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); - cass::IndexVec indices; - if (user_type->get_indices(cass::StringRef(name, name_length), &indices) == 0) { + IndexVec indices; + if (user_type->get_indices(StringRef(name, name_length), &indices) == 0) { return NULL; } @@ -139,8 +142,8 @@ CassError cass_data_type_type_name(const CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); *name = user_type->type_name().data(); *name_length = user_type->type_name().size(); @@ -161,10 +164,10 @@ CassError cass_data_type_set_type_name_n(CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - cass::UserType* user_type - = static_cast(data_type->from()); + UserType* user_type + = static_cast(data_type->from()); - user_type->set_type_name(cass::String(type_name, type_name_length)); + user_type->set_type_name(String(type_name, type_name_length)); return CASS_OK; } @@ -176,8 +179,8 @@ CassError cass_data_type_keyspace(const CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); *keyspace = user_type->keyspace().data(); *keyspace_length = user_type->keyspace().size(); @@ -198,10 +201,10 @@ CassError cass_data_type_set_keyspace_n(CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - cass::UserType* user_type - = static_cast(data_type->from()); + UserType* user_type + = static_cast(data_type->from()); - user_type->set_keyspace(cass::String(keyspace, keyspace_length)); + user_type->set_keyspace(String(keyspace, keyspace_length)); return CASS_OK; } @@ -213,8 +216,8 @@ CassError cass_data_type_class_name(const CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - const cass::CustomType* custom_type - = static_cast(data_type->from()); + const CustomType* custom_type + = static_cast(data_type->from()); *class_name = custom_type->class_name().data(); *class_name_length = custom_type->class_name().size(); @@ -235,10 +238,10 @@ CassError cass_data_type_set_class_name_n(CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - cass::CustomType* custom_type - = static_cast(data_type->from()); + CustomType* custom_type + = static_cast(data_type->from()); - custom_type->set_class_name(cass::String(class_name, class_name_length)); + custom_type->set_class_name(String(class_name, class_name_length)); return CASS_OK; } @@ -249,12 +252,12 @@ size_t cass_data_sub_type_count(const CassDataType* data_type) { size_t cass_data_type_sub_type_count(const CassDataType* data_type) { if (data_type->is_collection() || data_type->is_tuple()) { - const cass::CompositeType* composite_type - = static_cast(data_type->from()); + const CompositeType* composite_type + = static_cast(data_type->from()); return composite_type->types().size(); } else if (data_type->is_user_type()) { - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); return user_type->fields().size(); } return 0; @@ -268,14 +271,14 @@ CassError cass_data_type_sub_type_name(const CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - const cass::UserType* user_type - = static_cast(data_type->from()); + const UserType* user_type + = static_cast(data_type->from()); if (index >= user_type->fields().size()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } - cass::StringRef field_name = user_type->fields()[index].name; + StringRef field_name = user_type->fields()[index].name; *name = field_name.data(); *name_length = field_name.size(); @@ -289,8 +292,8 @@ CassError cass_data_type_add_sub_type(CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - cass::CompositeType* composite_type - = static_cast(data_type->from()); + CompositeType* composite_type + = static_cast(data_type->from()); switch (composite_type->value_type()) { case CASS_VALUE_TYPE_LIST: @@ -298,18 +301,18 @@ CassError cass_data_type_add_sub_type(CassDataType* data_type, if (composite_type->types().size() >= 1) { return CASS_ERROR_LIB_BAD_PARAMS; } - composite_type->types().push_back(cass::DataType::ConstPtr(sub_data_type)); + composite_type->types().push_back(DataType::ConstPtr(sub_data_type)); break; case CASS_VALUE_TYPE_MAP: if (composite_type->types().size() >= 2) { return CASS_ERROR_LIB_BAD_PARAMS; } - composite_type->types().push_back(cass::DataType::ConstPtr(sub_data_type)); + composite_type->types().push_back(DataType::ConstPtr(sub_data_type)); break; case CASS_VALUE_TYPE_TUPLE: - composite_type->types().push_back(cass::DataType::ConstPtr(sub_data_type)); + composite_type->types().push_back(DataType::ConstPtr(sub_data_type)); break; default: @@ -336,11 +339,11 @@ CassError cass_data_type_add_sub_type_by_name_n(CassDataType* data_type, return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } - cass::UserType* user_type - = static_cast(data_type->from()); + UserType* user_type + = static_cast(data_type->from()); - user_type->add_field(cass::String(name, name_length), - cass::DataType::ConstPtr(sub_data_type)); + user_type->add_field(String(name, name_length), + DataType::ConstPtr(sub_data_type)); return CASS_OK; @@ -348,8 +351,8 @@ CassError cass_data_type_add_sub_type_by_name_n(CassDataType* data_type, CassError cass_data_type_add_sub_value_type(CassDataType* data_type, CassValueType sub_value_type) { - cass::DataType::ConstPtr sub_data_type( - new cass::DataType(sub_value_type)); + DataType::ConstPtr sub_data_type( + new DataType(sub_value_type)); return cass_data_type_add_sub_type(data_type, CassDataType::to(sub_data_type.get())); } @@ -358,8 +361,8 @@ CassError cass_data_type_add_sub_value_type(CassDataType* data_type, CassError cass_data_type_add_sub_value_type_by_name(CassDataType* data_type, const char* name, CassValueType sub_value_type) { - cass::DataType::ConstPtr sub_data_type( - new cass::DataType(sub_value_type)); + DataType::ConstPtr sub_data_type( + new DataType(sub_value_type)); return cass_data_type_add_sub_type_by_name(data_type, name, CassDataType::to(sub_data_type.get())); } @@ -368,8 +371,8 @@ CassError cass_data_type_add_sub_value_type_by_name_n(CassDataType* data_type, const char* name, size_t name_length, CassValueType sub_value_type) { - cass::DataType::ConstPtr sub_data_type( - new cass::DataType(sub_value_type)); + DataType::ConstPtr sub_data_type( + new DataType(sub_value_type)); return cass_data_type_add_sub_type_by_name_n(data_type, name, name_length, CassDataType::to(sub_data_type.get())); } @@ -380,8 +383,6 @@ void cass_data_type_free(CassDataType* data_type) { } // extern "C" -namespace cass { - const DataType::ConstPtr DataType::NIL; DataType::ConstPtr DataType::create_by_class(StringRef name) { @@ -452,19 +453,17 @@ const DataType::ConstPtr& SimpleDataTypeCache::by_value_type(uint16_t value_type return data_type; } -bool cass::IsValidDataType::operator()(const Collection* value, - const DataType::ConstPtr& data_type) const { +bool IsValidDataType::operator()(const Collection* value, + const DataType::ConstPtr& data_type) const { return value->data_type()->equals(data_type); } -bool cass::IsValidDataType::operator()(const Tuple* value, - const DataType::ConstPtr& data_type) const { +bool IsValidDataType::operator()(const Tuple* value, + const DataType::ConstPtr& data_type) const { return value->data_type()->equals(data_type); } -bool cass::IsValidDataType::operator()(const UserTypeValue* value, - const DataType::ConstPtr& data_type) const { +bool IsValidDataType::operator()(const UserTypeValue* value, + const DataType::ConstPtr& data_type) const { return value->data_type()->equals(data_type); } - -} // namespace cass diff --git a/cpp-driver/src/data_type.hpp b/cpp-driver/src/data_type.hpp index 6d008068e..d078919ea 100644 --- a/cpp-driver/src/data_type.hpp +++ b/cpp-driver/src/data_type.hpp @@ -28,7 +28,7 @@ #include "types.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Collection; class Tuple; @@ -324,7 +324,7 @@ class UserType : public DataType { public: typedef SharedRefPtr Ptr; typedef SharedRefPtr ConstPtr; - typedef cass::Map Map; + typedef internal::Map Map; struct Field : public HashTableEntry { Field(const String& field_name, @@ -601,8 +601,8 @@ struct IsValidDataType { bool operator()(const UserTypeValue* value, const DataType::ConstPtr& data_type) const; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::DataType, CassDataType) +EXTERNAL_TYPE(datastax::internal::core::DataType, CassDataType) #endif diff --git a/cpp-driver/src/data_type_parser.cpp b/cpp-driver/src/data_type_parser.cpp index dd3260f5b..7e55fc1d7 100644 --- a/cpp-driver/src/data_type_parser.cpp +++ b/cpp-driver/src/data_type_parser.cpp @@ -32,7 +32,8 @@ #define UDT_TYPE "org.apache.cassandra.db.marshal.UserType" #define TUPLE_TYPE "org.apache.cassandra.db.marshal.TupleType" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; int hex_value(int c) { if (c >= '0' && c <= '9') { @@ -641,5 +642,3 @@ void DataTypeClassNameParser::Parser::parse_error(const String& str, static_cast(index), error); } - -} // namespace cass diff --git a/cpp-driver/src/data_type_parser.hpp b/cpp-driver/src/data_type_parser.hpp index 9f71824d0..ae1b6fb76 100644 --- a/cpp-driver/src/data_type_parser.hpp +++ b/cpp-driver/src/data_type_parser.hpp @@ -28,7 +28,7 @@ #define EMPTY_TYPE "org.apache.cassandra.db.marshal.EmptyType" -namespace cass { +namespace datastax { namespace internal { namespace core { class ParserBase { public: @@ -180,6 +180,6 @@ class DataTypeClassNameParser { DataTypeClassNameParser(); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/dc_aware_policy.cpp b/cpp-driver/src/dc_aware_policy.cpp index 3a4a26024..a767317a7 100644 --- a/cpp-driver/src/dc_aware_policy.cpp +++ b/cpp-driver/src/dc_aware_policy.cpp @@ -22,7 +22,9 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; DCAwarePolicy::DCAwarePolicy(const String& local_dc, size_t used_hosts_per_remote_dc, @@ -171,7 +173,7 @@ void DCAwarePolicy::PerDCHostMap::remove_host_from_dc(const String& dc, const Ho ScopedWriteLock wl(&rwlock_); Map::iterator i = map_.find(dc); if (i != map_.end()) { - cass::remove_host(i->second, host); + core::remove_host(i->second, host); } } @@ -179,7 +181,7 @@ bool DCAwarePolicy::PerDCHostMap::remove_host(const Address& address) { ScopedWriteLock wl(&rwlock_); for (Map::iterator i = map_.begin(), end = map_.end(); i != end; ++i) { - if (cass::remove_host(i->second, address)) { + if (core::remove_host(i->second, address)) { return true; } } @@ -268,5 +270,3 @@ Host::Ptr DCAwarePolicy::DCAwareQueryPlan::compute_next() { return Host::Ptr(); } - -} // namespace cass diff --git a/cpp-driver/src/dc_aware_policy.hpp b/cpp-driver/src/dc_aware_policy.hpp index 4baf7a1eb..d8f4d973f 100644 --- a/cpp-driver/src/dc_aware_policy.hpp +++ b/cpp-driver/src/dc_aware_policy.hpp @@ -27,7 +27,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class DCAwarePolicy : public LoadBalancingPolicy { public: @@ -65,7 +65,7 @@ class DCAwarePolicy : public LoadBalancingPolicy { private: class PerDCHostMap { public: - typedef cass::Map Map; + typedef internal::Map Map; typedef Set KeySet; PerDCHostMap() : no_hosts_(new HostVec()) { @@ -126,6 +126,6 @@ class DCAwarePolicy : public LoadBalancingPolicy { DISALLOW_COPY_AND_ASSIGN(DCAwarePolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/decoder.cpp b/cpp-driver/src/decoder.cpp index ba2fc0d7d..b7a904769 100644 --- a/cpp-driver/src/decoder.cpp +++ b/cpp-driver/src/decoder.cpp @@ -25,7 +25,7 @@ } \ } while (0) -namespace cass { +using namespace datastax::internal::core; void Decoder::maybe_log_remaining() const { if (remaining_ > 0) { @@ -38,7 +38,7 @@ bool Decoder::decode_inet(Address* output) { CHECK_REMAINING(sizeof(uint8_t), "length of inet"); uint8_t address_length = 0; - input_ = cass::decode_byte(input_, address_length); + input_ = internal::decode_byte(input_, address_length); remaining_ -= sizeof(uint8_t); if (address_length > CASS_INET_V6_LENGTH) { LOG_ERROR("Invalid inet address length of %d bytes", address_length); @@ -53,7 +53,7 @@ bool Decoder::decode_inet(Address* output) { CHECK_REMAINING(sizeof(int32_t), "port"); int32_t port = 0; - input_ = cass::decode_int32(input_, port); + input_ = internal::decode_int32(input_, port); remaining_ -= sizeof(int32_t); return Address::from_inet(address, address_length, port, output); @@ -62,7 +62,7 @@ bool Decoder::decode_inet(Address* output) { bool Decoder::decode_inet(CassInet* output) { CHECK_REMAINING(sizeof(uint8_t), "length of inet"); - input_ = cass::decode_byte(input_, output->address_length); + input_ = internal::decode_byte(input_, output->address_length); remaining_ -= sizeof(uint8_t); if (output->address_length > CASS_INET_V6_LENGTH) { LOG_ERROR("Invalid inet address length of %d bytes", @@ -126,7 +126,7 @@ bool Decoder::decode_warnings(WarningVec& output) { return false; } uint16_t count = 0; - input_ = cass::decode_uint16(input_, count); + input_ = internal::decode_uint16(input_, count); remaining_ -= sizeof(uint16_t); for (uint16_t i = 0; i < count; ++i) { @@ -179,5 +179,3 @@ void Decoder::notify_error(const char* detail, size_t bytes) const { type_); } } - -} // namespace cass diff --git a/cpp-driver/src/decoder.hpp b/cpp-driver/src/decoder.hpp index 31ee20955..77b65f77e 100644 --- a/cpp-driver/src/decoder.hpp +++ b/cpp-driver/src/decoder.hpp @@ -30,7 +30,7 @@ } \ } while (0) -namespace cass { +namespace datastax { namespace internal { namespace core { typedef Map > StringMultimap; @@ -96,7 +96,7 @@ friend class Value; inline bool decode_byte(uint8_t& output) { CHECK_REMAINING(sizeof(uint8_t), "byte"); - input_ = cass::decode_byte(input_, output); + input_ = internal::decode_byte(input_, output); remaining_ -= sizeof(uint8_t); return true; } @@ -104,7 +104,7 @@ friend class Value; inline bool as_byte(uint8_t* output) const { CHECK_REMAINING(sizeof(uint8_t), "byte"); - cass::decode_byte(input_, *output); + internal::decode_byte(input_, *output); return true; } @@ -118,7 +118,7 @@ friend class Value; inline bool decode_int8(int8_t& output) { CHECK_REMAINING(sizeof(int8_t), "signed byte"); - input_ = cass::decode_int8(input_, output); + input_ = internal::decode_int8(input_, output); remaining_ -= sizeof(int8_t); return true; } @@ -126,14 +126,14 @@ friend class Value; inline bool as_int8(int8_t* output) const { CHECK_REMAINING(sizeof(int8_t), "signed byte"); - cass::decode_int8(input_, *output); + internal::decode_int8(input_, *output); return true; } inline bool decode_uint16(uint16_t& output) { CHECK_REMAINING(sizeof(uint16_t), "unsigned short"); - input_ = cass::decode_uint16(input_, output); + input_ = internal::decode_uint16(input_, output); remaining_ -= sizeof(uint16_t); return true; } @@ -141,7 +141,7 @@ friend class Value; inline bool decode_int16(int16_t& output) { CHECK_REMAINING(sizeof(int16_t), "short"); - input_ = cass::decode_int16(input_, output); + input_ = internal::decode_int16(input_, output); remaining_ -= sizeof(int16_t); return true; } @@ -149,14 +149,14 @@ friend class Value; inline bool as_int16(int16_t* output) const { CHECK_REMAINING(sizeof(int16_t), "short"); - cass::decode_int16(input_, *output); + internal::decode_int16(input_, *output); return true; } inline bool decode_uint32(uint32_t& output) { CHECK_REMAINING(sizeof(uint32_t), "unsigned int"); - input_ = cass::decode_uint32(input_, output); + input_ = internal::decode_uint32(input_, output); remaining_ -= sizeof(uint32_t); return true; } @@ -164,14 +164,14 @@ friend class Value; inline bool as_uint32(uint32_t* output) const { CHECK_REMAINING(sizeof(uint32_t), "unsigned int"); - cass::decode_uint32(input_, *output); + internal::decode_uint32(input_, *output); return true; } inline bool decode_int32(int32_t& output) { CHECK_REMAINING(sizeof(int32_t), "int"); - input_ = cass::decode_int32(input_, output); + input_ = internal::decode_int32(input_, output); remaining_ -= sizeof(int32_t); return true; } @@ -179,14 +179,14 @@ friend class Value; inline bool as_int32(int32_t* output) const { CHECK_REMAINING(sizeof(int32_t), "int"); - cass::decode_int32(input_, *output); + internal::decode_int32(input_, *output); return true; } inline bool decode_int64(int64_t& output) { CHECK_REMAINING(sizeof(int64_t), "long"); - input_ = cass::decode_int64(input_, output); + input_ = internal::decode_int64(input_, output); remaining_ -= sizeof(int64_t); return true; } @@ -194,14 +194,14 @@ friend class Value; inline bool as_int64(int64_t* output) const { CHECK_REMAINING(sizeof(int64_t), "long"); - cass::decode_int64(input_, *output); + internal::decode_int64(input_, *output); return true; } inline bool decode_float(float& output) { CHECK_REMAINING(sizeof(int32_t), "float"); - input_ = cass::decode_float(input_, output); + input_ = internal::decode_float(input_, output); remaining_ -= sizeof(int32_t); return true; } @@ -209,14 +209,14 @@ friend class Value; inline bool as_float(float* output) const { CHECK_REMAINING(sizeof(int32_t), "float"); - cass::decode_float(input_, *output); + internal::decode_float(input_, *output); return true; } inline bool decode_double(double& output) { CHECK_REMAINING(sizeof(int64_t), "double"); - input_ = cass::decode_double(input_, output); + input_ = internal::decode_double(input_, output); remaining_ -= sizeof(int64_t); return true; } @@ -224,7 +224,7 @@ friend class Value; inline bool as_double(double* output) const { CHECK_REMAINING(sizeof(int64_t), "double"); - cass::decode_double(input_, *output); + internal::decode_double(input_, *output); return true; } @@ -232,7 +232,7 @@ friend class Value; CHECK_REMAINING(sizeof(uint16_t), "length of string"); uint16_t string_size = 0; - input_ = cass::decode_uint16(input_, string_size); + input_ = internal::decode_uint16(input_, string_size); remaining_ -= sizeof(uint16_t); CHECK_REMAINING(string_size, "string"); @@ -256,7 +256,7 @@ friend class Value; CHECK_REMAINING(sizeof(int32_t), "length of long string"); int32_t string_size = 0; - input_ = cass::decode_int32(input_, string_size); + input_ = internal::decode_int32(input_, string_size); remaining_ -= sizeof(int32_t); CHECK_REMAINING(string_size, "string"); @@ -271,7 +271,7 @@ friend class Value; CHECK_REMAINING(sizeof(int32_t), "length of bytes"); int32_t bytes_size = 0; - input_ = cass::decode_int32(input_, bytes_size); + input_ = internal::decode_int32(input_, bytes_size); remaining_ -= sizeof(int32_t); if (bytes_size < 0) { @@ -312,7 +312,7 @@ friend class Value; CHECK_REMAINING(sizeof(uint16_t), "size of string map"); uint16_t pairs = 0; - input_ = cass::decode_uint16(input_, pairs); + input_ = internal::decode_uint16(input_, pairs); remaining_ -= sizeof(uint16_t); map.clear(); @@ -335,7 +335,7 @@ friend class Value; CHECK_REMAINING(sizeof(uint16_t), "count of stringlist"); uint16_t count = 0; - input_ = cass::decode_uint16(input_, count); + input_ = internal::decode_uint16(input_, count); remaining_ -= sizeof(uint16_t); output.clear(); @@ -355,7 +355,7 @@ friend class Value; CHECK_REMAINING(sizeof(uint16_t), "count of stringlist"); uint16_t count = 0; - input_ = cass::decode_uint16(input_, count); + input_ = internal::decode_uint16(input_, count); remaining_ -= sizeof(uint16_t); output.clear(); @@ -374,7 +374,7 @@ friend class Value; size_t total_read = sizeof(uint16_t); CHECK_REMAINING(total_read, "count of stringlist"); uint16_t count = 0; - const char* pos = cass::decode_uint16(input_, count); + const char* pos = internal::decode_uint16(input_, count); output.clear(); output.reserve(count); @@ -382,7 +382,7 @@ friend class Value; total_read += sizeof(uint16_t); CHECK_REMAINING(total_read, "length of string"); uint16_t string_size = 0; - pos = cass::decode_uint16(pos, string_size); + pos = internal::decode_uint16(pos, string_size); total_read += string_size; CHECK_REMAINING(total_read, "string"); @@ -397,7 +397,7 @@ friend class Value; CHECK_REMAINING(sizeof(uint16_t), "pair(s) of string multimap"); uint16_t pairs = 0; - input_ = cass::decode_uint16(input_, pairs); + input_ = internal::decode_uint16(input_, pairs); remaining_ -= sizeof(uint16_t); output.clear(); @@ -418,7 +418,7 @@ friend class Value; size_t& class_name_size) { CHECK_REMAINING(sizeof(uint16_t), "option type"); - input_ = cass::decode_uint16(input_, type); + input_ = internal::decode_uint16(input_, type); remaining_ -= sizeof(uint16_t); if (type == CASS_VALUE_TYPE_CUSTOM) { @@ -432,7 +432,7 @@ friend class Value; size_t bytes = sizeof(uint8_t) * 16; CHECK_REMAINING(bytes, "UUID"); - input_ = cass::decode_uuid(input_, output); + input_ = internal::decode_uuid(input_, output); remaining_ -= bytes; return true; } @@ -440,7 +440,7 @@ friend class Value; inline bool as_uuid(CassUuid* output) const { CHECK_REMAINING(sizeof(uint8_t) * 16, "UUID"); - cass::decode_uuid(input_, output); + internal::decode_uuid(input_, output); return true; } @@ -464,7 +464,7 @@ friend class Value; // We mask out high-order bits to prevent sign-extension as the value is placed in a 64-bit arg // to the num_leading_zeros function. - int extra_bytes = cass::num_leading_zeros(~first_byte & 0xff) - 56; + int extra_bytes = internal::num_leading_zeros(~first_byte & 0xff) - 56; CHECK_REMAINING(extra_bytes, "vint value"); // Build up the vint value one byte at a time from the data bytes. @@ -486,7 +486,7 @@ friend class Value; int32_t* scale) { CHECK_REMAINING(sizeof(int32_t), "decimal scale"); - const char* pos = cass::decode_int32(input_, *scale); + const char* pos = internal::decode_int32(input_, *scale); if (remaining_ - sizeof(int32_t) <= 0) { notify_error("decimal value", remaining_ - sizeof(int32_t)); @@ -503,13 +503,13 @@ friend class Value; uint64_t decoded = 0; if (!decoder.decode_vint(decoded)) return false; - *out_months = static_cast(cass::decode_zig_zag(decoded)); + *out_months = static_cast(internal::decode_zig_zag(decoded)); if (!decoder.decode_vint(decoded)) return false; - *out_days = static_cast(cass::decode_zig_zag(decoded)); + *out_days = static_cast(internal::decode_zig_zag(decoded)); if (!decoder.decode_vint(decoded)) return false; - *out_nanos = static_cast(cass::decode_zig_zag(decoded)); + *out_nanos = static_cast(internal::decode_zig_zag(decoded)); return true; } @@ -520,7 +520,7 @@ friend class Value; return false; } uint16_t count = 0; - input_ = cass::decode_uint16(input_, count); + input_ = internal::decode_uint16(input_, count); remaining_ -= sizeof(uint16_t); for (uint16_t i = 0; i < count; ++i) { @@ -540,7 +540,7 @@ friend class Value; notify_error("count of failures", sizeof(int32_t)); return false; } - input_ = cass::decode_int32(input_, output_size); + input_ = internal::decode_int32(input_, output_size); remaining_ -= sizeof(int32_t); // Format: @@ -583,7 +583,7 @@ friend class Value; void notify_error(const char* detail, size_t bytes) const; }; -} // namespace cass +} } } // namespace datastax::internal::core #undef CHECK_REMAINING diff --git a/cpp-driver/src/delayed_connector.cpp b/cpp-driver/src/delayed_connector.cpp index bb12ed675..2267f8c88 100644 --- a/cpp-driver/src/delayed_connector.cpp +++ b/cpp-driver/src/delayed_connector.cpp @@ -18,7 +18,8 @@ #include "event_loop.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; DelayedConnector::DelayedConnector(const Host::Ptr& host, ProtocolVersion protocol_version, @@ -111,5 +112,3 @@ void DelayedConnector::on_connect(Connector* connector) { void DelayedConnector::on_delayed_connect(Timer* timer) { internal_connect(timer->loop()); } - -} // namespace cass diff --git a/cpp-driver/src/delayed_connector.hpp b/cpp-driver/src/delayed_connector.hpp index aa441d3fc..df2df4983 100644 --- a/cpp-driver/src/delayed_connector.hpp +++ b/cpp-driver/src/delayed_connector.hpp @@ -24,7 +24,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ConnectionPool; class EventLoop; @@ -37,7 +37,7 @@ class DelayedConnector : public RefCounted { typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; /** * Constructor @@ -128,6 +128,6 @@ class DelayedConnector : public RefCounted { bool is_canceled_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/dense_hash_map.hpp b/cpp-driver/src/dense_hash_map.hpp index be28641ae..a48ba3937 100644 --- a/cpp-driver/src/dense_hash_map.hpp +++ b/cpp-driver/src/dense_hash_map.hpp @@ -12,7 +12,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template , @@ -20,9 +20,9 @@ template > > { + internal::Allocator > > { public: - typedef cass::Allocator > Allocator; + typedef internal::Allocator > Allocator; explicit DenseHashMap(size_t expected_max_items_in_table = 0, const HashFcn& hf = HashFcn(), @@ -44,6 +44,6 @@ class DenseHashMap hf, eql, alloc) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/dense_hash_set.hpp b/cpp-driver/src/dense_hash_set.hpp index 1a8612ba3..5fcda7080 100644 --- a/cpp-driver/src/dense_hash_set.hpp +++ b/cpp-driver/src/dense_hash_set.hpp @@ -12,7 +12,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template , @@ -20,9 +20,9 @@ template > { + internal::Allocator > { public: - typedef cass::Allocator Allocator; + typedef internal::Allocator Allocator; explicit DenseHashSet(size_t expected_max_items_in_table = 0, const HashFcn& hf = HashFcn(), @@ -44,6 +44,6 @@ class DenseHashSet hf, eql, alloc) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/deque.hpp b/cpp-driver/src/deque.hpp index a12542a9e..1fcc8953c 100644 --- a/cpp-driver/src/deque.hpp +++ b/cpp-driver/src/deque.hpp @@ -12,12 +12,12 @@ #include -namespace cass { +namespace datastax { namespace internal { template -class Deque : public std::deque > { +class Deque : public std::deque > { public: - typedef cass::Allocator Allocator; + typedef internal::Allocator Allocator; explicit Deque(const Allocator& alloc = Allocator()) : std::deque(alloc) { } @@ -36,6 +36,6 @@ class Deque : public std::deque > { : std::deque(other) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/driver_info.cpp b/cpp-driver/src/driver_info.cpp index 18094e81c..318e7a069 100644 --- a/cpp-driver/src/driver_info.cpp +++ b/cpp-driver/src/driver_info.cpp @@ -26,7 +26,7 @@ STRINGIFY(CASS_VERSION_MINOR) "." \ STRINGIFY(CASS_VERSION_PATCH) -namespace cass { +namespace datastax { namespace internal { const char* driver_name() { return "DataStax Apache Cassandra C/C++ Driver"; @@ -40,4 +40,4 @@ const char* driver_version() { } } -} // namespace cass +} } // namespace datastax::internal diff --git a/cpp-driver/src/driver_info.hpp b/cpp-driver/src/driver_info.hpp index c4f365ac1..00ab7bc7d 100644 --- a/cpp-driver/src/driver_info.hpp +++ b/cpp-driver/src/driver_info.hpp @@ -17,11 +17,11 @@ #ifndef __CASS_DRIVER_INFO_HPP_INCLUDED__ #define __CASS_DRIVER_INFO_HPP_INCLUDED__ -namespace cass { +namespace datastax { namespace internal { const char* driver_name(); const char* driver_version(); -} // namespace cass +} } // namespace datastax::internal #endif // __CASS_DRIVER_INFO_HPP_INCLUDED__ diff --git a/cpp-driver/src/encode.cpp b/cpp-driver/src/encode.cpp index 586a43206..1b11bb725 100644 --- a/cpp-driver/src/encode.cpp +++ b/cpp-driver/src/encode.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" #include "utils.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { static char* encode_vint(char* output, uint64_t value, size_t value_size) { if (value_size == 1) { @@ -50,14 +50,14 @@ static Buffer encode_internal(CassDuration value, bool with_length) { // We need vint sizes for each attribute. size_t vint_sizes[3]; - zigzag_values[0] = cass::encode_zig_zag(value.months); - zigzag_values[1] = cass::encode_zig_zag(value.days); - zigzag_values[2] = cass::encode_zig_zag(value.nanos); + zigzag_values[0] = encode_zig_zag(value.months); + zigzag_values[1] = encode_zig_zag(value.days); + zigzag_values[2] = encode_zig_zag(value.nanos); // We also need the total size of all three vint's. size_t data_size = 0; for (int i = 0; i < 3; ++i) { - vint_sizes[i] = cass::vint_size(zigzag_values[i]); + vint_sizes[i] = vint_size(zigzag_values[i]); data_size += vint_sizes[i]; } @@ -86,4 +86,4 @@ Buffer encode_with_length(CassDuration value) { return encode_internal(value, true); } -} // namespace cass +} } } // namespace datastax::internal::core diff --git a/cpp-driver/src/encode.hpp b/cpp-driver/src/encode.hpp index f01ecd8de..6644194df 100644 --- a/cpp-driver/src/encode.hpp +++ b/cpp-driver/src/encode.hpp @@ -20,7 +20,7 @@ #include "buffer.hpp" #include "types.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { inline Buffer encode_with_length(CassNull) { Buffer buf(sizeof(int32_t)); @@ -222,7 +222,6 @@ Buffer encode(CassDuration value); Buffer encode_with_length(CassDuration value); -} // namespace cass +} } } // namespace datastax::internal::core #endif - diff --git a/cpp-driver/src/error_response.cpp b/cpp-driver/src/error_response.cpp index a7f3958e4..553769a8a 100644 --- a/cpp-driver/src/error_response.cpp +++ b/cpp-driver/src/error_response.cpp @@ -22,6 +22,10 @@ #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { void cass_error_result_free(const CassErrorResult* error_result) { @@ -105,7 +109,7 @@ CassError cass_error_result_arg_type(const CassErrorResult* error_result, if (index > error_result->arg_types().size()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } - cass::StringRef arg_type_ref = error_result->arg_types()[index]; + StringRef arg_type_ref = error_result->arg_types()[index]; *arg_type = arg_type_ref.data(); *arg_type_length = arg_type_ref.size(); return CASS_OK; @@ -113,8 +117,6 @@ CassError cass_error_result_arg_type(const CassErrorResult* error_result, } // extern "C" -namespace cass { - String ErrorResponse::error_message() const { OStringStream ss; ss << "'" << message().to_string() << "'" @@ -197,5 +199,3 @@ bool check_error_or_invalid_response(const String& prefix, uint8_t expected_opco return true; } - -} // namespace cass diff --git a/cpp-driver/src/error_response.hpp b/cpp-driver/src/error_response.hpp index 4d28a15fa..c02f439df 100644 --- a/cpp-driver/src/error_response.hpp +++ b/cpp-driver/src/error_response.hpp @@ -30,7 +30,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class ErrorResponse : public Response { public: @@ -87,8 +87,8 @@ class ErrorResponse : public Response { bool check_error_or_invalid_response(const String& prefix, uint8_t expected_opcode, const Response* response); -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::ErrorResponse, CassErrorResult) +EXTERNAL_TYPE(datastax::internal::core::ErrorResponse, CassErrorResult) #endif diff --git a/cpp-driver/src/event_loop.cpp b/cpp-driver/src/event_loop.cpp index 51ddfa4c0..70eb3ac06 100644 --- a/cpp-driver/src/event_loop.cpp +++ b/cpp-driver/src/event_loop.cpp @@ -21,7 +21,8 @@ #include #endif -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; #if defined(HAVE_SIGTIMEDWAIT) && !defined(HAVE_NOSIGPIPE) static int block_sigpipe() { @@ -243,5 +244,3 @@ EventLoop* RoundRobinEventLoopGroup::add(Task* task) { event_loop->add(task); return event_loop; } - -} // namespace cass diff --git a/cpp-driver/src/event_loop.hpp b/cpp-driver/src/event_loop.hpp index 81633687c..77f85d5c9 100644 --- a/cpp-driver/src/event_loop.hpp +++ b/cpp-driver/src/event_loop.hpp @@ -32,7 +32,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class EventLoop; @@ -229,6 +229,6 @@ class RoundRobinEventLoopGroup : public EventLoopGroup { size_t num_threads_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/event_response.cpp b/cpp-driver/src/event_response.cpp index c11d608a9..5313668a1 100644 --- a/cpp-driver/src/event_response.cpp +++ b/cpp-driver/src/event_response.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; bool EventResponse::decode(Decoder& decoder) { decoder.set_type("event"); @@ -106,5 +106,3 @@ bool EventResponse::decode(Decoder& decoder) { decoder.maybe_log_remaining(); return true; } - -} // namespace cass diff --git a/cpp-driver/src/event_response.hpp b/cpp-driver/src/event_response.hpp index facc314a8..218cb9aa1 100644 --- a/cpp-driver/src/event_response.hpp +++ b/cpp-driver/src/event_response.hpp @@ -24,7 +24,7 @@ #include "string_ref.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class EventResponse : public Response { public: @@ -90,6 +90,6 @@ class EventResponse : public Response { StringRefVec arg_types_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/execute_request.cpp b/cpp-driver/src/execute_request.cpp index b148ed897..ce8dc940b 100644 --- a/cpp-driver/src/execute_request.cpp +++ b/cpp-driver/src/execute_request.cpp @@ -20,7 +20,7 @@ #include "protocol.hpp" #include "request_callback.hpp" -namespace cass { +using namespace datastax::internal::core; ExecuteRequest::ExecuteRequest(const Prepared* prepared) : Statement(prepared) @@ -46,5 +46,3 @@ int ExecuteRequest::encode(ProtocolVersion version, RequestCallback* callback, B length += encode_end(version, callback, bufs); return length; } - -} // namespace cass diff --git a/cpp-driver/src/execute_request.hpp b/cpp-driver/src/execute_request.hpp index 52fa21b5c..7f9be105b 100644 --- a/cpp-driver/src/execute_request.hpp +++ b/cpp-driver/src/execute_request.hpp @@ -24,7 +24,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ExecuteRequest : public Statement { public: @@ -51,6 +51,6 @@ class ExecuteRequest : public Statement { Prepared::ConstPtr prepared_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/execution_profile.cpp b/cpp-driver/src/execution_profile.cpp index e17bdebf1..b978353a2 100644 --- a/cpp-driver/src/execution_profile.cpp +++ b/cpp-driver/src/execution_profile.cpp @@ -7,11 +7,14 @@ #include "execution_profile.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassExecProfile* cass_execution_profile_new() { - cass::ExecutionProfile* profile = - new cass::ExecutionProfile(); + ExecutionProfile* profile = + new ExecutionProfile(); return CassExecProfile::to(profile); } @@ -39,7 +42,7 @@ CassError cass_execution_profile_set_serial_consistency(CassExecProfile* profile CassError cass_execution_profile_set_load_balance_round_robin(CassExecProfile* profile) { profile->set_load_balancing_policy( - new cass::RoundRobinPolicy()); + new RoundRobinPolicy()); return CASS_OK; } @@ -66,9 +69,9 @@ CassError cass_execution_profile_set_load_balance_dc_aware_n(CassExecProfile* pr return CASS_ERROR_LIB_BAD_PARAMS; } profile->set_load_balancing_policy( - new cass::DCAwarePolicy(cass::String(local_dc, local_dc_length), - used_hosts_per_remote_dc, - !allow_remote_dcs_for_local_cl)); + new DCAwarePolicy(String(local_dc, local_dc_length), + used_hosts_per_remote_dc, + !allow_remote_dcs_for_local_cl)); return CASS_OK; } @@ -96,7 +99,7 @@ CassError cass_execution_profile_set_latency_aware_routing_settings(CassExecProf cass_uint64_t retry_period_ms, cass_uint64_t update_rate_ms, cass_uint64_t min_measured) { - cass::LatencyAwarePolicy::Settings settings; + LatencyAwarePolicy::Settings settings; settings.exclusion_threshold = exclusion_threshold; settings.scale_ns = scale_ms * 1000 * 1000; settings.retry_period_ns = retry_period_ms * 1000 * 1000; @@ -120,8 +123,8 @@ CassError cass_execution_profile_set_whitelist_filtering_n(CassExecProfile* prof if (hosts_length == 0) { profile->whitelist().clear(); } else { - cass::explode(cass::String(hosts, hosts_length), - profile->whitelist()); + explode(String(hosts, hosts_length), + profile->whitelist()); } return CASS_OK; } @@ -139,8 +142,8 @@ CassError cass_execution_profile_set_blacklist_filtering_n(CassExecProfile* prof if (hosts_length == 0) { profile->blacklist().clear(); } else { - cass::explode(cass::String(hosts, hosts_length), - profile->blacklist()); + explode(String(hosts, hosts_length), + profile->blacklist()); } return CASS_OK; } @@ -158,8 +161,8 @@ CassError cass_execution_profile_set_whitelist_dc_filtering_n(CassExecProfile* p if (dcs_length == 0) { profile->whitelist_dc().clear(); } else { - cass::explode(cass::String(dcs, dcs_length), - profile->whitelist_dc()); + explode(String(dcs, dcs_length), + profile->whitelist_dc()); } return CASS_OK; } @@ -177,8 +180,8 @@ CassError cass_execution_profile_set_blacklist_dc_filtering_n(CassExecProfile* p if (dcs_length == 0) { profile->blacklist_dc().clear(); } else { - cass::explode(cass::String(dcs, dcs_length), - profile->blacklist_dc()); + explode(String(dcs, dcs_length), + profile->blacklist_dc()); } return CASS_OK; } @@ -196,13 +199,13 @@ CassError cass_execution_profile_set_constant_speculative_execution_policy(CassE return CASS_ERROR_LIB_BAD_PARAMS; } profile->set_speculative_execution_policy( - new cass::ConstantSpeculativeExecutionPolicy(constant_delay_ms, - max_speculative_executions)); + new ConstantSpeculativeExecutionPolicy(constant_delay_ms, + max_speculative_executions)); return CASS_OK; } CassError cass_execution_profile_set_no_speculative_execution_policy(CassExecProfile* profile) { - profile->set_speculative_execution_policy(new cass::NoSpeculativeExecutionPolicy()); + profile->set_speculative_execution_policy(new NoSpeculativeExecutionPolicy()); return CASS_OK; } diff --git a/cpp-driver/src/execution_profile.hpp b/cpp-driver/src/execution_profile.hpp index 1382fddf5..532c861a2 100644 --- a/cpp-driver/src/execution_profile.hpp +++ b/cpp-driver/src/execution_profile.hpp @@ -23,7 +23,7 @@ #include "whitelist_policy.hpp" #include "whitelist_dc_policy.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ExecutionProfile : public Allocated { public: @@ -197,8 +197,8 @@ class ExecutionProfile : public Allocated { SpeculativeExecutionPolicy::Ptr speculative_execution_policy_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::ExecutionProfile, CassExecProfile) +EXTERNAL_TYPE(datastax::internal::core::ExecutionProfile, CassExecProfile) #endif // __CASS_EXECUTION_PROFILE_HPP_INCLUDED__ diff --git a/cpp-driver/src/fixed_allocator.hpp b/cpp-driver/src/fixed_allocator.hpp index fc6bdba5a..be93ad731 100644 --- a/cpp-driver/src/fixed_allocator.hpp +++ b/cpp-driver/src/fixed_allocator.hpp @@ -24,7 +24,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { // This is an allocator that starts using a fixed size buffer that only // uses the heap when exceeded. The allocator can be @@ -111,6 +111,6 @@ class FixedAllocator { Fixed* fixed_; }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/fixnl.sh b/cpp-driver/src/fixnl.sh new file mode 100755 index 000000000..9791c1b9e --- /dev/null +++ b/cpp-driver/src/fixnl.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +function fixnl() { + echo "Fixing $1..." + awk '/^$/ {nlstack=nlstack "\n";next;} {printf "%s",nlstack; nlstack=""; print;}' $1 > $1.tmp && mv $1.tmp $1 +} + +shopt -s globstar + +for file in **/*.cpp; do fixnl "$file"; done +for file in **/*.hpp; do fixnl "$file"; done diff --git a/cpp-driver/src/future.cpp b/cpp-driver/src/future.cpp index 6ee0b3f4b..4912292d2 100644 --- a/cpp-driver/src/future.cpp +++ b/cpp-driver/src/future.cpp @@ -22,6 +22,10 @@ #include "result_response.hpp" #include "scoped_ptr.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { void cass_future_free(CassFuture* future) { @@ -52,58 +56,58 @@ cass_bool_t cass_future_wait_timed(CassFuture* future, cass_duration_t wait_us) } const CassResult* cass_future_get_result(CassFuture* future) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return NULL; } - cass::Response::Ptr response( - static_cast(future->from())->response()); + Response::Ptr response( + static_cast(future->from())->response()); if (!response || response->opcode() == CQL_OPCODE_ERROR) { return NULL; } response->inc_ref(); return CassResult::to( - static_cast(response.get())); + static_cast(response.get())); } const CassPrepared* cass_future_get_prepared(CassFuture* future) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return NULL; } - cass::ResponseFuture* response_future = - static_cast(future->from()); + ResponseFuture* response_future = + static_cast(future->from()); - cass::SharedRefPtr result(response_future->response()); + SharedRefPtr result(response_future->response()); if (!result || result->kind() != CASS_RESULT_KIND_PREPARED) { return NULL; } - cass::Prepared* prepared = new cass::Prepared(result, - response_future->prepare_request, - *response_future->schema_metadata); + Prepared* prepared = new Prepared(result, + response_future->prepare_request, + *response_future->schema_metadata); prepared->inc_ref(); return CassPrepared::to(prepared); } const CassErrorResult* cass_future_get_error_result(CassFuture* future) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return NULL; } - cass::Response::Ptr response( - static_cast(future->from())->response()); + Response::Ptr response( + static_cast(future->from())->response()); if (!response || response->opcode() != CQL_OPCODE_ERROR) { return NULL; } response->inc_ref(); return CassErrorResult::to( - static_cast(response.get())); + static_cast(response.get())); } CassError cass_future_error_code(CassFuture* future) { - const cass::Future::Error* error = future->error(); + const Future::Error* error = future->error(); if (error != NULL) { return error->code; } else { @@ -114,9 +118,9 @@ CassError cass_future_error_code(CassFuture* future) { void cass_future_error_message(CassFuture* future, const char** message, size_t* message_length) { - const cass::Future::Error* error = future->error(); + const Future::Error* error = future->error(); if (error != NULL) { - const cass::String& m = error->message; + const String& m = error->message; *message = m.data(); *message_length = m.length(); } else { @@ -126,12 +130,12 @@ void cass_future_error_message(CassFuture* future, } CassError cass_future_tracing_id(CassFuture* future, CassUuid* tracing_id) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return CASS_ERROR_LIB_INVALID_FUTURE_TYPE; } - cass::Response::Ptr response( - static_cast(future->from())->response()); + Response::Ptr response( + static_cast(future->from())->response()); if (!response || !response->has_tracing_id()) { return CASS_ERROR_LIB_NO_TRACING_ID; } @@ -142,11 +146,11 @@ CassError cass_future_tracing_id(CassFuture* future, CassUuid* tracing_id) { } size_t cass_future_custom_payload_item_count(CassFuture* future) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return 0; } - cass::Response::Ptr response( - static_cast(future->from())->response()); + Response::Ptr response( + static_cast(future->from())->response()); if (!response) return 0; return response->custom_payload().size(); } @@ -157,20 +161,20 @@ CassError cass_future_custom_payload_item(CassFuture* future, size_t* name_length, const cass_byte_t** value, size_t* value_size) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return CASS_ERROR_LIB_INVALID_FUTURE_TYPE; } - cass::Response::Ptr response( - static_cast(future->from())->response()); + Response::Ptr response( + static_cast(future->from())->response()); if (!response) return CASS_ERROR_LIB_NO_CUSTOM_PAYLOAD; - const cass::CustomPayloadVec& custom_payload = + const CustomPayloadVec& custom_payload = response->custom_payload(); if (index >= custom_payload.size()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } - const cass::CustomPayloadItem& item = custom_payload[index]; + const CustomPayloadItem& item = custom_payload[index]; *name = item.name.data(); *name_length = item.name.size(); *value = reinterpret_cast(item.value.data()); @@ -180,8 +184,6 @@ CassError cass_future_custom_payload_item(CassFuture* future, } // extern "C" -namespace cass { - bool Future::set_callback(Future::Callback callback, void* data) { ScopedMutex lock(&mutex_); if (callback_) { @@ -210,7 +212,3 @@ void Future::internal_set(ScopedMutex& lock) { // on this future see the side effects of the callback. uv_cond_broadcast(&cond_); } - -} // namespace cass - - diff --git a/cpp-driver/src/future.hpp b/cpp-driver/src/future.hpp index e4567d636..d8a1e32d9 100644 --- a/cpp-driver/src/future.hpp +++ b/cpp-driver/src/future.hpp @@ -30,7 +30,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { struct Error; @@ -145,8 +145,8 @@ class Future : public RefCounted { DISALLOW_COPY_AND_ASSIGN(Future); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Future, CassFuture) +EXTERNAL_TYPE(datastax::internal::core::Future, CassFuture) #endif diff --git a/cpp-driver/src/get_time-mac.cpp b/cpp-driver/src/get_time-mac.cpp index f6712e0db..9672cb5e0 100644 --- a/cpp-driver/src/get_time-mac.cpp +++ b/cpp-driver/src/get_time-mac.cpp @@ -22,7 +22,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { // Information on converting the absolute time to nanoseconds can be found // here: https://developer.apple.com/library/content/qa/qa1398/_index.html. @@ -57,7 +57,6 @@ uint64_t get_time_monotonic_ns() { return time * ClockInfo::frequency(); } -} // namespace cass +} } // namespace datastax::internal #endif // defined(__APPLE__) && defined(__MACH__) - diff --git a/cpp-driver/src/get_time-unix.cpp b/cpp-driver/src/get_time-unix.cpp index 8b456ba64..129ed7647 100644 --- a/cpp-driver/src/get_time-unix.cpp +++ b/cpp-driver/src/get_time-unix.cpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { class ClockInfo { public: @@ -44,7 +44,6 @@ bool ClockInfo::supports_monotonic_; static ClockInfo __clock_info__; // Initializer - uint64_t get_time_since_epoch_us() { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); @@ -63,7 +62,6 @@ uint64_t get_time_monotonic_ns() { } } -} // namespace cass +} } // namespace datastax::internal #endif - diff --git a/cpp-driver/src/get_time-win.cpp b/cpp-driver/src/get_time-win.cpp index 8d1e7e59f..17462d025 100644 --- a/cpp-driver/src/get_time-win.cpp +++ b/cpp-driver/src/get_time-win.cpp @@ -25,7 +25,7 @@ #include "get_time.hpp" -namespace cass { +namespace datastax { namespace internal { // Information for using the query performance counter can be found here: // https://msdn.microsoft.com/en-us/library/dn553408(v=vs.85).aspx @@ -69,7 +69,6 @@ uint64_t get_time_monotonic_ns() { } } -} // namespace cass +} } // namespace datastax::internal #endif // defined(_WIN32) - diff --git a/cpp-driver/src/get_time.hpp b/cpp-driver/src/get_time.hpp index 9c12c4ab8..0c8ed4098 100644 --- a/cpp-driver/src/get_time.hpp +++ b/cpp-driver/src/get_time.hpp @@ -25,7 +25,7 @@ #define MICROSECONDS_PER_MILLISECOND 1000LL -namespace cass { +namespace datastax { namespace internal { uint64_t get_time_since_epoch_us(); @@ -38,6 +38,6 @@ inline uint64_t get_time_since_epoch_ms() { // `get_time_since_epoch_us()` will be used. uint64_t get_time_monotonic_ns(); -} +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/hash.hpp b/cpp-driver/src/hash.hpp index 03a646413..f58db20ce 100644 --- a/cpp-driver/src/hash.hpp +++ b/cpp-driver/src/hash.hpp @@ -20,7 +20,7 @@ #include #include -namespace cass { namespace hash { +namespace datastax { namespace hash { typedef int (Op)(int); @@ -52,7 +52,7 @@ inline uint32_t fnv1a(const char* data, size_t length, Op op = nop) { } #endif -} } // namespace cass::hash +} } // namespace datastax::hash #endif diff --git a/cpp-driver/src/hash_table.hpp b/cpp-driver/src/hash_table.hpp index 2cc202411..961e25682 100644 --- a/cpp-driver/src/hash_table.hpp +++ b/cpp-driver/src/hash_table.hpp @@ -30,7 +30,7 @@ // additional memory. #define CASS_LOAD_FACTOR 0.75 -namespace cass { +namespace datastax { namespace internal { namespace core { typedef SmallVector IndexVec; @@ -40,7 +40,7 @@ struct HashTableEntry { : index(0) , next(NULL) { } - // Requires a "name" String or cass::StringRef field + // Requires a "name" String or datastax::StringRef field size_t index; T* next; }; @@ -217,6 +217,6 @@ void CaseInsensitiveHashTable::reindex() { } } -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/histogram_wrapper.hpp b/cpp-driver/src/histogram_wrapper.hpp index 93f687f95..25dee9008 100644 --- a/cpp-driver/src/histogram_wrapper.hpp +++ b/cpp-driver/src/histogram_wrapper.hpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class HistogramWrapper { public: @@ -74,7 +74,7 @@ class HistogramWrapper { String name_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif // CASS_INTERNAL_DIAGNOSTICS diff --git a/cpp-driver/src/host.cpp b/cpp-driver/src/host.cpp index f484112d5..d1700e423 100644 --- a/cpp-driver/src/host.cpp +++ b/cpp-driver/src/host.cpp @@ -20,7 +20,10 @@ #include "value.hpp" #include "collection_iterator.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { void add_host(CopyOnWriteHostVec& hosts, const Host::Ptr& host) { HostVec::iterator i; @@ -50,6 +53,8 @@ bool remove_host(CopyOnWriteHostVec& hosts, const Address& address) { return false; } +} } } // namespace datastax::internal::core + void Host::LatencyTracker::update(uint64_t latency_ns) { uint64_t now = uv_hrtime(); @@ -165,5 +170,3 @@ void ExternalHostListener::on_host_removed(const Host::Ptr& host) { address.address_length = host->address().to_inet(address.address); callback_(CASS_HOST_LISTENER_EVENT_REMOVE, address, data_); } - -} // namespace cass diff --git a/cpp-driver/src/host.hpp b/cpp-driver/src/host.hpp index 3adce5468..68d93a1d0 100644 --- a/cpp-driver/src/host.hpp +++ b/cpp-driver/src/host.hpp @@ -33,7 +33,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Row; @@ -325,6 +325,6 @@ void add_host(CopyOnWriteHostVec& hosts, const Host::Ptr& host); void remove_host(CopyOnWriteHostVec& hosts, const Host::Ptr& host); bool remove_host(CopyOnWriteHostVec& hosts, const Address& address); -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/host_targeting_policy.cpp b/cpp-driver/src/host_targeting_policy.cpp index c9a0ee17b..24102677a 100644 --- a/cpp-driver/src/host_targeting_policy.cpp +++ b/cpp-driver/src/host_targeting_policy.cpp @@ -16,12 +16,14 @@ #include "host_targeting_policy.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; void HostTargetingPolicy::init(const SharedRefPtr& connected_host, - const cass::HostMap& hosts, + const core::HostMap& hosts, Random* random) { - for (cass::HostMap::const_iterator it = hosts.begin(), + for (core::HostMap::const_iterator it = hosts.begin(), end = hosts.end(); it != end; ++it) { hosts_[it->first] = it->second; } @@ -69,5 +71,3 @@ SharedRefPtr HostTargetingPolicy::HostTargetingQueryPlan::compute_next() { return next; } } - -} // namespace cass diff --git a/cpp-driver/src/host_targeting_policy.hpp b/cpp-driver/src/host_targeting_policy.hpp index 2130f5a2d..2fecd4dfd 100644 --- a/cpp-driver/src/host_targeting_policy.hpp +++ b/cpp-driver/src/host_targeting_policy.hpp @@ -22,7 +22,7 @@ #include "load_balancing.hpp" #include "request_handler.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class HostTargetingPolicy : public ChainedLoadBalancingPolicy { public: @@ -30,7 +30,7 @@ class HostTargetingPolicy : public ChainedLoadBalancingPolicy { : ChainedLoadBalancingPolicy(child_policy) { } virtual void init(const SharedRefPtr& connected_host, - const cass::HostMap& hosts, Random* random); + const HostMap& hosts, Random* random); virtual QueryPlan* new_query_plan(const String& keyspace, RequestHandler* request_handler, @@ -70,6 +70,6 @@ class HostTargetingPolicy : public ChainedLoadBalancingPolicy { HostMap hosts_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/iterator.cpp b/cpp-driver/src/iterator.cpp index 5ccfcbb5c..9ca025b8d 100644 --- a/cpp-driver/src/iterator.cpp +++ b/cpp-driver/src/iterator.cpp @@ -23,6 +23,9 @@ #include "row_iterator.hpp" #include "user_type_field_iterator.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { void cass_iterator_free(CassIterator* iterator) { @@ -38,39 +41,39 @@ CassIteratorType cass_iterator_type(CassIterator* iterator) { } CassIterator* cass_iterator_from_result(const CassResult* result) { - return CassIterator::to(new cass::ResultIterator(result)); + return CassIterator::to(new ResultIterator(result)); } CassIterator* cass_iterator_from_row(const CassRow* row) { - return CassIterator::to(new cass::RowIterator(row)); + return CassIterator::to(new RowIterator(row)); } CassIterator* cass_iterator_from_collection(const CassValue* value) { if (value->is_null() || !value->is_collection()) { return NULL; } - return CassIterator::to(new cass::CollectionIterator(value)); + return CassIterator::to(new CollectionIterator(value)); } CassIterator* cass_iterator_from_tuple(const CassValue* value) { if (value->is_null() || !value->is_tuple()) { return NULL; } - return CassIterator::to(new cass::TupleIterator(value)); + return CassIterator::to(new TupleIterator(value)); } CassIterator* cass_iterator_from_map(const CassValue* value) { if (value->is_null() || !value->is_map()) { return NULL; } - return CassIterator::to(new cass::MapIterator(value)); + return CassIterator::to(new MapIterator(value)); } CassIterator* cass_iterator_fields_from_user_type(const CassValue* value) { if (value->is_null() || !value->is_user_type()) { return NULL; } - return CassIterator::to(new cass::UserTypeFieldIterator(value)); + return CassIterator::to(new UserTypeFieldIterator(value)); } CassError cass_iterator_get_user_type_field_name(const CassIterator* iterator, @@ -79,8 +82,8 @@ CassError cass_iterator_get_user_type_field_name(const CassIterator* iterator, if (iterator->type() != CASS_ITERATOR_TYPE_USER_TYPE_FIELD) { return CASS_ERROR_LIB_BAD_PARAMS; } - cass::StringRef field_name - = static_cast( + StringRef field_name + = static_cast( iterator->from())->field_name(); *name = field_name.data(); *name_length = field_name.size(); @@ -92,7 +95,7 @@ const CassValue* cass_iterator_get_user_type_field_value(const CassIterator* ite return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->field_value()); } @@ -101,7 +104,7 @@ const CassRow* cass_iterator_get_row(const CassIterator* iterator) { return NULL; } return CassRow::to( - static_cast( + static_cast( iterator->from())->row()); } @@ -110,7 +113,7 @@ const CassValue* cass_iterator_get_column(const CassIterator* iterator) { return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->column()); } @@ -120,7 +123,7 @@ const CassValue* cass_iterator_get_value(const CassIterator* iterator) { return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->value()); } @@ -129,7 +132,7 @@ const CassValue* cass_iterator_get_map_key(const CassIterator* iterator) { return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->key()); } @@ -138,7 +141,7 @@ const CassValue* cass_iterator_get_map_value(const CassIterator* iterator) { return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->value()); } diff --git a/cpp-driver/src/iterator.hpp b/cpp-driver/src/iterator.hpp index f46731702..4e69f3d65 100644 --- a/cpp-driver/src/iterator.hpp +++ b/cpp-driver/src/iterator.hpp @@ -21,7 +21,7 @@ #include "cassandra.h" #include "external.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Iterator : public Allocated { public: @@ -38,8 +38,8 @@ class Iterator : public Allocated { const CassIteratorType type_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Iterator, CassIterator) +EXTERNAL_TYPE(datastax::internal::core::Iterator, CassIterator) #endif diff --git a/cpp-driver/src/json.hpp b/cpp-driver/src/json.hpp index 67dbd252e..89d1214f1 100644 --- a/cpp-driver/src/json.hpp +++ b/cpp-driver/src/json.hpp @@ -19,8 +19,7 @@ #include "memory.hpp" -namespace cass { -namespace json { +namespace datastax { namespace internal { namespace json { template static T* new_() { @@ -37,13 +36,13 @@ static void delete_(T* ptr) { Memory::free(ptr); } -} } // namespace cass::json +} } } // namespace datastax::internal::json -#define RAPIDJSON_NAMESPACE cass::rapidjson -#define RAPIDJSON_NAMESPACE_BEGIN namespace cass { namespace rapidjson { +#define RAPIDJSON_NAMESPACE datastax::rapidjson +#define RAPIDJSON_NAMESPACE_BEGIN namespace datastax { namespace rapidjson { #define RAPIDJSON_NAMESPACE_END } } -#define RAPIDJSON_NEW(x) cass::json::new_ -#define RAPIDJSON_DELETE(x) cass::json::delete_(x) +#define RAPIDJSON_NEW(x) ::datastax::internal::json::new_ +#define RAPIDJSON_DELETE(x) ::datastax::internal::json::delete_(x) #include "third_party/rapidjson/rapidjson/document.h" #include "third_party/rapidjson/rapidjson/stringbuffer.h" @@ -55,8 +54,7 @@ static void delete_(T* ptr) { # define JSON_WRITE_TYPE PrettyWriter #endif -namespace cass { -namespace json { +namespace datastax { namespace internal { namespace json { class Allocator { public: @@ -73,14 +71,14 @@ class Allocator { } }; -typedef cass::rapidjson::GenericDocument, cass::rapidjson::MemoryPoolAllocator, json::Allocator> Document; -typedef cass::rapidjson::GenericValue, cass::rapidjson::MemoryPoolAllocator > Value; -typedef cass::rapidjson::GenericStringBuffer, json::Allocator> StringBuffer; +typedef datastax::rapidjson::GenericDocument, datastax::rapidjson::MemoryPoolAllocator, json::Allocator> Document; +typedef datastax::rapidjson::GenericValue, datastax::rapidjson::MemoryPoolAllocator > Value; +typedef datastax::rapidjson::GenericStringBuffer, json::Allocator> StringBuffer; -template, typename TargetEncoding = cass::rapidjson::UTF8<>, typename StackAllocator = json::Allocator, unsigned writeFlags = cass::rapidjson::kWriteDefaultFlags> -class Writer : public cass::rapidjson::JSON_WRITE_TYPE { +template, typename TargetEncoding = datastax::rapidjson::UTF8<>, typename StackAllocator = json::Allocator, unsigned writeFlags = datastax::rapidjson::kWriteDefaultFlags> +class Writer : public datastax::rapidjson::JSON_WRITE_TYPE { public: - typedef cass::rapidjson::JSON_WRITE_TYPE Type; + typedef datastax::rapidjson::JSON_WRITE_TYPE Type; explicit Writer(OutputStream& os, StackAllocator* stackAllocator = 0, size_t levelDepth = Type::kDefaultLevelDepth) : Type(os, stackAllocator, levelDepth) { } @@ -89,6 +87,6 @@ class Writer : public cass::rapidjson::JSON_WRITE_TYPE #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; void LatencyAwarePolicy::init(const Host::Ptr& connected_host, const HostMap& hosts, @@ -122,5 +124,3 @@ Host::Ptr LatencyAwarePolicy::LatencyAwareQueryPlan::compute_next() { return Host::Ptr(); } - -} // namespace cass diff --git a/cpp-driver/src/latency_aware_policy.hpp b/cpp-driver/src/latency_aware_policy.hpp index 39e5474e3..1999b520c 100644 --- a/cpp-driver/src/latency_aware_policy.hpp +++ b/cpp-driver/src/latency_aware_policy.hpp @@ -23,7 +23,7 @@ #include "scoped_ptr.hpp" #include "timer.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class LatencyAwarePolicy : public ChainedLoadBalancingPolicy { public: @@ -104,6 +104,6 @@ class LatencyAwarePolicy : public ChainedLoadBalancingPolicy { DISALLOW_COPY_AND_ASSIGN(LatencyAwarePolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/list.hpp b/cpp-driver/src/list.hpp index 77c1b8481..065ab7dea 100644 --- a/cpp-driver/src/list.hpp +++ b/cpp-driver/src/list.hpp @@ -21,7 +21,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template class List { @@ -139,6 +139,6 @@ void List::insert_before(Node* pos, Node* node) { pos->prev_ = node; } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/list_policy.cpp b/cpp-driver/src/list_policy.cpp index d86efa07a..153e24731 100644 --- a/cpp-driver/src/list_policy.cpp +++ b/cpp-driver/src/list_policy.cpp @@ -18,7 +18,9 @@ #include "logger.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; void ListPolicy::init(const Host::Ptr& connected_host, const HostMap& hosts, @@ -65,5 +67,3 @@ void ListPolicy::on_host_removed(const Host::Ptr& host) { child_policy_->on_host_removed(host); } } - -} // namespace cass diff --git a/cpp-driver/src/list_policy.hpp b/cpp-driver/src/list_policy.hpp index 637d52093..2dd99a8dd 100644 --- a/cpp-driver/src/list_policy.hpp +++ b/cpp-driver/src/list_policy.hpp @@ -21,7 +21,7 @@ #include "host.hpp" #include "scoped_ptr.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ListPolicy : public ChainedLoadBalancingPolicy { public: @@ -48,7 +48,6 @@ class ListPolicy : public ChainedLoadBalancingPolicy { }; -} // namespace cass +} } } // namespace datastax::internal::core #endif - diff --git a/cpp-driver/src/load_balancing.hpp b/cpp-driver/src/load_balancing.hpp index db7c8085d..458ced298 100644 --- a/cpp-driver/src/load_balancing.hpp +++ b/cpp-driver/src/load_balancing.hpp @@ -48,9 +48,12 @@ typedef enum CassHostDistance_ { } // extern "C" -namespace cass { +namespace datastax { namespace internal { class Random; + +namespace core { + class RequestHandler; class TokenMap; @@ -147,7 +150,6 @@ class ChainedLoadBalancingPolicy : public LoadBalancingPolicy { LoadBalancingPolicy::Ptr child_policy_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif - diff --git a/cpp-driver/src/logger.cpp b/cpp-driver/src/logger.cpp index 7f7cdda49..bda55c04e 100644 --- a/cpp-driver/src/logger.cpp +++ b/cpp-driver/src/logger.cpp @@ -16,6 +16,8 @@ #include "logger.hpp" +using namespace datastax::internal; + extern "C" { void cass_log_cleanup() { @@ -23,12 +25,12 @@ void cass_log_cleanup() { } void cass_log_set_level(CassLogLevel log_level) { - cass::Logger::set_log_level(log_level); + Logger::set_log_level(log_level); } void cass_log_set_callback(CassLogCallback callback, void* data) { - cass::Logger::set_callback(callback, data); + Logger::set_callback(callback, data); } void cass_log_set_queue_size(size_t queue_size) { @@ -37,7 +39,7 @@ void cass_log_set_queue_size(size_t queue_size) { } // extern "C" -namespace cass { +namespace datastax { namespace internal { namespace core { void stderr_log_callback(const CassLogMessage* message, void* data) { fprintf(stderr, "%u.%03u [%s] (%s:%d:%s): %s\n", @@ -48,10 +50,12 @@ void stderr_log_callback(const CassLogMessage* message, void* data) { message->message); } +} } } // namespace datastax::internal::core + void noop_log_callback(const CassLogMessage* message, void* data) { } CassLogLevel Logger::log_level_ = CASS_LOG_WARN; -CassLogCallback Logger::cb_ = stderr_log_callback; +CassLogCallback Logger::cb_ = core::stderr_log_callback; void* Logger::data_ = NULL; void Logger::internal_log(CassLogLevel severity, @@ -74,5 +78,3 @@ void Logger::set_callback(CassLogCallback cb, void* data) { cb_ = cb == NULL ? noop_log_callback : cb; data_ = data; } - -} // namespace cass diff --git a/cpp-driver/src/logger.hpp b/cpp-driver/src/logger.hpp index 0f55a0638..80d825c73 100644 --- a/cpp-driver/src/logger.hpp +++ b/cpp-driver/src/logger.hpp @@ -24,7 +24,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { class Logger { public: @@ -63,7 +63,7 @@ class Logger { Logger(); // Keep this object from being created }; -} // namespace cass +} } // namespace datastax::internal // These macros allow the LOG_() methods to accept one or more // arguments (including the format string). This needs to be extended @@ -103,8 +103,8 @@ class Logger { #endif #define LOG_CHECK_LEVEL(severity, ...) do { \ - if (severity <= cass::Logger::log_level()) { \ - cass::Logger::log(severity, \ + if (severity <= ::datastax::internal::Logger::log_level()) { \ + ::datastax::internal::Logger::log(severity, \ LOG_FILE_, __LINE__, LOG_FUNCTION_, \ LOG_FIRST_(__VA_ARGS__) LOG_REST_(__VA_ARGS__)); \ } \ diff --git a/cpp-driver/src/loop_watcher.hpp b/cpp-driver/src/loop_watcher.hpp index 16c1242bf..f0a1108a2 100644 --- a/cpp-driver/src/loop_watcher.hpp +++ b/cpp-driver/src/loop_watcher.hpp @@ -23,12 +23,12 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { template class LoopWatcher { public: - typedef cass::Callback Callback; + typedef internal::Callback Callback; typedef HType HandleType; LoopWatcher() @@ -165,6 +165,6 @@ class Check : public LoopWatcher { } }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/map.hpp b/cpp-driver/src/map.hpp index 1bc285c4a..20624d3aa 100644 --- a/cpp-driver/src/map.hpp +++ b/cpp-driver/src/map.hpp @@ -13,14 +13,14 @@ #include -namespace cass { +namespace datastax { namespace internal { template > class Map : public Allocated, - public std::map > > { + public std::map > > { public: - typedef cass::Allocator > Allocator; + typedef internal::Allocator > Allocator; explicit Map(const Compare& compare = Compare(), const Allocator& alloc = Allocator()) @@ -36,6 +36,6 @@ class Map : : std::map(first, last, compare, alloc) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/map_iterator.cpp b/cpp-driver/src/map_iterator.cpp index 9ec497e39..1b1b25973 100644 --- a/cpp-driver/src/map_iterator.cpp +++ b/cpp-driver/src/map_iterator.cpp @@ -16,7 +16,7 @@ #include "map_iterator.hpp" -namespace cass { +using namespace datastax::internal::core; bool MapIterator::decode_pair() { if (!decoder_.decode_value(map_->primary_data_type(), key_, true)) return false; @@ -30,5 +30,3 @@ bool MapIterator::next() { ++index_; return decode_pair(); } - -} // namespace cass diff --git a/cpp-driver/src/map_iterator.hpp b/cpp-driver/src/map_iterator.hpp index 91d96f7cf..67210f4ea 100644 --- a/cpp-driver/src/map_iterator.hpp +++ b/cpp-driver/src/map_iterator.hpp @@ -22,7 +22,7 @@ #include "serialization.hpp" #include "value.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class MapIterator : public Iterator { public: @@ -57,6 +57,6 @@ class MapIterator : public Iterator { const int32_t count_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/md5.cpp b/cpp-driver/src/md5.cpp index 62761bd0a..043104903 100644 --- a/cpp-driver/src/md5.cpp +++ b/cpp-driver/src/md5.cpp @@ -61,7 +61,7 @@ (block_[(n)]) #endif -namespace cass { +using namespace datastax::internal; Md5::Md5() : lo_(0), hi_(0) @@ -257,5 +257,3 @@ const uint8_t* Md5::body(const uint8_t* data, size_t size) return ptr; } - -} // namespace cass diff --git a/cpp-driver/src/md5.hpp b/cpp-driver/src/md5.hpp index c7e985304..47642d726 100644 --- a/cpp-driver/src/md5.hpp +++ b/cpp-driver/src/md5.hpp @@ -25,7 +25,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { class Md5 { public: @@ -50,6 +50,6 @@ class Md5 { }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/memory.cpp b/cpp-driver/src/memory.cpp index 4595fcf3f..aafd6d71d 100644 --- a/cpp-driver/src/memory.cpp +++ b/cpp-driver/src/memory.cpp @@ -13,12 +13,14 @@ #include +using namespace datastax::internal; + extern "C" { void cass_alloc_set_functions(CassMallocFunction malloc_func, CassReallocFunction realloc_func, CassFreeFunction free_func) { - cass::Memory::set_functions(malloc_func, realloc_func, free_func); + Memory::set_functions(malloc_func, realloc_func, free_func); } } // extern "C" @@ -45,8 +47,6 @@ void operator delete[](void* ptr) throw() { } #endif -namespace cass { - CassMallocFunction Memory::malloc_func_ = NULL; CassReallocFunction Memory::realloc_func_ = NULL; CassFreeFunction Memory::free_func_ = NULL; @@ -79,6 +79,3 @@ void Memory::set_functions(CassMallocFunction malloc_func, uv_replace_allocator(Memory::malloc_func_, Memory::realloc_func_, calloc_, Memory::free_func_); #endif } - -} // namespace cass - diff --git a/cpp-driver/src/memory.hpp b/cpp-driver/src/memory.hpp index 5f3bc6caa..588235474 100644 --- a/cpp-driver/src/memory.hpp +++ b/cpp-driver/src/memory.hpp @@ -11,7 +11,7 @@ #include "cassandra.h" #include -namespace cass { +namespace datastax { namespace internal { class Memory { public: @@ -50,6 +50,6 @@ class Memory { static CassFreeFunction free_func_; }; -} // namespace cass +}} // namespace datastax::internal #endif diff --git a/cpp-driver/src/metadata.cpp b/cpp-driver/src/metadata.cpp index b8c95d672..40ea228f8 100644 --- a/cpp-driver/src/metadata.cpp +++ b/cpp-driver/src/metadata.cpp @@ -38,13 +38,17 @@ #include #include -static cass::String& append_arguments(cass::String& full_name, - const cass::String& arguments) { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + +static String& append_arguments(String& full_name, + const String& arguments) { full_name.push_back('('); bool first = true; - cass::IStringStream stream(arguments); + IStringStream stream(arguments); while (!stream.eof()) { - cass::String argument; + String argument; std::getline(stream, argument, ','); // Remove white-space argument.erase(std::remove_if(argument.begin(), argument.end(), ::isspace), @@ -85,7 +89,7 @@ const CassKeyspaceMeta* cass_schema_meta_keyspace_by_name(const CassSchemaMeta* const CassKeyspaceMeta* cass_schema_meta_keyspace_by_name_n(const CassSchemaMeta* schema_meta, const char* keyspace, size_t keyspace_length) { - return CassKeyspaceMeta::to(schema_meta->get_keyspace(cass::String(keyspace, keyspace_length))); + return CassKeyspaceMeta::to(schema_meta->get_keyspace(String(keyspace, keyspace_length))); } void cass_keyspace_meta_name(const CassKeyspaceMeta* keyspace_meta, @@ -107,7 +111,7 @@ const CassTableMeta* cass_keyspace_meta_table_by_name_n(const CassKeyspaceMeta* const char* table, size_t table_length) { - return CassTableMeta::to(keyspace_meta->get_table(cass::String(table, table_length))); + return CassTableMeta::to(keyspace_meta->get_table(String(table, table_length))); } const CassMaterializedViewMeta* cass_keyspace_meta_materialized_view_by_name(const CassKeyspaceMeta* keyspace_meta, @@ -119,7 +123,7 @@ const CassMaterializedViewMeta* cass_keyspace_meta_materialized_view_by_name_n(c const char* view, size_t view_length) { - return CassMaterializedViewMeta::to(keyspace_meta->get_view(cass::String(view, view_length))); + return CassMaterializedViewMeta::to(keyspace_meta->get_view(String(view, view_length))); } const CassDataType* cass_keyspace_meta_user_type_by_name(const CassKeyspaceMeta* keyspace_meta, @@ -130,7 +134,7 @@ const CassDataType* cass_keyspace_meta_user_type_by_name(const CassKeyspaceMeta* const CassDataType* cass_keyspace_meta_user_type_by_name_n(const CassKeyspaceMeta* keyspace_meta, const char* type, size_t type_length) { - return CassDataType::to(keyspace_meta->get_user_type(cass::String(type, type_length))); + return CassDataType::to(keyspace_meta->get_user_type(String(type, type_length))); } const CassFunctionMeta* cass_keyspace_meta_function_by_name(const CassKeyspaceMeta* keyspace_meta, @@ -147,9 +151,9 @@ const CassFunctionMeta* cass_keyspace_meta_function_by_name_n(const CassKeyspace size_t name_length, const char* arguments, size_t arguments_length) { - cass::String full_function_name(name, name_length); + String full_function_name(name, name_length); return CassFunctionMeta::to(keyspace_meta->get_function( - append_arguments(full_function_name, cass::String(arguments, arguments_length)))); + append_arguments(full_function_name, String(arguments, arguments_length)))); } const CassAggregateMeta* cass_keyspace_meta_aggregate_by_name(const CassKeyspaceMeta* keyspace_meta, @@ -165,9 +169,9 @@ const CassAggregateMeta* cass_keyspace_meta_aggregate_by_name_n(const CassKeyspa size_t name_length, const char* arguments, size_t arguments_length) { - cass::String full_aggregate_name(name, name_length); + String full_aggregate_name(name, name_length); return CassAggregateMeta::to(keyspace_meta->get_aggregate( - append_arguments(full_aggregate_name, cass::String(arguments, arguments_length)))); + append_arguments(full_aggregate_name, String(arguments, arguments_length)))); } const CassValue* cass_keyspace_meta_field_by_name(const CassKeyspaceMeta* keyspace_meta, @@ -177,7 +181,7 @@ const CassValue* cass_keyspace_meta_field_by_name(const CassKeyspaceMeta* keyspa const CassValue* cass_keyspace_meta_field_by_name_n(const CassKeyspaceMeta* keyspace_meta, const char* name, size_t name_length) { - return CassValue::to(keyspace_meta->get_field(cass::String(name, name_length))); + return CassValue::to(keyspace_meta->get_field(String(name, name_length))); } void cass_table_meta_name(const CassTableMeta* table_meta, @@ -198,7 +202,7 @@ const CassColumnMeta* cass_table_meta_column_by_name(const CassTableMeta* table_ const CassColumnMeta* cass_table_meta_column_by_name_n(const CassTableMeta* table_meta, const char* column, size_t column_length) { - return CassColumnMeta::to(table_meta->get_column(cass::String(column, column_length))); + return CassColumnMeta::to(table_meta->get_column(String(column, column_length))); } size_t cass_table_meta_column_count(const CassTableMeta* table_meta) { @@ -221,7 +225,7 @@ const CassIndexMeta* cass_table_meta_index_by_name(const CassTableMeta* table_me const CassIndexMeta* cass_table_meta_index_by_name_n(const CassTableMeta* table_meta, const char* index, size_t index_length) { - return CassIndexMeta::to(table_meta->get_index(cass::String(index, index_length))); + return CassIndexMeta::to(table_meta->get_index(String(index, index_length))); } size_t cass_table_meta_index_count(const CassTableMeta* table_meta) { @@ -244,7 +248,7 @@ const CassMaterializedViewMeta* cass_table_meta_materialized_view_by_name(const const CassMaterializedViewMeta* cass_table_meta_materialized_view_by_name_n(const CassTableMeta* table_meta, const char* view, size_t view_length) { - return CassMaterializedViewMeta::to(table_meta->get_view(cass::String(view, view_length))); + return CassMaterializedViewMeta::to(table_meta->get_view(String(view, view_length))); } size_t cass_table_meta_materialized_view_count(const CassTableMeta* table_meta) { @@ -298,7 +302,7 @@ const CassValue* cass_table_meta_field_by_name(const CassTableMeta* table_meta, const CassValue* cass_table_meta_field_by_name_n(const CassTableMeta* table_meta, const char* name, size_t name_length) { - return CassValue::to(table_meta->get_field(cass::String(name, name_length))); + return CassValue::to(table_meta->get_field(String(name, name_length))); } const CassColumnMeta* cass_materialized_view_meta_column_by_name(const CassMaterializedViewMeta* view_meta, @@ -309,7 +313,7 @@ const CassColumnMeta* cass_materialized_view_meta_column_by_name(const CassMater const CassColumnMeta* cass_materialized_view_meta_column_by_name_n(const CassMaterializedViewMeta* view_meta, const char* column, size_t column_length) { - return CassColumnMeta::to(view_meta->get_column(cass::String(column, column_length))); + return CassColumnMeta::to(view_meta->get_column(String(column, column_length))); } void cass_materialized_view_meta_name(const CassMaterializedViewMeta* view_meta, @@ -332,7 +336,7 @@ const CassValue* cass_materialized_view_meta_field_by_name(const CassMaterialize const CassValue* cass_materialized_view_meta_field_by_name_n(const CassMaterializedViewMeta* view_meta, const char* name, size_t name_length) { - return CassValue::to(view_meta->get_field(cass::String(name, name_length))); + return CassValue::to(view_meta->get_field(String(name, name_length))); } size_t cass_materialized_view_meta_column_count(const CassMaterializedViewMeta* view_meta) { @@ -402,7 +406,7 @@ cass_column_meta_field_by_name(const CassColumnMeta* column_meta, const CassValue* cass_column_meta_field_by_name_n(const CassColumnMeta* column_meta, const char* name, size_t name_length) { - return CassValue::to(column_meta->get_field(cass::String(name, name_length))); + return CassValue::to(column_meta->get_field(String(name, name_length))); } void cass_index_meta_name(const CassIndexMeta* index_meta, @@ -434,7 +438,7 @@ cass_index_meta_field_by_name(const CassIndexMeta* index_meta, const CassValue* cass_index_meta_field_by_name_n(const CassIndexMeta* index_meta, const char* name, size_t name_length) { - return CassValue::to(index_meta->get_field(cass::String(name, name_length))); + return CassValue::to(index_meta->get_field(String(name, name_length))); } void cass_function_meta_name(const CassFunctionMeta* function_meta, @@ -481,7 +485,7 @@ CassError cass_function_meta_argument(const CassFunctionMeta* function_meta, if (index >= function_meta->args().size()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } - const cass::FunctionMetadata::Argument& arg = function_meta->args()[index]; + const FunctionMetadata::Argument& arg = function_meta->args()[index]; *name = arg.name.data(); *name_length = arg.name.size(); *type = CassDataType::to(arg.type.get()); @@ -496,7 +500,7 @@ const CassDataType* cass_function_meta_argument_type_by_name(const CassFunctionM const CassDataType* cass_function_meta_argument_type_by_name_n(const CassFunctionMeta* function_meta, const char* name, size_t name_length) { - return CassDataType::to(function_meta->get_arg_type(cass::StringRef(name, name_length))); + return CassDataType::to(function_meta->get_arg_type(StringRef(name, name_length))); } const CassDataType* cass_function_meta_return_type(const CassFunctionMeta* function_meta) { @@ -511,7 +515,7 @@ const CassValue* cass_function_meta_field_by_name(const CassFunctionMeta* functi const CassValue* cass_function_meta_field_by_name_n(const CassFunctionMeta* function_meta, const char* name, size_t name_length) { - return CassValue::to(function_meta->get_field(cass::String(name, name_length))); + return CassValue::to(function_meta->get_field(String(name, name_length))); } void cass_aggregate_meta_name(const CassAggregateMeta* aggregate_meta, @@ -568,7 +572,7 @@ const CassValue* cass_aggregate_meta_field_by_name(const CassAggregateMeta* aggr const CassValue* cass_aggregate_meta_field_by_name_n(const CassAggregateMeta* aggregate_meta, const char* name, size_t name_length) { - return CassValue::to(aggregate_meta->get_field(cass::String(name, name_length))); + return CassValue::to(aggregate_meta->get_field(String(name, name_length))); } CassIterator* cass_iterator_keyspaces_from_schema_meta(const CassSchemaMeta* schema_meta) { @@ -644,7 +648,7 @@ const CassKeyspaceMeta* cass_iterator_get_keyspace_meta(const CassIterator* iter return NULL; } return CassKeyspaceMeta::to( - static_cast( + static_cast( iterator->from())->keyspace()); } @@ -653,7 +657,7 @@ const CassTableMeta* cass_iterator_get_table_meta(const CassIterator* iterator) return NULL; } return CassTableMeta::to( - static_cast( + static_cast( iterator->from())->table()); } @@ -662,7 +666,7 @@ const CassMaterializedViewMeta* cass_iterator_get_materialized_view_meta(const C return NULL; } return CassMaterializedViewMeta::to( - static_cast( + static_cast( iterator->from())->view()); } @@ -671,7 +675,7 @@ const CassDataType* cass_iterator_get_user_type(const CassIterator* iterator) { return NULL; } return CassDataType::to( - static_cast( + static_cast( iterator->from())->type()); } @@ -680,7 +684,7 @@ const CassFunctionMeta* cass_iterator_get_function_meta(const CassIterator* iter return NULL; } return CassFunctionMeta::to( - static_cast( + static_cast( iterator->from())->function()); } @@ -689,7 +693,7 @@ const CassAggregateMeta* cass_iterator_get_aggregate_meta(const CassIterator* it return NULL; } return CassAggregateMeta::to( - static_cast( + static_cast( iterator->from())->aggregate()); } @@ -698,7 +702,7 @@ const CassColumnMeta* cass_iterator_get_column_meta(const CassIterator* iterator return NULL; } return CassColumnMeta::to( - static_cast( + static_cast( iterator->from())->column()); } @@ -707,7 +711,7 @@ const CassIndexMeta* cass_iterator_get_index_meta(const CassIterator* iterator) return NULL; } return CassIndexMeta::to( - static_cast( + static_cast( iterator->from())->index()); } @@ -717,8 +721,8 @@ CassError cass_iterator_get_meta_field_name(const CassIterator* iterator, if (iterator->type() != CASS_ITERATOR_TYPE_META_FIELD) { return CASS_ERROR_LIB_BAD_PARAMS; } - const cass::MetadataField* field = - static_cast(iterator->from())->field(); + const MetadataField* field = + static_cast(iterator->from())->field(); *name = field->name().data(); *name_length = field->name().size(); return CASS_OK; @@ -729,19 +733,17 @@ const CassValue* cass_iterator_get_meta_field_value(const CassIterator* iterator return NULL; } return CassValue::to( - static_cast( + static_cast( iterator->from())->field()->value()); } } // extern "C" -namespace cass { - -static const char* table_column_name(const cass::VersionNumber& server_version) { +static const char* table_column_name(const VersionNumber& server_version) { return server_version >= VersionNumber(3, 0, 0) ? "table_name" : "columnfamily_name"; } -static const char* signature_column_name(const cass::VersionNumber& server_version) { +static const char* signature_column_name(const VersionNumber& server_version) { return server_version >= VersionNumber(3, 0, 0) ? "argument_types" : "signature"; } @@ -1021,7 +1023,7 @@ void MetadataBase::add_json_list_field(const Row* row, const String& name) { Collection collection(CollectionType::list(DataType::Ptr(new DataType(CASS_VALUE_TYPE_TEXT)), false), d.Size()); for (json::Value::ConstValueIterator i = d.Begin(); i != d.End(); ++i) { - collection.append(cass::CassString(i->GetString(), i->GetStringLength())); + collection.append(CassString(i->GetString(), i->GetStringLength())); } size_t encoded_size = collection.get_items_size(); @@ -2071,8 +2073,8 @@ void Metadata::InternalData::update_user_types(const VersionNumber& server_versi break; } - const cass::Value* name = names.value(); - const cass::Value* type = types.value(); + const Value* name = names.value(); + const Value* type = types.value(); if (name->is_null() || type->is_null()) { LOG_ERROR("'field_name' or 'field_type' is null for keyspace \"%s\" and type \"%s\"", @@ -2365,6 +2367,3 @@ KeyspaceMetadata* Metadata::InternalData::get_or_create_keyspace(const String& n } return &i->second; } - -} // namespace cass - diff --git a/cpp-driver/src/metadata.hpp b/cpp-driver/src/metadata.hpp index 518a24c7f..5d093fbbf 100644 --- a/cpp-driver/src/metadata.hpp +++ b/cpp-driver/src/metadata.hpp @@ -34,7 +34,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class ColumnMetadata; class TableMetadata; @@ -46,7 +46,7 @@ template class MapIteratorImpl { public: typedef T ItemType; - typedef cass::Map Collection; + typedef internal::Map Collection; MapIteratorImpl(const Collection& map) : next_(map.begin()) @@ -100,7 +100,7 @@ class VecIteratorImpl { class MetadataField { public: - typedef cass::Map Map; + typedef internal::Map Map; MetadataField() { } @@ -188,7 +188,7 @@ class MetadataIteratorImpl : public Iterator { class FunctionMetadata : public MetadataBase, public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; struct Argument { @@ -231,7 +231,7 @@ inline bool operator==(const FunctionMetadata::Argument& a, StringRef b) { class AggregateMetadata : public MetadataBase, public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; AggregateMetadata(const VersionNumber& server_version, SimpleDataTypeCache& cache, @@ -260,7 +260,7 @@ class AggregateMetadata : public MetadataBase, public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; CassIndexType type() const { return type_; } @@ -297,7 +297,7 @@ class IndexMetadata : public MetadataBase, public RefCounted { class ColumnMetadata : public MetadataBase, public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; ColumnMetadata(const String& name) @@ -394,7 +394,7 @@ class TableMetadataBase : public MetadataBase, public RefCounted Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; static const ViewMetadata::Ptr NIL; @@ -469,7 +469,7 @@ inline bool operator==(const ViewMetadata::Ptr& a, const ViewMetadata::Ptr& b) { class TableMetadata : public TableMetadataBase { public: typedef SharedRefPtr Ptr; - typedef cass::Map Map; + typedef internal::Map Map; typedef Vector Vec; typedef Vector KeyAliases; @@ -515,7 +515,7 @@ class TableMetadata : public TableMetadataBase { class KeyspaceMetadata : public MetadataBase { public: - typedef cass::Map Map; + typedef internal::Map Map; typedef CopyOnWritePtr MapPtr; class TableIterator : public MetadataIteratorImpl > { @@ -748,17 +748,15 @@ class Metadata { DISALLOW_COPY_AND_ASSIGN(Metadata); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Metadata::SchemaSnapshot, CassSchemaMeta) -EXTERNAL_TYPE(cass::KeyspaceMetadata, CassKeyspaceMeta) -EXTERNAL_TYPE(cass::TableMetadata, CassTableMeta) -EXTERNAL_TYPE(cass::ViewMetadata, CassMaterializedViewMeta) -EXTERNAL_TYPE(cass::ColumnMetadata, CassColumnMeta) -EXTERNAL_TYPE(cass::IndexMetadata, CassIndexMeta) -EXTERNAL_TYPE(cass::FunctionMetadata, CassFunctionMeta) -EXTERNAL_TYPE(cass::AggregateMetadata, CassAggregateMeta) +EXTERNAL_TYPE(datastax::internal::core::Metadata::SchemaSnapshot, CassSchemaMeta) +EXTERNAL_TYPE(datastax::internal::core::KeyspaceMetadata, CassKeyspaceMeta) +EXTERNAL_TYPE(datastax::internal::core::TableMetadata, CassTableMeta) +EXTERNAL_TYPE(datastax::internal::core::ViewMetadata, CassMaterializedViewMeta) +EXTERNAL_TYPE(datastax::internal::core::ColumnMetadata, CassColumnMeta) +EXTERNAL_TYPE(datastax::internal::core::IndexMetadata, CassIndexMeta) +EXTERNAL_TYPE(datastax::internal::core::FunctionMetadata, CassFunctionMeta) +EXTERNAL_TYPE(datastax::internal::core::AggregateMetadata, CassAggregateMeta) #endif - - diff --git a/cpp-driver/src/metrics.hpp b/cpp-driver/src/metrics.hpp index 70c50ed6f..68a6bd9f7 100644 --- a/cpp-driver/src/metrics.hpp +++ b/cpp-driver/src/metrics.hpp @@ -34,7 +34,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Metrics : public Allocated { public: @@ -471,6 +471,6 @@ class Metrics : public Allocated { DISALLOW_COPY_AND_ASSIGN(Metrics); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/micro_timer.cpp b/cpp-driver/src/micro_timer.cpp index a372d7a6d..e6939c206 100644 --- a/cpp-driver/src/micro_timer.cpp +++ b/cpp-driver/src/micro_timer.cpp @@ -23,7 +23,7 @@ #include #endif -namespace cass { +using namespace datastax::internal::core; #ifdef HAVE_TIMERFD @@ -162,5 +162,3 @@ void MicroTimer::on_timeout(Timer* timer) { } #endif - -} // namespace cass diff --git a/cpp-driver/src/micro_timer.hpp b/cpp-driver/src/micro_timer.hpp index bf95f0498..362c32167 100644 --- a/cpp-driver/src/micro_timer.hpp +++ b/cpp-driver/src/micro_timer.hpp @@ -32,7 +32,7 @@ // Only affects busy wait timer version #define CASS_PERCENT_OF_MILLSECOND_THRESHOLD 95 -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A timer that supports microsecond precision. It is not intended for general @@ -48,7 +48,7 @@ namespace cass { */ class MicroTimer { public: - typedef cass::Callback Callback; + typedef internal::Callback Callback; MicroTimer(); ~MicroTimer() { stop(); } @@ -113,6 +113,6 @@ class MicroTimer { DISALLOW_COPY_AND_ASSIGN(MicroTimer); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/monitor_reporting.cpp b/cpp-driver/src/monitor_reporting.cpp index 588298f29..9a5bac35f 100644 --- a/cpp-driver/src/monitor_reporting.cpp +++ b/cpp-driver/src/monitor_reporting.cpp @@ -16,12 +16,10 @@ #include "monitor_reporting.hpp" -namespace cass { +using namespace datastax::internal::core; MonitorReporting* create_monitor_reporting(const String& client_id, const String& session_id, const Config& config) { return new NopMonitorReporting(); } - -} // namespace cass diff --git a/cpp-driver/src/monitor_reporting.hpp b/cpp-driver/src/monitor_reporting.hpp index 6cfc1a3ba..e2a16a297 100644 --- a/cpp-driver/src/monitor_reporting.hpp +++ b/cpp-driver/src/monitor_reporting.hpp @@ -22,7 +22,7 @@ #include "load_balancing.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; @@ -53,6 +53,6 @@ MonitorReporting* create_monitor_reporting(const String& client_id, const String& session_id, const Config& config); -} // namespace cass +} } } // namespace datastax::internal::core #endif // __CASS_MONITOR_REPORTING_HPP_INCLUDED__ diff --git a/cpp-driver/src/mpmc_queue.hpp b/cpp-driver/src/mpmc_queue.hpp index f1cfc875f..8a31673fd 100644 --- a/cpp-driver/src/mpmc_queue.hpp +++ b/cpp-driver/src/mpmc_queue.hpp @@ -31,7 +31,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { template class MPMCQueue : public Allocated { @@ -160,6 +160,6 @@ class MPMCQueue : public Allocated { DISALLOW_COPY_AND_ASSIGN(MPMCQueue); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/murmur3.cpp b/cpp-driver/src/murmur3.cpp index 72e6be578..48d1250cf 100644 --- a/cpp-driver/src/murmur3.cpp +++ b/cpp-driver/src/murmur3.cpp @@ -57,7 +57,7 @@ inline int64_t rotl64 (int64_t x, int8_t r) { #endif // !defined(_MSC_VER) -namespace cass { +namespace datastax { namespace internal { FORCE_INLINE int64_t getblock(const int64_t * p, int i) { return p[i]; @@ -152,4 +152,5 @@ int64_t MurmurHash3_x64_128(const void * key, const int len, return h1; } -} +} } // namespace datastax::internal + diff --git a/cpp-driver/src/murmur3.hpp b/cpp-driver/src/murmur3.hpp index 1e6ff9b54..8e016df25 100644 --- a/cpp-driver/src/murmur3.hpp +++ b/cpp-driver/src/murmur3.hpp @@ -26,11 +26,11 @@ #include -namespace cass { +namespace datastax { namespace internal { int64_t MurmurHash3_x64_128(const void * key, const int len, const uint32_t seed); -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/name_resolver.hpp b/cpp-driver/src/name_resolver.hpp index c7301db56..2329338e6 100644 --- a/cpp-driver/src/name_resolver.hpp +++ b/cpp-driver/src/name_resolver.hpp @@ -25,13 +25,13 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class NameResolver : public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum Status { NEW, @@ -134,6 +134,6 @@ class NameResolver : public RefCounted { Callback callback_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/options_request.hpp b/cpp-driver/src/options_request.hpp index c61f5787f..ecd4a0497 100644 --- a/cpp-driver/src/options_request.hpp +++ b/cpp-driver/src/options_request.hpp @@ -20,7 +20,7 @@ #include "request.hpp" #include "constants.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class OptionsRequest : public Request { public: @@ -31,6 +31,6 @@ class OptionsRequest : public Request { int encode(ProtocolVersion version, RequestCallback* callback, BufferVec* bufs) const { return 0; } }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/pooled_connection.cpp b/cpp-driver/src/pooled_connection.cpp index 4e17dcbe4..ebbc50398 100644 --- a/cpp-driver/src/pooled_connection.cpp +++ b/cpp-driver/src/pooled_connection.cpp @@ -20,7 +20,8 @@ #include "event_loop.hpp" #include "query_request.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; /** * A request callback that sets the keyspace then runs the original request @@ -176,5 +177,3 @@ void PooledConnection::on_close(Connection* connection) { pool_->close_connection(this, ConnectionPool::Protected()); dec_ref(); } - -} // namespace cass diff --git a/cpp-driver/src/pooled_connection.hpp b/cpp-driver/src/pooled_connection.hpp index 483a32d52..c99f60d83 100644 --- a/cpp-driver/src/pooled_connection.hpp +++ b/cpp-driver/src/pooled_connection.hpp @@ -22,7 +22,7 @@ #include "ref_counted.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ConnectionPool; class EventLoop; @@ -87,6 +87,6 @@ class PooledConnection : public RefCounted EventLoop* const event_loop_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/prepare_all_handler.cpp b/cpp-driver/src/prepare_all_handler.cpp index 519edaa67..30413b639 100644 --- a/cpp-driver/src/prepare_all_handler.cpp +++ b/cpp-driver/src/prepare_all_handler.cpp @@ -18,7 +18,8 @@ #include "connection.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; PrepareAllHandler::PrepareAllHandler(const Host::Ptr& current_host, const Response::Ptr& response, @@ -75,5 +76,3 @@ void PrepareAllCallback::on_internal_timeout() { LOG_WARN("Prepare all timed out on host %s", address_.to_string().c_str()); finish(); // Don't wait for the request to come back } - -} // namespace cass diff --git a/cpp-driver/src/prepare_all_handler.hpp b/cpp-driver/src/prepare_all_handler.hpp index 1cfbbf8b7..7fb07339a 100644 --- a/cpp-driver/src/prepare_all_handler.hpp +++ b/cpp-driver/src/prepare_all_handler.hpp @@ -25,7 +25,7 @@ #include "request_handler.hpp" #include "response.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A handler that tracks the progress of prepares on all hosts and returns the @@ -78,6 +78,6 @@ class PrepareAllCallback : public SimpleRequestCallback { bool is_finished_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/prepare_host_handler.cpp b/cpp-driver/src/prepare_host_handler.cpp index 9b5571bb0..c07ffa48e 100644 --- a/cpp-driver/src/prepare_host_handler.cpp +++ b/cpp-driver/src/prepare_host_handler.cpp @@ -23,7 +23,8 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; struct CompareEntryKeyspace { bool operator()(const PreparedMetadata::Entry::Ptr& lhs, @@ -216,5 +217,3 @@ void PrepareHostHandler::SetKeyspaceCallback::on_internal_timeout() { handler_->host_->address_string().c_str()); handler_->close(); } - -} // namespace cass diff --git a/cpp-driver/src/prepare_host_handler.hpp b/cpp-driver/src/prepare_host_handler.hpp index 0ceafa3d8..f9c585597 100644 --- a/cpp-driver/src/prepare_host_handler.hpp +++ b/cpp-driver/src/prepare_host_handler.hpp @@ -24,7 +24,7 @@ #include "ref_counted.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Connector; @@ -34,7 +34,7 @@ class Connector; class PrepareHostHandler : public RefCounted , public ConnectionListener { public: - typedef cass::Callback Callback; + typedef internal::Callback Callback; typedef SharedRefPtr Ptr; @@ -119,6 +119,6 @@ class PrepareHostHandler : public RefCounted PreparedMetadata::Entry::Vec::const_iterator current_entry_it_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/prepare_request.cpp b/cpp-driver/src/prepare_request.cpp index 7af0b9c45..bd5062843 100644 --- a/cpp-driver/src/prepare_request.cpp +++ b/cpp-driver/src/prepare_request.cpp @@ -19,7 +19,7 @@ #include "protocol.hpp" #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; int PrepareRequest::encode(ProtocolVersion version, RequestCallback* callback, BufferVec* bufs) const { // [long string] @@ -49,5 +49,3 @@ int PrepareRequest::encode(ProtocolVersion version, RequestCallback* callback, B } return length; } - -} // namespace cass diff --git a/cpp-driver/src/prepare_request.hpp b/cpp-driver/src/prepare_request.hpp index 515d3a66e..0d7be9f42 100644 --- a/cpp-driver/src/prepare_request.hpp +++ b/cpp-driver/src/prepare_request.hpp @@ -21,7 +21,7 @@ #include "request.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class PrepareRequest : public Request { public: @@ -47,6 +47,6 @@ class PrepareRequest : public Request { String query_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/prepared.cpp b/cpp-driver/src/prepared.cpp index 4e1000e5d..1d71559ab 100644 --- a/cpp-driver/src/prepared.cpp +++ b/cpp-driver/src/prepared.cpp @@ -20,6 +20,10 @@ #include "logger.hpp" #include "external.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { void cass_prepared_free(const CassPrepared* prepared) { @@ -27,7 +31,7 @@ void cass_prepared_free(const CassPrepared* prepared) { } CassStatement* cass_prepared_bind(const CassPrepared* prepared) { - cass::ExecuteRequest* execute = new cass::ExecuteRequest(prepared); + ExecuteRequest* execute = new ExecuteRequest(prepared); execute->inc_ref(); return CassStatement::to(execute); } @@ -36,11 +40,11 @@ CassError cass_prepared_parameter_name(const CassPrepared* prepared, size_t index, const char** name, size_t* name_length) { - const cass::SharedRefPtr& metadata(prepared->result()->metadata()); + const SharedRefPtr& metadata(prepared->result()->metadata()); if (index >= metadata->column_count()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } - const cass::ColumnDefinition def = metadata->get_column_definition(index); + const ColumnDefinition def = metadata->get_column_definition(index); *name = def.name.data(); *name_length = def.name.size(); return CASS_OK; @@ -48,7 +52,7 @@ CassError cass_prepared_parameter_name(const CassPrepared* prepared, const CassDataType* cass_prepared_parameter_data_type(const CassPrepared* prepared, size_t index) { - const cass::SharedRefPtr& metadata(prepared->result()->metadata()); + const SharedRefPtr& metadata(prepared->result()->metadata()); if (index >= metadata->column_count()) { return NULL; } @@ -65,10 +69,10 @@ const CassDataType* cass_prepared_parameter_data_type_by_name_n(const CassPrepar const char* name, size_t name_length) { - const cass::SharedRefPtr& metadata(prepared->result()->metadata()); + const SharedRefPtr& metadata(prepared->result()->metadata()); - cass::IndexVec indices; - if (metadata->get_indices(cass::StringRef(name, name_length), &indices) == 0) { + IndexVec indices; + if (metadata->get_indices(StringRef(name, name_length), &indices) == 0) { return NULL; } return CassDataType::to(metadata->get_column_definition(indices[0]).data_type.get()); @@ -76,8 +80,6 @@ const CassDataType* cass_prepared_parameter_data_type_by_name_n(const CassPrepar } // extern "C" -namespace cass { - Prepared::Prepared(const ResultResponse::Ptr& result, const PrepareRequest::ConstPtr& prepare_request, const Metadata::SchemaSnapshot& schema_metadata) @@ -112,5 +114,3 @@ Prepared::Prepared(const ResultResponse::Ptr& result, } } } - -} // namespace cass diff --git a/cpp-driver/src/prepared.hpp b/cpp-driver/src/prepared.hpp index b536747ac..2fef42749 100644 --- a/cpp-driver/src/prepared.hpp +++ b/cpp-driver/src/prepared.hpp @@ -31,7 +31,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Prepared : public RefCounted { public: @@ -130,8 +130,8 @@ class PreparedMetadata { Map metadata_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Prepared, CassPrepared) +EXTERNAL_TYPE(datastax::internal::core::Prepared, CassPrepared) #endif diff --git a/cpp-driver/src/protocol.cpp b/cpp-driver/src/protocol.cpp index e417044a7..c9ce19b04 100644 --- a/cpp-driver/src/protocol.cpp +++ b/cpp-driver/src/protocol.cpp @@ -21,7 +21,7 @@ #define DSE_PROTOCOL_VERSION_BIT 0x40 #define DSE_PROTOCOL_VERSION_MASK 0x3F -namespace cass { +using namespace datastax::internal::core; ProtocolVersion::ProtocolVersion() : value_(-1) { } @@ -111,5 +111,3 @@ bool ProtocolVersion::supports_result_metadata_id() const { return false; //return version_ >= CASS_PROTOCOL_VERSION_V5; } - -} // namespace cass diff --git a/cpp-driver/src/protocol.hpp b/cpp-driver/src/protocol.hpp index 145b70223..2a2bee76f 100644 --- a/cpp-driver/src/protocol.hpp +++ b/cpp-driver/src/protocol.hpp @@ -21,7 +21,7 @@ #include "constants.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A type that represents the protocol version for Cassandra/DSE. @@ -135,6 +135,6 @@ class ProtocolVersion { int value_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/query_request.cpp b/cpp-driver/src/query_request.cpp index 16dcdc041..ef4e5fba4 100644 --- a/cpp-driver/src/query_request.cpp +++ b/cpp-driver/src/query_request.cpp @@ -21,7 +21,8 @@ #include "logger.hpp" #include "serialization.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; int QueryRequest::encode(ProtocolVersion version, RequestCallback* callback, BufferVec* bufs) const { int32_t result; @@ -76,5 +77,3 @@ size_t QueryRequest::get_indices(StringRef name, IndexVec* indices) { return indices->size(); } - -} // namespace cass diff --git a/cpp-driver/src/query_request.hpp b/cpp-driver/src/query_request.hpp index a61e216da..69d0b6037 100644 --- a/cpp-driver/src/query_request.hpp +++ b/cpp-driver/src/query_request.hpp @@ -23,7 +23,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class QueryRequest : public Statement { public: @@ -63,6 +63,6 @@ class QueryRequest : public Statement { ScopedPtr value_names_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/random.cpp b/cpp-driver/src/random.cpp index e38b17f26..a3fc97ebb 100644 --- a/cpp-driver/src/random.cpp +++ b/cpp-driver/src/random.cpp @@ -41,7 +41,7 @@ #include #endif -namespace cass { +namespace datastax { namespace internal { Random::Random() // Use high resolution time if we can't get a real random seed @@ -147,7 +147,7 @@ uint64_t Random::next(uint64_t max) { return seed; } - #endif -} // namespace cass +} } // namespace datastax::internal + diff --git a/cpp-driver/src/random.hpp b/cpp-driver/src/random.hpp index e6d2fe77b..ffa1c6d82 100644 --- a/cpp-driver/src/random.hpp +++ b/cpp-driver/src/random.hpp @@ -23,7 +23,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { class Random : public Allocated { public: @@ -49,7 +49,6 @@ void random_shuffle(RandomAccessIterator first, } } -} // namespace cass +} } // namespace datastax::internal #endif - diff --git a/cpp-driver/src/ready_response.hpp b/cpp-driver/src/ready_response.hpp index 10fd4e52b..e4642cb2e 100644 --- a/cpp-driver/src/ready_response.hpp +++ b/cpp-driver/src/ready_response.hpp @@ -19,7 +19,7 @@ #include "response.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ReadyResponse : public Response { public: @@ -29,6 +29,6 @@ class ReadyResponse : public Response { virtual bool decode(Decoder& decoder) { return true; } }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/ref_counted.hpp b/cpp-driver/src/ref_counted.hpp index f56574f0b..7f6f609e5 100644 --- a/cpp-driver/src/ref_counted.hpp +++ b/cpp-driver/src/ref_counted.hpp @@ -26,7 +26,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { template class RefCounted : public Allocated { @@ -163,6 +163,6 @@ class RefBuffer : public RefCounted { DISALLOW_COPY_AND_ASSIGN(RefBuffer); }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/register_request.cpp b/cpp-driver/src/register_request.cpp index 33aeebcd7..e8910fc1a 100644 --- a/cpp-driver/src/register_request.cpp +++ b/cpp-driver/src/register_request.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; int RegisterRequest::encode(ProtocolVersion version, RequestCallback* callback, BufferVec* bufs) const { // [string list] @@ -48,6 +48,3 @@ int RegisterRequest::encode(ProtocolVersion version, RequestCallback* callback, return length; } - -} // namespace cas - diff --git a/cpp-driver/src/register_request.hpp b/cpp-driver/src/register_request.hpp index f6f9ee1d1..7d1c47ff1 100644 --- a/cpp-driver/src/register_request.hpp +++ b/cpp-driver/src/register_request.hpp @@ -20,7 +20,7 @@ #include "request.hpp" #include "constants.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class RegisterRequest : public Request { public: @@ -34,5 +34,5 @@ class RegisterRequest : public Request { int event_types_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/request.cpp b/cpp-driver/src/request.cpp index c40a2bd41..4e0ec557e 100644 --- a/cpp-driver/src/request.cpp +++ b/cpp-driver/src/request.cpp @@ -18,10 +18,12 @@ #include "external.hpp" +using namespace datastax::internal::core; + extern "C" { CassCustomPayload* cass_custom_payload_new() { - cass::CustomPayload* payload = new cass::CustomPayload(); + CustomPayload* payload = new CustomPayload(); payload->inc_ref(); return CassCustomPayload::to(payload); } @@ -58,8 +60,6 @@ void cass_custom_payload_free(CassCustomPayload* payload) { } // extern "C" -namespace cass { - void CustomPayload::set(const char* name, size_t name_length, const uint8_t* value, size_t value_size) { Buffer buf(sizeof(uint16_t) + name_length + sizeof(int32_t) + value_size); size_t pos = buf.encode_string(0, name, name_length); @@ -78,5 +78,3 @@ int32_t CustomPayload::encode(BufferVec* bufs) const { } return length; } - -} // namespace cass diff --git a/cpp-driver/src/request.hpp b/cpp-driver/src/request.hpp index a3b75997c..f48fe3f0b 100644 --- a/cpp-driver/src/request.hpp +++ b/cpp-driver/src/request.hpp @@ -31,7 +31,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class RequestCallback; @@ -233,9 +233,9 @@ class RoutableRequest : public Request { virtual bool get_routing_key(String* routing_key) const = 0; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::CustomPayload, CassCustomPayload) +EXTERNAL_TYPE(datastax::internal::core::CustomPayload, CassCustomPayload) #endif diff --git a/cpp-driver/src/request_callback.cpp b/cpp-driver/src/request_callback.cpp index f4c35d363..2be76947f 100644 --- a/cpp-driver/src/request_callback.cpp +++ b/cpp-driver/src/request_callback.cpp @@ -27,7 +27,8 @@ #include "result_response.hpp" #include "serialization.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; void RequestWrapper::set_prepared_metadata(const PreparedMetadata::Entry::Ptr& entry) { prepared_metadata_entry_ = entry; @@ -315,5 +316,3 @@ void ChainedRequestCallback::maybe_finish() { } } } - -} // namespace cass diff --git a/cpp-driver/src/request_callback.hpp b/cpp-driver/src/request_callback.hpp index 200f1b946..f085e0d94 100644 --- a/cpp-driver/src/request_callback.hpp +++ b/cpp-driver/src/request_callback.hpp @@ -34,7 +34,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; class Connection; @@ -384,6 +384,6 @@ class ChainedRequestCallback : public SimpleRequestCallback { Map responses_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/request_handler.cpp b/cpp-driver/src/request_handler.cpp index c671f0db9..83e1856d8 100644 --- a/cpp-driver/src/request_handler.cpp +++ b/cpp-driver/src/request_handler.cpp @@ -32,7 +32,9 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; class SingleHostQueryPlan : public QueryPlan { public: @@ -54,12 +56,12 @@ class PrepareCallback : public SimpleRequestCallback { PrepareCallback(const String& query, RequestExecution* request_execution); private: - class PrepareRequest : public cass::PrepareRequest { + class PrepareRequest : public core::PrepareRequest { public: PrepareRequest(const String& query, const String& keyspace, uint64_t request_timeout_ms) - : cass::PrepareRequest(query) { + : core::PrepareRequest(query) { set_keyspace(keyspace); set_request_timeout_ms(request_timeout_ms); } @@ -665,5 +667,3 @@ void RequestExecution::set_error_with_error_response(const Response::Ptr& error, CassError code, const String& message) { request_handler_->set_error_with_error_response(current_host_, error, code, message); } - -} // namespace cass diff --git a/cpp-driver/src/request_handler.hpp b/cpp-driver/src/request_handler.hpp index 4130c1b2c..69af18453 100644 --- a/cpp-driver/src/request_handler.hpp +++ b/cpp-driver/src/request_handler.hpp @@ -37,7 +37,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; class Connection; @@ -330,6 +330,6 @@ class RequestExecution : public RequestCallback { const uint64_t start_time_ns_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/request_processor.cpp b/cpp-driver/src/request_processor.cpp index b293feaa8..29b50b313 100644 --- a/cpp-driver/src/request_processor.cpp +++ b/cpp-driver/src/request_processor.cpp @@ -23,7 +23,11 @@ #include "tracing_data_handler.hpp" #include "utils.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { class ProcessorRunClose : public Task { public: @@ -141,6 +145,8 @@ class NopRequestProcessorListener : public RequestProcessorListener { virtual void on_close(RequestProcessor* processor) { } }; +} } } // namespace datastax::internal::core + static NopRequestProcessorListener nop_request_processor_listener__; RequestProcessorSettings::RequestProcessorSettings() @@ -621,5 +627,3 @@ bool RequestProcessor::write_wait_callback(const RequestHandler::Ptr& request_ha } return false; } - -} // namespace cass diff --git a/cpp-driver/src/request_processor.hpp b/cpp-driver/src/request_processor.hpp index 0567428cf..034e1af6d 100644 --- a/cpp-driver/src/request_processor.hpp +++ b/cpp-driver/src/request_processor.hpp @@ -33,7 +33,7 @@ #include "timer.hpp" #include "token_map.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ConnectionPoolManagerInitializer; class RequestProcessor; @@ -64,7 +64,7 @@ class KeyspaceChangedHandler : public RefCounted { * An internal task that keeps the original keyspace change handler * alive so that processing happens on the original event loop. */ - class Task : public cass::Task { + class Task : public core::Task { public: Task(const KeyspaceChangedResponse& response) : response_(response) { } @@ -373,6 +373,6 @@ class RequestProcessor : public RefCounted #endif }; -} // namespace cass +} } } // namespace datastax::internal::core #endif // __CASS_REQUEST_PROCESSOR_HPP_INCLUDED__ diff --git a/cpp-driver/src/request_processor_initializer.cpp b/cpp-driver/src/request_processor_initializer.cpp index 8ba01642e..61a1dadee 100644 --- a/cpp-driver/src/request_processor_initializer.cpp +++ b/cpp-driver/src/request_processor_initializer.cpp @@ -19,7 +19,11 @@ #include "request_processor_initializer.hpp" #include "scoped_lock.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { class RunInitializeProcessor : public Task { public: @@ -34,6 +38,8 @@ class RunInitializeProcessor : public Task { RequestProcessorInitializer::Ptr initializer_; }; +} } } // namespace datastax::internal::core + RequestProcessorInitializer::RequestProcessorInitializer(const Host::Ptr& connected_host, ProtocolVersion protocol_version, const HostMap& hosts, @@ -183,5 +189,3 @@ void RequestProcessorInitializer::on_initialize(ConnectionPoolManagerInitializer connection_pool_manager_initializer_.reset(); dec_ref(); } - -} // namespace cass diff --git a/cpp-driver/src/request_processor_initializer.hpp b/cpp-driver/src/request_processor_initializer.hpp index a45aba63a..85cb43706 100644 --- a/cpp-driver/src/request_processor_initializer.hpp +++ b/cpp-driver/src/request_processor_initializer.hpp @@ -27,7 +27,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; class EventLoop; @@ -43,7 +43,7 @@ class RequestProcessorInitializer public: typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum RequestProcessorError { REQUEST_PROCESSOR_OK, @@ -177,6 +177,6 @@ class RequestProcessorInitializer Atomic remaining_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/resolver.hpp b/cpp-driver/src/resolver.hpp index 13e076c64..0fc359443 100644 --- a/cpp-driver/src/resolver.hpp +++ b/cpp-driver/src/resolver.hpp @@ -28,13 +28,13 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Resolver : public RefCounted { public: typedef SharedRefPtr Ptr; typedef Vector Vec; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum Status { NEW, @@ -160,7 +160,7 @@ class Resolver : public RefCounted { class MultiResolver : public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; MultiResolver(const Callback& callback) : remaining_(0) @@ -205,6 +205,6 @@ class MultiResolver : public RefCounted { DISALLOW_COPY_AND_ASSIGN(MultiResolver); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/response.cpp b/cpp-driver/src/response.cpp index eb54cb9a0..8b5927f0f 100644 --- a/cpp-driver/src/response.cpp +++ b/cpp-driver/src/response.cpp @@ -26,7 +26,7 @@ #include -namespace cass { +using namespace datastax::internal::core; /** * A dummy invalid protocol error response that's used to handle responses @@ -209,6 +209,3 @@ ssize_t ResponseMessage::decode(const char* input, size_t size) { return input_pos - input; } - -} // namespace cass - diff --git a/cpp-driver/src/response.hpp b/cpp-driver/src/response.hpp index eb89f6222..282c7428b 100644 --- a/cpp-driver/src/response.hpp +++ b/cpp-driver/src/response.hpp @@ -29,7 +29,7 @@ #define CHECK_RESULT(result) if(!(result)) return false; -namespace cass { +namespace datastax { namespace internal { namespace core { class Response : public RefCounted { public: @@ -129,6 +129,6 @@ class ResponseMessage : public Allocated { DISALLOW_COPY_AND_ASSIGN(ResponseMessage); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/result_iterator.hpp b/cpp-driver/src/result_iterator.hpp index c53a341f3..11880c0ba 100644 --- a/cpp-driver/src/result_iterator.hpp +++ b/cpp-driver/src/result_iterator.hpp @@ -21,7 +21,7 @@ #include "result_response.hpp" #include "row.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ResultIterator : public Iterator { public: @@ -64,6 +64,6 @@ class ResultIterator : public Iterator { Row row_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/result_metadata.cpp b/cpp-driver/src/result_metadata.cpp index 29674ef49..e6c8030c6 100644 --- a/cpp-driver/src/result_metadata.cpp +++ b/cpp-driver/src/result_metadata.cpp @@ -24,7 +24,9 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; ResultMetadata::ResultMetadata(size_t column_count, const RefBuffer::Ptr& buffer) @@ -38,5 +40,3 @@ size_t ResultMetadata::get_indices(StringRef name, IndexVec* result) const{ void ResultMetadata::add(const ColumnDefinition& def) { defs_.add(def); } - -} // namespace cass diff --git a/cpp-driver/src/result_metadata.hpp b/cpp-driver/src/result_metadata.hpp index 7d4fbd613..d0b4400d9 100644 --- a/cpp-driver/src/result_metadata.hpp +++ b/cpp-driver/src/result_metadata.hpp @@ -27,7 +27,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { struct ColumnDefinition : public HashTableEntry { StringRef name; @@ -59,6 +59,6 @@ class ResultMetadata : public RefCounted { DISALLOW_COPY_AND_ASSIGN(ResultMetadata); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/result_response.cpp b/cpp-driver/src/result_response.cpp index a4b4532b7..92e15fa74 100644 --- a/cpp-driver/src/result_response.cpp +++ b/cpp-driver/src/result_response.cpp @@ -23,6 +23,10 @@ #include "result_response.hpp" #include "serialization.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { void cass_result_free(const CassResult* result) { @@ -47,21 +51,21 @@ CassError cass_result_column_name(const CassResult* result, size_t index, const char** name, size_t* name_length) { - const cass::SharedRefPtr& metadata(result->metadata()); + const SharedRefPtr& metadata(result->metadata()); if (index >= metadata->column_count()) { return CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS; } if (result->kind() != CASS_RESULT_KIND_ROWS) { return CASS_ERROR_LIB_BAD_PARAMS; } - const cass::ColumnDefinition def = metadata->get_column_definition(index); + const ColumnDefinition def = metadata->get_column_definition(index); *name = def.name.data(); *name_length = def.name.size(); return CASS_OK; } CassValueType cass_result_column_type(const CassResult* result, size_t index) { - const cass::SharedRefPtr& metadata(result->metadata()); + const SharedRefPtr& metadata(result->metadata()); if (result->kind() == CASS_RESULT_KIND_ROWS && index < metadata->column_count()) { return metadata->get_column_definition(index).data_type->value_type(); @@ -70,7 +74,7 @@ CassValueType cass_result_column_type(const CassResult* result, size_t index) { } const CassDataType* cass_result_column_data_type(const CassResult* result, size_t index) { - const cass::SharedRefPtr& metadata(result->metadata()); + const SharedRefPtr& metadata(result->metadata()); if (result->kind() == CASS_RESULT_KIND_ROWS && index < metadata->column_count()) { return CassDataType::to(metadata->get_column_definition(index).data_type.get()); @@ -102,8 +106,6 @@ CassError cass_result_paging_state_token(const CassResult* result, } // extern "C" -namespace cass { - class DataTypeDecoder { public: DataTypeDecoder(Decoder& decoder, SimpleDataTypeCache& cache) @@ -347,5 +349,3 @@ bool ResultResponse::decode_schema_change(Decoder& decoder) { CHECK_RESULT(decoder.decode_string(&table_)); return true; } - -} // namespace cass diff --git a/cpp-driver/src/result_response.hpp b/cpp-driver/src/result_response.hpp index bf2ae1e50..c1e5098a2 100644 --- a/cpp-driver/src/result_response.hpp +++ b/cpp-driver/src/result_response.hpp @@ -26,7 +26,7 @@ #include "string_ref.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ResultIterator; @@ -115,8 +115,8 @@ class ResultResponse : public Response { DISALLOW_COPY_AND_ASSIGN(ResultResponse); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::ResultResponse, CassResult) +EXTERNAL_TYPE(datastax::internal::core::ResultResponse, CassResult) #endif diff --git a/cpp-driver/src/retry_policy.cpp b/cpp-driver/src/retry_policy.cpp index 629aa463a..8e35eb64f 100644 --- a/cpp-driver/src/retry_policy.cpp +++ b/cpp-driver/src/retry_policy.cpp @@ -20,33 +20,36 @@ #include "logger.hpp" #include "request.hpp" +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { CassRetryPolicy* cass_retry_policy_default_new() { - cass::RetryPolicy* policy = new cass::DefaultRetryPolicy(); + RetryPolicy* policy = new DefaultRetryPolicy(); policy->inc_ref(); return CassRetryPolicy::to(policy); } CassRetryPolicy* cass_retry_policy_downgrading_consistency_new() { - cass::RetryPolicy* policy = new cass::DowngradingConsistencyRetryPolicy(); + RetryPolicy* policy = new DowngradingConsistencyRetryPolicy(); policy->inc_ref(); return CassRetryPolicy::to(policy); } CassRetryPolicy* cass_retry_policy_fallthrough_new() { - cass::RetryPolicy* policy = new cass::FallthroughRetryPolicy(); + RetryPolicy* policy = new FallthroughRetryPolicy(); policy->inc_ref(); return CassRetryPolicy::to(policy); } CassRetryPolicy* cass_retry_policy_logging_new(CassRetryPolicy* child_retry_policy) { - if (child_retry_policy->type() == cass::RetryPolicy::LOGGING) { + if (child_retry_policy->type() == RetryPolicy::LOGGING) { return NULL; } - cass::RetryPolicy* policy - = new cass::LoggingRetryPolicy( - cass::SharedRefPtr(child_retry_policy)); + RetryPolicy* policy + = new LoggingRetryPolicy( + SharedRefPtr(child_retry_policy)); policy->inc_ref(); return CassRetryPolicy::to(policy); } @@ -57,8 +60,6 @@ void cass_retry_policy_free(CassRetryPolicy* policy) { } // extern "C" -namespace cass { - inline RetryPolicy::RetryDecision max_likely_to_work(int received) { if (received >= 3) { return RetryPolicy::RetryDecision::retry(CASS_CONSISTENCY_THREE); @@ -318,5 +319,3 @@ RetryPolicy::RetryDecision LoggingRetryPolicy::on_request_error(const Request* r return decision; } - -} // namespace cass diff --git a/cpp-driver/src/retry_policy.hpp b/cpp-driver/src/retry_policy.hpp index c0f73dd31..925f973c3 100644 --- a/cpp-driver/src/retry_policy.hpp +++ b/cpp-driver/src/retry_policy.hpp @@ -28,7 +28,7 @@ # endif #endif -namespace cass { +namespace datastax { namespace internal { namespace core { class ErrorResponse; class Request; @@ -182,9 +182,8 @@ class LoggingRetryPolicy : public RetryPolicy { RetryPolicy::Ptr retry_policy_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::RetryPolicy, CassRetryPolicy) +EXTERNAL_TYPE(datastax::internal::core::RetryPolicy, CassRetryPolicy) #endif - diff --git a/cpp-driver/src/ring_buffer.cpp b/cpp-driver/src/ring_buffer.cpp index 824072f44..59d62d8e2 100644 --- a/cpp-driver/src/ring_buffer.cpp +++ b/cpp-driver/src/ring_buffer.cpp @@ -44,8 +44,7 @@ #include #include -namespace cass { -namespace rb { +using namespace datastax::internal::rb; RingBuffer::~RingBuffer() { Buffer* current = head_.next_; @@ -267,6 +266,3 @@ void RingBuffer::reset() { write_head_ = read_head_; assert(length_ == 0); } - -} // namespace rb -} // namespace cass diff --git a/cpp-driver/src/ring_buffer.hpp b/cpp-driver/src/ring_buffer.hpp index 4ee363eea..c68ac1e56 100644 --- a/cpp-driver/src/ring_buffer.hpp +++ b/cpp-driver/src/ring_buffer.hpp @@ -47,8 +47,7 @@ #include -namespace cass { -namespace rb { +namespace datastax { namespace internal { namespace rb { class RingBuffer { private: @@ -160,7 +159,6 @@ size_t RingBuffer::peek_multiple(Position pos, SmallVector* bufs) { return total; } -} // namespace rb -} // namespace cass +} } } // namespace datastax::internal::rb #endif diff --git a/cpp-driver/src/round_robin_policy.cpp b/cpp-driver/src/round_robin_policy.cpp index 06e95f014..bdf7dd53f 100644 --- a/cpp-driver/src/round_robin_policy.cpp +++ b/cpp-driver/src/round_robin_policy.cpp @@ -20,7 +20,9 @@ #include #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; RoundRobinPolicy::RoundRobinPolicy() : hosts_(new HostVec()) @@ -96,5 +98,3 @@ Host::Ptr RoundRobinPolicy::RoundRobinQueryPlan::compute_next() { } return Host::Ptr(); } - -} // namespace cass diff --git a/cpp-driver/src/round_robin_policy.hpp b/cpp-driver/src/round_robin_policy.hpp index 9ea1ea7d3..6eed4c966 100644 --- a/cpp-driver/src/round_robin_policy.hpp +++ b/cpp-driver/src/round_robin_policy.hpp @@ -23,7 +23,7 @@ #include "host.hpp" #include "random.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class RoundRobinPolicy : public LoadBalancingPolicy { public: @@ -77,6 +77,6 @@ class RoundRobinPolicy : public LoadBalancingPolicy { DISALLOW_COPY_AND_ASSIGN(RoundRobinPolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/row.cpp b/cpp-driver/src/row.cpp index 6cd0ea301..44c0a6d04 100644 --- a/cpp-driver/src/row.cpp +++ b/cpp-driver/src/row.cpp @@ -22,6 +22,9 @@ #include "serialization.hpp" #include "string_ref.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { const CassValue* cass_row_get_column(const CassRow* row, size_t index) { @@ -41,12 +44,12 @@ const CassValue* cass_row_get_column_by_name_n(const CassRow* row, const char* name, size_t name_length) { - return CassValue::to(row->get_by_name(cass::StringRef(name, name_length))); + return CassValue::to(row->get_by_name(StringRef(name, name_length))); } } // extern "C" -namespace cass { +namespace datastax { namespace internal { namespace core { bool decode_row(Decoder& decoder, const ResultResponse* result, OutputValueVec& output) { @@ -62,6 +65,8 @@ bool decode_row(Decoder& decoder, const ResultResponse* result, return true; } +} } } // namespace datastax::internal::core + const Value* Row::get_by_name(const StringRef& name) const { IndexVec indices; if (result_->metadata()->get_indices(name, &indices) == 0) { @@ -78,5 +83,3 @@ bool Row::get_string_by_name(const StringRef& name, String* out) const { *out = value->decoder().as_string(); return true; } - -} diff --git a/cpp-driver/src/row.hpp b/cpp-driver/src/row.hpp index 20d777f18..ceb78859d 100644 --- a/cpp-driver/src/row.hpp +++ b/cpp-driver/src/row.hpp @@ -22,7 +22,7 @@ #include "string_ref.hpp" #include "value.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class ResultResponse; @@ -51,8 +51,8 @@ class Row { bool decode_row(Decoder& decoder, const ResultResponse* result, OutputValueVec& output); -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Row, CassRow) +EXTERNAL_TYPE(datastax::internal::core::Row, CassRow) #endif diff --git a/cpp-driver/src/row_iterator.hpp b/cpp-driver/src/row_iterator.hpp index 7fcd6c0f9..d566ce393 100644 --- a/cpp-driver/src/row_iterator.hpp +++ b/cpp-driver/src/row_iterator.hpp @@ -20,7 +20,7 @@ #include "iterator.hpp" #include "row.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class RowIterator : public Iterator { public: @@ -47,6 +47,6 @@ class RowIterator : public Iterator { int32_t index_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/schema_agreement_handler.cpp b/cpp-driver/src/schema_agreement_handler.cpp index 8179505f8..73f699175 100644 --- a/cpp-driver/src/schema_agreement_handler.cpp +++ b/cpp-driver/src/schema_agreement_handler.cpp @@ -24,7 +24,8 @@ #define SELECT_PEERS_SCHEMA \ "SELECT peer, rpc_address, schema_version FROM system.peers" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; SchemaAgreementHandler::SchemaAgreementHandler(const RequestHandler::Ptr& request_handler, const Host::Ptr& current_host, @@ -114,5 +115,3 @@ void SchemaAgreementHandler::on_error(WaitForHandler::WaitForError code, const S break; } } - -} // namespace cass diff --git a/cpp-driver/src/schema_agreement_handler.hpp b/cpp-driver/src/schema_agreement_handler.hpp index fdeb81be5..19bce432a 100644 --- a/cpp-driver/src/schema_agreement_handler.hpp +++ b/cpp-driver/src/schema_agreement_handler.hpp @@ -21,7 +21,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A listener that used for determining if a host is up. @@ -79,6 +79,6 @@ class SchemaAgreementHandler : public WaitForHandler { SchemaAgreementListener* const listener_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/scoped_lock.hpp b/cpp-driver/src/scoped_lock.hpp index 0f68ac852..dd7130968 100644 --- a/cpp-driver/src/scoped_lock.hpp +++ b/cpp-driver/src/scoped_lock.hpp @@ -22,7 +22,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { class Mutex { public: @@ -100,6 +100,6 @@ typedef ScopedLock ScopedMutex; typedef ScopedLock ScopedReadLock; typedef ScopedLock ScopedWriteLock; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/scoped_ptr.hpp b/cpp-driver/src/scoped_ptr.hpp index cbac8d432..9bef65cd8 100644 --- a/cpp-driver/src/scoped_ptr.hpp +++ b/cpp-driver/src/scoped_ptr.hpp @@ -22,7 +22,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template struct DefaultDeleter { @@ -105,6 +105,6 @@ class ScopedArray { DISALLOW_COPY_AND_ASSIGN(ScopedArray); }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/serialization.hpp b/cpp-driver/src/serialization.hpp index e0bbcd4ec..df766874a 100644 --- a/cpp-driver/src/serialization.hpp +++ b/cpp-driver/src/serialization.hpp @@ -30,7 +30,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { // http://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html // This frees us from having to deal with endian stuff on every platform. @@ -225,6 +225,6 @@ inline uint64_t encode_zig_zag(int64_t n) { return (n << 1) ^ (n >> 63); } -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/session.cpp b/cpp-driver/src/session.cpp index 69d43e4bc..9b6e7e199 100644 --- a/cpp-driver/src/session.cpp +++ b/cpp-driver/src/session.cpp @@ -30,10 +30,13 @@ #include "scoped_lock.hpp" #include "statement.hpp" +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassSession* cass_session_new() { - cass::Session* session = new cass::Session(); + Session* session = new Session(); return CassSession::to(session); } @@ -63,14 +66,14 @@ CassFuture* cass_session_connect_keyspace_n(CassSession* session, const CassCluster* cluster, const char* keyspace, size_t keyspace_length) { - cass::Future::Ptr future( - session->connect(cluster->config(), cass::String(keyspace, keyspace_length))); + Future::Ptr future( + session->connect(cluster->config(), String(keyspace, keyspace_length))); future->inc_ref(); return CassFuture::to(future.get()); } CassFuture* cass_session_close(CassSession* session) { - cass::Future::Ptr future(session->close()); + Future::Ptr future(session->close()); future->inc_ref(); return CassFuture::to(future.get()); } @@ -82,40 +85,40 @@ CassFuture* cass_session_prepare(CassSession* session, const char* query) { CassFuture* cass_session_prepare_n(CassSession* session, const char* query, size_t query_length) { - cass::Future::Ptr future(session->prepare(query, query_length)); + Future::Ptr future(session->prepare(query, query_length)); future->inc_ref(); return CassFuture::to(future.get()); } CassFuture* cass_session_prepare_from_existing(CassSession* session, CassStatement* statement) { - cass::Future::Ptr future(session->prepare(statement)); + Future::Ptr future(session->prepare(statement)); future->inc_ref(); return CassFuture::to(future.get()); } CassFuture* cass_session_execute(CassSession* session, const CassStatement* statement) { - cass::Future::Ptr future(session->execute(cass::Request::ConstPtr(statement->from()))); + Future::Ptr future(session->execute(Request::ConstPtr(statement->from()))); future->inc_ref(); return CassFuture::to(future.get()); } CassFuture* cass_session_execute_batch(CassSession* session, const CassBatch* batch) { - cass::Future::Ptr future(session->execute(cass::Request::ConstPtr(batch->from()))); + Future::Ptr future(session->execute(Request::ConstPtr(batch->from()))); future->inc_ref(); return CassFuture::to(future.get()); } const CassSchemaMeta* cass_session_get_schema_meta(const CassSession* session) { return CassSchemaMeta::to( - new cass::Metadata::SchemaSnapshot( + new Metadata::SchemaSnapshot( session->cluster()->schema_snapshot())); } void cass_session_get_metrics(const CassSession* session, CassMetrics* metrics) { - const cass::Metrics* internal_metrics = session->metrics(); + const Metrics* internal_metrics = session->metrics(); if (internal_metrics == NULL) { LOG_WARN("Attempted to get metrics before connecting session object"); @@ -123,7 +126,7 @@ void cass_session_get_metrics(const CassSession* session, return; } - cass::Metrics::Histogram::Snapshot requests_snapshot; + Metrics::Histogram::Snapshot requests_snapshot; internal_metrics->request_latencies.get_snapshot(&requests_snapshot); metrics->requests.min = requests_snapshot.min; @@ -153,7 +156,7 @@ void cass_session_get_metrics(const CassSession* session, void cass_session_get_speculative_execution_metrics(const CassSession* session, CassSpeculativeExecutionMetrics* metrics) { - const cass::Metrics* internal_metrics = session->metrics(); + const Metrics* internal_metrics = session->metrics(); if (internal_metrics == NULL) { LOG_WARN("Attempted to get speculative execution metrics before connecting session object"); @@ -161,7 +164,7 @@ void cass_session_get_speculative_execution_metrics(const CassSession* session, return; } - cass::Metrics::Histogram::Snapshot speculative_snapshot; + Metrics::Histogram::Snapshot speculative_snapshot; internal_metrics->speculative_request_latencies.get_snapshot(&speculative_snapshot); metrics->min = speculative_snapshot.min; @@ -182,13 +185,13 @@ void cass_session_get_speculative_execution_metrics(const CassSession* session, } // extern "C" -namespace cass { - static inline bool least_busy_comp(const RequestProcessor::Ptr& a, const RequestProcessor::Ptr& b) { return a->request_count() < b->request_count(); } +namespace datastax { namespace internal { namespace core { + /** * An initialize helper class for `Session`. This keeps the initialization * logic and data out of the core class itself. @@ -291,6 +294,8 @@ class SessionInitializer : public RefCounted { RequestProcessor::Vec request_processors_; }; +} } } // namespace datastax::internal::core + Session::Session() : request_processor_count_(0) , is_closing_(false) { @@ -544,5 +549,3 @@ void Session::on_close(RequestProcessor* processor) { notify_closed(); } } - -} // namespace cass diff --git a/cpp-driver/src/session.hpp b/cpp-driver/src/session.hpp index 504785715..91ffb2553 100644 --- a/cpp-driver/src/session.hpp +++ b/cpp-driver/src/session.hpp @@ -25,7 +25,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class RequestProcessorInitializer; class Statement; @@ -111,8 +111,8 @@ class Session bool is_closing_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Session, CassSession) +EXTERNAL_TYPE(datastax::internal::core::Session, CassSession) #endif diff --git a/cpp-driver/src/session_base.cpp b/cpp-driver/src/session_base.cpp index 2a0ecefde..03f6169f4 100644 --- a/cpp-driver/src/session_base.cpp +++ b/cpp-driver/src/session_base.cpp @@ -24,7 +24,9 @@ #include "utils.hpp" #include "uuids.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; class SessionFuture : public Future { public: @@ -53,7 +55,7 @@ SessionBase::~SessionBase() { Future::Ptr SessionBase::connect(const Config& config, const String& keyspace) { - cass::Future::Ptr future(new SessionFuture()); + Future::Ptr future(new SessionFuture()); ScopedMutex l(&mutex_); if (state_ != SESSION_STATE_CLOSED) { @@ -121,7 +123,7 @@ Future::Ptr SessionBase::connect(const Config& config, } Future::Ptr SessionBase::close() { - cass::Future::Ptr future(new SessionFuture()); + Future::Ptr future(new SessionFuture()); ScopedMutex l(&mutex_); if (state_ == SESSION_STATE_CLOSED || @@ -225,5 +227,3 @@ void SessionBase::on_initialize(ClusterConnector* connector) { } } } - -} // namespace cass diff --git a/cpp-driver/src/session_base.hpp b/cpp-driver/src/session_base.hpp index ffbe6384f..a99b26ba0 100644 --- a/cpp-driver/src/session_base.hpp +++ b/cpp-driver/src/session_base.hpp @@ -22,11 +22,14 @@ #include "schema_agreement_handler.hpp" #include "token_map.hpp" -namespace cass { +namespace datastax { namespace internal { -class ClusterConfig; class Random; +namespace core { + +class ClusterConfig; + /** * A base class for implementing a session. It manages the state machine for * connecting and closing a session. @@ -162,6 +165,6 @@ class SessionBase : public ClusterListener { CassUuid session_id_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/set.hpp b/cpp-driver/src/set.hpp index fb2876497..091b12eac 100644 --- a/cpp-driver/src/set.hpp +++ b/cpp-driver/src/set.hpp @@ -13,14 +13,14 @@ #include -namespace cass { +namespace datastax { namespace internal { template > class Set : public Allocated - , public std::set > { + , public std::set > { public: - typedef cass::Allocator Allocator; + typedef internal::Allocator Allocator; explicit Set(const Compare& compare = Compare(), const Allocator& alloc = Allocator()) @@ -36,6 +36,6 @@ class Set : std::set(first, last, compare, alloc) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/small_dense_hash_map.hpp b/cpp-driver/src/small_dense_hash_map.hpp index d7263ca73..5239cdc98 100644 --- a/cpp-driver/src/small_dense_hash_map.hpp +++ b/cpp-driver/src/small_dense_hash_map.hpp @@ -29,7 +29,7 @@ #define MIN_BUCKETS(N) STATIC_NEXT_POW_2((((N * 100) / OCCUPANCY_PCT) + 1)) -namespace cass { +namespace datastax { namespace internal { namespace core { // This hash map uses a fixed buffer as long as it doesn't exceed N items. // This can help to avoid heap allocation in cases where the hash map remains @@ -67,6 +67,6 @@ class SmallDenseHashMap DISALLOW_COPY_AND_ASSIGN(SmallDenseHashMap); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/small_vector.hpp b/cpp-driver/src/small_vector.hpp index a39b564b5..f24fd3bf7 100644 --- a/cpp-driver/src/small_vector.hpp +++ b/cpp-driver/src/small_vector.hpp @@ -21,7 +21,7 @@ #include -namespace cass { +namespace datastax { namespace internal { // This vector uses a fixed buffer as long as it doesn't exceed N items. // This can help to avoid heap allocation in cases where the vector remains @@ -49,6 +49,6 @@ class SmallVector : public std::vector > { DISALLOW_COPY_AND_ASSIGN(SmallVector); }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/socket.cpp b/cpp-driver/src/socket.cpp index 230da4ec0..5762ef865 100644 --- a/cpp-driver/src/socket.cpp +++ b/cpp-driver/src/socket.cpp @@ -25,7 +25,8 @@ #define MAX_BUFFER_REUSE_NO 8 #define BUFFER_REUSE_SIZE 64 * 1024 -namespace cass { +using namespace datastax::internal; +using namespace datastax::internal::core; typedef Vector UvBufVec; @@ -400,5 +401,3 @@ void Socket::cleanup_free_writes() { delete *i; } } - -} // namespace cass diff --git a/cpp-driver/src/socket.hpp b/cpp-driver/src/socket.hpp index c53ebc448..91010b31c 100644 --- a/cpp-driver/src/socket.hpp +++ b/cpp-driver/src/socket.hpp @@ -31,7 +31,7 @@ #define MIN_BUFFERS_SIZE 128 -namespace cass { +namespace datastax { namespace internal { namespace core { class Socket; class SocketWriteBase; @@ -199,7 +199,7 @@ class SocketWriteBase : public Allocated , public List::Node { public: - typedef cass::List List; + typedef internal::List List; /** * Constructor @@ -379,6 +379,6 @@ class Socket : public RefCounted { String address_string_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/socket_connector.cpp b/cpp-driver/src/socket_connector.cpp index edb696d8d..27146b7c9 100644 --- a/cpp-driver/src/socket_connector.cpp +++ b/cpp-driver/src/socket_connector.cpp @@ -21,7 +21,10 @@ #define SSL_HANDSHAKE_MAX_BUFFER_SIZE (16 * 1024 + 5) -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A socket handler that handles the SSL handshake process. @@ -62,6 +65,8 @@ class SslHandshakeHandler : public SocketHandler { SocketConnector* connector_; }; +} } } // namespace datastax::internal::core + SocketSettings::SocketSettings() : hostname_resolution_enabled(CASS_DEFAULT_HOSTNAME_RESOLUTION_ENABLED) , resolve_timeout_ms(CASS_DEFAULT_RESOLVE_TIMEOUT_MS) @@ -293,5 +298,3 @@ void SocketConnector::on_no_resolve(Timer* timer) { internal_connect(timer->loop()); } } - -} // namespace cass diff --git a/cpp-driver/src/socket_connector.hpp b/cpp-driver/src/socket_connector.hpp index b99976f26..662974e8a 100644 --- a/cpp-driver/src/socket_connector.hpp +++ b/cpp-driver/src/socket_connector.hpp @@ -22,7 +22,7 @@ #include "socket.hpp" #include "tcp_connector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Config; @@ -62,7 +62,7 @@ class SocketConnector : public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum SocketError { SOCKET_OK, @@ -168,6 +168,6 @@ class SocketConnector : public RefCounted { SocketSettings settings_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/speculative_execution.hpp b/cpp-driver/src/speculative_execution.hpp index 6f7238f6e..ccec31675 100644 --- a/cpp-driver/src/speculative_execution.hpp +++ b/cpp-driver/src/speculative_execution.hpp @@ -24,7 +24,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Request; @@ -100,6 +100,6 @@ class ConstantSpeculativeExecutionPolicy : public SpeculativeExecutionPolicy { const int max_speculative_executions_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/spin_lock.hpp b/cpp-driver/src/spin_lock.hpp index d42b9fb86..a07258820 100644 --- a/cpp-driver/src/spin_lock.hpp +++ b/cpp-driver/src/spin_lock.hpp @@ -20,7 +20,7 @@ #ifndef __CASS_SPINLOCK_HPP_INCLUDED__ #define __CASS_SPINLOCK_HPP_INCLUDED__ -namespace cass { +namespace datastax { namespace internal { namespace core { class Spinlock { public: @@ -96,6 +96,6 @@ struct SpinlockPool { template Spinlock SpinlockPool::spinlocks_[41]; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/spsc_queue.hpp b/cpp-driver/src/spsc_queue.hpp index 506175845..865f20b53 100644 --- a/cpp-driver/src/spsc_queue.hpp +++ b/cpp-driver/src/spsc_queue.hpp @@ -34,7 +34,7 @@ #include "scoped_ptr.hpp" #include "utils.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { template class SPSCQueue { @@ -101,6 +101,6 @@ class SPSCQueue { DISALLOW_COPY_AND_ASSIGN(SPSCQueue); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/ssl.cpp b/cpp-driver/src/ssl.cpp index 0f0769227..7ed19c38e 100644 --- a/cpp-driver/src/ssl.cpp +++ b/cpp-driver/src/ssl.cpp @@ -21,15 +21,17 @@ #include +using namespace datastax::internal::core; + extern "C" { CassSsl* cass_ssl_new() { - cass::SslContextFactory::init_once(); + SslContextFactory::init_once(); return cass_ssl_new_no_lib_init(); } CassSsl* cass_ssl_new_no_lib_init() { - cass::SslContext::Ptr ssl_context(cass::SslContextFactory::create()); + SslContext::Ptr ssl_context(SslContextFactory::create()); ssl_context->inc_ref(); return CassSsl::to(ssl_context.get()); } @@ -81,9 +83,5 @@ CassError cass_ssl_set_private_key_n(CassSsl* ssl, } // extern "C" -namespace cass { - template uv_once_t SslContextFactoryBase::ssl_init_guard = UV_ONCE_INIT; - -} // namespace cass diff --git a/cpp-driver/src/ssl.hpp b/cpp-driver/src/ssl.hpp index 50d29415d..158a45f87 100644 --- a/cpp-driver/src/ssl.hpp +++ b/cpp-driver/src/ssl.hpp @@ -28,7 +28,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class SslSession : public Allocated { public: @@ -141,7 +141,7 @@ void SslContextFactoryBase::cleanup() { T::internal_cleanup(); } -} // namespace cass +} } } // namespace datastax::internal::core #ifdef HAVE_OPENSSL #include "ssl/ssl_openssl_impl.hpp" @@ -149,6 +149,6 @@ void SslContextFactoryBase::cleanup() { #include "ssl/ssl_no_impl.hpp" #endif -EXTERNAL_TYPE(cass::SslContext, CassSsl) +EXTERNAL_TYPE(datastax::internal::core::SslContext, CassSsl) #endif diff --git a/cpp-driver/src/ssl/ring_buffer_bio.cpp b/cpp-driver/src/ssl/ring_buffer_bio.cpp index 0d96d4c20..a0eba8b9f 100644 --- a/cpp-driver/src/ssl/ring_buffer_bio.cpp +++ b/cpp-driver/src/ssl/ring_buffer_bio.cpp @@ -50,8 +50,7 @@ #define BIO_set_init(b, i) ((b)->init = i) #endif -namespace cass { -namespace rb { +using namespace datastax::internal::rb; #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) const BIO_METHOD RingBufferBio::method_ = { @@ -216,6 +215,3 @@ long RingBufferBio::ctrl(BIO* bio, int cmd, long num, void* ptr) { } return ret; } - -} // namespace rb -} // namespace cass diff --git a/cpp-driver/src/ssl/ring_buffer_bio.hpp b/cpp-driver/src/ssl/ring_buffer_bio.hpp index 64014045e..6b63ecddf 100644 --- a/cpp-driver/src/ssl/ring_buffer_bio.hpp +++ b/cpp-driver/src/ssl/ring_buffer_bio.hpp @@ -51,8 +51,7 @@ #define BIO_get_data(b) ((b)->ptr) #endif -namespace cass { -namespace rb { +namespace datastax { namespace internal { namespace rb { // This wrapper is used to contain the ring buffer state kept in the BIO's // user data field. OpenSSL 1.1 made the BIO's structure opaque which removed access @@ -97,7 +96,6 @@ class RingBufferBio { #endif }; -} // namespace rb -} // namespace cass +} } } // namespace datastax::internal::rb #endif diff --git a/cpp-driver/src/ssl/ssl_no_impl.cpp b/cpp-driver/src/ssl/ssl_no_impl.cpp index 3a9763cf5..d7426c12a 100644 --- a/cpp-driver/src/ssl/ssl_no_impl.cpp +++ b/cpp-driver/src/ssl/ssl_no_impl.cpp @@ -16,7 +16,8 @@ #include "ssl.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; NoSslSession::NoSslSession(const Address& address, const String& hostname) : SslSession(address, hostname, CASS_SSL_VERIFY_NONE) { @@ -24,30 +25,27 @@ NoSslSession::NoSslSession(const Address& address, const String& hostname) error_message_ = "SSL support not built into driver"; } -SslSession* cass::NoSslContext::create_session(const Address& address, const String& hostname) { +SslSession* NoSslContext::create_session(const Address& address, const String& hostname) { return new NoSslSession(address, hostname); } -CassError cass::NoSslContext::add_trusted_cert(const char* cert, - size_t cert_length) { +CassError NoSslContext::add_trusted_cert(const char* cert, + size_t cert_length) { return CASS_ERROR_LIB_NOT_IMPLEMENTED; } -CassError cass::NoSslContext::set_cert(const char* cert, - size_t cert_length) { +CassError NoSslContext::set_cert(const char* cert, + size_t cert_length) { return CASS_ERROR_LIB_NOT_IMPLEMENTED; } -CassError cass::NoSslContext::set_private_key(const char* key, - size_t key_length, - const char* password, - size_t password_length) { +CassError NoSslContext::set_private_key(const char* key, + size_t key_length, + const char* password, + size_t password_length) { return CASS_ERROR_LIB_NOT_IMPLEMENTED; } SslContext::Ptr NoSslContextFactory::create() { return SslContext::Ptr(new NoSslContext()); } - - -} // namespace cass diff --git a/cpp-driver/src/ssl/ssl_no_impl.hpp b/cpp-driver/src/ssl/ssl_no_impl.hpp index cd695aabe..f6213473c 100644 --- a/cpp-driver/src/ssl/ssl_no_impl.hpp +++ b/cpp-driver/src/ssl/ssl_no_impl.hpp @@ -17,7 +17,7 @@ #ifndef __CASS_SSL_NO_IMPL_HPP_INCLUDED__ #define __CASS_SSL_NO_IMPL_HPP_INCLUDED__ -namespace cass { +namespace datastax { namespace internal { namespace core { class NoSslSession : public SslSession { public: @@ -54,7 +54,6 @@ class NoSslContextFactory : public SslContextFactoryBase { typedef SslContextFactoryBase SslContextFactory; -} // namespace cass +} } } // namespace datastax::internal::core #endif - diff --git a/cpp-driver/src/ssl/ssl_openssl_impl.cpp b/cpp-driver/src/ssl/ssl_openssl_impl.cpp index 725e705e7..8f735cab0 100644 --- a/cpp-driver/src/ssl/ssl_openssl_impl.cpp +++ b/cpp-driver/src/ssl/ssl_openssl_impl.cpp @@ -36,7 +36,9 @@ #define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE SSL_F_USE_CERTIFICATE_CHAIN_FILE #endif -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; #if DEBUG_SSL #define SSL_PRINT_INFO(ssl, w, flag, msg) do { \ @@ -690,5 +692,3 @@ void OpenSslContextFactory::internal_cleanup() { rb::RingBufferBio::cleanup(); #endif } - -} // namespace cass diff --git a/cpp-driver/src/ssl/ssl_openssl_impl.hpp b/cpp-driver/src/ssl/ssl_openssl_impl.hpp index fe981bd1d..a037dc65c 100644 --- a/cpp-driver/src/ssl/ssl_openssl_impl.hpp +++ b/cpp-driver/src/ssl/ssl_openssl_impl.hpp @@ -23,7 +23,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class OpenSslSession : public SslSession { public: @@ -82,6 +82,6 @@ class OpenSslContextFactory : public SslContextFactoryBase SslContextFactory; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/stack.hpp b/cpp-driver/src/stack.hpp index db152dec6..d7ae87745 100644 --- a/cpp-driver/src/stack.hpp +++ b/cpp-driver/src/stack.hpp @@ -12,7 +12,7 @@ #include -namespace cass { +namespace datastax { namespace internal { template > class Stack : public std::stack { @@ -24,6 +24,6 @@ class Stack : public std::stack { : std::stack(other) { } }; -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/startup_request.cpp b/cpp-driver/src/startup_request.cpp index 866049560..bf932d494 100644 --- a/cpp-driver/src/startup_request.cpp +++ b/cpp-driver/src/startup_request.cpp @@ -17,7 +17,8 @@ #include "startup_request.hpp" #include "driver_info.hpp" -namespace cass { +using namespace datastax::internal; +using namespace datastax::internal::core; int StartupRequest::encode(ProtocolVersion version, RequestCallback* callback, @@ -53,5 +54,3 @@ int StartupRequest::encode(ProtocolVersion version, return length; } - -} // namespace cass diff --git a/cpp-driver/src/startup_request.hpp b/cpp-driver/src/startup_request.hpp index 6f64c17d3..d24c6e80d 100644 --- a/cpp-driver/src/startup_request.hpp +++ b/cpp-driver/src/startup_request.hpp @@ -23,7 +23,7 @@ #include "scoped_ptr.hpp" #include "string.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class StartupRequest : public Request { public: @@ -56,6 +56,6 @@ class StartupRequest : public Request { bool no_compact_enabled_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/statement.cpp b/cpp-driver/src/statement.cpp index 65a423adc..2affee1bf 100644 --- a/cpp-driver/src/statement.cpp +++ b/cpp-driver/src/statement.cpp @@ -31,6 +31,10 @@ #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { CassStatement* cass_statement_new(const char* query, @@ -41,8 +45,8 @@ CassStatement* cass_statement_new(const char* query, CassStatement* cass_statement_new_n(const char* query, size_t query_length, size_t parameter_count) { - cass::QueryRequest* query_request - = new cass::QueryRequest(query, query_length, parameter_count); + QueryRequest* query_request + = new QueryRequest(query, query_length, parameter_count); query_request->inc_ref(); return CassStatement::to(query_request); } @@ -70,7 +74,7 @@ CassError cass_statement_set_keyspace_n(CassStatement* statement, if (statement->opcode() == CQL_OPCODE_EXECUTE) { return CASS_ERROR_LIB_BAD_PARAMS; } - statement->set_keyspace(cass::String(keyspace, keyspace_length)); + statement->set_keyspace(String(keyspace, keyspace_length)); return CASS_OK; } @@ -103,9 +107,9 @@ CassError cass_statement_set_paging_state(CassStatement* statement, } CassError cass_statement_set_paging_state_token(CassStatement* statement, - const char* paging_state, - size_t paging_state_size) { - statement->set_paging_state(cass::String(paging_state, paging_state_size)); + const char* paging_state, + size_t paging_state_size) { + statement->set_paging_state(String(paging_state, paging_state_size)); return CASS_OK; } @@ -150,9 +154,9 @@ CassError cass_statement_set_execution_profile_n(CassStatement* statement, const char* name, size_t name_length) { if (name_length > 0) { - statement->set_execution_profile_name(cass::String(name, name_length)); + statement->set_execution_profile_name(String(name, name_length)); } else { - statement->set_execution_profile_name(cass::String()); + statement->set_execution_profile_name(String()); } return CASS_OK; } @@ -173,10 +177,10 @@ CassError cass_statement_set_host_n(CassStatement* statement, const char* host, size_t host_length, int port) { - cass::Address address; - if (!cass::Address::from_string(cass::String(host, host_length), - port, - &address)) { + Address address; + if (!Address::from_string(String(host, host_length), + port, + &address)) { return CASS_ERROR_LIB_BAD_PARAMS; } statement->set_host(address); @@ -186,10 +190,10 @@ CassError cass_statement_set_host_n(CassStatement* statement, CassError cass_statement_set_host_inet(CassStatement* statement, const CassInet* host, int port) { - cass::Address address; - if (!cass::Address::from_inet(host->address, - host->address_length, - port, &address)) { + Address address; + if (!Address::from_inet(host->address, + host->address_length, + port, &address)) { return CASS_ERROR_LIB_BAD_PARAMS; } statement->set_host(address); @@ -198,20 +202,20 @@ CassError cass_statement_set_host_inet(CassStatement* statement, #define CASS_STATEMENT_BIND(Name, Params, Value) \ CassError cass_statement_bind_##Name(CassStatement* statement, \ - size_t index Params) { \ - return statement->set(index, Value); \ - } \ + size_t index Params) { \ + return statement->set(index, Value); \ +} \ CassError cass_statement_bind_##Name##_by_name(CassStatement* statement, \ - const char* name Params) { \ - return statement->set(cass::StringRef(name), Value); \ - } \ + const char* name Params) { \ + return statement->set(StringRef(name), Value); \ +} \ CassError cass_statement_bind_##Name##_by_name_n(CassStatement* statement, \ - const char* name, \ - size_t name_length Params) { \ - return statement->set(cass::StringRef(name, name_length), Value); \ - } + const char* name, \ + size_t name_length Params) { \ + return statement->set(StringRef(name, name_length), Value); \ +} -CASS_STATEMENT_BIND(null, ZERO_PARAMS_(), cass::CassNull()) +CASS_STATEMENT_BIND(null, ZERO_PARAMS_(), CassNull()) CASS_STATEMENT_BIND(int8, ONE_PARAM_(cass_int8_t value), value) CASS_STATEMENT_BIND(int16, ONE_PARAM_(cass_int16_t value), value) CASS_STATEMENT_BIND(int32, ONE_PARAM_(cass_int32_t value), value) @@ -227,13 +231,13 @@ CASS_STATEMENT_BIND(tuple, ONE_PARAM_(const CassTuple* value), value->from()) CASS_STATEMENT_BIND(user_type, ONE_PARAM_(const CassUserType* value), value->from()) CASS_STATEMENT_BIND(bytes, TWO_PARAMS_(const cass_byte_t* value, size_t value_size), - cass::CassBytes(value, value_size)) + CassBytes(value, value_size)) CASS_STATEMENT_BIND(decimal, THREE_PARAMS_(const cass_byte_t* varint, size_t varint_size, int scale), - cass::CassDecimal(varint, varint_size, scale)) + CassDecimal(varint, varint_size, scale)) CASS_STATEMENT_BIND(duration, THREE_PARAMS_(cass_int32_t months, cass_int32_t days, cass_int64_t nanos), - cass::CassDuration(months, days, nanos)) + CassDuration(months, days, nanos)) #undef CASS_STATEMENT_BIND @@ -245,14 +249,14 @@ CassError cass_statement_bind_string(CassStatement* statement, size_t index, CassError cass_statement_bind_string_n(CassStatement* statement, size_t index, const char* value, size_t value_length) { - return statement->set(index, cass::CassString(value, value_length)); + return statement->set(index, CassString(value, value_length)); } CassError cass_statement_bind_string_by_name(CassStatement* statement, const char* name, const char* value) { - return statement->set(cass::StringRef(name), - cass::CassString(value, SAFE_STRLEN(value))); + return statement->set(StringRef(name), + CassString(value, SAFE_STRLEN(value))); } CassError cass_statement_bind_string_by_name_n(CassStatement* statement, @@ -260,8 +264,8 @@ CassError cass_statement_bind_string_by_name_n(CassStatement* statement, size_t name_length, const char* value, size_t value_length) { - return statement->set(cass::StringRef(name, name_length), - cass::CassString(value, SAFE_STRLEN(value))); + return statement->set(StringRef(name, name_length), + CassString(value, SAFE_STRLEN(value))); } CassError cass_statement_bind_custom(CassStatement* statement, @@ -270,8 +274,8 @@ CassError cass_statement_bind_custom(CassStatement* statement, const cass_byte_t* value, size_t value_size) { return statement->set(index, - cass::CassCustom(cass::StringRef(class_name), - value, value_size)); + CassCustom(StringRef(class_name), + value, value_size)); } CassError cass_statement_bind_custom_n(CassStatement* statement, @@ -281,8 +285,8 @@ CassError cass_statement_bind_custom_n(CassStatement* statement, const cass_byte_t* value, size_t value_size) { return statement->set(index, - cass::CassCustom(cass::StringRef(class_name, class_name_length), - value, value_size)); + CassCustom(StringRef(class_name, class_name_length), + value, value_size)); } CassError cass_statement_bind_custom_by_name(CassStatement* statement, @@ -290,9 +294,9 @@ CassError cass_statement_bind_custom_by_name(CassStatement* statement, const char* class_name, const cass_byte_t* value, size_t value_size) { - return statement->set(cass::StringRef(name), - cass::CassCustom(cass::StringRef(class_name), - value, value_size)); + return statement->set(StringRef(name), + CassCustom(StringRef(class_name), + value, value_size)); } CassError cass_statement_bind_custom_by_name_n(CassStatement* statement, @@ -302,15 +306,13 @@ CassError cass_statement_bind_custom_by_name_n(CassStatement* statement, size_t class_name_length, const cass_byte_t* value, size_t value_size) { - return statement->set(cass::StringRef(name, name_length), - cass::CassCustom(cass::StringRef(class_name, class_name_length), - value, value_size)); + return statement->set(StringRef(name, name_length), + CassCustom(StringRef(class_name, class_name_length), + value, value_size)); } } // extern "C" -namespace cass { - Statement::Statement(const char* query, size_t query_length, size_t values_count) : RoutableRequest(CQL_OPCODE_QUERY) , AbstractData(values_count) @@ -483,7 +485,7 @@ int32_t Statement::encode_values(ProtocolVersion version, RequestCallback* callb bufs->push_back(element.get_buffer()); } else { if (version >= CASS_PROTOCOL_VERSION_V4) { - bufs->push_back(cass::encode_with_length(CassUnset())); + bufs->push_back(core::encode_with_length(CassUnset())); } else { OStringStream ss; ss << "Query parameter at index " << i << " was not set"; @@ -605,5 +607,3 @@ bool Statement::calculate_routing_key(const Vector& key_indices, String* return true; } - -} // namespace cass diff --git a/cpp-driver/src/statement.hpp b/cpp-driver/src/statement.hpp index c6ef354a9..5eecbac84 100644 --- a/cpp-driver/src/statement.hpp +++ b/cpp-driver/src/statement.hpp @@ -30,7 +30,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class RequestCallback; @@ -107,8 +107,8 @@ class Statement : public RoutableRequest, public AbstractData { DISALLOW_COPY_AND_ASSIGN(Statement); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Statement, CassStatement) +EXTERNAL_TYPE(datastax::internal::core::Statement, CassStatement) #endif diff --git a/cpp-driver/src/stream_manager.hpp b/cpp-driver/src/stream_manager.hpp index bc1d81dcc..a45c0c44f 100644 --- a/cpp-driver/src/stream_manager.hpp +++ b/cpp-driver/src/stream_manager.hpp @@ -30,7 +30,7 @@ #include #endif -namespace cass { +namespace datastax { namespace internal { namespace core { struct StreamHash { std::size_t operator()(int stream) const { @@ -151,6 +151,6 @@ class StreamManager { DISALLOW_COPY_AND_ASSIGN(StreamManager); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/string.hpp b/cpp-driver/src/string.hpp index f8a4e7636..6b45141a4 100644 --- a/cpp-driver/src/string.hpp +++ b/cpp-driver/src/string.hpp @@ -16,9 +16,11 @@ #include #include -namespace cass { +namespace datastax { -typedef std::basic_string, cass::Allocator > String; +typedef std::basic_string, internal::Allocator > String; + +namespace internal { class OStringStream : public std::basic_ostream > { @@ -28,7 +30,7 @@ class OStringStream : public std::basic_ostream > typedef traits_type::int_type int_type; typedef traits_type::pos_type pos_type; typedef traits_type::off_type off_type; - typedef cass::Allocator allocator_type; + typedef internal::Allocator allocator_type; typedef std::basic_string string_type; @@ -51,7 +53,7 @@ class OStringStream : public std::basic_ostream > void str(const string_type& str) { sb_.str(str); } private: - std::basic_stringbuf, cass::Allocator > sb_; + std::basic_stringbuf, internal::Allocator > sb_; }; class IStringStream : public std::basic_istream > @@ -62,7 +64,7 @@ class IStringStream : public std::basic_istream > typedef traits_type::int_type int_type; typedef traits_type::pos_type pos_type; typedef traits_type::off_type off_type; - typedef cass::Allocator allocator_type; + typedef internal::Allocator allocator_type; typedef std::basic_string string_type; @@ -85,10 +87,10 @@ class IStringStream : public std::basic_istream > void str(const string_type& str) { sb_.str(str); } private: - std::basic_stringbuf, cass::Allocator > sb_; + std::basic_stringbuf, internal::Allocator > sb_; }; -} // namepsace cass +} } // namepsace datastax::internal namespace std { @@ -97,9 +99,9 @@ namespace tr1 { #endif template <> -struct hash { - size_t operator()(const cass::String& str) const { - return cass::hash::fnv1a(str.data(), str.size()); +struct hash { + size_t operator()(const datastax::String& str) const { + return datastax::hash::fnv1a(str.data(), str.size()); } }; diff --git a/cpp-driver/src/string_ref.cpp b/cpp-driver/src/string_ref.cpp index 1fc6ac905..7e1e17352 100644 --- a/cpp-driver/src/string_ref.cpp +++ b/cpp-driver/src/string_ref.cpp @@ -16,9 +16,8 @@ #include "string_ref.hpp" -namespace cass { +namespace datastax { const StringRef::size_type StringRef::npos = -1; -} // namespace cass - +} // namespace datastax diff --git a/cpp-driver/src/string_ref.hpp b/cpp-driver/src/string_ref.hpp index b605bcd00..ecaa7a975 100644 --- a/cpp-driver/src/string_ref.hpp +++ b/cpp-driver/src/string_ref.hpp @@ -28,7 +28,7 @@ #include #include -namespace cass { +namespace datastax { template int compare(const char* s1, const char* s2, @@ -147,15 +147,15 @@ class StringRef { } else if(length_ > ref.length_) { return 1; } - return cass::compare(ptr_, ref.ptr_, length_, is_equal); + return datastax::compare(ptr_, ref.ptr_, length_, is_equal); } const char* ptr_; size_t length_; }; -typedef Vector StringVec; -typedef Vector StringRefVec; +typedef internal::Vector StringVec; +typedef internal::Vector StringRefVec; inline StringVec to_strings(const StringRefVec& refs) { StringVec strings; @@ -170,14 +170,14 @@ inline StringVec to_strings(const StringRefVec& refs) { inline bool starts_with(const StringRef& input, const StringRef& target) { return input.length() >= target.length() && - cass::compare(input.data(), target.data(), target.size(), - StringRef::IsEqual()) == 0; + compare(input.data(), target.data(), target.size(), + StringRef::IsEqual()) == 0; } inline bool ends_with(const StringRef& input, const StringRef& target) { return input.length() >= target.length() && - cass::compare(input.data() + (input.length() - target.length()), - target.data(), target.size(), StringRef::IsEqual()) == 0; + compare(input.data() + (input.length() - target.length()), + target.data(), target.size(), StringRef::IsEqual()) == 0; } inline bool iequals(const StringRef& lhs, const StringRef& rhs) { @@ -196,6 +196,6 @@ struct StringRefIEquals { } }; -} // namespace cass +} // namespace datastax #endif diff --git a/cpp-driver/src/supported_response.cpp b/cpp-driver/src/supported_response.cpp index 787b38e5c..daba03728 100644 --- a/cpp-driver/src/supported_response.cpp +++ b/cpp-driver/src/supported_response.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; bool SupportedResponse::decode(Decoder& decoder) { decoder.set_type("supported"); @@ -43,5 +43,3 @@ bool SupportedResponse::decode(Decoder& decoder) { } return true; } - -} // namespace cass diff --git a/cpp-driver/src/supported_response.hpp b/cpp-driver/src/supported_response.hpp index d0b1b6be2..8bc475b9d 100644 --- a/cpp-driver/src/supported_response.hpp +++ b/cpp-driver/src/supported_response.hpp @@ -22,7 +22,7 @@ #include "string.hpp" #include "vector.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class SupportedResponse : public Response { public: @@ -41,6 +41,6 @@ class SupportedResponse : public Response { Vector protocol_versions_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/tcp_connector.hpp b/cpp-driver/src/tcp_connector.hpp index 447be4a81..4bc2dc7a4 100644 --- a/cpp-driver/src/tcp_connector.hpp +++ b/cpp-driver/src/tcp_connector.hpp @@ -23,7 +23,7 @@ #include "callback.hpp" #include "ref_counted.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A wrapper for uv_connect that handles connecting a TCP connection. @@ -32,7 +32,7 @@ class TcpConnector : public RefCounted { public: typedef SharedRefPtr Ptr; - typedef cass::Callback Callback; + typedef internal::Callback Callback; enum Status { NEW, @@ -125,6 +125,6 @@ class TcpConnector : public RefCounted { int uv_status_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/testing.cpp b/cpp-driver/src/testing.cpp index 7c2be1b28..6ee6c242a 100644 --- a/cpp-driver/src/testing.cpp +++ b/cpp-driver/src/testing.cpp @@ -28,14 +28,16 @@ #include "result_response.hpp" #include "session.hpp" -namespace cass { +namespace datastax { namespace internal { namespace testing { + +using namespace core; String get_host_from_future(CassFuture* future) { - if (future->type() != cass::Future::FUTURE_TYPE_RESPONSE) { + if (future->type() != Future::FUTURE_TYPE_RESPONSE) { return ""; } - cass::ResponseFuture* response_future = - static_cast(future->from()); + ResponseFuture* response_future = + static_cast(future->from()); return response_future->address().to_string(); } @@ -70,7 +72,7 @@ int64_t create_murmur3_hash_from_string(const String &value) { } uint64_t get_time_since_epoch_in_ms() { - return cass::get_time_since_epoch_ms(); + return internal::get_time_since_epoch_ms(); } uint64_t get_host_latency_average(CassSession* session, String ip_address, int port) { @@ -82,4 +84,4 @@ uint64_t get_host_latency_average(CassSession* session, String ip_address, int p return 0; } -} // namespace cass +} } } // namespace datastax::internal::testing diff --git a/cpp-driver/src/testing.hpp b/cpp-driver/src/testing.hpp index 30325796d..bfc4c53fe 100644 --- a/cpp-driver/src/testing.hpp +++ b/cpp-driver/src/testing.hpp @@ -23,7 +23,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace testing { CASS_EXPORT String get_host_from_future(CassFuture* future); @@ -39,6 +39,6 @@ CASS_EXPORT uint64_t get_time_since_epoch_in_ms(); CASS_EXPORT uint64_t get_host_latency_average(CassSession* session, String ip_address, int port); -} // namespace cass +} } } // namespace datastax::internal::testing #endif diff --git a/cpp-driver/src/third_party/curl/hostcheck.hpp b/cpp-driver/src/third_party/curl/hostcheck.hpp index 989270730..f909472a3 100644 --- a/cpp-driver/src/third_party/curl/hostcheck.hpp +++ b/cpp-driver/src/third_party/curl/hostcheck.hpp @@ -27,4 +27,3 @@ int Curl_cert_hostcheck(const char *match_pattern, const char *hostname); #endif /* HEADER_CURL_HOSTCHECK_H */ - diff --git a/cpp-driver/src/timer.cpp b/cpp-driver/src/timer.cpp index c5039aac9..03a15739d 100644 --- a/cpp-driver/src/timer.cpp +++ b/cpp-driver/src/timer.cpp @@ -16,7 +16,7 @@ #include "timer.hpp" -namespace cass { +using namespace datastax::internal::core; Timer::Timer() : handle_(NULL) @@ -70,5 +70,3 @@ void Timer::handle_timeout() { void Timer::on_close(uv_handle_t* handle) { delete reinterpret_cast*>(handle); } - -} // namespace cass diff --git a/cpp-driver/src/timer.hpp b/cpp-driver/src/timer.hpp index b1d6a7ce1..b9ff0aa6d 100644 --- a/cpp-driver/src/timer.hpp +++ b/cpp-driver/src/timer.hpp @@ -23,11 +23,11 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class Timer { public: - typedef cass::Callback Callback; + typedef internal::Callback Callback; Timer(); ~Timer(); @@ -61,6 +61,6 @@ class Timer { DISALLOW_COPY_AND_ASSIGN(Timer); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/timestamp_generator.cpp b/cpp-driver/src/timestamp_generator.cpp index 758df3037..41a1765f1 100644 --- a/cpp-driver/src/timestamp_generator.cpp +++ b/cpp-driver/src/timestamp_generator.cpp @@ -20,25 +20,27 @@ #include "get_time.hpp" #include "logger.hpp" +using namespace datastax::internal::core; + extern "C" { CassTimestampGen* cass_timestamp_gen_server_side_new() { - cass::TimestampGenerator* timestamp_gen = new cass::ServerSideTimestampGenerator(); + TimestampGenerator* timestamp_gen = new ServerSideTimestampGenerator(); timestamp_gen->inc_ref(); return CassTimestampGen::to(timestamp_gen); } CassTimestampGen* cass_timestamp_gen_monotonic_new() { - cass::TimestampGenerator* timestamp_gen = new cass::MonotonicTimestampGenerator(); + TimestampGenerator* timestamp_gen = new MonotonicTimestampGenerator(); timestamp_gen->inc_ref(); return CassTimestampGen::to(timestamp_gen); } CassTimestampGen* cass_timestamp_gen_monotonic_new_with_settings(int64_t warning_threshold_us, int64_t warning_interval_ms) { - cass::TimestampGenerator* timestamp_gen - = new cass::MonotonicTimestampGenerator(warning_threshold_us, - warning_interval_ms); + TimestampGenerator* timestamp_gen + = new MonotonicTimestampGenerator(warning_threshold_us, + warning_interval_ms); timestamp_gen->inc_ref(); return CassTimestampGen::to(timestamp_gen); } @@ -49,8 +51,6 @@ void cass_timestamp_gen_free(CassTimestampGen* timestamp_gen) { } // extern "C" -namespace cass { - int64_t MonotonicTimestampGenerator::next() { while (true) { int64_t last = last_.load(); @@ -91,5 +91,3 @@ int64_t MonotonicTimestampGenerator::compute_next(int64_t last) { return current; } - -} // namespace cass diff --git a/cpp-driver/src/timestamp_generator.hpp b/cpp-driver/src/timestamp_generator.hpp index 5fb754494..102438b5c 100644 --- a/cpp-driver/src/timestamp_generator.hpp +++ b/cpp-driver/src/timestamp_generator.hpp @@ -26,7 +26,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { class TimestampGenerator : public RefCounted { public: @@ -84,9 +84,8 @@ class MonotonicTimestampGenerator : public TimestampGenerator { const int64_t warning_interval_ms_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::TimestampGenerator, CassTimestampGen) +EXTERNAL_TYPE(datastax::internal::core::TimestampGenerator, CassTimestampGen) #endif - diff --git a/cpp-driver/src/token_aware_policy.cpp b/cpp-driver/src/token_aware_policy.cpp index 56d71ce7f..90301599d 100644 --- a/cpp-driver/src/token_aware_policy.cpp +++ b/cpp-driver/src/token_aware_policy.cpp @@ -21,7 +21,9 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; // The number of replicas is bounded by replication factor per DC. In practice, the number // of replicas is fairly small so a linear search should be extremely fast. @@ -109,5 +111,3 @@ Host::Ptr TokenAwarePolicy::TokenAwareQueryPlan::compute_next() { } return Host::Ptr(); } - -} // namespace cass diff --git a/cpp-driver/src/token_aware_policy.hpp b/cpp-driver/src/token_aware_policy.hpp index 9fbe09fcb..8aabce16b 100644 --- a/cpp-driver/src/token_aware_policy.hpp +++ b/cpp-driver/src/token_aware_policy.hpp @@ -22,7 +22,7 @@ #include "host.hpp" #include "scoped_ptr.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class TokenAwarePolicy : public ChainedLoadBalancingPolicy { public: @@ -74,6 +74,6 @@ class TokenAwarePolicy : public ChainedLoadBalancingPolicy { private: DISALLOW_COPY_AND_ASSIGN(TokenAwarePolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/token_map.cpp b/cpp-driver/src/token_map.cpp index db7ac7d73..b7a113d54 100644 --- a/cpp-driver/src/token_map.cpp +++ b/cpp-driver/src/token_map.cpp @@ -18,7 +18,8 @@ #include "token_map_impl.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; TokenMap::Ptr TokenMap::from_partitioner(StringRef partitioner) { if (ends_with(partitioner, Murmur3Partitioner::name())) { @@ -32,5 +33,3 @@ TokenMap::Ptr TokenMap::from_partitioner(StringRef partitioner) { return Ptr(); } } - -} // namespace cass diff --git a/cpp-driver/src/token_map.hpp b/cpp-driver/src/token_map.hpp index 5a077584a..e19097140 100644 --- a/cpp-driver/src/token_map.hpp +++ b/cpp-driver/src/token_map.hpp @@ -20,13 +20,13 @@ #include "host.hpp" #include "ref_counted.hpp" #include "string.hpp" +#include "string_ref.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class VersionNumber; class Value; class ResultResponse; -class StringRef; class TokenMap : public RefCounted { public: @@ -52,6 +52,6 @@ class TokenMap : public RefCounted { const String& routing_key) const = 0; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/token_map_impl.cpp b/cpp-driver/src/token_map_impl.cpp index 73018c59e..36246dd50 100644 --- a/cpp-driver/src/token_map_impl.cpp +++ b/cpp-driver/src/token_map_impl.cpp @@ -19,7 +19,8 @@ #include "md5.hpp" #include "murmur3.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; static int64_t parse_int64(const char* p, size_t n) { int c; @@ -151,5 +152,3 @@ ByteOrderedPartitioner::Token ByteOrderedPartitioner::hash(const StringRef& str) const uint8_t* data = reinterpret_cast(str.data()); return Token(data, data + str.size()); } - -} // namespace cass diff --git a/cpp-driver/src/token_map_impl.hpp b/cpp-driver/src/token_map_impl.hpp index 0690229c6..b4cd08f30 100644 --- a/cpp-driver/src/token_map_impl.hpp +++ b/cpp-driver/src/token_map_impl.hpp @@ -42,8 +42,8 @@ namespace std { template<> -struct equal_to { - bool operator()(const cass::Host::Ptr& lhs, const cass::Host::Ptr& rhs) const { +struct equal_to { + bool operator()(const datastax::internal::core::Host::Ptr& lhs, const datastax::internal::core::Host::Ptr& rhs) const { if (lhs == rhs) { return true; } @@ -56,10 +56,10 @@ struct equal_to { } // namespace std -namespace cass { +namespace datastax { namespace internal { namespace core { struct HostHash { - std::size_t operator()(const cass::Host::Ptr& host) const { + std::size_t operator()(const Host::Ptr& host) const { if (!host) return 0; return hash(host->address()); } @@ -785,6 +785,6 @@ void TokenMapImpl::build_replicas() { } } -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/tracing_data_handler.cpp b/cpp-driver/src/tracing_data_handler.cpp index 517c7236f..cfbb6d6aa 100644 --- a/cpp-driver/src/tracing_data_handler.cpp +++ b/cpp-driver/src/tracing_data_handler.cpp @@ -19,7 +19,8 @@ #include "query_request.hpp" #include "result_iterator.hpp" -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; TracingDataHandler::TracingDataHandler(const RequestHandler::Ptr& request_handler, const Host::Ptr& current_host, @@ -76,5 +77,3 @@ void TracingDataHandler::on_error(WaitForHandler::WaitForError code, const Strin break; } } - -} // namespace cass diff --git a/cpp-driver/src/tracing_data_handler.hpp b/cpp-driver/src/tracing_data_handler.hpp index d005295bb..d9f604fe1 100644 --- a/cpp-driver/src/tracing_data_handler.hpp +++ b/cpp-driver/src/tracing_data_handler.hpp @@ -24,7 +24,7 @@ #define SELECT_TRACES_SESSION \ "SELECT session_id FROM system_traces.sessions WHERE session_id = ?" -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A handler that waits for tracing data to become available for a specified @@ -69,6 +69,6 @@ class TracingDataHandler : public WaitForHandler { CassConsistency consistency_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/tuple.cpp b/cpp-driver/src/tuple.cpp index 9b2ea37f4..4aa74f81e 100644 --- a/cpp-driver/src/tuple.cpp +++ b/cpp-driver/src/tuple.cpp @@ -25,10 +25,13 @@ #include +using namespace datastax; +using namespace datastax::internal::core; + extern "C" { CassTuple* cass_tuple_new(size_t item_count) { - return CassTuple::to(new cass::Tuple(item_count)); + return CassTuple::to(new Tuple(item_count)); } CassTuple* cass_tuple_new_from_data_type(const CassDataType* data_type) { @@ -36,8 +39,8 @@ CassTuple* cass_tuple_new_from_data_type(const CassDataType* data_type) { return NULL; } return CassTuple::to( - new cass::Tuple( - cass::DataType::ConstPtr(data_type))); + new Tuple( + DataType::ConstPtr(data_type))); } void cass_tuple_free(CassTuple* tuple) { @@ -53,7 +56,7 @@ const CassDataType* cass_tuple_data_type(const CassTuple* tuple) { return tuple->set(index, Value); \ } -CASS_TUPLE_SET(null, ZERO_PARAMS_(), cass::CassNull()) +CASS_TUPLE_SET(null, ZERO_PARAMS_(), CassNull()) CASS_TUPLE_SET(int8, ONE_PARAM_(cass_int8_t value), value) CASS_TUPLE_SET(int16, ONE_PARAM_(cass_int16_t value), value) CASS_TUPLE_SET(int32, ONE_PARAM_(cass_int32_t value), value) @@ -69,27 +72,27 @@ CASS_TUPLE_SET(tuple, ONE_PARAM_(const CassTuple* value), value) CASS_TUPLE_SET(user_type, ONE_PARAM_(const CassUserType* value), value) CASS_TUPLE_SET(bytes, TWO_PARAMS_(const cass_byte_t* value, size_t value_size), - cass::CassBytes(value, value_size)) + CassBytes(value, value_size)) CASS_TUPLE_SET(decimal, THREE_PARAMS_(const cass_byte_t* varint, size_t varint_size, int scale), - cass::CassDecimal(varint, varint_size, scale)) + CassDecimal(varint, varint_size, scale)) CASS_TUPLE_SET(duration, THREE_PARAMS_(cass_int32_t months, cass_int32_t days, cass_int64_t nanos), - cass::CassDuration(months, days, nanos)) + CassDuration(months, days, nanos)) #undef CASS_TUPLE_SET CassError cass_tuple_set_string(CassTuple* tuple, size_t index, const char* value) { - return tuple->set(index, cass::CassString(value, SAFE_STRLEN(value))); + return tuple->set(index, CassString(value, SAFE_STRLEN(value))); } CassError cass_tuple_set_string_n(CassTuple* tuple, size_t index, const char* value, size_t value_length) { - return tuple->set(index, cass::CassString(value, value_length)); + return tuple->set(index, CassString(value, value_length)); } CassError cass_tuple_set_custom(CassTuple* tuple, @@ -98,8 +101,8 @@ CassError cass_tuple_set_custom(CassTuple* tuple, const cass_byte_t* value, size_t value_size) { return tuple->set(index, - cass::CassCustom(cass::StringRef(class_name), - value, value_size)); + CassCustom(StringRef(class_name), + value, value_size)); } CassError cass_tuple_set_custom_n(CassTuple* tuple, @@ -109,17 +112,15 @@ CassError cass_tuple_set_custom_n(CassTuple* tuple, const cass_byte_t* value, size_t value_size) { return tuple->set(index, - cass::CassCustom(cass::StringRef(class_name, class_name_length), - value, value_size)); + CassCustom(StringRef(class_name, class_name_length), + value, value_size)); } } // extern "C" -namespace cass { - CassError Tuple::set(size_t index, CassNull value) { CASS_TUPLE_CHECK_INDEX_AND_TYPE(index, value); - items_[index] = cass::encode_with_length(value); + items_[index] = core::encode_with_length(value); return CASS_OK; } @@ -180,5 +181,3 @@ void Tuple::encode_buffers(size_t pos, Buffer* buf) const { } } } - -} // namespace cass diff --git a/cpp-driver/src/tuple.hpp b/cpp-driver/src/tuple.hpp index 943644f5c..af527223a 100644 --- a/cpp-driver/src/tuple.hpp +++ b/cpp-driver/src/tuple.hpp @@ -31,7 +31,7 @@ if (rc != CASS_OK) return rc; \ } while(0) -namespace cass { +namespace datastax { namespace internal { namespace core { class Collection; class UserTypeValue; @@ -52,7 +52,7 @@ class Tuple : public Allocated { #define SET_TYPE(Type) \ CassError set(size_t index, const Type value) { \ CASS_TUPLE_CHECK_INDEX_AND_TYPE(index, value); \ - items_[index] = cass::encode_with_length(value); \ + items_[index] = core::encode_with_length(value); \ return CASS_OK; \ } @@ -109,9 +109,8 @@ class Tuple : public Allocated { DISALLOW_COPY_AND_ASSIGN(Tuple); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Tuple, CassTuple) +EXTERNAL_TYPE(datastax::internal::core::Tuple, CassTuple) #endif - diff --git a/cpp-driver/src/types.hpp b/cpp-driver/src/types.hpp index 14b3ecf2b..dc8d2d648 100644 --- a/cpp-driver/src/types.hpp +++ b/cpp-driver/src/types.hpp @@ -20,7 +20,7 @@ #include "cassandra.h" #include "string_ref.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { struct CassNull { }; @@ -74,6 +74,6 @@ struct CassDuration { cass_int64_t nanos; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/user_type_field_iterator.cpp b/cpp-driver/src/user_type_field_iterator.cpp index 699218305..6bc4a2d93 100644 --- a/cpp-driver/src/user_type_field_iterator.cpp +++ b/cpp-driver/src/user_type_field_iterator.cpp @@ -18,7 +18,7 @@ #include "serialization.hpp" -namespace cass { +using namespace datastax::internal::core; bool UserTypeFieldIterator::next() { if (next_ == end_) { @@ -27,5 +27,3 @@ bool UserTypeFieldIterator::next() { current_ = next_++; return decoder_.decode_value(current_->type, value_); } - -} // namespace cass diff --git a/cpp-driver/src/user_type_field_iterator.hpp b/cpp-driver/src/user_type_field_iterator.hpp index a93c4ae8e..f7b333eac 100644 --- a/cpp-driver/src/user_type_field_iterator.hpp +++ b/cpp-driver/src/user_type_field_iterator.hpp @@ -23,7 +23,7 @@ #include "serialization.hpp" #include "value.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class UserTypeFieldIterator : public Iterator { public: @@ -56,6 +56,6 @@ class UserTypeFieldIterator : public Iterator { Value value_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/user_type_value.cpp b/cpp-driver/src/user_type_value.cpp index e42ecd640..4cae0b9fd 100644 --- a/cpp-driver/src/user_type_value.cpp +++ b/cpp-driver/src/user_type_value.cpp @@ -24,6 +24,10 @@ #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { CassUserType* cass_user_type_new_from_data_type(const CassDataType* data_type) { @@ -31,8 +35,8 @@ CassUserType* cass_user_type_new_from_data_type(const CassDataType* data_type) { return NULL; } return CassUserType::to( - new cass::UserTypeValue( - cass::DataType::ConstPtr(data_type))); + new UserTypeValue( + DataType::ConstPtr(data_type))); } void cass_user_type_free(CassUserType* user_type) { @@ -50,15 +54,15 @@ const CassDataType* cass_user_type_data_type(const CassUserType* user_type) { } \ CassError cass_user_type_set_##Name##_by_name(CassUserType* user_type, \ const char* name Params) { \ - return user_type->set(cass::StringRef(name), Value); \ + return user_type->set(StringRef(name), Value); \ } \ CassError cass_user_type_set_##Name##_by_name_n(CassUserType* user_type, \ const char* name, \ size_t name_length Params) { \ - return user_type->set(cass::StringRef(name, name_length), Value); \ + return user_type->set(StringRef(name, name_length), Value); \ } -CASS_USER_TYPE_SET(null, ZERO_PARAMS_(), cass::CassNull()) +CASS_USER_TYPE_SET(null, ZERO_PARAMS_(), CassNull()) CASS_USER_TYPE_SET(int8, ONE_PARAM_(cass_int8_t value), value) CASS_USER_TYPE_SET(int16, ONE_PARAM_(cass_int16_t value), value) CASS_USER_TYPE_SET(int32, ONE_PARAM_(cass_int32_t value), value) @@ -74,34 +78,34 @@ CASS_USER_TYPE_SET(tuple, ONE_PARAM_(const CassTuple* value), value) CASS_USER_TYPE_SET(user_type, ONE_PARAM_(const CassUserType* value), value) CASS_USER_TYPE_SET(bytes, TWO_PARAMS_(const cass_byte_t* value, size_t value_size), - cass::CassBytes(value, value_size)) + CassBytes(value, value_size)) CASS_USER_TYPE_SET(decimal, THREE_PARAMS_(const cass_byte_t* varint, size_t varint_size, int scale), - cass::CassDecimal(varint, varint_size, scale)) + CassDecimal(varint, varint_size, scale)) CASS_USER_TYPE_SET(duration, THREE_PARAMS_(cass_int32_t months, cass_int32_t days, cass_int64_t nanos), - cass::CassDuration(months, days, nanos)) + CassDuration(months, days, nanos)) #undef CASS_USER_TYPE_SET CassError cass_user_type_set_string(CassUserType* user_type, size_t index, const char* value) { - return user_type->set(index, cass::CassString(value, SAFE_STRLEN(value))); + return user_type->set(index, CassString(value, SAFE_STRLEN(value))); } CassError cass_user_type_set_string_n(CassUserType* user_type, size_t index, const char* value, size_t value_length) { - return user_type->set(index, cass::CassString(value, value_length)); + return user_type->set(index, CassString(value, value_length)); } CassError cass_user_type_set_string_by_name(CassUserType* user_type, const char* name, const char* value) { - return user_type->set(cass::StringRef(name), - cass::CassString(value, SAFE_STRLEN(value))); + return user_type->set(StringRef(name), + CassString(value, SAFE_STRLEN(value))); } CassError cass_user_type_set_string_by_name_n(CassUserType* user_type, @@ -109,8 +113,8 @@ CassError cass_user_type_set_string_by_name_n(CassUserType* user_type, size_t name_length, const char* value, size_t value_length) { - return user_type->set(cass::StringRef(name, name_length), - cass::CassString(value, value_length)); + return user_type->set(StringRef(name, name_length), + CassString(value, value_length)); } CassError cass_user_type_set_custom(CassUserType* user_type, @@ -119,7 +123,7 @@ CassError cass_user_type_set_custom(CassUserType* user_type, const cass_byte_t* value, size_t value_size) { return user_type->set(index, - cass::CassCustom(cass::StringRef(class_name), + CassCustom(StringRef(class_name), value, value_size)); } @@ -130,7 +134,7 @@ CassError cass_user_type_set_custom_n(CassUserType* user_type, const cass_byte_t* value, size_t value_size) { return user_type->set(index, - cass::CassCustom(cass::StringRef(class_name, class_name_length), + CassCustom(StringRef(class_name, class_name_length), value, value_size)); } @@ -139,8 +143,8 @@ CassError cass_user_type_set_custom_by_name(CassUserType* user_type, const char* class_name, const cass_byte_t* value, size_t value_size) { - return user_type->set(cass::StringRef(name), - cass::CassCustom(cass::StringRef(class_name), + return user_type->set(StringRef(name), + CassCustom(StringRef(class_name), value, value_size)); } @@ -151,8 +155,8 @@ CassError cass_user_type_set_custom_by_name_n(CassUserType* user_type, size_t class_name_length, const cass_byte_t* value, size_t value_size) { - return user_type->set(cass::StringRef(name, name_length), - cass::CassCustom(cass::StringRef(class_name, class_name_length), + return user_type->set(StringRef(name, name_length), + CassCustom(StringRef(class_name, class_name_length), value, value_size)); } diff --git a/cpp-driver/src/user_type_value.hpp b/cpp-driver/src/user_type_value.hpp index c7dd5c64d..718ea0620 100644 --- a/cpp-driver/src/user_type_value.hpp +++ b/cpp-driver/src/user_type_value.hpp @@ -23,7 +23,7 @@ #include "external.hpp" #include "ref_counted.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class UserTypeValue : public AbstractData { public: @@ -49,8 +49,8 @@ class UserTypeValue : public AbstractData { DISALLOW_COPY_AND_ASSIGN(UserTypeValue); }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::UserTypeValue, CassUserType) +EXTERNAL_TYPE(datastax::internal::core::UserTypeValue, CassUserType) #endif diff --git a/cpp-driver/src/utils.cpp b/cpp-driver/src/utils.cpp index 425f8b8b3..4f30a3a4d 100644 --- a/cpp-driver/src/utils.cpp +++ b/cpp-driver/src/utils.cpp @@ -29,7 +29,7 @@ #include #endif -namespace cass { +namespace datastax { namespace internal { String opcode_to_string(int opcode) { switch (opcode) { @@ -229,4 +229,4 @@ void set_thread_name(const String& thread_name) { #endif } -} // namespace cass +} } // namespace datastax::internal diff --git a/cpp-driver/src/utils.hpp b/cpp-driver/src/utils.hpp index 1315b5ac5..e214fd6eb 100644 --- a/cpp-driver/src/utils.hpp +++ b/cpp-driver/src/utils.hpp @@ -30,10 +30,7 @@ #include #endif -namespace cass { - -class BufferPiece; -class Value; +namespace datastax { namespace internal { typedef Vector ContactPointList; typedef Vector DcList; @@ -127,6 +124,6 @@ static void set_pointer_keys(C& container) { void thread_yield(); -} // namespace cass +} } // namespace datastax::internal #endif diff --git a/cpp-driver/src/uuids.cpp b/cpp-driver/src/uuids.cpp index f47dc51cd..8ac6154c3 100644 --- a/cpp-driver/src/uuids.cpp +++ b/cpp-driver/src/uuids.cpp @@ -31,6 +31,9 @@ #define MIN_CLOCK_SEQ_AND_NODE 0x8080808080808080LL #define MAX_CLOCK_SEQ_AND_NODE 0x7f7f7f7f7f7f7f7fLL +using namespace datastax::internal; +using namespace datastax::internal::core; + static uint64_t to_milliseconds(uint64_t timestamp) { return timestamp / 10000L; } @@ -46,11 +49,11 @@ static uint64_t set_version(uint64_t timestamp, uint8_t version) { extern "C" { CassUuidGen* cass_uuid_gen_new() { - return CassUuidGen::to(new cass::UuidGen()); + return CassUuidGen::to(new UuidGen()); } CassUuidGen* cass_uuid_gen_new_with_node(cass_uint64_t node) { - return CassUuidGen::to(new cass::UuidGen(node)); + return CassUuidGen::to(new UuidGen(node)); } void cass_uuid_gen_free(CassUuidGen* uuid_gen) { @@ -91,7 +94,7 @@ cass_uint8_t cass_uuid_version(CassUuid uuid) { void cass_uuid_string(CassUuid uuid, char* output) { size_t pos = 0; char encoded[16]; - cass::encode_uuid(encoded, uuid); + encode_uuid(encoded, uuid); static const char half_byte_to_hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (size_t i = 0; i < 16; ++i) { @@ -159,15 +162,13 @@ CassError cass_uuid_from_string_n(const char* str, pos += 2; } - cass::decode_uuid(buf, output); + decode_uuid(buf, output); return CASS_OK; } } // extern "C" -namespace cass { - UuidGen::UuidGen() : clock_seq_and_node_(0) , last_timestamp_(0LL) @@ -289,5 +290,3 @@ uint64_t UuidGen::monotonic_timestamp() { } } } - -} // namespace cass diff --git a/cpp-driver/src/uuids.hpp b/cpp-driver/src/uuids.hpp index b5f132ece..f0f88cce0 100644 --- a/cpp-driver/src/uuids.hpp +++ b/cpp-driver/src/uuids.hpp @@ -27,7 +27,7 @@ #include #include -namespace cass { +namespace datastax { namespace internal { namespace core { class UuidGen : public Allocated { public: @@ -50,8 +50,8 @@ class UuidGen : public Allocated { MT19937_64 ng_; }; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::UuidGen, CassUuidGen) +EXTERNAL_TYPE(datastax::internal::core::UuidGen, CassUuidGen) #endif diff --git a/cpp-driver/src/value.cpp b/cpp-driver/src/value.cpp index 01c656d89..f8be74153 100644 --- a/cpp-driver/src/value.cpp +++ b/cpp-driver/src/value.cpp @@ -30,6 +30,10 @@ } \ } while (0) +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; + extern "C" { const CassDataType* cass_value_data_type(const CassValue* value) { @@ -71,7 +75,7 @@ CassError cass_value_get_uint32(const CassValue* value, cass_uint32_t* output) { CassError cass_value_get_int64(const CassValue* value, cass_int64_t* output) { if (value == NULL || value->is_null()) return CASS_ERROR_LIB_NULL_VALUE; - if (!cass::is_int64_type(value->value_type())) { + if (!is_int64_type(value->value_type())) { return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } CHECK_VALUE(value->decoder().as_int64(output)); @@ -108,7 +112,7 @@ CassError cass_value_get_bool(const CassValue* value, cass_bool_t* output) { CassError cass_value_get_uuid(const CassValue* value, CassUuid* output) { if (value == NULL || value->is_null()) return CASS_ERROR_LIB_NULL_VALUE; - if (!cass::is_uuid_type(value->value_type())) { + if (!is_uuid_type(value->value_type())) { return CASS_ERROR_LIB_INVALID_VALUE_TYPE; } CHECK_VALUE(value->decoder().as_uuid(output)); @@ -129,7 +133,7 @@ CassError cass_value_get_string(const CassValue* value, const char** output, size_t* output_length) { if (value == NULL || value->is_null()) return CASS_ERROR_LIB_NULL_VALUE; - cass::StringRef buffer = value->decoder().as_string_ref(); + StringRef buffer = value->decoder().as_string_ref(); *output = buffer.data(); *output_length = buffer.size(); return CASS_OK; @@ -139,7 +143,7 @@ CassError cass_value_get_bytes(const CassValue* value, const cass_byte_t** output, size_t* output_size) { if (value == NULL || value->is_null()) return CASS_ERROR_LIB_NULL_VALUE; - cass::StringRef buffer = value->decoder().as_string_ref(); + StringRef buffer = value->decoder().as_string_ref(); *output = reinterpret_cast(buffer.data()); *output_size = buffer.size(); return CASS_OK; @@ -178,8 +182,8 @@ cass_bool_t cass_value_is_collection(const CassValue* value) { } cass_bool_t cass_value_is_duration(const CassValue* value) { - cass::IsValidDataType is_valid; - cass::CassDuration dummy(0, 0, 0); + IsValidDataType is_valid; + CassDuration dummy(0, 0, 0); return static_cast(is_valid(dummy, value->data_type())); } @@ -197,9 +201,6 @@ CassValueType cass_value_secondary_sub_type(const CassValue* collection) { } // extern "C" - -namespace cass { - Value::Value(const DataType::ConstPtr &data_type, Decoder decoder) : data_type_(data_type) , count_(0) @@ -256,5 +257,3 @@ StringVec Value::as_stringlist() const { } return stringlist; } - -} // namespace cass diff --git a/cpp-driver/src/value.hpp b/cpp-driver/src/value.hpp index 45e3380a1..ff81d1bbf 100644 --- a/cpp-driver/src/value.hpp +++ b/cpp-driver/src/value.hpp @@ -23,7 +23,7 @@ #include "result_metadata.hpp" #include "string_ref.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class Value { public: @@ -152,8 +152,8 @@ class Value { typedef Vector OutputValueVec; -} // namespace cass +} } } // namespace datastax::internal::core -EXTERNAL_TYPE(cass::Value, CassValue) +EXTERNAL_TYPE(datastax::internal::core::Value, CassValue) #endif diff --git a/cpp-driver/src/vector.hpp b/cpp-driver/src/vector.hpp index e6fd2b14f..cec9f4a23 100644 --- a/cpp-driver/src/vector.hpp +++ b/cpp-driver/src/vector.hpp @@ -13,14 +13,14 @@ #include -namespace cass { +namespace datastax { namespace internal { template class Vector : public Allocated - , public std::vector > { + , public std::vector > { public: - typedef cass::Allocator Allocator; + typedef internal::Allocator Allocator; explicit Vector(const Allocator& alloc = Allocator()) : std::vector(alloc) { } @@ -36,6 +36,6 @@ class Vector : std::vector(first, last) { } }; -} // namepsace cass +} } // namepsace datastax::internal #endif diff --git a/cpp-driver/src/wait_for_handler.cpp b/cpp-driver/src/wait_for_handler.cpp index 5268b5088..2fd218de0 100644 --- a/cpp-driver/src/wait_for_handler.cpp +++ b/cpp-driver/src/wait_for_handler.cpp @@ -21,7 +21,10 @@ #include -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; + +namespace datastax { namespace internal { namespace core { /** * A callback that handles a chain of requests on behalf of the wait handler. @@ -47,6 +50,8 @@ void WaitForCallback::on_chain_write(Connection* connection) { handler_->start(connection); } +} } } // namespace datastax::internal::core + void WaitForCallback::on_chain_set() { if (handler_->on_set(Ptr(this))) { handler_->finish(); @@ -122,7 +127,7 @@ void WaitForHandler::on_retry_timeout(Timer* timer) { on_error(WaitForHandler::WAIT_FOR_ERROR_CONNECTION_CLOSED, "Connection closed"); finish(); } else if (connection_->write_and_flush(callback(requests_)) == - cass::Request::REQUEST_ERROR_NO_AVAILABLE_STREAM_IDS) { + core::Request::REQUEST_ERROR_NO_AVAILABLE_STREAM_IDS) { on_error(WaitForHandler::WAIT_FOR_ERROR_NO_STREAMS, "Connection closed"); finish(); } @@ -145,5 +150,3 @@ WaitForHandler::WaitForHandler(const RequestHandler::Ptr& request_handler, , request_handler_(request_handler) , current_host_(current_host) , response_(response) { } - -} // namespace cass diff --git a/cpp-driver/src/wait_for_handler.hpp b/cpp-driver/src/wait_for_handler.hpp index a36a357bd..c227e1f5b 100644 --- a/cpp-driver/src/wait_for_handler.hpp +++ b/cpp-driver/src/wait_for_handler.hpp @@ -25,7 +25,7 @@ #include -namespace cass { +namespace datastax { namespace internal { namespace core { /** * A handler that waits for server-side data by running queries and verifying @@ -129,6 +129,6 @@ class WaitForHandler : public RefCounted { const Response::Ptr response_; }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/whitelist_dc_policy.cpp b/cpp-driver/src/whitelist_dc_policy.cpp index 1d5366946..aa099dd0f 100644 --- a/cpp-driver/src/whitelist_dc_policy.cpp +++ b/cpp-driver/src/whitelist_dc_policy.cpp @@ -16,7 +16,7 @@ #include "whitelist_dc_policy.hpp" -namespace cass { +using namespace datastax::internal::core; bool WhitelistDCPolicy::is_valid_host(const Host::Ptr& host) const { const String& host_dc = host->dc(); @@ -28,5 +28,3 @@ bool WhitelistDCPolicy::is_valid_host(const Host::Ptr& host) const { } return false; } - -} // namespace cass diff --git a/cpp-driver/src/whitelist_dc_policy.hpp b/cpp-driver/src/whitelist_dc_policy.hpp index b31f61c3b..383cc76ba 100644 --- a/cpp-driver/src/whitelist_dc_policy.hpp +++ b/cpp-driver/src/whitelist_dc_policy.hpp @@ -22,7 +22,7 @@ #include "scoped_ptr.hpp" #include "list_policy.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class WhitelistDCPolicy : public ListPolicy { public: @@ -46,6 +46,6 @@ class WhitelistDCPolicy : public ListPolicy { DISALLOW_COPY_AND_ASSIGN(WhitelistDCPolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/src/whitelist_policy.cpp b/cpp-driver/src/whitelist_policy.cpp index 53c0d07b7..ffcbc7940 100644 --- a/cpp-driver/src/whitelist_policy.cpp +++ b/cpp-driver/src/whitelist_policy.cpp @@ -16,7 +16,7 @@ #include "whitelist_policy.hpp" -namespace cass { +using namespace datastax::internal::core; bool WhitelistPolicy::is_valid_host(const Host::Ptr& host) const { const String& host_address = host->address().to_string(false); @@ -29,5 +29,3 @@ bool WhitelistPolicy::is_valid_host(const Host::Ptr& host) const { } return false; } - -} // namespace cass diff --git a/cpp-driver/src/whitelist_policy.hpp b/cpp-driver/src/whitelist_policy.hpp index 7f1a68d1d..7f9f08e71 100644 --- a/cpp-driver/src/whitelist_policy.hpp +++ b/cpp-driver/src/whitelist_policy.hpp @@ -22,7 +22,7 @@ #include "scoped_ptr.hpp" #include "list_policy.hpp" -namespace cass { +namespace datastax { namespace internal { namespace core { class WhitelistPolicy : public ListPolicy { public: @@ -46,6 +46,6 @@ class WhitelistPolicy : public ListPolicy { DISALLOW_COPY_AND_ASSIGN(WhitelistPolicy); }; -} // namespace cass +} } } // namespace datastax::internal::core #endif diff --git a/cpp-driver/test/integration_tests/src/policy_tools.cpp b/cpp-driver/test/integration_tests/src/policy_tools.cpp index 57cb6706e..f353f532f 100644 --- a/cpp-driver/test/integration_tests/src/policy_tools.cpp +++ b/cpp-driver/test/integration_tests/src/policy_tools.cpp @@ -22,6 +22,8 @@ #include "testing.hpp" #include "policy_tools.hpp" +using namespace datastax::internal::testing; + void PolicyTool::show_coordinators() // show what queries went to what nodes IP. { for (std::map::const_iterator p = coordinators.begin(); p != coordinators.end(); ++p) { @@ -138,7 +140,7 @@ void PolicyTool::query(CassSession* session, int n, CassConsistency cl) 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()).c_str()); + add_coordinator(get_host_from_future(future.get()).c_str()); } } @@ -155,7 +157,7 @@ CassError PolicyTool::query_return_error(CassSession* session, int n, CassConsis if (rc != CASS_OK) { return rc; } - add_coordinator(cass::get_host_from_future(future.get()).c_str()); + add_coordinator(get_host_from_future(future.get()).c_str()); } return CASS_OK; } diff --git a/cpp-driver/test/integration_tests/src/test_config.cpp b/cpp-driver/test/integration_tests/src/test_config.cpp index b81a7d26a..f252770b3 100644 --- a/cpp-driver/test/integration_tests/src/test_config.cpp +++ b/cpp-driver/test/integration_tests/src/test_config.cpp @@ -20,6 +20,8 @@ #include "testing.hpp" #include "test_utils.hpp" +using namespace datastax::internal::testing; + struct ConfigTests { ConfigTests() { } }; @@ -34,13 +36,13 @@ BOOST_AUTO_TEST_CASE(options) { unsigned connect_timeout = 9999; cass_cluster_set_connect_timeout(cluster.get(), connect_timeout); - BOOST_CHECK(cass::get_connect_timeout_from_cluster(cluster.get()) == connect_timeout); + BOOST_CHECK(get_connect_timeout_from_cluster(cluster.get()) == connect_timeout); } { int port = 7000; cass_cluster_set_port(cluster.get(), port); - BOOST_CHECK(cass::get_port_from_cluster(cluster.get()) == port); + BOOST_CHECK(get_port_from_cluster(cluster.get()) == port); } } @@ -51,29 +53,29 @@ BOOST_AUTO_TEST_CASE(contact_points) // Simple const char* contact_points1 = "127.0.0.1,127.0.0.2,127.0.0.3"; cass_cluster_set_contact_points(cluster.get(), contact_points1); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); // Clear cass_cluster_set_contact_points(cluster.get(), ""); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).empty()); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).empty()); // Extra commas const char* contact_points1_commas = ",,,,127.0.0.1,,,,127.0.0.2,127.0.0.3,,,,"; cass_cluster_set_contact_points(cluster.get(), contact_points1_commas); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); // Clear cass_cluster_set_contact_points(cluster.get(), ""); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).empty()); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).empty()); // Extra whitespace const char* contact_points1_ws = " ,\r\n, , , 127.0.0.1 ,,, ,\t127.0.0.2,127.0.0.3, \t\n, ,, "; cass_cluster_set_contact_points(cluster.get(), contact_points1_ws); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); // Clear cass_cluster_set_contact_points(cluster.get(), ""); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).empty()); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).empty()); // Append const char* contact_point1 = "127.0.0.1"; @@ -85,7 +87,7 @@ BOOST_AUTO_TEST_CASE(contact_points) const char* contact_point3 = "127.0.0.3"; cass_cluster_set_contact_points(cluster.get(), contact_point3); - BOOST_REQUIRE(cass::get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); + BOOST_REQUIRE(get_contact_points_from_cluster(cluster.get()).compare(contact_points1) == 0); } BOOST_AUTO_TEST_SUITE_END() diff --git a/cpp-driver/test/integration_tests/src/test_control_connection.cpp b/cpp-driver/test/integration_tests/src/test_control_connection.cpp index c59e75c99..db458bc75 100644 --- a/cpp-driver/test/integration_tests/src/test_control_connection.cpp +++ b/cpp-driver/test/integration_tests/src/test_control_connection.cpp @@ -28,6 +28,8 @@ #include #include +using namespace datastax::internal::testing; + struct ControlConnectionTests { public: boost::shared_ptr ccm; @@ -45,7 +47,7 @@ struct ControlConnectionTests { test_utils::CassStatementPtr statement(cass_statement_new(query.str().c_str(), 0)); test_utils::CassFuturePtr future(cass_session_execute(session.get(), statement.get())); if (cass_future_error_code(future.get()) == CASS_OK) { - return cass::get_host_from_future(future.get()).c_str(); + return get_host_from_future(future.get()).c_str(); } else { CassString message; cass_future_error_message(future.get(), &message.data, &message.length); diff --git a/cpp-driver/test/integration_tests/src/test_latency_aware_policy.cpp b/cpp-driver/test/integration_tests/src/test_latency_aware_policy.cpp index 098627694..22adb53c3 100644 --- a/cpp-driver/test/integration_tests/src/test_latency_aware_policy.cpp +++ b/cpp-driver/test/integration_tests/src/test_latency_aware_policy.cpp @@ -27,6 +27,8 @@ #define DEFAULT_CASSANDRA_NODE_PORT 9042 #define WARM_UP_QUERY_COUNT 25 +using namespace datastax::internal::testing; + struct LatencyAwarePolicyTest { public: boost::shared_ptr ccm_; @@ -173,10 +175,10 @@ struct LatencyAwarePolicyTest { if (!is_error_) { // Get the host latency - std::string host_ip_address = cass::get_host_from_future(future.get()).c_str(); - double host_latency = static_cast(cass::get_host_latency_average(session_.get(), - host_ip_address.c_str(), - DEFAULT_CASSANDRA_NODE_PORT)) / 1e6; + std::string host_ip_address = get_host_from_future(future.get()).c_str(); + double host_latency = static_cast(get_host_latency_average(session_.get(), + host_ip_address.c_str(), + DEFAULT_CASSANDRA_NODE_PORT)) / 1e6; // Update the max latency incurred std::stringstream node_value; diff --git a/cpp-driver/test/integration_tests/src/test_prepare_on_up_or_add_host.cpp b/cpp-driver/test/integration_tests/src/test_prepare_on_up_or_add_host.cpp index 09334bce6..4bf4413a1 100644 --- a/cpp-driver/test/integration_tests/src/test_prepare_on_up_or_add_host.cpp +++ b/cpp-driver/test/integration_tests/src/test_prepare_on_up_or_add_host.cpp @@ -29,6 +29,8 @@ #include "test_utils.hpp" #include "testing.hpp" +using namespace datastax::internal::testing; + /** * Test harness for prepare on up or add host functionality. */ @@ -181,7 +183,7 @@ struct PrepareOnUpOrAddHostTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr statement(cass_statement_new("SELECT * FROM system.peers", 0)); test_utils::CassFuturePtr future(cass_session_execute(session.get(), statement.get())); - std::string host(cass::get_host_from_future(future.get()).c_str()); + std::string host(get_host_from_future(future.get()).c_str()); if (cass_future_error_code(future.get()) == CASS_OK && host == ip_address.str()) { return; } diff --git a/cpp-driver/test/integration_tests/src/test_prepared_batch.cpp b/cpp-driver/test/integration_tests/src/test_prepared_batch.cpp index 645951394..4361581d6 100644 --- a/cpp-driver/test/integration_tests/src/test_prepared_batch.cpp +++ b/cpp-driver/test/integration_tests/src/test_prepared_batch.cpp @@ -29,6 +29,8 @@ #include "test_utils.hpp" #include "testing.hpp" +using namespace datastax::internal::testing; + /** * Test harness for prepared statements in batches. */ @@ -57,7 +59,7 @@ struct PreparedBatchTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr statement(cass_statement_new("SELECT * FROM system.peers", 0)); test_utils::CassFuturePtr future(cass_session_execute(session.get(), statement.get())); - std::string host(cass::get_host_from_future(future.get()).c_str()); + std::string host(get_host_from_future(future.get()).c_str()); if (cass_future_error_code(future.get()) == CASS_OK && host == ip_address.str()) { return; } diff --git a/cpp-driver/test/integration_tests/src/test_prepared_existing.cpp b/cpp-driver/test/integration_tests/src/test_prepared_existing.cpp index 66d2406ea..d9f602988 100644 --- a/cpp-driver/test/integration_tests/src/test_prepared_existing.cpp +++ b/cpp-driver/test/integration_tests/src/test_prepared_existing.cpp @@ -26,6 +26,8 @@ #include "statement.hpp" #include "test_utils.hpp" +using namespace datastax::internal::core; + /** * Test harness for prepared from existing functionality. */ @@ -101,7 +103,7 @@ BOOST_AUTO_TEST_CASE(prepare_from_existing_simple_statement) { test_utils::CassStatementPtr bound_statement(cass_prepared_bind(prepared.get())); BOOST_REQUIRE(bound_statement); - cass::ExecuteRequest* execute_request = static_cast(bound_statement->from()); + ExecuteRequest* execute_request = static_cast(bound_statement->from()); // Validate that the bound statement inherited the settings from the original statement BOOST_CHECK_EQUAL(execute_request->consistency(), CASS_CONSISTENCY_LOCAL_QUORUM); @@ -149,7 +151,7 @@ BOOST_AUTO_TEST_CASE(prepare_from_existing_bound_statement) { test_utils::CassStatementPtr bound_statement2(cass_prepared_bind(prepared2.get())); BOOST_REQUIRE(bound_statement2); - cass::ExecuteRequest* execute_request = static_cast(bound_statement2->from()); + ExecuteRequest* execute_request = static_cast(bound_statement2->from()); // Validate that the bound statement inherited the settings from the original bound statement BOOST_CHECK_EQUAL(execute_request->consistency(), CASS_CONSISTENCY_LOCAL_QUORUM); diff --git a/cpp-driver/test/integration_tests/src/test_speculative_execution_policy.cpp b/cpp-driver/test/integration_tests/src/test_speculative_execution_policy.cpp index 909caa845..f755ef4c2 100644 --- a/cpp-driver/test/integration_tests/src/test_speculative_execution_policy.cpp +++ b/cpp-driver/test/integration_tests/src/test_speculative_execution_policy.cpp @@ -38,6 +38,8 @@ "return arg;" \ "$$;" +using namespace datastax::internal::core; + /** * Speculative Execution Policy Integration Test Class * @@ -108,7 +110,7 @@ struct TestSpeculativeExecutionPolicy : public test_utils::SingleSessionTest { cass_statement_set_is_idempotent(statement.get(), (is_idempotent ? cass_true : cass_false)); cass_statement_set_request_timeout(statement.get(), timeout_ms); - cass::Statement* native_statement = static_cast(statement.get()); + Statement* native_statement = static_cast(statement.get()); native_statement->set_record_attempted_addresses(true); test_utils::CassFuturePtr future(cass_session_execute(session, statement.get())); if (expected_error_code == CASS_OK) { @@ -130,11 +132,11 @@ struct TestSpeculativeExecutionPolicy : public test_utils::SingleSessionTest { std::vector attempted_hosts(test_utils::CassFuturePtr future) { // Gather and return the attempted hosts from the response std::vector attempted_hosts; - cass::Future* native_future = static_cast(future.get()); - if (native_future->type() == cass::Future::FUTURE_TYPE_RESPONSE) { - cass::ResponseFuture* native_response_future = static_cast(native_future); - cass::AddressVec attempted_addresses = native_response_future->attempted_addresses(); - for (cass::AddressVec::iterator iterator = attempted_addresses.begin(); + Future* native_future = static_cast(future.get()); + if (native_future->type() == Future::FUTURE_TYPE_RESPONSE) { + ResponseFuture* native_response_future = static_cast(native_future); + AddressVec attempted_addresses = native_response_future->attempted_addresses(); + for (AddressVec::iterator iterator = attempted_addresses.begin(); iterator != attempted_addresses.end(); ++iterator) { attempted_hosts.push_back(iterator->to_string().c_str()); } @@ -151,9 +153,9 @@ struct TestSpeculativeExecutionPolicy : public test_utils::SingleSessionTest { */ std::string executed_host(test_utils::CassFuturePtr future) { std::string host; - cass::Future* native_future = static_cast(future.get()); - if (native_future->type() == cass::Future::FUTURE_TYPE_RESPONSE) { - cass::ResponseFuture* native_response_future = static_cast(native_future); + Future* native_future = static_cast(future.get()); + if (native_future->type() == Future::FUTURE_TYPE_RESPONSE) { + ResponseFuture* native_response_future = static_cast(native_future); host = native_response_future->address().to_string().c_str(); } return host; diff --git a/cpp-driver/test/integration_tests/src/test_timestamps.cpp b/cpp-driver/test/integration_tests/src/test_timestamps.cpp index fec157f1e..cbce9c6fe 100644 --- a/cpp-driver/test/integration_tests/src/test_timestamps.cpp +++ b/cpp-driver/test/integration_tests/src/test_timestamps.cpp @@ -23,6 +23,9 @@ #include #include +using namespace datastax::internal; +using namespace datastax::internal::core; + struct TimestampsTest : public test_utils::SingleSessionTest { typedef test_utils::CassBatchPtr CassBatchPtr; typedef test_utils::CassFuturePtr CassFuturePtr; @@ -64,7 +67,7 @@ struct TimestampsTest : public test_utils::SingleSessionTest { } }; -class TestTimestampGenerator : public cass::TimestampGenerator { +class TestTimestampGenerator : public TimestampGenerator { public: TestTimestampGenerator(int64_t timestamp) : TimestampGenerator(SERVER_SIDE) // Doesn't matter for this test @@ -76,7 +79,7 @@ class TestTimestampGenerator : public cass::TimestampGenerator { int64_t timestamp_; }; -class TestMonotonicTimestampGenerator : public cass::MonotonicTimestampGenerator { +class TestMonotonicTimestampGenerator : public MonotonicTimestampGenerator { public: std::vector timestamps_; @@ -85,7 +88,7 @@ class TestMonotonicTimestampGenerator : public cass::MonotonicTimestampGenerator : MonotonicTimestampGenerator(warning_threshold_us, warning_interval_ms) { } virtual int64_t next() { - int64_t timestamp = cass::MonotonicTimestampGenerator::next(); + int64_t timestamp = MonotonicTimestampGenerator::next(); timestamps_.push_back(timestamp); return timestamp; } @@ -185,7 +188,7 @@ BOOST_AUTO_TEST_CASE(generator) CCM::CassVersion version = test_utils::get_version(); if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TimestampsTest tester; - cass::SharedRefPtr gen(new TestTimestampGenerator(1234)); + SharedRefPtr gen(new TestTimestampGenerator(1234)); cass_cluster_set_timestamp_gen(tester.cluster, CassTimestampGen::to(gen.get())); tester.create_session(); @@ -269,7 +272,7 @@ BOOST_AUTO_TEST_CASE(server_side) cass_statement_bind_string(statement.get(), 0, key.c_str()); cass_statement_bind_string(statement.get(), 1, key.c_str()); - uint64_t timestamp = cass::get_time_since_epoch_ms(); + uint64_t timestamp = get_time_since_epoch_ms(); test_utils::CassFuturePtr future(cass_session_execute(tester.session, statement.get())); BOOST_REQUIRE(cass_future_error_code(future.get()) == CASS_OK); @@ -294,7 +297,7 @@ BOOST_AUTO_TEST_CASE(server_side) BOOST_AUTO_TEST_CASE(monotonic_generator) { TimestampsTest tester; - cass::SharedRefPtr gen(new TestMonotonicTimestampGenerator()); // mimics cass_timestamp_gen_monotonic_new()) + SharedRefPtr gen(new TestMonotonicTimestampGenerator()); // mimics cass_timestamp_gen_monotonic_new()) cass_cluster_set_timestamp_gen(tester.cluster, CassTimestampGen::to(gen.get())); tester.create_session(); @@ -331,7 +334,7 @@ BOOST_AUTO_TEST_CASE(monotonic_generator) BOOST_AUTO_TEST_CASE(monotonic_generator_warnings) { TimestampsTest tester; - cass::SharedRefPtr gen(new TestMonotonicTimestampGenerator(1, 1000)); // mimics cass_timestamp_gen_monotonic_new_with_settings()) + SharedRefPtr gen(new TestMonotonicTimestampGenerator(1, 1000)); // mimics cass_timestamp_gen_monotonic_new_with_settings()) cass_cluster_set_timestamp_gen(tester.cluster, CassTimestampGen::to(gen.get())); tester.create_session(); diff --git a/cpp-driver/test/integration_tests/src/test_token_aware_policy.cpp b/cpp-driver/test/integration_tests/src/test_token_aware_policy.cpp index 268f867c9..93555bf7e 100644 --- a/cpp-driver/test/integration_tests/src/test_token_aware_policy.cpp +++ b/cpp-driver/test/integration_tests/src/test_token_aware_policy.cpp @@ -39,6 +39,8 @@ #include #include +using namespace datastax::internal::testing; + BOOST_AUTO_TEST_SUITE(token_aware_policy) struct TestTokenMap { @@ -77,7 +79,7 @@ struct TestTokenMap { cass_value_get_string(data_center, &str.data, &str.length); std::string dc(str.data, str.length); - std::string ip = cass::get_host_from_future(future.get()).c_str(); + std::string ip = get_host_from_future(future.get()).c_str(); test_utils::CassIteratorPtr iterator(cass_iterator_from_collection(token_set)); while (cass_iterator_next(iterator.get())) { cass_value_get_string(cass_iterator_get_value(iterator.get()), &str.data, &str.length); @@ -89,7 +91,7 @@ struct TestTokenMap { ReplicaSet get_expected_replicas(size_t rf, const std::string& value, const std::string& local_dc = "") { ReplicaSet replicas; - TokenHostMap::iterator i = tokens.upper_bound(cass::create_murmur3_hash_from_string(value.c_str())); + TokenHostMap::iterator i = tokens.upper_bound(create_murmur3_hash_from_string(value.c_str())); while (replicas.size() < rf) { if (local_dc.empty() || local_dc == i->second.dc) { replicas.insert(i->second.ip); @@ -115,7 +117,7 @@ std::string get_replica(test_utils::CassSessionPtr session, cass_statement_set_keyspace(statement.get(), keyspace.c_str()); test_utils::CassFuturePtr future( cass_session_execute(session.get(), statement.get())); - return cass::get_host_from_future(future.get()).c_str(); + return get_host_from_future(future.get()).c_str(); } TestTokenMap::ReplicaSet get_replicas(size_t rf, diff --git a/src/client_insights.cpp b/src/client_insights.cpp index 1263fca5d..19e5d159f 100644 --- a/src/client_insights.cpp +++ b/src/client_insights.cpp @@ -43,30 +43,33 @@ "validation is disabled" #define CONFIG_ANTIPATTERN_MSG_PLAINTEXT_NO_SSL "Plain text authentication is " \ "enabled without client-to-node " \ - "encryption" + "encryption""" -namespace cass { +namespace datastax { namespace internal { namespace core { MonitorReporting* create_monitor_reporting(const String& client_id, const String& session_id, - const cass::Config& config) { + const Config& config) { // Ensure the client monitor events should be enabled unsigned interval_secs = config.monitor_reporting_interval_secs(); if (interval_secs > 0) { - return new dse::ClientInsights(client_id, - session_id, - interval_secs); + return new enterprise::ClientInsights(client_id, + session_id, + interval_secs); } return new NopMonitorReporting(); } -} // namespace cass +} } } // namespace datastax::internal::core -using namespace dse; +using namespace datastax::internal::core; +using namespace datastax::internal; + +namespace datastax { namespace internal { namespace enterprise { #ifdef _WIN32 #define ERROR_BUFFER_MAX_LENGTH 1024 -cass::String get_last_error() { +String get_last_error() { DWORD rc = GetLastError(); char buf[ERROR_BUFFER_MAX_LENGTH]; @@ -77,19 +80,19 @@ cass::String get_last_error() { reinterpret_cast(&buf[0]), ERROR_BUFFER_MAX_LENGTH, NULL); - cass::String str(buf, size); - cass::trim(str); + String str(buf, size); + trim(str); return str; } #endif -cass::String get_hostname() { +String get_hostname() { #ifdef _WIN32 WSADATA data; WORD version_required = MAKEWORD(2, 2); if (WSAStartup(version_required, &data) != 0) { LOG_WARN("Unable to determine hostname: Failed to initialize WinSock2"); - return cass::String(); + return String(); } #endif @@ -99,13 +102,13 @@ cass::String get_hostname() { LOG_WARN("Unable to determine hostname: Error code %d", rc); return "UNKNOWN"; } - return cass::String(buf, size); + return String(buf, size); } struct Os { - cass::String name; - cass::String version; - cass::String arch; + String name; + String version; + String arch; }; Os get_os() { Os os; @@ -114,14 +117,14 @@ Os get_os() { DWORD size = GetFileVersionInfoSize(TEXT("kernel32.dll"), NULL); if (size) { - cass::Vector version_info(size); + Vector version_info(size); if (GetFileVersionInfo(TEXT("kernel32.dll"), 0, size, &version_info[0])) { VS_FIXEDFILEINFO* file_info = NULL; UINT file_info_length = 0; if (VerQueryValue(&version_info[0], TEXT("\\"), reinterpret_cast(&file_info), &file_info_length)) { - cass::OStringStream oss; + OStringStream oss; oss << static_cast(HIWORD(file_info->dwProductVersionMS)) << "." << static_cast(LOWORD(file_info->dwProductVersionMS)) << "." << static_cast(HIWORD(file_info->dwProductVersionLS)); @@ -154,7 +157,7 @@ Os get_os() { struct Cpus { int length; - cass::String model; + String model; }; Cpus get_cpus() { Cpus cpus; @@ -174,26 +177,24 @@ Cpus get_cpus() { return cpus; } -namespace dse { - -class ClientInsightsRequestCallback : public cass::SimpleRequestCallback { +class ClientInsightsRequestCallback : public SimpleRequestCallback { public: - typedef cass::SharedRefPtr Ptr; + typedef SharedRefPtr Ptr; - ClientInsightsRequestCallback(const cass::String& json, - const cass::String& event_type) - : cass::SimpleRequestCallback("CALL InsightsRpc.reportInsight('" + json + "')") + ClientInsightsRequestCallback(const String& json, + const String& event_type) + : SimpleRequestCallback("CALL InsightsRpc.reportInsight('" + json + "')") , event_type_(event_type) { } - virtual void on_internal_set(cass::ResponseMessage* response) { + virtual void on_internal_set(ResponseMessage* response) { if (response->opcode() != CQL_OPCODE_RESULT) { LOG_DEBUG("Failed to send %s event message: Invalid response [%s]", event_type_.c_str(), - cass::opcode_to_string(response->opcode()).c_str()); + opcode_to_string(response->opcode()).c_str()); } } - virtual void on_internal_error(CassError code, const cass::String& message) { + virtual void on_internal_error(CassError code, const String& message) { LOG_DEBUG("Failed to send %s event message: %s", event_type_.c_str(), message.c_str()); @@ -205,10 +206,10 @@ class ClientInsightsRequestCallback : public cass::SimpleRequestCallback { } private: - cass::String event_type_; + String event_type_; }; -void metadata(ClientInsights::Writer& writer, const cass::String& name) { +void metadata(ClientInsights::Writer& writer, const String& name) { writer.Key("metadata"); writer.StartObject(); @@ -219,7 +220,7 @@ void metadata(ClientInsights::Writer& writer, const cass::String& name) { writer.Key("insightType"); writer.String("EVENT"); //TODO: Make this an enumeration in the future writer.Key("timestamp"); - writer.Uint64(cass::get_time_since_epoch_ms()); + writer.Uint64(get_time_since_epoch_ms()); writer.Key("tags"); writer.StartObject(); writer.Key("language"); @@ -229,16 +230,16 @@ void metadata(ClientInsights::Writer& writer, const cass::String& name) { writer.EndObject(); } -class StartupMessageHandler : public cass::RefCounted { +class StartupMessageHandler : public RefCounted { public: - typedef cass::SharedRefPtr Ptr; - - StartupMessageHandler(const cass::Connection::Ptr& connection, - const cass::String& client_id, - const cass::String& session_id, - const cass::Config& config, - const cass::HostMap& hosts, - const cass::LoadBalancingPolicy::Vec& initialized_policies) + typedef SharedRefPtr Ptr; + + StartupMessageHandler(const Connection::Ptr& connection, + const String& client_id, + const String& session_id, + const Config& config, + const HostMap& hosts, + const LoadBalancingPolicy::Vec& initialized_policies) : connection_(connection) , client_id_(client_id) , session_id_(session_id) @@ -256,7 +257,7 @@ class StartupMessageHandler : public cass::RefCounted { writer.EndObject(); assert(writer.IsComplete() && "Startup JSON is incomplete"); - connection_->write_and_flush(cass::RequestCallback::Ptr( + connection_->write_and_flush(RequestCallback::Ptr( new ClientInsightsRequestCallback(buffer.GetString(), METADATA_STARTUP_NAME))); } @@ -280,7 +281,7 @@ class StartupMessageHandler : public cass::RefCounted { if (!config_.application_name().empty()) { writer.String(config_.application_name().c_str()); } else { - writer.String(cass::driver_name()); + writer.String(driver_name()); is_application_name_generated = true; } writer.Key("applicationNameWasGenerated"); @@ -290,9 +291,9 @@ class StartupMessageHandler : public cass::RefCounted { writer.String(config_.application_version().c_str()); } writer.Key("driverName"); - writer.String(cass::driver_name()); + writer.String(driver_name()); writer.Key("driverVersion"); - writer.String(cass::driver_version()); + writer.String(driver_version()); contact_points(writer); data_centers(writer); writer.Key("initialControlConnection"); @@ -329,7 +330,7 @@ class StartupMessageHandler : public cass::RefCounted { map_end = contact_points_resolved_.end(); map_it != map_end; ++map_it) { writer.Key(map_it->first.c_str()); writer.StartArray(); - for (cass::AddressSet::const_iterator vec_it = map_it->second.begin(), + for (AddressSet::const_iterator vec_it = map_it->second.begin(), vec_end = map_it->second.end(); vec_it != vec_end; ++vec_it) { writer.String(vec_it->to_string(true).c_str()); } @@ -343,10 +344,10 @@ class StartupMessageHandler : public cass::RefCounted { writer.Key("dataCenters"); writer.StartArray(); - cass::Set data_centers; - for (cass::HostMap::const_iterator it = hosts_.begin(), end = hosts_.end(); + Set data_centers; + for (HostMap::const_iterator it = hosts_.begin(), end = hosts_.end(); it != end; ++it) { - const cass::String& data_center = it->second->dc(); + const String& data_center = it->second->dc(); if (data_centers.insert(data_center).second) { writer.String(data_center.c_str()); } @@ -359,11 +360,11 @@ class StartupMessageHandler : public cass::RefCounted { writer.Key("executionProfiles"); writer.StartObject(); - const cass::ExecutionProfile& default_profile = config_.default_profile(); - const cass::ExecutionProfile::Map& profiles = config_.profiles(); + const ExecutionProfile& default_profile = config_.default_profile(); + const ExecutionProfile::Map& profiles = config_.profiles(); writer.Key("default"); execution_profile_as_json(writer, default_profile); - for (cass::ExecutionProfile::Map::const_iterator it = profiles.begin(), + for (ExecutionProfile::Map::const_iterator it = profiles.begin(), end = profiles.end(); it != end; ++it) { writer.Key(it->first.c_str()); execution_profile_as_json(writer, it->second, &default_profile); @@ -405,7 +406,7 @@ class StartupMessageHandler : public cass::RefCounted { writer.Key("ssl"); writer.StartObject(); - const cass::SslContext::Ptr& ssl_context = config_.ssl_context(); + const SslContext::Ptr& ssl_context = config_.ssl_context(); writer.Key("enabled"); if (ssl_context) { writer.Bool(true); @@ -423,7 +424,7 @@ class StartupMessageHandler : public cass::RefCounted { } void auth_provider(ClientInsights::Writer& writer) { - const cass::AuthProvider::Ptr& auth_provider = config_.auth_provider(); + const AuthProvider::Ptr& auth_provider = config_.auth_provider(); if (auth_provider) { writer.Key("authProvider"); writer.StartObject(); @@ -589,26 +590,26 @@ class StartupMessageHandler : public cass::RefCounted { private: // Startup message helper methods void resolve_contact_points() { - const cass::ContactPointList& contact_points = config_.contact_points(); + const ContactPointList& contact_points = config_.contact_points(); const int port = config_.port(); - cass::MultiResolver::Ptr resolver; + MultiResolver::Ptr resolver; - for (cass::ContactPointList::const_iterator it = contact_points.begin(), + for (ContactPointList::const_iterator it = contact_points.begin(), end = contact_points.end(); it != end; ++it) { - const cass::String& contact_point = *it; - cass::Address address; + const String& contact_point = *it; + Address address; // Attempt to parse the contact point string. If it's an IP address // then immediately add it to our resolved contact points, otherwise // attempt to resolve the string as a hostname. - if (cass::Address::from_string(contact_point, port, &address)) { - cass::AddressSet addresses; + if (Address::from_string(contact_point, port, &address)) { + AddressSet addresses; addresses.insert(address); contact_points_resolved_[contact_point] = addresses; } else { if (!resolver) { inc_ref(); resolver.reset( - new cass::MultiResolver( + new MultiResolver( bind_callback(&StartupMessageHandler::on_resolve, this))); } resolver->resolve(connection_->loop(), @@ -622,15 +623,15 @@ class StartupMessageHandler : public cass::RefCounted { // the destructor } - void on_resolve(cass::MultiResolver* resolver) { - const cass::Resolver::Vec& resolvers = resolver->resolvers(); - for (cass::Resolver::Vec::const_iterator it = resolvers.begin(), + void on_resolve(MultiResolver* resolver) { + const Resolver::Vec& resolvers = resolver->resolvers(); + for (Resolver::Vec::const_iterator it = resolvers.begin(), end = resolvers.end(); it != end; ++it) { - const cass::Resolver::Ptr resolver(*it); - cass::AddressSet addresses; + const Resolver::Ptr resolver(*it); + AddressSet addresses; if (resolver->is_success()) { if (!resolver->addresses().empty()) { - for (cass::AddressVec::const_iterator it = resolver->addresses().begin(), + for (AddressVec::const_iterator it = resolver->addresses().begin(), end = resolver->addresses().end(); it != end; ++it) { addresses.insert(*it); } @@ -642,8 +643,8 @@ class StartupMessageHandler : public cass::RefCounted { dec_ref(); // Send startup message in destructor } - cass::String get_local_address(const uv_tcp_t* tcp) const { - cass::Address interface_address; + String get_local_address(const uv_tcp_t* tcp) const { + Address interface_address; struct sockaddr socket_address; int namelen = sizeof(socket_address); if (uv_tcp_getsockname(tcp, &socket_address, &namelen) == 0 && @@ -654,8 +655,8 @@ class StartupMessageHandler : public cass::RefCounted { } void execution_profile_as_json(ClientInsights::Writer& writer, - const cass::ExecutionProfile& profile, - const cass::ExecutionProfile* default_profile = NULL) { + const ExecutionProfile& profile, + const ExecutionProfile* default_profile = NULL) { writer.StartObject(); if (!default_profile || @@ -675,16 +676,16 @@ class StartupMessageHandler : public cass::RefCounted { } if (!default_profile || (default_profile && profile.retry_policy() != default_profile->retry_policy())) { - const cass::RetryPolicy::Ptr& retry_policy = profile.retry_policy(); + const RetryPolicy::Ptr& retry_policy = profile.retry_policy(); if (retry_policy) { writer.Key("retryPolicy"); - if (retry_policy->type() == cass::RetryPolicy::DEFAULT) { + if (retry_policy->type() == RetryPolicy::DEFAULT) { writer.String("DefaultRetryPolicy"); - } else if (retry_policy->type() == cass::RetryPolicy::DOWNGRADING) { + } else if (retry_policy->type() == RetryPolicy::DOWNGRADING) { writer.String("DowngradingConsistencyRetryPolicy"); - } else if (retry_policy->type() == cass::RetryPolicy::FALLTHROUGH) { + } else if (retry_policy->type() == RetryPolicy::FALLTHROUGH) { writer.String("FallthroughRetryPolicy"); - } else if (retry_policy->type() == cass::RetryPolicy::LOGGING) { + } else if (retry_policy->type() == RetryPolicy::LOGGING) { writer.String("LoggingRetryPolicy"); } else { LOG_DEBUG("Invalid retry policy: %d", retry_policy->type()); @@ -697,18 +698,18 @@ class StartupMessageHandler : public cass::RefCounted { writer.Key("loadBalancing"); writer.StartObject(); writer.Key("type"); - cass::LoadBalancingPolicy* current_lbp = profile.load_balancing_policy().get(); + LoadBalancingPolicy* current_lbp = profile.load_balancing_policy().get(); do { // NOTE: DCAware and RoundRobin are leaf policies (e.g. not chainable) - if (dynamic_cast(current_lbp)) { + if (dynamic_cast(current_lbp)) { writer.String("DCAwarePolicy"); break; - } else if (dynamic_cast(current_lbp)) { + } else if (dynamic_cast(current_lbp)) { writer.String("RoundRobinPolicy"); break; } - if (cass::ChainedLoadBalancingPolicy* chained_lbp = dynamic_cast(current_lbp)) { + if (ChainedLoadBalancingPolicy* chained_lbp = dynamic_cast(current_lbp)) { current_lbp = chained_lbp->child_policy().get(); } else { current_lbp = NULL; @@ -716,7 +717,7 @@ class StartupMessageHandler : public cass::RefCounted { } while (current_lbp); writer.Key("options"); writer.StartObject(); - if (cass::DCAwarePolicy* dc_lbp = dynamic_cast(current_lbp)) { + if (DCAwarePolicy* dc_lbp = dynamic_cast(current_lbp)) { writer.Key("localDc"); if (dc_lbp->local_dc().empty()) { writer.Null(); @@ -732,19 +733,19 @@ class StartupMessageHandler : public cass::RefCounted { writer.Bool(profile.host_targeting()); if (!profile.blacklist().empty()) { writer.Key("blacklist"); - writer.String(cass::implode(profile.blacklist()).c_str()); + writer.String(implode(profile.blacklist()).c_str()); } if (!profile.blacklist_dc().empty()) { writer.Key("blacklistDc"); - writer.String(cass::implode(profile.blacklist_dc()).c_str()); + writer.String(implode(profile.blacklist_dc()).c_str()); } if (!profile.whitelist().empty()) { writer.Key("whitelist"); - writer.String(cass::implode(profile.whitelist()).c_str()); + writer.String(implode(profile.whitelist()).c_str()); } if (!profile.whitelist_dc().empty()) { writer.Key("whitelistDc"); - writer.String(cass::implode(profile.whitelist_dc()).c_str()); + writer.String(implode(profile.whitelist_dc()).c_str()); } if (profile.token_aware_routing()) { writer.Key("tokenAwareRouting"); @@ -773,7 +774,7 @@ class StartupMessageHandler : public cass::RefCounted { writer.EndObject(); // loadBalancingPolicy } - typedef cass::ConstantSpeculativeExecutionPolicy CSEP; + typedef ConstantSpeculativeExecutionPolicy CSEP; CSEP* default_csep = default_profile ? dynamic_cast(default_profile->speculative_execution_policy().get()) : NULL; CSEP* csep = dynamic_cast(profile.speculative_execution_policy().get()); if (csep) { @@ -800,14 +801,14 @@ class StartupMessageHandler : public cass::RefCounted { writer.EndObject(); // executionProfile } - typedef std::pair StringPair; - typedef cass::Vector StringPairVec; - StringPairVec get_config_anti_patterns(const cass::ExecutionProfile& default_profile, - const cass::ExecutionProfile::Map& profiles, - const cass::LoadBalancingPolicy::Vec& policies, - const cass::HostMap& hosts, - const cass::SslContext::Ptr& ssl_context, - const cass::AuthProvider::Ptr& auth_provider) { + typedef std::pair StringPair; + typedef Vector StringPairVec; + StringPairVec get_config_anti_patterns(const ExecutionProfile& default_profile, + const ExecutionProfile::Map& profiles, + const LoadBalancingPolicy::Vec& policies, + const HostMap& hosts, + const SslContext::Ptr& ssl_context, + const AuthProvider::Ptr& auth_provider) { StringPairVec config_anti_patterns; if (is_contact_points_multiple_dcs(policies, hosts)) { @@ -817,9 +818,9 @@ class StartupMessageHandler : public cass::RefCounted { CONFIG_ANTIPATTERN_MSG_MULTI_DC_HOSTS); } - for (cass::LoadBalancingPolicy::Vec::const_iterator it = policies.begin(), + for (LoadBalancingPolicy::Vec::const_iterator it = policies.begin(), end = policies.end(); it != end; ++it) { - cass::DCAwarePolicy* dc_lbp = get_dc_aware_policy(*it); + DCAwarePolicy* dc_lbp = get_dc_aware_policy(*it); if (dc_lbp && !dc_lbp->skip_remote_dcs_for_local_cl()) { config_anti_patterns.push_back(StringPair("useRemoteHosts", CONFIG_ANTIPATTERN_MSG_REMOTE_HOSTS)); @@ -831,7 +832,7 @@ class StartupMessageHandler : public cass::RefCounted { bool is_downgrading_consistency_enabled = is_downgrading_retry_anti_pattern(default_profile.retry_policy()); if (!is_downgrading_consistency_enabled) { - for (cass::ExecutionProfile::Map::const_iterator it = profiles.begin(), + for (ExecutionProfile::Map::const_iterator it = profiles.begin(), end = profiles.end(); it != end; ++it) { if (is_downgrading_retry_anti_pattern(it->second.retry_policy())) { is_downgrading_consistency_enabled = true; @@ -854,7 +855,7 @@ class StartupMessageHandler : public cass::RefCounted { } if (auth_provider && - auth_provider->name().find("PlainTextAuthProvider") != cass::String::npos && + auth_provider->name().find("PlainTextAuthProvider") != String::npos && !ssl_context) { config_anti_patterns.push_back(StringPair("plainTextAuthWithoutSsl", CONFIG_ANTIPATTERN_MSG_PLAINTEXT_NO_SSL)); @@ -865,13 +866,13 @@ class StartupMessageHandler : public cass::RefCounted { return config_anti_patterns; } - cass::DCAwarePolicy* get_dc_aware_policy(const cass::LoadBalancingPolicy::Ptr& policy) { - cass::LoadBalancingPolicy* current_lbp = policy.get(); + DCAwarePolicy* get_dc_aware_policy(const LoadBalancingPolicy::Ptr& policy) { + LoadBalancingPolicy* current_lbp = policy.get(); do { - if (cass::DCAwarePolicy* dc_lbp = dynamic_cast(current_lbp)) { + if (DCAwarePolicy* dc_lbp = dynamic_cast(current_lbp)) { return dc_lbp; } - if (cass::ChainedLoadBalancingPolicy* chained_lbp = dynamic_cast(current_lbp)) { + if (ChainedLoadBalancingPolicy* chained_lbp = dynamic_cast(current_lbp)) { current_lbp = chained_lbp->child_policy().get(); } else { break; @@ -881,26 +882,26 @@ class StartupMessageHandler : public cass::RefCounted { return NULL; } - bool is_contact_points_multiple_dcs(const cass::LoadBalancingPolicy::Vec& policies, - const cass::HostMap& hosts) { + bool is_contact_points_multiple_dcs(const LoadBalancingPolicy::Vec& policies, + const HostMap& hosts) { // Get the DC aware load balancing policy if it is the only policy that // exists. If found this policy will be used after the contact points have // been resolved in order to determine if there are contacts points that exist // in multiple DCs using a copy of the discovered hosts. if (policies.size() == 1) { - cass::DCAwarePolicy* policy = get_dc_aware_policy(policies[0]); + DCAwarePolicy* policy = get_dc_aware_policy(policies[0]); if (policy) { // Loop through the resolved contacts, find the correct initialized host // and if the contact point is a remote host identify as an anti-pattern for (ResolvedHostMap::const_iterator resolved_it = contact_points_resolved_.begin(), hosts_end = contact_points_resolved_.end(); resolved_it != hosts_end; ++resolved_it) { - const cass::AddressSet& addresses = resolved_it->second; - for (cass::AddressSet::const_iterator addresses_it = addresses.begin(), + const AddressSet& addresses = resolved_it->second; + for (AddressSet::const_iterator addresses_it = addresses.begin(), addresses_end = addresses.end(); addresses_it != addresses_end; ++addresses_it) { - const cass::Address& address = *addresses_it; - for (cass::HostMap::const_iterator hosts_it = hosts.begin(), + const Address& address = *addresses_it; + for (HostMap::const_iterator hosts_it = hosts.begin(), hosts_end = hosts.end(); hosts_it != hosts_end; ++hosts_it) { - const cass::Host::Ptr& host = hosts_it->second; + const Host::Ptr& host = hosts_it->second; if (host->address() == address && policy->distance(host) == CASS_HOST_DISTANCE_REMOTE) { return true; @@ -914,50 +915,48 @@ class StartupMessageHandler : public cass::RefCounted { return false; } - bool is_downgrading_retry_anti_pattern(const cass::RetryPolicy::Ptr& policy) { - if (policy && policy->type() == cass::RetryPolicy::DOWNGRADING) { + bool is_downgrading_retry_anti_pattern(const RetryPolicy::Ptr& policy) { + if (policy && policy->type() == RetryPolicy::DOWNGRADING) { return true; } return false; } private: - const cass::Connection::Ptr connection_; - const cass::String client_id_; - const cass::String session_id_; - const cass::Config config_; - const cass::HostMap hosts_; - const cass::LoadBalancingPolicy::Vec initialized_policies_; + const Connection::Ptr connection_; + const String client_id_; + const String session_id_; + const Config config_; + const HostMap hosts_; + const LoadBalancingPolicy::Vec initialized_policies_; private: - typedef cass::Map ResolvedHostMap; + typedef Map ResolvedHostMap; ResolvedHostMap contact_points_resolved_; }; -} // namespace dse - -ClientInsights::ClientInsights(const cass::String& client_id, - const cass::String& session_id, +ClientInsights::ClientInsights(const String& client_id, + const String& session_id, unsigned interval_secs) : client_id_(client_id) , session_id_(session_id) , interval_ms_(interval_secs * 1000) { } -uint64_t ClientInsights::interval_ms(const cass::VersionNumber& dse_server_version) const { +uint64_t ClientInsights::interval_ms(const VersionNumber& dse_server_version) const { // DSE v5.1.13+ (backported) // DSE v6.0.5+ (backported) // DSE v6.7.0 was the first to supported the Insights RPC call - if ((dse_server_version >= cass::VersionNumber(5, 1, 13) && dse_server_version < cass::VersionNumber(6, 0, 0)) || - dse_server_version >= cass::VersionNumber(6, 0, 5)) { + if ((dse_server_version >= VersionNumber(5, 1, 13) && dse_server_version < VersionNumber(6, 0, 0)) || + dse_server_version >= VersionNumber(6, 0, 5)) { return interval_ms_; } return 0; } -void ClientInsights::send_startup_message(const cass::Connection::Ptr& connection, - const cass::Config& config, - const cass::HostMap& hosts, - const cass::LoadBalancingPolicy::Vec& initialized_policies) { +void ClientInsights::send_startup_message(const Connection::Ptr& connection, + const Config& config, + const HostMap& hosts, + const LoadBalancingPolicy::Vec& initialized_policies) { StartupMessageHandler::Ptr handler = StartupMessageHandler::Ptr(new StartupMessageHandler(connection, client_id_, session_id_, @@ -967,8 +966,8 @@ void ClientInsights::send_startup_message(const cass::Connection::Ptr& connectio handler->send_message(); } -void ClientInsights::send_status_message(const cass::Connection::Ptr& connection, - const cass::HostMap& hosts) { +void ClientInsights::send_status_message(const Connection::Ptr& connection, + const HostMap& hosts) { StringBuffer buffer; Writer writer(buffer); @@ -987,10 +986,10 @@ void ClientInsights::send_status_message(const cass::Connection::Ptr& connection writer.Key("conntectedNodes"); writer.StartObject(); - for (cass::HostMap::const_iterator it = hosts.begin(), + for (HostMap::const_iterator it = hosts.begin(), end = hosts.end(); it != end; ++it) { - cass::String address_with_port = it->first.to_string(true); - const cass::Host::Ptr& host = it->second; + String address_with_port = it->first.to_string(true); + const Host::Ptr& host = it->second; writer.Key(address_with_port.c_str()); writer.StartObject(); writer.Key("connections"); @@ -1005,7 +1004,9 @@ void ClientInsights::send_status_message(const cass::Connection::Ptr& connection writer.EndObject(); assert(writer.IsComplete() && "Status JSON is incomplete"); - connection->write_and_flush(cass::RequestCallback::Ptr( + connection->write_and_flush(RequestCallback::Ptr( new ClientInsightsRequestCallback(buffer.GetString(), METADATA_STATUS_NAME))); } + +} } } // namespace datastax::internal::enterprise diff --git a/src/client_insights.hpp b/src/client_insights.hpp index bbf0cee62..29774dd41 100644 --- a/src/client_insights.hpp +++ b/src/client_insights.hpp @@ -13,41 +13,35 @@ #include "monitor_reporting.hpp" #include "resolver.hpp" -namespace cass { - -class Session; - -} // namespace cass - -namespace dse { +namespace datastax { namespace internal { namespace enterprise { class ClientInsightsRequestCallback; class StartupMessageHandler; -class ClientInsights : public cass::MonitorReporting { +class ClientInsights : public core::MonitorReporting { public: - typedef cass::json::StringBuffer StringBuffer; - typedef cass::json::Writer Writer; + typedef json::StringBuffer StringBuffer; + typedef json::Writer Writer; - ClientInsights(const cass::String& client_id, - const cass::String& session_id, + ClientInsights(const String& client_id, + const String& session_id, unsigned interval_secs); virtual ~ClientInsights() { } - virtual uint64_t interval_ms(const cass::VersionNumber& dse_server_version) const; - virtual void send_startup_message(const cass::Connection::Ptr& connection, - const cass::Config& config, - const cass::HostMap& hosts, - const cass::LoadBalancingPolicy::Vec& initialized_policies); - virtual void send_status_message(const cass::Connection::Ptr& connection, - const cass::HostMap& hosts); + virtual uint64_t interval_ms(const core::VersionNumber& dse_server_version) const; + virtual void send_startup_message(const core::Connection::Ptr& connection, + const core::Config& config, + const core::HostMap& hosts, + const core::LoadBalancingPolicy::Vec& initialized_policies); + virtual void send_status_message(const core::Connection::Ptr& connection, + const core::HostMap& hosts); private: - const cass::String client_id_; - const cass::String session_id_; + const String client_id_; + const String session_id_; const uint64_t interval_ms_; }; -} // namespace dse +} } } // namespace datastax::internal::enterprise #endif // __DSE_CLIENT_INSIGHTS_HPP_INCLUDED__ diff --git a/src/cluster_config.cpp b/src/cluster_config.cpp index 2dada89bb..3f8833966 100644 --- a/src/cluster_config.cpp +++ b/src/cluster_config.cpp @@ -9,15 +9,17 @@ #include "dse_auth.hpp" #include "cluster_config.hpp" -#include "memory.hpp" #include "string.hpp" +using namespace datastax; +using namespace datastax::internal::enterprise; + static void dse_plaintext_authenticator_cleanup(void* data) { - delete static_cast(data); + delete static_cast(data); } static void dse_gssapi_authenticator_cleanup(void* data) { - delete static_cast(data); + delete static_cast(data); } extern "C" { @@ -60,14 +62,14 @@ CassError cass_cluster_set_dse_plaintext_authenticator_proxy_n(CassCluster* clus const char* password, size_t password_length, const char* authorization_id, size_t authorization_id_length) { CassError rc = cass_cluster_set_authenticator_callbacks(cluster, - dse::PlaintextAuthenticatorData::callbacks(), + PlaintextAuthenticatorData::callbacks(), dse_plaintext_authenticator_cleanup, - new dse::PlaintextAuthenticatorData(cass::String(username, username_length), - cass::String(password, password_length), - cass::String(authorization_id, authorization_id_length))); + new PlaintextAuthenticatorData(String(username, username_length), + String(password, password_length), + String(authorization_id, authorization_id_length))); if (rc == CASS_OK) { - cass::String name = "DSEPlainTextAuthProvider"; + String name = "DSEPlainTextAuthProvider"; if (authorization_id_length > 0) { name.append(" (Proxy)"); } @@ -109,13 +111,13 @@ CassError cass_cluster_set_dse_gssapi_authenticator_proxy_n(CassCluster* cluster const char* principal, size_t principal_length, const char* authorization_id, size_t authorization_id_length) { CassError rc = cass_cluster_set_authenticator_callbacks(cluster, - dse::GssapiAuthenticatorData::callbacks(), + GssapiAuthenticatorData::callbacks(), dse_gssapi_authenticator_cleanup, - new dse::GssapiAuthenticatorData(cass::String(service, service_length), - cass::String(principal, principal_length), - cass::String(authorization_id, authorization_id_length))); + new GssapiAuthenticatorData(String(service, service_length), + String(principal, principal_length), + String(authorization_id, authorization_id_length))); if (rc == CASS_OK) { - cass::String name = "DSEGSSAPIAuthProvider"; + String name = "DSEGSSAPIAuthProvider"; if (authorization_id_length > 0) { name.append(" (Proxy)"); } @@ -134,8 +136,8 @@ void cass_cluster_set_application_name(CassCluster* cluster, void cass_cluster_set_application_name_n(CassCluster* cluster, const char* application_name, size_t application_name_length) { - cluster->config().set_application_name(cass::String(application_name, - application_name_length)); + cluster->config().set_application_name(String(application_name, + application_name_length)); } void cass_cluster_set_application_version(CassCluster* cluster, @@ -147,8 +149,8 @@ void cass_cluster_set_application_version(CassCluster* cluster, void cass_cluster_set_application_version_n(CassCluster* cluster, const char* application_version, size_t application_version_length) { - cluster->config().set_application_version(cass::String(application_version, - application_version_length)); + cluster->config().set_application_version(String(application_version, + application_version_length)); } void cass_cluster_set_client_id(CassCluster* cluster, CassUuid client_id) { diff --git a/src/collection.cpp b/src/collection.cpp index 98307c810..b52ade8bb 100644 --- a/src/collection.cpp +++ b/src/collection.cpp @@ -12,9 +12,11 @@ #include "line_string.hpp" #include "polygon.hpp" +using namespace datastax::internal::enterprise; + CassError cass_collection_append_dse_point(CassCollection* collection, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_collection_append_custom(collection, DSE_POINT_TYPE, bytes.data(), bytes.size()); } @@ -33,7 +35,7 @@ CassError cass_collection_append_dse_polygon(CassCollection* collection, CassError cass_collection_append_dse_date_range(CassCollection* collection, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_collection_append_custom(collection, DSE_DATE_RANGE_TYPE, bytes.data(), bytes.size()); } diff --git a/src/date_range.cpp b/src/date_range.cpp index e2797968b..f3f253aff 100644 --- a/src/date_range.cpp +++ b/src/date_range.cpp @@ -8,7 +8,46 @@ #include "serialization.hpp" #include "cpp-driver/src/serialization.hpp" -namespace dse { +extern "C" { + +DseDateRangeBound dse_date_range_bound_init(DseDateRangePrecision precision, + cass_int64_t time_ms) { + DseDateRangeBound bound; + bound.precision = precision; + bound.time_ms = time_ms; + return bound; +} + +DseDateRangeBound dse_date_range_bound_unbounded() { + DseDateRangeBound bound; + bound.precision = DSE_DATE_RANGE_PRECISION_UNBOUNDED; + bound.time_ms = -1; + return bound; +} + +cass_bool_t dse_date_range_bound_is_unbounded(DseDateRangeBound bound) { + return static_cast(bound.precision == DSE_DATE_RANGE_PRECISION_UNBOUNDED); +} + +DseDateRange* dse_date_range_init(DseDateRange* range, + DseDateRangeBound lower_bound, + DseDateRangeBound upper_bound) { + range->lower_bound = lower_bound; + range->upper_bound = upper_bound; + range->is_single_date = cass_false; + return range; +} + +DseDateRange* dse_date_range_init_single_date(DseDateRange* range, + DseDateRangeBound date) { + range->lower_bound = date; + range->is_single_date = cass_true; + return range; +} + +} // extern "C" + +namespace datastax { namespace internal { namespace enterprise { Bytes encode_date_range(const DseDateRange *range) { Bytes bytes; @@ -37,72 +76,37 @@ Bytes encode_date_range(const DseDateRange *range) { case DATE_RANGE_BOUND_TYPE_SINGLE_DATE_OPEN: bytes.resize(sizeof(int8_t)); pos = reinterpret_cast(&bytes[0]); - cass::encode_int8(pos, range_type); + encode_int8(pos, range_type); break; case DATE_RANGE_BOUND_TYPE_SINGLE_DATE: case DATE_RANGE_BOUND_TYPE_OPEN_RANGE_HIGH: // type, from_time, from_precision bytes.resize(sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t)); pos = reinterpret_cast(&bytes[0]); - pos = cass::encode_int8(pos, range_type); - pos = cass::encode_int64(pos, range->lower_bound.time_ms); - cass::encode_int8(pos, range->lower_bound.precision); + pos = encode_int8(pos, range_type); + pos = encode_int64(pos, range->lower_bound.time_ms); + encode_int8(pos, range->lower_bound.precision); break; case DATE_RANGE_BOUND_TYPE_OPEN_RANGE_LOW: // type, to_time, to_precision bytes.resize(sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t)); pos = reinterpret_cast(&bytes[0]); - pos = cass::encode_int8(pos, range_type); - pos = cass::encode_int64(pos, range->upper_bound.time_ms); - cass::encode_int8(pos, range->upper_bound.precision); + pos = encode_int8(pos, range_type); + pos = encode_int64(pos, range->upper_bound.time_ms); + encode_int8(pos, range->upper_bound.precision); break; case DATE_RANGE_BOUND_TYPE_CLOSED_RANGE: // type, from_time, from_precision, to_time, to_precision bytes.resize(sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t)); pos = reinterpret_cast(&bytes[0]); - pos = cass::encode_int8(pos, range_type); - pos = cass::encode_int64(pos, range->lower_bound.time_ms); - pos = cass::encode_int8(pos, range->lower_bound.precision); - pos = cass::encode_int64(pos, range->upper_bound.time_ms); - cass::encode_int8(pos, range->upper_bound.precision); + pos = encode_int8(pos, range_type); + pos = encode_int64(pos, range->lower_bound.time_ms); + pos = encode_int8(pos, range->lower_bound.precision); + pos = encode_int64(pos, range->upper_bound.time_ms); + encode_int8(pos, range->upper_bound.precision); break; } return bytes; } -} - -DseDateRangeBound dse_date_range_bound_init(DseDateRangePrecision precision, - cass_int64_t time_ms) { - DseDateRangeBound bound; - bound.precision = precision; - bound.time_ms = time_ms; - return bound; -} - -DseDateRangeBound dse_date_range_bound_unbounded() { - DseDateRangeBound bound; - bound.precision = DSE_DATE_RANGE_PRECISION_UNBOUNDED; - bound.time_ms = -1; - return bound; -} - -cass_bool_t dse_date_range_bound_is_unbounded(DseDateRangeBound bound) { - return static_cast(bound.precision == DSE_DATE_RANGE_PRECISION_UNBOUNDED); -} - -DseDateRange* dse_date_range_init(DseDateRange* range, - DseDateRangeBound lower_bound, - DseDateRangeBound upper_bound) { - range->lower_bound = lower_bound; - range->upper_bound = upper_bound; - range->is_single_date = cass_false; - return range; -} - -DseDateRange* dse_date_range_init_single_date(DseDateRange* range, - DseDateRangeBound date) { - range->lower_bound = date; - range->is_single_date = cass_true; - return range; -} +} } } // datastax::internal::enterprise diff --git a/src/date_range.hpp b/src/date_range.hpp index 933aa7190..fa16b41ca 100644 --- a/src/date_range.hpp +++ b/src/date_range.hpp @@ -10,8 +10,10 @@ #include "serialization.hpp" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { + Bytes encode_date_range(const DseDateRange *range); -} + +} } } // datastax::internal::enterprise #endif diff --git a/src/driver_info.cpp b/src/driver_info.cpp index dfb65bad2..b86740065 100644 --- a/src/driver_info.cpp +++ b/src/driver_info.cpp @@ -26,7 +26,7 @@ STRINGIFY(DSE_VERSION_MINOR) "." \ STRINGIFY(DSE_VERSION_PATCH) -namespace cass { +namespace datastax { namespace internal { const char* driver_name() { return "DataStax Enterprise C/C++ Driver"; @@ -40,4 +40,4 @@ const char* driver_version() { } } -} // namespace cass +} } // namespace datastax::internal diff --git a/src/dse_auth.cpp b/src/dse_auth.cpp index aba145d2e..c5b42547e 100644 --- a/src/dse_auth.cpp +++ b/src/dse_auth.cpp @@ -25,6 +25,10 @@ #define GSSAPI_AUTH_MECHANISM "GSSAPI" #define GSSAPI_AUTH_SERVER_INITIAL_CHALLENGE "GSSAPI-START" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::enterprise; + static void dse_gssapi_authenticator_nop_lock(void* data) { } static void dse_gssapi_authenticator_nop_unlock(void* data) { } @@ -33,15 +37,13 @@ extern "C" { CassError dse_gssapi_authenticator_set_lock_callbacks(DseGssapiAuthenticatorLockCallback lock_callback, DseGssapiAuthenticatorUnlockCallback unlock_callback, void* data) { - return dse::GssapiAuthenticatorData::set_lock_callbacks(lock_callback, unlock_callback, data); + return GssapiAuthenticatorData::set_lock_callbacks(lock_callback, unlock_callback, data); } } // extern "C" -namespace dse { - void PlaintextAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) { - cass::StringRef authenticator(DSE_AUTHENTICATOR); + StringRef authenticator(DSE_AUTHENTICATOR); if (authenticator == cass_authenticator_class_name(auth, NULL)) { cass_authenticator_set_response(auth, @@ -56,11 +58,11 @@ void PlaintextAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) void PlaintextAuthenticatorData::on_challenge(CassAuthenticator* auth, void* data, const char* token, size_t token_size) { - cass::StringRef plaintext(PLAINTEXT_AUTH_SERVER_INITIAL_CHALLENGE); + StringRef plaintext(PLAINTEXT_AUTH_SERVER_INITIAL_CHALLENGE); PlaintextAuthenticatorData* plaintext_auth = static_cast(data); - if (plaintext == cass::StringRef(token, token_size)) { + if (plaintext == StringRef(token, token_size)) { size_t username_size = plaintext_auth->username_.size(); size_t password_size = plaintext_auth->password_.size(); size_t authorization_id_size = plaintext_auth->authorization_id_.size(); @@ -85,7 +87,7 @@ void PlaintextAuthenticatorData::on_challenge(CassAuthenticator* auth, void* dat return; } - cass::String error("Unexpected token returned during plaintext challenge '"); + String error("Unexpected token returned during plaintext challenge '"); error.append(token, token_size); error.append("'"); @@ -157,7 +159,7 @@ class GssapiName { } }; -class GssapiAuthenticator : public cass::Allocated { +class GssapiAuthenticator : public Allocated { public: enum State { NEGOTIATION, @@ -177,34 +179,34 @@ class GssapiAuthenticator : public cass::Allocated { AUTH_CONFIDENTIALITY = 3 }; - GssapiAuthenticator(const cass::String& authorization_id); + GssapiAuthenticator(const String& authorization_id); ~GssapiAuthenticator(); - const cass::String& response() const { return response_; } - const cass::String& error() const { return error_; } + const String& response() const { return response_; } + const String& error() const { return error_; } - Result init(const cass::String& service, const cass::String& principal); + Result init(const String& service, const String& principal); Result process(const char* token, size_t token_length); private: Result negotiate(gss_buffer_t challenge_token); Result authenticate(gss_buffer_t challenge_token); - static cass::String display_status(OM_uint32 maj, OM_uint32 min); + static String display_status(OM_uint32 maj, OM_uint32 min); private: gss_ctx_id_t context_; gss_name_t server_name_; OM_uint32 gss_flags_; gss_cred_id_t client_creds_; - cass::String username_; - cass::String response_; - cass::String error_; + String username_; + String response_; + String error_; State state_; - cass::String authorization_id_; + String authorization_id_; }; -GssapiAuthenticator::GssapiAuthenticator(const cass::String& authorization_id) +GssapiAuthenticator::GssapiAuthenticator(const String& authorization_id) : context_(GSS_C_NO_CONTEXT) , server_name_(GSS_C_NO_NAME) , gss_flags_(GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG) @@ -238,7 +240,7 @@ GssapiAuthenticator::~GssapiAuthenticator() { } } -GssapiAuthenticator::Result GssapiAuthenticator::init(const cass::String& service, const cass::String& principal) { +GssapiAuthenticator::Result GssapiAuthenticator::init(const String& service, const String& principal) { OM_uint32 maj_stat; OM_uint32 min_stat; gss_buffer_desc name_token = GSS_C_EMPTY_BUFFER; @@ -377,7 +379,7 @@ GssapiAuthenticator::Result GssapiAuthenticator::authenticate(gss_buffer_t chall OM_uint32 req_output_size; OM_uint32 max_input_size; unsigned char qop; - cass::String input; + String input; gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; GssapiBuffer output_token; @@ -434,7 +436,7 @@ GssapiAuthenticator::Result GssapiAuthenticator::authenticate(gss_buffer_t chall input.push_back((req_output_size >> 0) & 0xFF); // Send the authorization_id if present (proxy login), otherwise the username. - const cass::String& authorization_id = authorization_id_.empty() ? username_ : authorization_id_; + const String& authorization_id = authorization_id_.empty() ? username_ : authorization_id_; input.append(authorization_id); input_token.length = 4 + authorization_id.size(); @@ -467,8 +469,8 @@ GssapiAuthenticator::Result GssapiAuthenticator::authenticate(gss_buffer_t chall return RESULT_COMPLETE; } -cass::String GssapiAuthenticator::display_status(OM_uint32 maj, OM_uint32 min) { - cass::String error; +String GssapiAuthenticator::display_status(OM_uint32 maj, OM_uint32 min) { + String error; OM_uint32 message_context; message_context = 0; @@ -568,7 +570,7 @@ CassError GssapiAuthenticatorData::set_lock_callbacks(DseGssapiAuthenticatorLock } void GssapiAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) { - cass::StringRef authenticator(DSE_AUTHENTICATOR); + StringRef authenticator(DSE_AUTHENTICATOR); GssapiAuthenticatorData* gssapi_auth_data = static_cast(data); @@ -576,7 +578,7 @@ void GssapiAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) { = static_cast(cass_authenticator_exchange_data(auth)); if (gssapi_auth == NULL) { - cass::String service; + String service; size_t hostname_length = 0; const char* hostname = cass_authenticator_hostname(auth, &hostname_length); @@ -600,7 +602,7 @@ void GssapiAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) { if (gssapi_auth->init(service, gssapi_auth_data->principal()) == GssapiAuthenticator::RESULT_ERROR) { - cass::String error("Unable to intialize GSSAPI: "); + String error("Unable to intialize GSSAPI: "); error.append(gssapi_auth->error()); cass_authenticator_set_error_n(auth, error.data(), error.length()); return; @@ -620,20 +622,20 @@ void GssapiAuthenticatorData::on_initial(CassAuthenticator* auth, void* data) { void GssapiAuthenticatorData::on_challenge(CassAuthenticator* auth, void* data, const char* token, size_t token_size) { - cass::StringRef gssapi(GSSAPI_AUTH_SERVER_INITIAL_CHALLENGE); + StringRef gssapi(GSSAPI_AUTH_SERVER_INITIAL_CHALLENGE); GssapiAuthenticator* gssapi_auth = static_cast(cass_authenticator_exchange_data(auth)); - if (gssapi == cass::StringRef(token, token_size)) { + if (gssapi == StringRef(token, token_size)) { if (gssapi_auth->process("", 0) == GssapiAuthenticator::RESULT_ERROR) { - cass::String error("GSSAPI initial handshake failed: "); + String error("GSSAPI initial handshake failed: "); error.append(gssapi_auth->error()); cass_authenticator_set_error_n(auth, error.data(), error.length()); } } else { if (gssapi_auth->process(token, token_size) == GssapiAuthenticator::RESULT_ERROR) { - cass::String error("GSSAPI challenge handshake failed: "); + String error("GSSAPI challenge handshake failed: "); error.append(gssapi_auth->error()); cass_authenticator_set_error_n(auth, error.data(), error.length()); } @@ -660,5 +662,3 @@ CassAuthenticatorCallbacks GssapiAuthenticatorData::callbacks_ = { DseGssapiAuthenticatorLockCallback GssapiAuthenticatorData::lock_callback_ = dse_gssapi_authenticator_nop_lock; DseGssapiAuthenticatorUnlockCallback GssapiAuthenticatorData::unlock_callback_ = dse_gssapi_authenticator_nop_unlock; void* GssapiAuthenticatorData::data_ = NULL; - -} // namespace dse diff --git a/src/dse_auth.hpp b/src/dse_auth.hpp index 7e30694f4..d9cd9a4b3 100644 --- a/src/dse_auth.hpp +++ b/src/dse_auth.hpp @@ -14,13 +14,13 @@ #include -namespace dse { +namespace datastax { namespace internal { namespace enterprise { -class PlaintextAuthenticatorData : public cass::Allocated { +class PlaintextAuthenticatorData : public Allocated { public: - PlaintextAuthenticatorData(const cass::String& username, - const cass::String& password, - const cass::String& authorization_id) + PlaintextAuthenticatorData(const datastax::String& username, + const datastax::String& password, + const datastax::String& authorization_id) : username_(username) , password_(password) , authorization_id_(authorization_id) { } @@ -36,25 +36,25 @@ class PlaintextAuthenticatorData : public cass::Allocated { static CassAuthenticatorCallbacks callbacks_; private: - cass::String username_; - cass::String password_; - cass::String authorization_id_; + datastax::String username_; + datastax::String password_; + datastax::String authorization_id_; }; -class GssapiAuthenticatorData : public cass::Allocated { +class GssapiAuthenticatorData : public Allocated { public: - GssapiAuthenticatorData(const cass::String& service, - const cass::String& principal, - const cass::String& authorization_id) + GssapiAuthenticatorData(const datastax::String& service, + const datastax::String& principal, + const datastax::String& authorization_id) : service_(service) , principal_(principal) , authorization_id_(authorization_id) { } static const CassAuthenticatorCallbacks* callbacks() { return &callbacks_; } - const cass::String& service() const { return service_; } - const cass::String& principal() const { return principal_; } - const cass::String& authorization_id() const { return authorization_id_; } + const datastax::String& service() const { return service_; } + const datastax::String& principal() const { return principal_; } + const datastax::String& authorization_id() const { return authorization_id_; } static CassError set_lock_callbacks(DseGssapiAuthenticatorLockCallback lock_callback, DseGssapiAuthenticatorUnlockCallback unlock_callback, @@ -79,11 +79,11 @@ class GssapiAuthenticatorData : public cass::Allocated { static void* data_; private: - cass::String service_; - cass::String principal_; - cass::String authorization_id_; + datastax::String service_; + datastax::String principal_; + datastax::String authorization_id_; }; -} // namespace dse +} } } // namespace datastax::internal::enterprise #endif diff --git a/src/graph.cpp b/src/graph.cpp index 7bdde085c..ba58c5126 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -11,7 +11,7 @@ #include #include -#include // cass::encode_int64() +#include // datastax::encode_int64() #include #include #include @@ -22,40 +22,43 @@ #include #include -using cass::Logger; +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; namespace { static const DseGraphResult* find_member(const DseGraphResult* result, const char* name, size_t expected_index) { if (expected_index < result->MemberCount()) { - const cass::json::Value::Member& member = result->MemberBegin()[expected_index]; + const json::Value::Member& member = result->MemberBegin()[expected_index]; if (member.name == name) { return DseGraphResult::to(&member.value); } } - cass::json::Value::ConstMemberIterator i = result->FindMember(name); + json::Value::ConstMemberIterator i = result->FindMember(name); return i != result->MemberEnd() ? DseGraphResult::to(&i->value) : NULL; } -struct GraphAnalyticsRequest : public cass::Allocated { - GraphAnalyticsRequest(cass::Session* session, - cass::ResponseFuture* future, - const cass::Statement* statement) +struct GraphAnalyticsRequest : public Allocated { + GraphAnalyticsRequest(Session* session, + ResponseFuture* future, + const Statement* statement) : session(session) , future(future) , statement(statement) { } - cass::Session* session; - cass::SharedRefPtr future; - cass::SharedRefPtr statement; + Session* session; + SharedRefPtr future; + SharedRefPtr statement; }; void graph_analytics_callback(CassFuture* future, void* data) { GraphAnalyticsRequest* request = static_cast(data); - cass::ResponseFuture* response_future = static_cast(future->from()); - cass::Future::Error* error = response_future->error(); + ResponseFuture* response_future = static_cast(future->from()); + Future::Error* error = response_future->error(); if (error != NULL) { request->future->set_error_with_address(response_future->address(), error->code, error->message); @@ -69,25 +72,25 @@ void graph_analytics_callback(CassFuture* future, void* data) { void graph_analytics_lookup_callback(CassFuture* future, void* data) { GraphAnalyticsRequest* request = static_cast(data); - cass::ResponseFuture* response_future = static_cast(future->from()); - cass::ResultResponse* response = static_cast(response_future->response().get()); + ResponseFuture* response_future = static_cast(future->from()); + ResultResponse* response = static_cast(response_future->response().get()); - cass::Address preferred_address; + Address preferred_address; bool use_preferred_address = response->row_count() > 0; if (use_preferred_address) { - const cass::Value* value = response->first_row().get_by_name("result"); + const Value* value = response->first_row().get_by_name("result"); if (value == NULL || !value->is_map() || - !cass::is_string_type(value->primary_value_type()) || - !cass::is_string_type(value->secondary_value_type())) { + !is_string_type(value->primary_value_type()) || + !is_string_type(value->secondary_value_type())) { LOG_ERROR("The 'result' column is either not present or is not the " "expected type 'map' in analytics master lookup " "response."); use_preferred_address = false; } else { - cass::StringRef location; - cass::MapIterator iterator(value); + StringRef location; + MapIterator iterator(value); while(iterator.next()) { if (iterator.key()->to_string_ref() == "location") { location = iterator.value()->to_string_ref(); @@ -95,7 +98,7 @@ void graph_analytics_lookup_callback(CassFuture* future, void* data) { } } - if (!cass::Address::from_string(location.to_string(), + if (!Address::from_string(location.to_string(), request->session->config().port(), &preferred_address)) { LOG_ERROR("The 'location' map entry's value is not a valid address in " @@ -110,7 +113,7 @@ void graph_analytics_lookup_callback(CassFuture* future, void* data) { "analytics query. Using a coordinator node to route request..."); } - cass::Future::Ptr request_future( + Future::Ptr request_future( request->session->execute(request->statement, use_preferred_address ? &preferred_address : NULL)); request_future->set_callback(graph_analytics_callback, data); @@ -123,12 +126,12 @@ extern "C" { CassFuture* cass_session_execute_dse_graph(CassSession* session, const DseGraphStatement* statement) { if (statement->graph_source() == DSE_GRAPH_ANALYTICS_SOURCE) { - cass::ResponseFuture* future = new cass::ResponseFuture(); + ResponseFuture* future = new ResponseFuture(); - cass::Future::Ptr request_future( + Future::Ptr request_future( session->execute( - cass::Request::ConstPtr( - new cass::QueryRequest(DSE_LOOKUP_ANALYTICS_GRAPH_SERVER)))); + Request::ConstPtr( + new QueryRequest(DSE_LOOKUP_ANALYTICS_GRAPH_SERVER)))); request_future->set_callback(graph_analytics_lookup_callback, new GraphAnalyticsRequest(session, future, @@ -144,11 +147,11 @@ CassFuture* cass_session_execute_dse_graph(CassSession* session, DseGraphResultSet* cass_future_get_dse_graph_resultset(CassFuture* future) { const CassResult* result = cass_future_get_result(future); if (result == NULL) return NULL; - return DseGraphResultSet::to(new dse::GraphResultSet(result)); + return DseGraphResultSet::to(new GraphResultSet(result)); } DseGraphOptions* dse_graph_options_new() { - return DseGraphOptions::to(new dse::GraphOptions()); + return DseGraphOptions::to(new GraphOptions()); } DseGraphOptions* dse_graph_options_new_from_existing(const DseGraphOptions* options) { @@ -167,7 +170,7 @@ CassError dse_graph_options_set_graph_language(DseGraphOptions* options, CassError dse_graph_options_set_graph_language_n(DseGraphOptions* options, const char* language, size_t language_length) { - options->set_graph_language(cass::String(language, language_length)); + options->set_graph_language(String(language, language_length)); return CASS_OK; } @@ -179,7 +182,7 @@ CassError dse_graph_options_set_graph_source(DseGraphOptions* options, CassError dse_graph_options_set_graph_source_n(DseGraphOptions* options, const char* source, size_t source_length) { - options->set_graph_source(cass::String(source, source_length)); + options->set_graph_source(String(source, source_length)); return CASS_OK; } @@ -191,7 +194,7 @@ CassError dse_graph_options_set_graph_name(DseGraphOptions* options, CassError dse_graph_options_set_graph_name_n(DseGraphOptions* options, const char* name, size_t name_length) { - options->set_graph_name(cass::String(name, name_length)); + options->set_graph_name(String(name, name_length)); return CASS_OK; } @@ -223,7 +226,7 @@ DseGraphStatement* dse_graph_statement_new(const char* query, DseGraphStatement* dse_graph_statement_new_n(const char* query, size_t query_length, const DseGraphOptions* options) { - return DseGraphStatement::to(new dse::GraphStatement(query, query_length, + return DseGraphStatement::to(new GraphStatement(query, query_length, options)); } @@ -245,7 +248,7 @@ CassError dse_graph_statement_set_timestamp(DseGraphStatement* statement, } DseGraphObject* dse_graph_object_new() { - return DseGraphObject::to(new dse::GraphObject()); + return DseGraphObject::to(new GraphObject()); } void dse_graph_object_free(DseGraphObject* object) { @@ -392,7 +395,7 @@ CassError dse_graph_object_add_object_n(DseGraphObject* object, return CASS_ERROR_LIB_BAD_PARAMS; } object->add_key(name, name_length); - object->add_writer(value, cass::rapidjson::kObjectType); + object->add_writer(value, rapidjson::kObjectType); return CASS_OK; } @@ -412,7 +415,7 @@ CassError dse_graph_object_add_array_n(DseGraphObject* object, return CASS_ERROR_LIB_BAD_PARAMS; } object->add_key(name, name_length); - object->add_writer(value, cass::rapidjson::kArrayType); + object->add_writer(value, rapidjson::kArrayType); return CASS_OK; } @@ -556,7 +559,7 @@ CassError dse_graph_array_add_object(DseGraphArray* array, if (array->is_complete() || !value->is_complete()) { return CASS_ERROR_LIB_BAD_PARAMS; } - array->add_writer(value, cass::rapidjson::kObjectType); + array->add_writer(value, rapidjson::kObjectType); return CASS_OK; } @@ -565,7 +568,7 @@ CassError dse_graph_array_add_array(DseGraphArray* array, if (array->is_complete() || !value->is_complete()) { return CASS_ERROR_LIB_BAD_PARAMS; } - array->add_writer(value, cass::rapidjson::kArrayType); + array->add_writer(value, rapidjson::kArrayType); return CASS_OK; } @@ -610,13 +613,13 @@ const DseGraphResult* dse_graph_resultset_next(DseGraphResultSet* resultset) { DseGraphResultType dse_graph_result_type(const DseGraphResult* result) { switch (result->GetType()) { - case cass::rapidjson::kNullType: return DSE_GRAPH_RESULT_TYPE_NULL; - case cass::rapidjson::kFalseType: // Intentional fallthrough - case cass::rapidjson::kTrueType: return DSE_GRAPH_RESULT_TYPE_BOOL; - case cass::rapidjson::kNumberType: return DSE_GRAPH_RESULT_TYPE_NUMBER; - case cass::rapidjson::kStringType: return DSE_GRAPH_RESULT_TYPE_STRING; - case cass::rapidjson::kObjectType: return DSE_GRAPH_RESULT_TYPE_OBJECT; - case cass::rapidjson::kArrayType: return DSE_GRAPH_RESULT_TYPE_ARRAY; + case rapidjson::kNullType: return DSE_GRAPH_RESULT_TYPE_NULL; + case rapidjson::kFalseType: // Intentional fallthrough + case rapidjson::kTrueType: return DSE_GRAPH_RESULT_TYPE_BOOL; + case rapidjson::kNumberType: return DSE_GRAPH_RESULT_TYPE_NUMBER; + case rapidjson::kStringType: return DSE_GRAPH_RESULT_TYPE_STRING; + case rapidjson::kObjectType: return DSE_GRAPH_RESULT_TYPE_OBJECT; + case rapidjson::kArrayType: return DSE_GRAPH_RESULT_TYPE_ARRAY; } // Path should never be executed @@ -742,7 +745,7 @@ size_t dse_graph_result_member_count(const DseGraphResult* result) { const char* dse_graph_result_member_key(const DseGraphResult* result, size_t index, size_t* length) { - const cass::json::Value& key = result->MemberBegin()[index].name; + const json::Value& key = result->MemberBegin()[index].name; if (length != NULL) { *length = key.GetStringLength(); } @@ -790,8 +793,6 @@ CassError dse_graph_result_as_polygon(const DseGraphResult* result, } // extern "C" -namespace dse { - GraphOptions* GraphOptions::clone() const { GraphOptions* options = new GraphOptions(); @@ -823,8 +824,8 @@ GraphOptions* GraphOptions::clone() const { void GraphOptions::set_request_timeout_ms(int64_t timeout_ms) { request_timeout_ms_ = timeout_ms; if (timeout_ms > 0) { - cass::String value(sizeof(timeout_ms), 0); - cass::encode_int64(&value[0], timeout_ms); + String value(sizeof(timeout_ms), 0); + encode_int64(&value[0], timeout_ms); cass_custom_payload_set_n(payload_, DSE_GRAPH_REQUEST_TIMEOUT, sizeof(DSE_GRAPH_REQUEST_TIMEOUT) - 1, @@ -856,17 +857,15 @@ const GraphResult* GraphResultSet::next() { return NULL; } - cass::json::Value::ConstMemberIterator i = document_.FindMember("result"); + json::Value::ConstMemberIterator i = document_.FindMember("result"); return i != document_.MemberEnd() ? &i->value : NULL; } return NULL; } void GraphWriter::add_point(cass_double_t x, cass_double_t y) { - cass::OStringStream ss; + OStringStream ss; ss.precision(WKT_MAX_DIGITS); ss << "POINT (" << x << " " << y << ")"; String(ss.str().c_str()); } - -} // namespace dse diff --git a/src/graph.hpp b/src/graph.hpp index a73139fec..934a4423b 100644 --- a/src/graph.hpp +++ b/src/graph.hpp @@ -14,9 +14,8 @@ #include "json.hpp" #include "line_string.hpp" #include "polygon.hpp" -#include "string.hpp" -#include +#include "external.hpp" #include #define DSE_GRAPH_OPTION_LANGUAGE_KEY "graph-language" @@ -32,11 +31,11 @@ #define DSE_LOOKUP_ANALYTICS_GRAPH_SERVER "CALL DseClientTool.getAnalyticsGraphServer()" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { class GraphStatement; -class GraphOptions : public cass::Allocated { +class GraphOptions : public Allocated { public: GraphOptions() : payload_(cass_custom_payload_new()) @@ -55,23 +54,23 @@ class GraphOptions : public cass::Allocated { GraphOptions* clone() const; - void set_graph_language(const cass::String& graph_language) { + void set_graph_language(const datastax::String& graph_language) { cass_custom_payload_set_n(payload_, DSE_GRAPH_OPTION_LANGUAGE_KEY, sizeof(DSE_GRAPH_OPTION_LANGUAGE_KEY) - 1, reinterpret_cast(graph_language.data()), graph_language.size()); graph_language_ = graph_language; } - const cass::String graph_source() const { return graph_source_; } + const datastax::String graph_source() const { return graph_source_; } - void set_graph_source(const cass::String& graph_source) { + void set_graph_source(const datastax::String& graph_source) { cass_custom_payload_set_n(payload_, DSE_GRAPH_OPTION_SOURCE_KEY, sizeof(DSE_GRAPH_OPTION_SOURCE_KEY) - 1, reinterpret_cast(graph_source.data()), graph_source.size()); graph_source_ = graph_source; } - void set_graph_name(const cass::String& graph_name) { + void set_graph_name(const datastax::String& graph_name) { cass_custom_payload_set_n(payload_, DSE_GRAPH_OPTION_NAME_KEY, sizeof(DSE_GRAPH_OPTION_NAME_KEY) - 1, reinterpret_cast(graph_name.data()), graph_name.size()); @@ -100,20 +99,20 @@ class GraphOptions : public cass::Allocated { private: CassCustomPayload* payload_; - cass::String graph_language_; - cass::String graph_name_; - cass::String graph_source_; + datastax::String graph_language_; + datastax::String graph_name_; + datastax::String graph_source_; CassConsistency read_consistency_; CassConsistency write_consistency_; int64_t request_timeout_ms_; }; class GraphWriter - : public cass::Allocated - , private cass::json::Writer { + : public Allocated + , private json::Writer { public: GraphWriter() - : cass::json::Writer(buffer_) { } + : json::Writer(buffer_) { } const char* data() const { return buffer_.GetString(); } size_t length() const { return buffer_.GetSize(); } @@ -127,24 +126,24 @@ class GraphWriter void add_double(cass_double_t value) { Double(value); } void add_string(const char* string, size_t length) { - String(string, static_cast(length)); + String(string, static_cast(length)); } void add_key(const char* key, size_t length) { - Key(key, static_cast(length)); + Key(key, static_cast(length)); } void add_point(cass_double_t x, cass_double_t y); - void add_line_string(const dse::LineString* line_string) { + void add_line_string(const LineString* line_string) { String(line_string->to_wkt().c_str()); } - void add_polygon(const dse::Polygon* polygon) { + void add_polygon(const Polygon* polygon) { String(polygon->to_wkt().c_str()); } - void add_writer(const GraphWriter* writer, cass::rapidjson::Type type) { + void add_writer(const GraphWriter* writer, datastax::rapidjson::Type type) { size_t length = writer->buffer_.GetSize(); Prefix(type); memcpy(os_->Push(length), writer->buffer_.GetString(), length); @@ -163,7 +162,7 @@ class GraphWriter void end_array() { EndArray(); } private: - cass::json::StringBuffer buffer_; + json::StringBuffer buffer_; }; class GraphObject : public GraphWriter { @@ -198,7 +197,7 @@ class GraphArray : public GraphWriter { } }; -class GraphStatement : public cass::Allocated { +class GraphStatement : public Allocated { public: GraphStatement(const char* query, size_t length, const GraphOptions* options) @@ -222,7 +221,7 @@ class GraphStatement : public cass::Allocated { cass_statement_free(wrapped_); } - const cass::String graph_source() const { return graph_source_; } + const datastax::String graph_source() const { return graph_source_; } const CassStatement* wrapped() const { return wrapped_; } @@ -242,14 +241,14 @@ class GraphStatement : public cass::Allocated { } private: - cass::String query_; - cass::String graph_source_; + datastax::String query_; + datastax::String graph_source_; CassStatement* wrapped_; }; -typedef cass::json::Value GraphResult; +typedef json::Value GraphResult; -class GraphResultSet : public cass::Allocated { +class GraphResultSet : public Allocated { public: GraphResultSet(const CassResult* result) : rows_(cass_iterator_from_result(result)) @@ -267,19 +266,19 @@ class GraphResultSet : public cass::Allocated { const GraphResult* next(); private: - cass::json::Document document_; - cass::String json_; + json::Document document_; + datastax::String json_; CassIterator* rows_; const CassResult* result_; }; -} // namespace dse +} } } // namespace datastax::internal::enterprise -EXTERNAL_TYPE(dse::GraphOptions, DseGraphOptions) -EXTERNAL_TYPE(dse::GraphStatement, DseGraphStatement) -EXTERNAL_TYPE(dse::GraphArray, DseGraphArray) -EXTERNAL_TYPE(dse::GraphObject, DseGraphObject) -EXTERNAL_TYPE(dse::GraphResultSet, DseGraphResultSet) -EXTERNAL_TYPE(dse::GraphResult, DseGraphResult) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphOptions, DseGraphOptions) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphStatement, DseGraphStatement) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphArray, DseGraphArray) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphObject, DseGraphObject) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphResultSet, DseGraphResultSet) +EXTERNAL_TYPE(datastax::internal::enterprise::GraphResult, DseGraphResult) #endif diff --git a/src/line_string.cpp b/src/line_string.cpp index d81c153f0..1638998db 100644 --- a/src/line_string.cpp +++ b/src/line_string.cpp @@ -14,10 +14,14 @@ #include #include +using namespace datastax; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; + extern "C" { DseLineString* dse_line_string_new() { - return DseLineString::to(new dse::LineString()); + return DseLineString::to(new LineString()); } void dse_line_string_free(DseLineString* line_string) { @@ -44,7 +48,7 @@ CassError dse_line_string_finish(DseLineString* line_string) { } DseLineStringIterator* dse_line_string_iterator_new() { - return DseLineStringIterator::to(new dse::LineStringIterator()); + return DseLineStringIterator::to(new LineStringIterator()); } void dse_line_string_iterator_free(DseLineStringIterator* iterator) { @@ -77,15 +81,13 @@ CassError dse_line_string_iterator_next_point(DseLineStringIterator* iterator, } // extern "C" -namespace dse { - -cass::String LineString::to_wkt() const { +String LineString::to_wkt() const { // Special case empty line string if (num_points_ == 0) { return "LINESTRING EMPTY"; } - cass::OStringStream ss; + OStringStream ss; ss.precision(WKT_MAX_DIGITS); ss << "LINESTRING ("; const cass_byte_t* pos = bytes_.data() + WKB_HEADER_SIZE + sizeof(cass_uint32_t); @@ -104,11 +106,11 @@ cass::String LineString::to_wkt() const { CassError LineStringIterator::reset_binary(const CassValue* value) { size_t size = 0; const cass_byte_t* pos = NULL; - dse::WkbByteOrder byte_order; + WkbByteOrder byte_order; cass_uint32_t num_points = 0; CassError rc = CASS_OK; - rc = dse::validate_data_type(value, DSE_LINE_STRING_TYPE); + rc = validate_data_type(value, DSE_LINE_STRING_TYPE); if (rc != CASS_OK) return rc; rc = cass_value_get_bytes(value, &pos, &size); @@ -119,12 +121,12 @@ CassError LineStringIterator::reset_binary(const CassValue* value) { } size -= WKB_LINE_STRING_HEADER_SIZE; - if (dse::decode_header(pos, &byte_order) != dse::WKB_GEOMETRY_TYPE_LINESTRING) { + if (decode_header(pos, &byte_order) != WKB_GEOMETRY_TYPE_LINESTRING) { return CASS_ERROR_LIB_INVALID_DATA; } pos += WKB_HEADER_SIZE; - num_points = dse::decode_uint32(pos, byte_order); + num_points = decode_uint32(pos, byte_order); pos += sizeof(cass_uint32_t); if (size < 2 * num_points * sizeof(cass_double_t)) { @@ -241,5 +243,3 @@ CassError LineStringIterator::TextIterator::next_point(cass_double_t* x, cass_do return CASS_OK; } - -} // namespace dse diff --git a/src/line_string.hpp b/src/line_string.hpp index 4f673f349..c1a4aef96 100644 --- a/src/line_string.hpp +++ b/src/line_string.hpp @@ -15,11 +15,11 @@ #include "string.hpp" #include "wkt.hpp" -#include +#include "external.hpp" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { -class LineString : public cass::Allocated { +class LineString : public Allocated { public: LineString() { reset(); @@ -57,14 +57,14 @@ class LineString : public cass::Allocated { return CASS_OK; } - cass::String to_wkt() const; + datastax::String to_wkt() const; private: cass_uint32_t num_points_; Bytes bytes_; }; -class LineStringIterator : public cass::Allocated { +class LineStringIterator : public Allocated { public: LineStringIterator() : num_points_(0) @@ -83,7 +83,7 @@ class LineStringIterator : public cass::Allocated { } private: - class Iterator : public cass::Allocated { + class Iterator : public Allocated { public: virtual ~Iterator() { } virtual CassError next_point(cass_double_t *x, cass_double_t *y) = 0; @@ -124,9 +124,9 @@ class LineStringIterator : public cass::Allocated { TextIterator text_iterator_; }; -} // namespace dse +} } } // namespace datastax::internal::enterprise -EXTERNAL_TYPE(dse::LineString, DseLineString) -EXTERNAL_TYPE(dse::LineStringIterator, DseLineStringIterator) +EXTERNAL_TYPE(datastax::internal::enterprise::LineString, DseLineString) +EXTERNAL_TYPE(datastax::internal::enterprise::LineStringIterator, DseLineStringIterator) #endif diff --git a/src/point.hpp b/src/point.hpp index 7a94bec7d..5e2821c6e 100644 --- a/src/point.hpp +++ b/src/point.hpp @@ -10,7 +10,7 @@ #include "serialization.hpp" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { inline Bytes encode_point(cass_double_t x, cass_double_t y) { Bytes bytes; @@ -26,6 +26,6 @@ inline Bytes encode_point(cass_double_t x, cass_double_t y) { return bytes; } -} // namespace dse +} } } // namespace datastax::internal::enterprise #endif diff --git a/src/polygon.cpp b/src/polygon.cpp index f493791b7..14db1a212 100644 --- a/src/polygon.cpp +++ b/src/polygon.cpp @@ -12,10 +12,15 @@ #include #include +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; + extern "C" { DsePolygon* dse_polygon_new() { - return DsePolygon::to(new dse::Polygon()); + return DsePolygon::to(new enterprise::Polygon()); } void dse_polygon_free(DsePolygon* polygon) { @@ -47,7 +52,7 @@ CassError dse_polygon_finish(DsePolygon* polygon) { } DsePolygonIterator* dse_polygon_iterator_new() { - return DsePolygonIterator::to(new dse::PolygonIterator()); + return DsePolygonIterator::to(new PolygonIterator()); } CassError dse_polygon_iterator_reset(DsePolygonIterator* iterator, @@ -86,15 +91,13 @@ CassError dse_polygon_iterator_next_point(DsePolygonIterator* iterator, } // extern "C" -namespace dse { - -cass::String Polygon::to_wkt() const { +String Polygon::to_wkt() const { // Special case empty polygon if (num_rings_ == 0) { return "POLYGON EMPTY"; } - cass::OStringStream ss; + OStringStream ss; ss.precision(WKT_MAX_DIGITS); ss << "POLYGON ("; const cass_byte_t* pos = bytes_.data() + WKB_HEADER_SIZE + sizeof(cass_uint32_t); @@ -120,10 +123,10 @@ cass::String Polygon::to_wkt() const { CassError PolygonIterator::reset_binary(const CassValue* value) { size_t size; const cass_byte_t* pos; - dse::WkbByteOrder byte_order; + WkbByteOrder byte_order; cass_uint32_t num_rings; - CassError rc = dse::validate_data_type(value, DSE_POLYGON_TYPE); + CassError rc = validate_data_type(value, DSE_POLYGON_TYPE); if (rc != CASS_OK) return rc; rc = cass_value_get_bytes(value, &pos, &size); @@ -134,12 +137,12 @@ CassError PolygonIterator::reset_binary(const CassValue* value) { } size -= WKB_POLYGON_HEADER_SIZE; - if (dse::decode_header(pos, &byte_order) != dse::WKB_GEOMETRY_TYPE_POLYGON) { + if (decode_header(pos, &byte_order) != WKB_GEOMETRY_TYPE_POLYGON) { return CASS_ERROR_LIB_INVALID_DATA; } pos += WKB_HEADER_SIZE; - num_rings = dse::decode_uint32(pos, byte_order); + num_rings = decode_uint32(pos, byte_order); pos += sizeof(cass_uint32_t); const cass_byte_t* rings = pos; @@ -153,7 +156,7 @@ CassError PolygonIterator::reset_binary(const CassValue* value) { } size -= sizeof(cass_uint32_t); - num_points = dse::decode_uint32(pos, byte_order); + num_points = decode_uint32(pos, byte_order); pos += sizeof(cass_uint32_t); if (size < 2 * num_points * sizeof(cass_double_t)) { @@ -364,5 +367,3 @@ CassError PolygonIterator::TextIterator::next_point(cass_double_t* x, cass_doubl return CASS_OK; } - -} // namespace dse diff --git a/src/polygon.hpp b/src/polygon.hpp index 39829a701..ff4dbf489 100644 --- a/src/polygon.hpp +++ b/src/polygon.hpp @@ -15,11 +15,11 @@ #include "string.hpp" #include "wkt.hpp" -#include +#include "external.hpp" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { -class Polygon : public cass::Allocated { +class Polygon : public Allocated { public: Polygon() { reset(); @@ -67,7 +67,7 @@ class Polygon : public cass::Allocated { return finish_ring(); // Finish the last ring } - cass::String to_wkt() const; + datastax::String to_wkt() const; private: CassError finish_ring() { @@ -89,7 +89,7 @@ class Polygon : public cass::Allocated { Bytes bytes_; }; -class PolygonIterator : public cass::Allocated { +class PolygonIterator : public Allocated { private: enum State { STATE_NUM_POINTS, @@ -122,7 +122,7 @@ class PolygonIterator : public cass::Allocated { } private: - class Iterator : public cass::Allocated { + class Iterator : public Allocated { public: virtual ~Iterator() { } virtual CassError next_num_points(cass_uint32_t* num_points) = 0; @@ -171,9 +171,9 @@ class PolygonIterator : public cass::Allocated { TextIterator text_iterator_; }; -} // namespace dse +} } } // namespace datastax::internal::enterprise -EXTERNAL_TYPE(dse::Polygon, DsePolygon) -EXTERNAL_TYPE(dse::PolygonIterator, DsePolygonIterator) +EXTERNAL_TYPE(datastax::internal::enterprise::Polygon, DsePolygon) +EXTERNAL_TYPE(datastax::internal::enterprise::PolygonIterator, DsePolygonIterator) #endif diff --git a/src/protocol.cpp b/src/protocol.cpp index f54052331..0d9365bb7 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -23,7 +23,8 @@ #define DSE_PROTOCOL_VERSION_BIT 0x40 #define DSE_PROTOCOL_VERSION_MASK 0x3F -namespace cass { +using namespace datastax; +using namespace datastax::internal::core; static bool is_protocol_at_least_v5_or_dse_v2(int version) { if (version & DSE_PROTOCOL_VERSION_BIT) { @@ -129,5 +130,3 @@ bool ProtocolVersion::supports_result_metadata_id() const { assert(value_ > 0 && "Invalid protocol version"); return is_protocol_at_least_v5_or_dse_v2(value_); } - -} // namespace cass diff --git a/src/serialization.hpp b/src/serialization.hpp index c134e4238..fee8148ef 100644 --- a/src/serialization.hpp +++ b/src/serialization.hpp @@ -27,7 +27,7 @@ #define WKB_POLYGON_HEADER_SIZE (WKB_HEADER_SIZE + sizeof(cass_uint32_t)) // Header + Num rings #define WKB_LINE_STRING_HEADER_SIZE (WKB_HEADER_SIZE + sizeof(cass_uint32_t)) // Header + Num points -namespace dse { +namespace datastax { namespace internal { namespace enterprise { enum DateRangeBoundType { DATE_RANGE_BOUND_TYPE_SINGLE_DATE = 0, @@ -72,7 +72,7 @@ inline WkbByteOrder native_byte_order() { #endif -typedef cass::Vector Bytes; +typedef Vector Bytes; #if defined(HAVE_BUILTIN_BSWAP32) && defined(HAVE_BUILTIN_BSWAP64) inline cass_uint32_t swap_uint32(cass_uint32_t value) @@ -154,11 +154,11 @@ inline cass_uint32_t decode_uint32(const cass_byte_t* bytes, return value; } -inline dse::WkbGeometryType decode_header(const cass_byte_t* bytes, dse::WkbByteOrder* byte_order) { - *byte_order = static_cast(bytes[0]); - return static_cast(dse::decode_uint32(bytes + 1, *byte_order)); +inline WkbGeometryType decode_header(const cass_byte_t* bytes, WkbByteOrder* byte_order) { + *byte_order = static_cast(bytes[0]); + return static_cast(decode_uint32(bytes + 1, *byte_order)); } -} // namespace dse +} } } // namespace datastax::internal::enterprise #endif diff --git a/src/statement.cpp b/src/statement.cpp index b88918d0b..89f910287 100644 --- a/src/statement.cpp +++ b/src/statement.cpp @@ -14,12 +14,14 @@ #include "statement.hpp" +using namespace datastax::internal::enterprise; + extern "C" { CassError cass_statement_bind_dse_point(CassStatement* statement, size_t index, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_statement_bind_custom(statement, index, DSE_POINT_TYPE, bytes.data(), bytes.size()); } @@ -35,7 +37,7 @@ CassError cass_statement_bind_dse_point_by_name(CassStatement* statement, CassError cass_statement_bind_dse_point_by_name_n(CassStatement* statement, const char* name, size_t name_length, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_statement_bind_custom_by_name_n(statement, name, name_length, DSE_POINT_TYPE, sizeof(DSE_POINT_TYPE) - 1, @@ -91,7 +93,7 @@ CassError cass_statement_bind_dse_polygon_by_name_n(CassStatement* statement, CassError cass_statement_bind_dse_date_range(CassStatement* statement, size_t index, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_statement_bind_custom(statement, index, DSE_DATE_RANGE_TYPE, bytes.data(), bytes.size()); } @@ -104,7 +106,7 @@ CassError cass_statement_bind_dse_date_range_by_name(CassStatement* statement, CassError cass_statement_bind_dse_date_range_by_name_n(CassStatement* statement, const char* name, size_t name_length, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_statement_bind_custom_by_name_n(statement, name, name_length, DSE_DATE_RANGE_TYPE, sizeof(DSE_DATE_RANGE_TYPE) - 1, bytes.data(), bytes.size()); diff --git a/src/tuple.cpp b/src/tuple.cpp index 47504bf26..61b4dd21a 100644 --- a/src/tuple.cpp +++ b/src/tuple.cpp @@ -12,10 +12,14 @@ #include "line_string.hpp" #include "polygon.hpp" +using namespace datastax::internal::enterprise; + +extern "C" { + CassError cass_tuple_set_dse_point(CassTuple* tuple, size_t index, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_tuple_set_custom(tuple, index, DSE_POINT_TYPE, bytes.data(), bytes.size()); } @@ -37,7 +41,9 @@ CassError cass_tuple_set_dse_polygon(CassTuple* tuple, CassError cass_tuple_set_dse_date_range(CassTuple* tuple, size_t index, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_tuple_set_custom(tuple, index, DSE_DATE_RANGE_TYPE, bytes.data(), bytes.size()); } + +} // extern "C" diff --git a/src/user_type_value.cpp b/src/user_type_value.cpp index 442ef0308..3ef1d78a3 100644 --- a/src/user_type_value.cpp +++ b/src/user_type_value.cpp @@ -12,10 +12,14 @@ #include "line_string.hpp" #include "polygon.hpp" +using namespace datastax::internal::enterprise; + +extern "C" { + CassError cass_user_type_set_dse_point(CassUserType* user_type, size_t index, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_user_type_set_custom(user_type, index, DSE_POINT_TYPE, @@ -33,7 +37,7 @@ CassError cass_user_type_set_dse_point_by_name(CassUserType* user_type, CassError cass_user_type_set_dse_point_by_name_n(CassUserType* user_type, const char* name, size_t name_length, cass_double_t x, cass_double_t y) { - dse::Bytes bytes = dse::encode_point(x, y); + Bytes bytes = encode_point(x, y); return cass_user_type_set_custom_by_name_n(user_type, name, name_length, DSE_POINT_TYPE, sizeof(DSE_POINT_TYPE) - 1, @@ -99,7 +103,7 @@ CassError cass_user_type_set_dse_polygon_by_name_n(CassUserType* user_type, CassError cass_user_type_set_dse_date_range(CassUserType* user_type, size_t index, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_user_type_set_custom(user_type, index, DSE_DATE_RANGE_TYPE, @@ -117,9 +121,11 @@ CassError cass_user_type_set_dse_date_range_by_name(CassUserType* user_type, CassError cass_user_type_set_dse_date_range_by_name_n(CassUserType* user_type, const char* name, size_t name_length, const DseDateRange* range) { - dse::Bytes bytes = dse::encode_date_range(range); + Bytes bytes = encode_date_range(range); return cass_user_type_set_custom_by_name_n(user_type, name, name_length, DSE_DATE_RANGE_TYPE, sizeof(DSE_DATE_RANGE_TYPE) - 1, bytes.data(), bytes.size()); } + +} // extern "C" diff --git a/src/validate.hpp b/src/validate.hpp index 86e7d84f5..9a732e4a9 100644 --- a/src/validate.hpp +++ b/src/validate.hpp @@ -12,7 +12,7 @@ #include "string_ref.hpp" -namespace dse { +namespace datastax { namespace internal { namespace enterprise { inline CassError validate_data_type(const CassValue* value, const char* class_name) { @@ -30,14 +30,14 @@ inline CassError validate_data_type(const CassValue* value, size_t name_length; cass_data_type_class_name(data_type, &name, &name_length); - if (cass::StringRef(name, name_length) != class_name) { + if (StringRef(name, name_length) != class_name) { return CASS_ERROR_LIB_INVALID_CUSTOM_TYPE; } return CASS_OK; } -} // namespace dse +} } } // namespace datastax::internal::enterprise #endif diff --git a/src/value.cpp b/src/value.cpp index 2f15e7f2b..09aa7b2e5 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -13,6 +13,9 @@ #include "serialization.hpp" #include "validate.hpp" +using namespace datastax::internal; +using namespace datastax::internal::enterprise; + extern "C" { CassError cass_value_get_dse_point(const CassValue* value, @@ -20,7 +23,7 @@ CassError cass_value_get_dse_point(const CassValue* value, const cass_byte_t* pos; size_t size; - CassError rc = dse::validate_data_type(value, DSE_POINT_TYPE); + CassError rc = validate_data_type(value, DSE_POINT_TYPE); if (rc != CASS_OK) return rc; rc = cass_value_get_bytes(value, &pos, &size); @@ -30,16 +33,16 @@ CassError cass_value_get_dse_point(const CassValue* value, return CASS_ERROR_LIB_NOT_ENOUGH_DATA; } - dse::WkbByteOrder byte_order; - if (dse::decode_header(pos, &byte_order) != dse::WKB_GEOMETRY_TYPE_POINT) { + WkbByteOrder byte_order; + if (decode_header(pos, &byte_order) != WKB_GEOMETRY_TYPE_POINT) { return CASS_ERROR_LIB_INVALID_DATA; } pos += WKB_HEADER_SIZE; - *x = dse::decode_double(pos, byte_order); + *x = decode_double(pos, byte_order); pos += sizeof(cass_double_t); - *y = dse::decode_double(pos, byte_order); + *y = decode_double(pos, byte_order); return CASS_OK; } @@ -50,11 +53,11 @@ CassError cass_value_get_dse_date_range(const CassValue* value, size_t expected_size = 0; const char* pos = NULL; const char* end = NULL; - dse::DateRangeBoundType range_type; + DateRangeBoundType range_type; DseDateRangeBound* first_bound = NULL; int8_t decoded_byte = 0; - CassError rc = dse::validate_data_type(value, DSE_DATE_RANGE_TYPE); + CassError rc = validate_data_type(value, DSE_DATE_RANGE_TYPE); if (rc != CASS_OK) return rc; rc = cass_value_get_string(value, &pos, &size); @@ -70,29 +73,29 @@ CassError cass_value_get_dse_date_range(const CassValue* value, // Depending on the type of range, we may have a subset of the remaining fields. // This translates to having 0, 1, or 2 bounds. If we have one bound, it may be an upper or lower bound. - range_type = static_cast(*pos++); + range_type = static_cast(*pos++); range->is_single_date = static_cast( - range_type == dse::DATE_RANGE_BOUND_TYPE_SINGLE_DATE || - range_type == dse::DATE_RANGE_BOUND_TYPE_SINGLE_DATE_OPEN); + range_type == DATE_RANGE_BOUND_TYPE_SINGLE_DATE || + range_type == DATE_RANGE_BOUND_TYPE_SINGLE_DATE_OPEN); range->lower_bound = dse_date_range_bound_unbounded(); range->upper_bound = dse_date_range_bound_unbounded(); switch (range_type) { - case dse::DATE_RANGE_BOUND_TYPE_BOTH_OPEN_RANGE: - case dse::DATE_RANGE_BOUND_TYPE_SINGLE_DATE_OPEN: + case DATE_RANGE_BOUND_TYPE_BOTH_OPEN_RANGE: + case DATE_RANGE_BOUND_TYPE_SINGLE_DATE_OPEN: expected_size = sizeof(int8_t); break; - case dse::DATE_RANGE_BOUND_TYPE_SINGLE_DATE: - case dse::DATE_RANGE_BOUND_TYPE_OPEN_RANGE_HIGH: - case dse::DATE_RANGE_BOUND_TYPE_OPEN_RANGE_LOW: + case DATE_RANGE_BOUND_TYPE_SINGLE_DATE: + case DATE_RANGE_BOUND_TYPE_OPEN_RANGE_HIGH: + case DATE_RANGE_BOUND_TYPE_OPEN_RANGE_LOW: // type, from_time, from_precision expected_size = sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t); - first_bound = (range_type == dse::DATE_RANGE_BOUND_TYPE_OPEN_RANGE_LOW) ? - &(range->upper_bound) : - &(range->lower_bound); + first_bound = (range_type == DATE_RANGE_BOUND_TYPE_OPEN_RANGE_LOW) ? + &(range->upper_bound) : + &(range->lower_bound); break; - case dse::DATE_RANGE_BOUND_TYPE_CLOSED_RANGE: + case DATE_RANGE_BOUND_TYPE_CLOSED_RANGE: // type, from_time, from_precision, to_time, to_precision expected_size = sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t) + sizeof(int64_t) + sizeof(int8_t); first_bound = &(range->lower_bound); @@ -110,8 +113,8 @@ CassError cass_value_get_dse_date_range(const CassValue* value, } // We have at least one bound; write to the attribute that was chosen earlier. - pos = cass::decode_int64(const_cast(pos), first_bound->time_ms); - pos = cass::decode_int8(const_cast(pos), decoded_byte); + pos = decode_int64(const_cast(pos), first_bound->time_ms); + pos = decode_int8(const_cast(pos), decoded_byte); first_bound->precision = static_cast(decoded_byte); if (pos == end) { @@ -119,8 +122,8 @@ CassError cass_value_get_dse_date_range(const CassValue* value, } // This is the second bound; must be upper. - pos = cass::decode_int64(const_cast(pos), range->upper_bound.time_ms); - cass::decode_int8(const_cast(pos), decoded_byte); + pos = decode_int64(const_cast(pos), range->upper_bound.time_ms); + decode_int8(const_cast(pos), decoded_byte); range->upper_bound.precision = static_cast(decoded_byte); return CASS_OK; diff --git a/src/wkt.cpp b/src/wkt.cpp index 42a0aeb46..052e6a697 100644 --- a/src/wkt.cpp +++ b/src/wkt.cpp @@ -291,7 +291,7 @@ WktLexer::Token WktLexer::next_token() { #line 49 "wkt.rl" {te = p;p--;{ if (!skip_number_) { - number_ = atof(cass::String(ts, te).c_str()); + number_ = atof(datastax::String(ts, te).c_str()); } token = TK_NUMBER; {p++; goto _out; } @@ -305,7 +305,7 @@ WktLexer::Token WktLexer::next_token() { #line 49 "wkt.rl" {{p = ((te))-1;}{ if (!skip_number_) { - number_ = atof(cass::String(ts, te).c_str()); + number_ = atof(datastax::String(ts, te).c_str()); } token = TK_NUMBER; {p++; goto _out; } @@ -321,7 +321,7 @@ WktLexer::Token WktLexer::next_token() { case 8: {{p = ((te))-1;} if (!skip_number_) { - number_ = atof(cass::String(ts, te).c_str()); + number_ = atof(datastax::String(ts, te).c_str()); } token = TK_NUMBER; {p++; goto _out; } diff --git a/src/wkt.hpp b/src/wkt.hpp index 91f1a7cbf..338f4dfda 100644 --- a/src/wkt.hpp +++ b/src/wkt.hpp @@ -63,5 +63,4 @@ class WktLexer { bool skip_number_; }; - #endif diff --git a/src/wkt.rl b/src/wkt.rl index 1a538bc37..0e8c0f2d2 100644 --- a/src/wkt.rl +++ b/src/wkt.rl @@ -48,7 +48,7 @@ WktLexer::Token WktLexer::next_token() { ',' => { token = TK_COMMA; fbreak; }; number => { if (!skip_number_) { - number_ = atof(cass::String(ts, te).c_str()); + number_ = atof(datastax::String(ts, te).c_str()); } token = TK_NUMBER; fbreak; diff --git a/tests/src/integration/embedded_ads.hpp b/tests/src/integration/embedded_ads.hpp index 44b910c18..2eb199bc1 100644 --- a/tests/src/integration/embedded_ads.hpp +++ b/tests/src/integration/embedded_ads.hpp @@ -175,7 +175,7 @@ typedef struct CommandResult_ { * @return True is ADS is initialized; false otherwise */ static bool is_initialized() { - cass::ScopedMutex lock(&mutex_); + datastax::internal::ScopedMutex lock(&mutex_); return is_initialized_; } @@ -600,7 +600,7 @@ typedef struct CommandResult_ { * @param term_signal Terminating signal */ static void process_exit(uv_process_t* process, int64_t error_code, int term_signal) { - cass::ScopedMutex lock(&mutex_); + datastax::internal::ScopedMutex lock(&mutex_); TEST_LOG("Process " << process->pid << " Terminated: " << error_code); uv_close(reinterpret_cast(process), NULL); } @@ -613,7 +613,7 @@ typedef struct CommandResult_ { * @param buffer Buffer to allocate bytes for */ static void output_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer) { - cass::ScopedMutex lock(&mutex_); + datastax::internal::ScopedMutex lock(&mutex_); buffer->base = new char[OUTPUT_BUFFER_SIZE]; buffer->len = OUTPUT_BUFFER_SIZE; } @@ -626,7 +626,7 @@ typedef struct CommandResult_ { * @param buffer Buffer to process */ static void process_read(uv_stream_t* stream, ssize_t buffer_length, const uv_buf_t* buffer) { - cass::ScopedMutex lock(&mutex_); + datastax::internal::ScopedMutex lock(&mutex_); // Get the pipe message contents std::string* message = reinterpret_cast(stream->data); diff --git a/tests/src/unit/main.cpp b/tests/src/unit/main.cpp index 27c461bfd..10103199e 100644 --- a/tests/src/unit/main.cpp +++ b/tests/src/unit/main.cpp @@ -10,6 +10,9 @@ #include "string.hpp" #include "ssl.hpp" +using datastax::String; +using datastax::internal::core::SslContextFactory; + #if defined(_WIN32) && defined(_DEBUG) # ifdef USE_VISUAL_LEAK_DETECTOR # include @@ -122,14 +125,14 @@ class BootstrapListener : public testing::EmptyTestEventListener { << CASS_VERSION_MAJOR << "." << CASS_VERSION_MINOR << "." << CASS_VERSION_PATCH; - if (!cass::String(CASS_VERSION_SUFFIX).empty()) { + if (!String(CASS_VERSION_SUFFIX).empty()) { std::cout << "-" << CASS_VERSION_SUFFIX; } std::cout << std::endl << " DSE driver v" << DSE_VERSION_MAJOR << "." << DSE_VERSION_MINOR << "." << DSE_VERSION_PATCH; - if (!cass::String(DSE_VERSION_SUFFIX).empty()) { + if (!String(DSE_VERSION_SUFFIX).empty()) { std::cout << "-" << DSE_VERSION_SUFFIX; } std::cout << std::endl; @@ -141,11 +144,11 @@ class BootstrapListener : public testing::EmptyTestEventListener { } void OnTestStart(const testing::TestInfo& test_information) { - cass::SslContextFactory::init(); + SslContextFactory::init(); } void OnTestEnd(const testing::TestInfo& test_information) { - cass::SslContextFactory::cleanup(); + SslContextFactory::cleanup(); } }; diff --git a/tests/src/unit/tests/test_client_insights.cpp b/tests/src/unit/tests/test_client_insights.cpp index 277d52404..fc0ec5fda 100644 --- a/tests/src/unit/tests/test_client_insights.cpp +++ b/tests/src/unit/tests/test_client_insights.cpp @@ -14,15 +14,20 @@ #include "result_iterator.hpp" #include "session.hpp" +using namespace datastax; +using namespace datastax::internal; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; + class ClientInsightsUnitTest : public Unit { public: - class RpcPayloadLatch : public cass::RefCounted { + class RpcPayloadLatch : public RefCounted { public: typedef SharedRefPtr Ptr; RpcPayloadLatch(unsigned initial_payload_count = 1) : count_(initial_payload_count) - , future_(new cass::Future(cass::Future::FUTURE_TYPE_GENERIC)) { + , future_(new Future(Future::FUTURE_TYPE_GENERIC)) { uv_mutex_init(&mutex_); } @@ -35,19 +40,19 @@ class ClientInsightsUnitTest : public Unit { } void reset(unsigned count) { - cass::ScopedMutex lock(&mutex_); + ScopedMutex lock(&mutex_); count_ = count; - future_.reset(new cass::Future(cass::Future::FUTURE_TYPE_GENERIC)); + future_.reset(new Future(Future::FUTURE_TYPE_GENERIC)); } - void add_payload(const cass::String& payload) { - cass::ScopedMutex lock(&mutex_); + void add_payload(const String& payload) { + ScopedMutex lock(&mutex_); payloads_.push_back(payload); if (--count_ == 0) future_->set(); } - const cass::Vector& payloads() { - cass::ScopedMutex lock(&mutex_); + const Vector& payloads() { + ScopedMutex lock(&mutex_); return payloads_; } @@ -57,9 +62,9 @@ class ClientInsightsUnitTest : public Unit { private: unsigned count_; - cass::Future::Ptr future_; + Future::Ptr future_; uv_mutex_t mutex_; - cass::Vector payloads_; + Vector payloads_; }; class InsightsRpcQuery : public mockssandra::Action { @@ -72,7 +77,7 @@ class ClientInsightsUnitTest : public Unit { mockssandra::QueryParameters params; if (!request->decode_query(&query, ¶ms)) { request->error(mockssandra::ERROR_PROTOCOL_ERROR, "Invalid query message"); - } else if (cass::starts_with(query, "CALL InsightsRpc.reportInsight")) { + } else if (starts_with(query, "CALL InsightsRpc.reportInsight")) { size_t pos = query.find("('") + 2; // Skip starting single quote size_t len = (query.find_last_of("')") - 1) - pos; // Skip ending single quote latch_->add_payload(query.substr(pos, len)); @@ -96,12 +101,12 @@ class ClientInsightsUnitTest : public Unit { mockssandra::SimpleRequestHandlerBuilder builder; builder.on(mockssandra::OPCODE_QUERY) - .system_local_dse() - .system_peers_dse() - .execute(new InsightsRpcQuery(rpc_payload_latch_)) // Allow RPC calls to be stored in cluster - .is_query("wait") + .system_local_dse() + .system_peers_dse() + .execute(new InsightsRpcQuery(rpc_payload_latch_)) // Allow RPC calls to be stored in cluster + .is_query("wait") .then(mockssandra::Action::Builder().wait(2000).void_result()) // Allow queries to build up - .void_result(); + .void_result(); return builder.build(); } @@ -109,7 +114,7 @@ class ClientInsightsUnitTest : public Unit { void connect(unsigned interval_secs = 1) { config_.contact_points().push_back("127.0.0.1"); config_.set_monitor_reporting_interval_secs(interval_secs); - cass::Future::Ptr connect_future(session_.connect(config_)); + Future::Ptr connect_future(session_.connect(config_)); ASSERT_TRUE(connect_future->wait_for(WAIT_FOR_TIME)) << "Timed out waiting for session to connect"; ASSERT_FALSE(connect_future->error()) @@ -117,14 +122,14 @@ class ClientInsightsUnitTest : public Unit { << connect_future->error()->message; } - cass::String startup_message(uint64_t wait_time_sec = WAIT_FOR_TIME) const { + String startup_message(uint64_t wait_time_sec = WAIT_FOR_TIME) const { if (!rpc_payload_latch_->wait_for(wait_time_sec)) { return ""; } return rpc_payload_latch_->payload(); } - cass::String status_message(unsigned status_message_index = 1) const { + String status_message(unsigned status_message_index = 1) const { if (!rpc_payload_latch_->wait_for(WAIT_FOR_TIME * status_message_index)) { return ""; } @@ -136,8 +141,8 @@ class ClientInsightsUnitTest : public Unit { } protected: - cass::Config config_; - cass::Session session_; + Config config_; + Session session_; RpcPayloadLatch::Ptr rpc_payload_latch_; }; @@ -146,14 +151,14 @@ TEST_F(ClientInsightsUnitTest, StartupMetadata) { ASSERT_EQ(cluster.start_all(), 0); connect(); - cass::String message = startup_message(); - const uint64_t current_timestamp = cass::get_time_since_epoch_ms(); - cass::json::Document document; + String message = startup_message(); + const uint64_t current_timestamp = get_time_since_epoch_ms(); + json::Document document; document.Parse(message.c_str()); ASSERT_TRUE(document.IsObject()); ASSERT_TRUE(document.HasMember("metadata")); - const cass::json::Value& metadata = document["metadata"]; + const json::Value& metadata = document["metadata"]; ASSERT_TRUE(metadata.IsObject()); { // name @@ -174,7 +179,7 @@ TEST_F(ClientInsightsUnitTest, StartupMetadata) { } { // tags ASSERT_TRUE(metadata.HasMember("tags")); - const cass::json::Value& value = metadata["tags"]; + const json::Value& value = metadata["tags"]; ASSERT_TRUE(value.IsObject()); ASSERT_TRUE(value.HasMember("language")); ASSERT_STREQ("C/C++", value["language"].GetString()); @@ -186,8 +191,8 @@ TEST_F(ClientInsightsUnitTest, StartupData) { ASSERT_EQ(cluster.start_all(), 0); config_.contact_points().push_back("localhost"); // Used for hostname resolve - cass::String applicationName = "StartupData"; - cass::String applicationVersion = "v1.0.0-test"; + String applicationName = "StartupData"; + String applicationVersion = "v1.0.0-test"; CassConsistency consistency = CASS_CONSISTENCY_ALL; CassConsistency serial_consistency = CASS_CONSISTENCY_ONE; unsigned core_connections = 3; @@ -195,36 +200,36 @@ TEST_F(ClientInsightsUnitTest, StartupData) { unsigned periodic_status_interval = 7; unsigned reconnect_wait_time_ms = 9; unsigned request_timeout_ms = 11; - cass::RetryPolicy::Ptr retry_policy(new cass::FallthroughRetryPolicy()); + RetryPolicy::Ptr retry_policy(new FallthroughRetryPolicy()); config_.set_application_name(applicationName); config_.set_application_version(applicationVersion); config_.set_consistency(consistency); config_.set_serial_consistency(serial_consistency); config_.set_core_connections_per_host(core_connections); config_.set_connection_heartbeat_interval_secs(heartbeat_interval_secs); - config_.set_protocol_version(cass::ProtocolVersion::lowest_supported()); + config_.set_protocol_version(ProtocolVersion::lowest_supported()); config_.set_reconnect_wait_time(reconnect_wait_time_ms); config_.set_request_timeout(request_timeout_ms); config_.set_retry_policy(retry_policy.get()); connect(periodic_status_interval); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); ASSERT_TRUE(document.IsObject()); ASSERT_TRUE(document.HasMember("data")); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data.IsObject()); { // client ID ASSERT_TRUE(data.HasMember("clientId")); - ASSERT_STREQ(cass::to_string(session_.client_id()).c_str(), + ASSERT_STREQ(to_string(session_.client_id()).c_str(), data["clientId"].GetString()); } { // session ID ASSERT_TRUE(data.HasMember("sessionId")); - ASSERT_STREQ(cass::to_string(session_.session_id()).c_str(), + ASSERT_STREQ(to_string(session_.session_id()).c_str(), data["sessionId"].GetString()); } { // application name @@ -242,50 +247,50 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // driver name ASSERT_TRUE(data.HasMember("driverName")); - ASSERT_STREQ(cass::driver_name(), data["driverName"].GetString()); + ASSERT_STREQ(driver_name(), data["driverName"].GetString()); } { // driver version ASSERT_TRUE(data.HasMember("driverVersion")); - ASSERT_STREQ(cass::driver_version(), data["driverVersion"].GetString()); + ASSERT_STREQ(driver_version(), data["driverVersion"].GetString()); } { // contact points ASSERT_TRUE(data.HasMember("contactPoints")); - const cass::json::Value& value = data["contactPoints"]; + const json::Value& value = data["contactPoints"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(2u, value.MemberCount()); ASSERT_TRUE(value.HasMember("127.0.0.1")); - const cass::json::Value& local_ipv4_1 = value["127.0.0.1"]; + const json::Value& local_ipv4_1 = value["127.0.0.1"]; ASSERT_TRUE(local_ipv4_1.IsArray()); ASSERT_EQ(1u, local_ipv4_1.Size()); - cass::OStringStream ipv4_with_port; + OStringStream ipv4_with_port; ipv4_with_port << "127.0.0.1:" << config_.port(); - cass::OStringStream ipv6_with_port; + OStringStream ipv6_with_port; ipv6_with_port << "[::1]:" << config_.port(); ASSERT_EQ(ipv4_with_port.str(), local_ipv4_1.GetArray()[0].GetString()); ASSERT_TRUE(value.HasMember("localhost")); - const cass::json::Value& local_hostname = value["localhost"]; + const json::Value& local_hostname = value["localhost"]; ASSERT_GE(local_hostname.Size(), 1u); // More than one address could be resolved - cass::String resolved_local_hostname = local_hostname.GetArray()[0].GetString(); + String resolved_local_hostname = local_hostname.GetArray()[0].GetString(); ASSERT_TRUE(ipv6_with_port.str() == resolved_local_hostname || ipv4_with_port.str() == resolved_local_hostname); } { // data centers ASSERT_TRUE(data.HasMember("dataCenters")); - const cass::json::Value& value = data["dataCenters"]; + const json::Value& value = data["dataCenters"]; ASSERT_TRUE(value.IsArray()); ASSERT_EQ(1u, value.Size()); // Should only connect to 1 DC based on LBP ASSERT_STREQ("dc1", value.GetArray()[0].GetString()); } { // initial control connection ASSERT_TRUE(data.HasMember("initialControlConnection")); - cass::OStringStream ipv4_with_port; + OStringStream ipv4_with_port; ipv4_with_port << "127.0.0.1:" << config_.port(); ASSERT_EQ(ipv4_with_port.str(), - data["initialControlConnection"].GetString()); + data["initialControlConnection"].GetString()); } { // protocol version ASSERT_TRUE(data.HasMember("protocolVersion")); - ASSERT_EQ(cass::ProtocolVersion::lowest_supported().value(), + ASSERT_EQ(ProtocolVersion::lowest_supported().value(), data["protocolVersion"].GetInt()); } { // local address @@ -294,18 +299,18 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // hostname ASSERT_TRUE(data.HasMember("hostName")); - const cass::json::Value& value = data["hostName"]; + const json::Value& value = data["hostName"]; // No simple way to validate hostname on different machines ASSERT_TRUE(value.IsString()); ASSERT_GT(value.GetStringLength(), 0u); } { // execution profiles ASSERT_TRUE(data.HasMember("executionProfiles")); - const cass::json::Value& value = data["executionProfiles"]; + const json::Value& value = data["executionProfiles"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(1u, value.MemberCount()); ASSERT_TRUE(value.HasMember("default")); - const cass::json::Value& default_profile = value["default"]; + const json::Value& default_profile = value["default"]; ASSERT_TRUE(default_profile.IsObject()); ASSERT_EQ(5u, default_profile.MemberCount()); ASSERT_TRUE(default_profile.HasMember("requestTimeoutMs")); @@ -321,13 +326,13 @@ TEST_F(ClientInsightsUnitTest, StartupData) { ASSERT_STREQ("FallthroughRetryPolicy", default_profile["retryPolicy"].GetString()); ASSERT_TRUE(default_profile.HasMember("loadBalancing")); - const cass::json::Value& load_balancing = default_profile["loadBalancing"]; + const json::Value& load_balancing = default_profile["loadBalancing"]; ASSERT_TRUE(load_balancing.IsObject()); ASSERT_EQ(2u, load_balancing.MemberCount()); ASSERT_TRUE(load_balancing.HasMember("type")); ASSERT_STREQ("DCAwarePolicy", load_balancing["type"].GetString()); ASSERT_TRUE(load_balancing.HasMember("options")); - const cass::json::Value& options = load_balancing["options"]; + const json::Value& options = load_balancing["options"]; ASSERT_TRUE(options.IsObject()); ASSERT_EQ(5u, options.MemberCount()); ASSERT_TRUE(options.HasMember("localDc")); @@ -339,7 +344,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { ASSERT_TRUE(options.HasMember("hostTargeting")); ASSERT_FALSE(options["hostTargeting"].GetBool()); ASSERT_TRUE(options.HasMember("tokenAwareRouting")); - const cass::json::Value& token_aware_routing = options["tokenAwareRouting"]; + const json::Value& token_aware_routing = options["tokenAwareRouting"]; ASSERT_TRUE(token_aware_routing.IsObject()); ASSERT_EQ(1u, token_aware_routing.MemberCount()); ASSERT_TRUE(token_aware_routing.HasMember("shuffleReplicas")); @@ -347,7 +352,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // pool size by host distance ASSERT_TRUE(data.HasMember("poolSizeByHostDistance")); - const cass::json::Value& value = data["poolSizeByHostDistance"]; + const json::Value& value = data["poolSizeByHostDistance"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(2u, value.MemberCount()); ASSERT_TRUE(value.HasMember("local")); @@ -366,13 +371,13 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // reconnection policy ASSERT_TRUE(data.HasMember("reconnectionPolicy")); - const cass::json::Value& value = data["reconnectionPolicy"]; + const json::Value& value = data["reconnectionPolicy"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(2u, value.MemberCount()); ASSERT_TRUE(value.HasMember("type")); ASSERT_STREQ("ConstantReconnectionPolicy", value["type"].GetString()); ASSERT_TRUE(value.HasMember("options")); - const cass::json::Value& options = value["options"]; + const json::Value& options = value["options"]; ASSERT_TRUE(options.IsObject()); ASSERT_EQ(1u, options.MemberCount()); ASSERT_TRUE(options.HasMember("reconnectWaitTimeMs")); @@ -380,7 +385,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // SSL ASSERT_TRUE(data.HasMember("ssl")); - const cass::json::Value& value = data["ssl"]; + const json::Value& value = data["ssl"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(2u, value.MemberCount()); ASSERT_TRUE(value.HasMember("enabled")); @@ -390,11 +395,11 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // other options ASSERT_TRUE(data.HasMember("otherOptions")); - const cass::json::Value& value = data["otherOptions"]; + const json::Value& value = data["otherOptions"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(1u, value.MemberCount()); ASSERT_TRUE(value.HasMember("configuration")); - const cass::json::Value& configuration = value["configuration"]; + const json::Value& configuration = value["configuration"]; ASSERT_TRUE(configuration.IsObject()); ASSERT_EQ(24, configuration.MemberCount()); ASSERT_TRUE(configuration.HasMember("protocolVersion")); @@ -426,7 +431,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { configuration["maxTracingWaitTimeMs"].GetUint()); ASSERT_TRUE(configuration.HasMember("tracingConsistency")); ASSERT_STREQ(cass_consistency_string(config_.tracing_consistency()), - configuration["tracingConsistency"].GetString()); + configuration["tracingConsistency"].GetString()); ASSERT_TRUE(configuration.HasMember("coalesceDelayUs")); ASSERT_EQ(config_.coalesce_delay_us(), configuration["coalesceDelayUs"].GetUint64()); @@ -435,7 +440,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { configuration["newRequestRatio"].GetInt()); ASSERT_TRUE(configuration.HasMember("logLevel")); ASSERT_STREQ(cass_log_level_string(config_.log_level()), - configuration["logLevel"].GetString()); + configuration["logLevel"].GetString()); ASSERT_TRUE(configuration.HasMember("tcpNodelayEnable")); ASSERT_EQ(config_.tcp_nodelay_enable(), configuration["tcpNodelayEnable"].GetBool()); @@ -472,12 +477,12 @@ TEST_F(ClientInsightsUnitTest, StartupData) { } { // platform info ASSERT_TRUE(data.HasMember("platformInfo")); - const cass::json::Value& value = data["platformInfo"]; + const json::Value& value = data["platformInfo"]; // No simple way to validate platform information on different platforms ASSERT_TRUE(value.IsObject()); ASSERT_EQ(3u, value.MemberCount()); ASSERT_TRUE(value.HasMember("os")); - const cass::json::Value& os = value["os"]; + const json::Value& os = value["os"]; ASSERT_TRUE(os.IsObject()); ASSERT_EQ(3u, os.MemberCount()); ASSERT_TRUE(os.HasMember("name")); @@ -490,7 +495,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { ASSERT_TRUE(os["arch"].IsString()); ASSERT_GT(os["arch"].GetStringLength(), 0u); ASSERT_TRUE(value.HasMember("cpus")); - const cass::json::Value& cpus = value["cpus"]; + const json::Value& cpus = value["cpus"]; ASSERT_TRUE(cpus.IsObject()); ASSERT_EQ(2u, cpus.MemberCount()); ASSERT_TRUE(cpus.HasMember("length")); @@ -499,7 +504,7 @@ TEST_F(ClientInsightsUnitTest, StartupData) { ASSERT_TRUE(cpus["model"].IsString()); ASSERT_GT(cpus["model"].GetStringLength(), 0u); ASSERT_TRUE(value.HasMember("runtime")); - const cass::json::Value& runtime = value["runtime"]; + const json::Value& runtime = value["runtime"]; ASSERT_TRUE(runtime.IsObject()); ASSERT_EQ(3u, runtime.MemberCount()); // NOTE: No simple way to validate compiler with different compilers @@ -522,17 +527,17 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleDcs) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call(), 1, 1); ASSERT_EQ(cluster.start_all(), 0); - cass::LoadBalancingPolicy::Ptr load_balancing_policy(new cass::DCAwarePolicy("dc1", - 1, - false)); + LoadBalancingPolicy::Ptr load_balancing_policy(new DCAwarePolicy("dc1", + 1, + false)); config_.set_load_balancing_policy(load_balancing_policy.get()); connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_EQ(2u, data["dataCenters"].Size()); ASSERT_STREQ("dc1", data["dataCenters"].GetArray()[0].GetString()); ASSERT_STREQ("dc2", data["dataCenters"].GetArray()[1].GetString()); @@ -542,19 +547,19 @@ TEST_F(ClientInsightsUnitTest, StartupDataProtocolVersion) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call()); ASSERT_EQ(cluster.start_all(), 0); - cass::ProtocolVersion configured_protocol_version(CASS_PROTOCOL_VERSION_DSEV2); + ProtocolVersion configured_protocol_version(CASS_PROTOCOL_VERSION_DSEV2); config_.set_protocol_version(configured_protocol_version); // Mockssandra does not currently support DSE protocols connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); // Configured and connected protocol versions should be different - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; int data_protocol_version = data["protocolVersion"].GetInt(); int other_options_protocol_version = - data["otherOptions"]["configuration"]["protocolVersion"].GetInt(); + data["otherOptions"]["configuration"]["protocolVersion"].GetInt(); ASSERT_LT(data_protocol_version, configured_protocol_version.value()); ASSERT_EQ(other_options_protocol_version, configured_protocol_version.value()); @@ -564,19 +569,19 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call()); ASSERT_EQ(cluster.start_all(), 0); - cass::DCAwarePolicy::Ptr dc_aware(new cass::DCAwarePolicy("dc1", 1, true)); - cass::RoundRobinPolicy::Ptr round_robin(new cass::RoundRobinPolicy()); - cass::LatencyAwarePolicy::Settings latency_aware_settings; - cass::RetryPolicy::Ptr profile_retry_policy(new cass::DowngradingConsistencyRetryPolicy()); + DCAwarePolicy::Ptr dc_aware(new DCAwarePolicy("dc1", 1, true)); + RoundRobinPolicy::Ptr round_robin(new RoundRobinPolicy()); + LatencyAwarePolicy::Settings latency_aware_settings; + RetryPolicy::Ptr profile_retry_policy(new DowngradingConsistencyRetryPolicy()); latency_aware_settings.exclusion_threshold = 0.1; latency_aware_settings.scale_ns = 1; latency_aware_settings.retry_period_ns = 3; latency_aware_settings.update_rate_ms = 5; latency_aware_settings.min_measured = 7; - cass::ExecutionProfile quorum_profile; + ExecutionProfile quorum_profile; quorum_profile.set_consistency(CASS_CONSISTENCY_QUORUM); quorum_profile.set_request_timeout(300000); - cass::ExecutionProfile round_robin_profile; + ExecutionProfile round_robin_profile; round_robin_profile.set_load_balancing_policy(round_robin.get()); round_robin_profile.set_token_aware_routing(false); round_robin_profile.set_latency_aware_routing(true); @@ -589,17 +594,17 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { config_.set_execution_profile("round_robin", &round_robin_profile); connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; - const cass::json::Value& execution_profiles = data["executionProfiles"]; + const json::Value& data = document["data"]; + const json::Value& execution_profiles = data["executionProfiles"]; ASSERT_EQ(3u, execution_profiles.MemberCount()); ASSERT_TRUE(execution_profiles.HasMember("default")); ASSERT_TRUE(execution_profiles.HasMember("round_robin")); { // default profile - const cass::json::Value& execution_profile = execution_profiles["default"]; + const json::Value& execution_profile = execution_profiles["default"]; ASSERT_EQ(config_.request_timeout(), execution_profile["requestTimeoutMs"].GetUint()); ASSERT_STREQ(cass_consistency_string(config_.consistency()), @@ -608,9 +613,9 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { execution_profile["serialConsistency"].GetString()); ASSERT_STREQ("DefaultRetryPolicy", execution_profile["retryPolicy"].GetString()); - const cass::json::Value& load_balancing = execution_profile["loadBalancing"]; + const json::Value& load_balancing = execution_profile["loadBalancing"]; ASSERT_STREQ("DCAwarePolicy", load_balancing["type"].GetString()); - const cass::json::Value& options = load_balancing["options"]; + const json::Value& options = load_balancing["options"]; ASSERT_STREQ("dc1", options["localDc"].GetString()); ASSERT_EQ(1u, options["usedHostsPerRemoteDc"].GetUint()); ASSERT_FALSE(options["allowRemoteDcsForLocalCl"].GetBool()); @@ -619,7 +624,7 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { ASSERT_FALSE(options["tokenAwareRouting"]["shuffleReplicas"].GetBool()); } { // quorum profile - const cass::json::Value& execution_profile = execution_profiles["quorum"]; + const json::Value& execution_profile = execution_profiles["quorum"]; ASSERT_EQ(quorum_profile.request_timeout_ms(), execution_profile["requestTimeoutMs"].GetUint()); ASSERT_STREQ(cass_consistency_string(quorum_profile.consistency()), @@ -629,16 +634,16 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { ASSERT_FALSE(execution_profiles.HasMember("loadBalancing")); } { // round robin profile - const cass::json::Value& execution_profile = execution_profiles["round_robin"]; + const json::Value& execution_profile = execution_profiles["round_robin"]; ASSERT_FALSE(execution_profiles.HasMember("requestTimeoutMs")); ASSERT_FALSE(execution_profiles.HasMember("consistency")); ASSERT_FALSE(execution_profiles.HasMember("serialConsistency")); ASSERT_FALSE(execution_profiles.HasMember("retryPolicy")); - const cass::json::Value& load_balancing = execution_profile["loadBalancing"]; + const json::Value& load_balancing = execution_profile["loadBalancing"]; ASSERT_STREQ("RoundRobinPolicy", load_balancing["type"].GetString()); - const cass::json::Value& options = load_balancing["options"]; + const json::Value& options = load_balancing["options"]; ASSERT_TRUE(options["hostTargeting"].GetBool()); - const cass::json::Value& latency_aware_routing = options["latencyAwareRouting"]; + const json::Value& latency_aware_routing = options["latencyAwareRouting"]; ASSERT_EQ(latency_aware_settings.exclusion_threshold, latency_aware_routing["exclusionThreshold"].GetDouble()); ASSERT_EQ(latency_aware_settings.scale_ns, @@ -654,35 +659,35 @@ TEST_F(ClientInsightsUnitTest, StartupDataMultipleExecutionProfiles) { TEST_F(ClientInsightsUnitTest, StartupDataSsl) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call()); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ASSERT_EQ(cluster.start_all(), 0); config_.set_ssl_context(ssl_context.get()); connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data["ssl"]["enabled"].GetBool()); ASSERT_TRUE(data["ssl"]["certValidation"].GetBool()); } TEST_F(ClientInsightsUnitTest, StartupDataSslWithoutCertValidation) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call()); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ssl_context->set_verify_flags(SSL_VERIFY_NONE); ASSERT_EQ(cluster.start_all(), 0); config_.set_ssl_context(ssl_context.get()); connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data["ssl"]["enabled"].GetBool()); ASSERT_FALSE(data["ssl"]["certValidation"].GetBool()); } @@ -691,20 +696,20 @@ TEST_F(ClientInsightsUnitTest, StartupDataConfigAntiPatternWithoutSsl) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call()); ASSERT_EQ(cluster.start_all(), 0); - cass::LoadBalancingPolicy::Ptr dc_aware(new cass::DCAwarePolicy("dc1", - 1, - false)); // useRemoteHosts - cass::RetryPolicy::Ptr retry_policy(new cass::DowngradingConsistencyRetryPolicy()); + LoadBalancingPolicy::Ptr dc_aware(new DCAwarePolicy("dc1", + 1, + false)); // useRemoteHosts + RetryPolicy::Ptr retry_policy(new DowngradingConsistencyRetryPolicy()); config_.set_credentials("cassandra", "cassandra"); // plainTextAuthWithoutSsl connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data.HasMember("configAntiPatterns")); - const cass::json::Value& config_anti_patterns = data["configAntiPatterns"]; + const json::Value& config_anti_patterns = data["configAntiPatterns"]; ASSERT_TRUE(config_anti_patterns.IsObject()); ASSERT_EQ(1u, config_anti_patterns.MemberCount()); ASSERT_TRUE(config_anti_patterns.HasMember("plainTextAuthWithoutSsl")); @@ -714,27 +719,27 @@ TEST_F(ClientInsightsUnitTest, StartupDataConfigAntiPatternWithoutSsl) { TEST_F(ClientInsightsUnitTest, StartupDataConfigAntiPatternsWithSsl) { mockssandra::SimpleCluster cluster(simple_dse_with_rpc_call(), 1, 1); - cass::SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; + SslContext::Ptr ssl_context = use_ssl(&cluster).socket_settings.ssl_context; ssl_context->set_verify_flags(SSL_VERIFY_NONE); // sslWithoutCertValidation ASSERT_EQ(cluster.start_all(), 0); - cass::LoadBalancingPolicy::Ptr dc_aware(new cass::DCAwarePolicy("dc1", - 1, - false)); // useRemoteHosts - cass::RetryPolicy::Ptr retry_policy(new cass::DowngradingConsistencyRetryPolicy()); + LoadBalancingPolicy::Ptr dc_aware(new DCAwarePolicy("dc1", + 1, + false)); // useRemoteHosts + RetryPolicy::Ptr retry_policy(new DowngradingConsistencyRetryPolicy()); config_.set_load_balancing_policy(dc_aware.get()); config_.set_retry_policy(retry_policy.get()); // downgradingConsistency config_.set_ssl_context(ssl_context.get()); config_.contact_points().push_back("127.0.0.2"); // contactPointsMultipleDCs connect(); - cass::String message = startup_message(); - cass::json::Document document; + String message = startup_message(); + json::Document document; document.Parse(message.c_str()); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data.HasMember("configAntiPatterns")); - const cass::json::Value& config_anti_patterns = data["configAntiPatterns"]; + const json::Value& config_anti_patterns = data["configAntiPatterns"]; ASSERT_TRUE(config_anti_patterns.IsObject()); ASSERT_EQ(4u, config_anti_patterns.MemberCount()); ASSERT_TRUE(config_anti_patterns.HasMember("contactPointsMultipleDCs")); @@ -756,18 +761,18 @@ TEST_F(ClientInsightsUnitTest, StatusMetadata) { ASSERT_EQ(cluster.start_all(), 0); connect(); - cass::String message = status_message(); - cass::json::Document document; + String message = status_message(); + json::Document document; document.Parse(message.c_str()); ASSERT_TRUE(document.IsObject()); ASSERT_TRUE(document.HasMember("metadata")); - const cass::json::Value& metadata = document["metadata"]; + const json::Value& metadata = document["metadata"]; ASSERT_TRUE(metadata.IsObject()); { // name ASSERT_TRUE(metadata.HasMember("name")); - const cass::json::Value& value = metadata["name"]; + const json::Value& value = metadata["name"]; ASSERT_STREQ("driver.status", metadata["name"].GetString()); } } @@ -782,41 +787,41 @@ TEST_F(ClientInsightsUnitTest, StatusData) { config_.set_use_randomized_contact_points(false); connect(); - cass::String message = status_message(); - cass::json::Document document; + String message = status_message(); + json::Document document; document.Parse(message.c_str()); ASSERT_TRUE(document.IsObject()); ASSERT_TRUE(document.HasMember("data")); - const cass::json::Value& data = document["data"]; + const json::Value& data = document["data"]; ASSERT_TRUE(data.IsObject()); { // client ID ASSERT_TRUE(data.HasMember("clientId")); - ASSERT_STREQ(cass::to_string(session_.client_id()).c_str(), + ASSERT_STREQ(to_string(session_.client_id()).c_str(), data["clientId"].GetString()); } { // session ID ASSERT_TRUE(data.HasMember("sessionId")); - ASSERT_STREQ(cass::to_string(session_.session_id()).c_str(), + ASSERT_STREQ(to_string(session_.session_id()).c_str(), data["sessionId"].GetString()); } { // control connection ASSERT_TRUE(data.HasMember("controlConnection")); - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.1:" << config_.port(); ASSERT_EQ(ip_with_port.str(), data["controlConnection"].GetString()); } { // connected nodes ASSERT_TRUE(data.HasMember("conntectedNodes")); - const cass::json::Value& value = data["conntectedNodes"]; + const json::Value& value = data["conntectedNodes"]; ASSERT_TRUE(value.IsObject()); ASSERT_EQ(2u, value.MemberCount()); for (unsigned i = 1; i <= value.MemberCount(); ++i) { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0." << i << ":" << config_.port(); ASSERT_TRUE(value.HasMember(ip_with_port.str().c_str())); - const cass::json::Value& node = value[ip_with_port.str().c_str()]; + const json::Value& node = value[ip_with_port.str().c_str()]; ASSERT_TRUE(node.IsObject()); ASSERT_EQ(2u, node.MemberCount()); ASSERT_TRUE(node.HasMember("connections")); @@ -835,16 +840,16 @@ TEST_F(ClientInsightsUnitTest, StatusDataConnectedNodesRemovedNode) { config_.set_use_randomized_contact_points(false); connect(); - cass::String message = status_message(); + String message = status_message(); reset_latch(); - cass::json::Document document; + json::Document document; document.Parse(message.c_str()); { // connected nodes (all nodes should be connected) - const cass::json::Value& value = document["data"]["conntectedNodes"]; + const json::Value& value = document["data"]["conntectedNodes"]; ASSERT_EQ(3u, value.MemberCount()); for (unsigned i = 1; i <= value.MemberCount(); ++i) { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0." << i << ":" << config_.port(); int expected_connections (i == 1 ? 2 : 1); // Handle control connection ASSERT_EQ(expected_connections, @@ -857,18 +862,18 @@ TEST_F(ClientInsightsUnitTest, StatusDataConnectedNodesRemovedNode) { document.Parse(message.c_str()); { // connected nodes (node 2 should be missing) - const cass::json::Value& value = document["data"]["conntectedNodes"]; + const json::Value& value = document["data"]["conntectedNodes"]; ASSERT_EQ(2u, value.MemberCount()); { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.1:" << config_.port(); - const cass::json::Value& node = value[ip_with_port.str().c_str()]["connections"]; + const json::Value& node = value[ip_with_port.str().c_str()]["connections"]; EXPECT_EQ(2, node.GetInt()); // Ensure the control connection has moved to node 2 } { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.3:" << config_.port(); - const cass::json::Value& node = value[ip_with_port.str().c_str()]["connections"]; + const json::Value& node = value[ip_with_port.str().c_str()]["connections"]; ASSERT_EQ(1, node.GetInt()); } } @@ -881,25 +886,25 @@ TEST_F(ClientInsightsUnitTest, StatusDataUpdatedControlConnection) { config_.set_reconnect_wait_time(100u); // Reconnect immediately connect(); - cass::String message = startup_message(); + String message = startup_message(); cluster.stop(1); reset_latch(); - cass::json::Document document; + json::Document document; document.Parse(message.c_str()); - cass::String initial_control_connection = - document["data"]["initialControlConnection"].GetString(); + String initial_control_connection = + document["data"]["initialControlConnection"].GetString(); { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.1:" << config_.port(); ASSERT_EQ(ip_with_port.str(), initial_control_connection); } message = status_message(); document.Parse(message.c_str()); - cass::String control_connection = - document["data"]["controlConnection"].GetString(); + String control_connection = + document["data"]["controlConnection"].GetString(); { - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.2:" << config_.port(); ASSERT_EQ(ip_with_port.str(), control_connection); } @@ -911,23 +916,23 @@ TEST_F(ClientInsightsUnitTest, StatusDataInFlightQueries) { connect(); for (int i = 0; i < 37; ++i) { - cass::SharedRefPtr request(new cass::QueryRequest("wait", 0)); + SharedRefPtr request(new QueryRequest("wait", 0)); session_.execute(request, NULL); } - cass::OStringStream ip_with_port; + OStringStream ip_with_port; ip_with_port << "127.0.0.1:" << config_.port(); { - cass::String message = status_message(); - cass::json::Document document; + String message = status_message(); + json::Document document; document.Parse(message.c_str()); ASSERT_EQ(37, document["data"]["conntectedNodes"][ip_with_port.str().c_str()]["inFlightQueries"].GetInt()); } { - cass::String message = status_message(3); - cass::json::Document document; + String message = status_message(3); + json::Document document; document.Parse(message.c_str()); ASSERT_EQ(0, document["data"]["conntectedNodes"][ip_with_port.str().c_str()]["inFlightQueries"].GetInt()); } @@ -938,7 +943,7 @@ TEST_F(ClientInsightsUnitTest, DisableClientInsights) { ASSERT_EQ(cluster.start_all(), 0); connect(0); // Disable client insights - cass::String message = startup_message(); + String message = startup_message(); ASSERT_TRUE(message.empty()); message = status_message(); ASSERT_TRUE(message.empty()); diff --git a/tests/src/unit/tests/test_graph_object.cpp b/tests/src/unit/tests/test_graph_object.cpp index d5c8dbe98..b86899b36 100644 --- a/tests/src/unit/tests/test_graph_object.cpp +++ b/tests/src/unit/tests/test_graph_object.cpp @@ -11,6 +11,9 @@ #include "json.hpp" #include "graph.hpp" +using namespace datastax; +using namespace datastax::internal; + class GraphObjectUnitTest : public testing::Test { public: void SetUp() { @@ -45,7 +48,7 @@ class GraphObjectUnitTest : public testing::Test { } DseGraphObject* graph_object; - cass::json::Document document; + json::Document document; DseLineString* line_string; DseLineStringIterator* line_string_iterator; DsePolygon* polygon; @@ -68,34 +71,34 @@ TEST_F(GraphObjectUnitTest, PrimitiveTypes) { ASSERT_EQ(6u, dse_graph_result_member_count(graph_result)); const DseGraphResult* value; - ASSERT_EQ("null", cass::String(dse_graph_result_member_key(graph_result, 0, NULL))); + ASSERT_EQ("null", String(dse_graph_result_member_key(graph_result, 0, NULL))); value = dse_graph_result_member_value(graph_result, 0); ASSERT_TRUE(dse_graph_result_is_null(value)); - ASSERT_EQ("bool", cass::String(dse_graph_result_member_key(graph_result, 1, NULL))); + ASSERT_EQ("bool", String(dse_graph_result_member_key(graph_result, 1, NULL))); value = dse_graph_result_member_value(graph_result, 1); ASSERT_TRUE(dse_graph_result_is_bool(value)); ASSERT_TRUE(dse_graph_result_get_bool(value)); - ASSERT_EQ("int32", cass::String(dse_graph_result_member_key(graph_result, 2, NULL))); + ASSERT_EQ("int32", String(dse_graph_result_member_key(graph_result, 2, NULL))); value = dse_graph_result_member_value(graph_result, 2); ASSERT_TRUE(dse_graph_result_is_int32(value)); ASSERT_EQ(1, dse_graph_result_get_int32(value)); - ASSERT_EQ("int64", cass::String(dse_graph_result_member_key(graph_result, 3, NULL))); + ASSERT_EQ("int64", String(dse_graph_result_member_key(graph_result, 3, NULL))); value = dse_graph_result_member_value(graph_result, 3); ASSERT_TRUE(dse_graph_result_is_int64(value)); ASSERT_EQ(2, dse_graph_result_get_int64(value)); - ASSERT_EQ("double", cass::String(dse_graph_result_member_key(graph_result, 4, NULL))); + ASSERT_EQ("double", String(dse_graph_result_member_key(graph_result, 4, NULL))); value = dse_graph_result_member_value(graph_result, 4); ASSERT_TRUE(dse_graph_result_is_double(value)); ASSERT_EQ(1.2, dse_graph_result_get_double(value)); - ASSERT_EQ("string", cass::String(dse_graph_result_member_key(graph_result, 5, NULL))); + ASSERT_EQ("string", String(dse_graph_result_member_key(graph_result, 5, NULL))); value = dse_graph_result_member_value(graph_result, 5); ASSERT_TRUE(dse_graph_result_is_string(value)); - ASSERT_EQ("abc", cass::String(dse_graph_result_get_string(value, NULL))); + ASSERT_EQ("abc", String(dse_graph_result_get_string(value, NULL))); } TEST_F(GraphObjectUnitTest, Point) { @@ -109,7 +112,7 @@ TEST_F(GraphObjectUnitTest, Point) { const DseGraphResult* value; cass_double_t x, y; - ASSERT_EQ("point", cass::String(dse_graph_result_member_key(graph_result, 0, NULL))); + ASSERT_EQ("point", String(dse_graph_result_member_key(graph_result, 0, NULL))); value = dse_graph_result_member_value(graph_result, 0); ASSERT_EQ(CASS_OK, dse_graph_result_as_point(value, &x, &y)); ASSERT_EQ(1.0, x); ASSERT_EQ(2.0, y); @@ -132,7 +135,7 @@ TEST_F(GraphObjectUnitTest, LineString) { const DseGraphResult* value; cass_double_t x, y; - ASSERT_EQ("line_string", cass::String(dse_graph_result_member_key(graph_result, 0, NULL))); + ASSERT_EQ("line_string", String(dse_graph_result_member_key(graph_result, 0, NULL))); value = dse_graph_result_member_value(graph_result, 0); line_string_iterator = dse_line_string_iterator_new(); @@ -174,7 +177,7 @@ TEST_F(GraphObjectUnitTest, Polygon) { const DseGraphResult* value; cass_double_t x, y; - ASSERT_EQ("polygon", cass::String(dse_graph_result_member_key(graph_result, 0, NULL))); + ASSERT_EQ("polygon", String(dse_graph_result_member_key(graph_result, 0, NULL))); value = dse_graph_result_member_value(graph_result, 0); polygon_iterator = dse_polygon_iterator_new(); diff --git a/tests/src/unit/tests/test_line_string.cpp b/tests/src/unit/tests/test_line_string.cpp index 2161906be..90f1b320c 100644 --- a/tests/src/unit/tests/test_line_string.cpp +++ b/tests/src/unit/tests/test_line_string.cpp @@ -15,7 +15,11 @@ #include #define RESET_ITERATOR_WITH(x) iterator.reset_text((x), strlen((x))) - + +using namespace datastax; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; + class LineStringUnitTest : public testing::Test { public: void SetUp() { @@ -28,14 +32,14 @@ class LineStringUnitTest : public testing::Test { const CassValue* to_value() { char* data = const_cast(reinterpret_cast(line_string->bytes().data())); - value = cass::Value(cass::DataType::ConstPtr(new cass::CustomType(DSE_LINE_STRING_TYPE)), - cass::Decoder(data, line_string->bytes().size(), 0)); // Protocol version not used + value = Value(DataType::ConstPtr(new CustomType(DSE_LINE_STRING_TYPE)), + Decoder(data, line_string->bytes().size(), 0)); // Protocol version not used return CassValue::to(&value); } DseLineString* line_string; - cass::Value value; - dse::LineStringIterator iterator; + Value value; + LineStringIterator iterator; }; TEST_F(LineStringUnitTest, BinaryEmpty) { @@ -100,7 +104,7 @@ TEST_F(LineStringUnitTest, TextJunkAfterEmptyLineString) { } TEST_F(LineStringUnitTest, TextEmpty) { - cass::String wkt = line_string->to_wkt(); + String wkt = line_string->to_wkt(); ASSERT_EQ("LINESTRING EMPTY", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -110,7 +114,7 @@ TEST_F(LineStringUnitTest, TextEmpty) { TEST_F(LineStringUnitTest, TextSingle) { ASSERT_EQ(CASS_OK, dse_line_string_add_point(line_string, 0.0, 1.0)); - cass::String wkt = line_string->to_wkt(); + String wkt = line_string->to_wkt(); ASSERT_EQ("LINESTRING (0 1)", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -126,7 +130,7 @@ TEST_F(LineStringUnitTest, TextMultiple) { ASSERT_EQ(CASS_OK, dse_line_string_add_point(line_string, 2.0, 3.0)); ASSERT_EQ(CASS_OK, dse_line_string_add_point(line_string, 4.0, 5.0)); - cass::String wkt = line_string->to_wkt(); + String wkt = line_string->to_wkt(); ASSERT_EQ("LINESTRING (0 1, 2 3, 4 5)", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -146,7 +150,7 @@ TEST_F(LineStringUnitTest, TextMultiple) { TEST_F(LineStringUnitTest, TextPrecision) { ASSERT_EQ(CASS_OK, dse_line_string_add_point(line_string, 0.0001, 0.012345678901234567)); - cass::String wkt = line_string->to_wkt(); + String wkt = line_string->to_wkt(); ASSERT_EQ("LINESTRING (0.0001 0.012345678901234567)", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); diff --git a/tests/src/unit/tests/test_polygon.cpp b/tests/src/unit/tests/test_polygon.cpp index 77561e01c..dc69425e5 100644 --- a/tests/src/unit/tests/test_polygon.cpp +++ b/tests/src/unit/tests/test_polygon.cpp @@ -16,6 +16,10 @@ #define RESET_ITERATOR_WITH(x) iterator.reset_text((x), strlen((x))) +using namespace datastax; +using namespace datastax::internal::core; +using namespace datastax::internal::enterprise; + class PolygonUnitTest : public testing::Test { public: void SetUp() { @@ -28,14 +32,14 @@ class PolygonUnitTest : public testing::Test { const CassValue* to_value() { char* data = const_cast(reinterpret_cast(polygon->bytes().data())); - value = cass::Value(cass::DataType::ConstPtr(new cass::CustomType(DSE_POLYGON_TYPE)), - cass::Decoder(data, polygon->bytes().size(), 0)); // Protocol version not used + value = Value(DataType::ConstPtr(new CustomType(DSE_POLYGON_TYPE)), + Decoder(data, polygon->bytes().size(), 0)); // Protocol version not used return CassValue::to(&value); } DsePolygon* polygon; - cass::Value value; - dse::PolygonIterator iterator; + Value value; + PolygonIterator iterator; }; TEST_F(PolygonUnitTest, BinaryEmptyRing) { @@ -155,7 +159,7 @@ TEST_F(PolygonUnitTest, TextJunkAfterEmptyPolygon) { } TEST_F(PolygonUnitTest, TextEmpty) { - cass::String wkt = polygon->to_wkt(); + String wkt = polygon->to_wkt(); ASSERT_EQ("POLYGON EMPTY", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -166,7 +170,7 @@ TEST_F(PolygonUnitTest, TextEmptyRing) { ASSERT_EQ(CASS_OK, dse_polygon_start_ring(polygon)); ASSERT_EQ(CASS_OK, dse_polygon_finish(polygon)); - cass::String wkt = polygon->to_wkt(); + String wkt = polygon->to_wkt(); ASSERT_EQ("POLYGON (())", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -180,7 +184,7 @@ TEST_F(PolygonUnitTest, TextSingleRing) { ASSERT_EQ(CASS_OK, dse_polygon_add_point(polygon, 4, 5)); ASSERT_EQ(CASS_OK, dse_polygon_finish(polygon)); - cass::String wkt = polygon->to_wkt(); + String wkt = polygon->to_wkt(); ASSERT_EQ("POLYGON ((0 1, 2 3, 4 5))", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); @@ -215,7 +219,7 @@ TEST_F(PolygonUnitTest, TextMultipleRings) { ASSERT_EQ(CASS_OK, dse_polygon_finish(polygon)); - cass::String wkt = polygon->to_wkt(); + String wkt = polygon->to_wkt(); ASSERT_EQ("POLYGON ((0 1, 2 3, 4 5), (6 7, 8 9, 10 11, 12 13))", wkt); ASSERT_EQ(CASS_OK, iterator.reset_text(wkt.data(), wkt.size())); diff --git a/tests/src/unit/tests/test_protocol_version.cpp b/tests/src/unit/tests/test_protocol_version.cpp index 1d1fd8671..849007c1e 100644 --- a/tests/src/unit/tests/test_protocol_version.cpp +++ b/tests/src/unit/tests/test_protocol_version.cpp @@ -21,7 +21,7 @@ #include "dse.h" #include "protocol.hpp" -using cass::ProtocolVersion; +using datastax::internal::core::ProtocolVersion; class ProtocolVersionUnitTest : public Unit { }; From 0c8d1ebe819fb1e3865374ea6c1a896a178d4eaa Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Tue, 30 Apr 2019 15:03:28 -0400 Subject: [PATCH 04/27] CPP-770 Fix header file include guards (__CASS_XXX to DATASTAX_XXX) (#234) * Fix header include guards * Move cassconfig.hpp.in to driver_config.hpp.in --- cpp-driver/.gitignore | 2 +- cpp-driver/cmake/modules/CppDriver.cmake | 6 +++--- cpp-driver/{cassconfig.hpp.in => driver_config.hpp.in} | 4 ++-- cpp-driver/gtests/src/unit/test_token_map_utils.hpp | 4 ++-- cpp-driver/packaging/build_deb.sh | 2 +- cpp-driver/packaging/build_rpm.sh | 2 +- cpp-driver/src/abstract_data.hpp | 4 ++-- cpp-driver/src/address.hpp | 4 ++-- cpp-driver/src/aligned_storage.hpp | 4 ++-- cpp-driver/src/allocated.hpp | 4 ++-- cpp-driver/src/allocator.hpp | 4 ++-- cpp-driver/src/async.hpp | 4 ++-- cpp-driver/src/atomic.hpp | 6 +++--- cpp-driver/src/atomic/atomic_boost.hpp | 4 ++-- cpp-driver/src/atomic/atomic_intrinsics.hpp | 4 ++-- cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp | 4 ++-- cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp | 4 ++-- cpp-driver/src/atomic/atomic_std.hpp | 4 ++-- cpp-driver/src/auth.hpp | 4 ++-- cpp-driver/src/auth_requests.hpp | 4 ++-- cpp-driver/src/auth_responses.hpp | 4 ++-- cpp-driver/src/batch_request.hpp | 4 ++-- cpp-driver/src/blacklist_dc_policy.hpp | 4 ++-- cpp-driver/src/blacklist_policy.hpp | 4 ++-- cpp-driver/src/buffer.hpp | 4 ++-- cpp-driver/src/callback.hpp | 4 ++-- cpp-driver/src/cluster.hpp | 4 ++-- cpp-driver/src/cluster_config.hpp | 4 ++-- cpp-driver/src/cluster_connector.hpp | 4 ++-- cpp-driver/src/collection.hpp | 4 ++-- cpp-driver/src/collection_iterator.hpp | 4 ++-- cpp-driver/src/config.hpp | 4 ++-- cpp-driver/src/connection.hpp | 4 ++-- cpp-driver/src/connection_pool.hpp | 4 ++-- cpp-driver/src/connection_pool_connector.hpp | 4 ++-- cpp-driver/src/connection_pool_manager.hpp | 4 ++-- cpp-driver/src/connection_pool_manager_initializer.hpp | 4 ++-- cpp-driver/src/connector.hpp | 4 ++-- cpp-driver/src/constants.hpp | 4 ++-- cpp-driver/src/control_connection.hpp | 4 ++-- cpp-driver/src/control_connector.hpp | 4 ++-- cpp-driver/src/copy_on_write_ptr.hpp | 4 ++-- cpp-driver/src/data_type.hpp | 4 ++-- cpp-driver/src/data_type_parser.hpp | 4 ++-- cpp-driver/src/dc_aware_policy.hpp | 4 ++-- cpp-driver/src/decoder.hpp | 6 +++--- cpp-driver/src/delayed_connector.hpp | 4 ++-- cpp-driver/src/dense_hash_map.hpp | 4 ++-- cpp-driver/src/dense_hash_set.hpp | 4 ++-- cpp-driver/src/deque.hpp | 4 ++-- cpp-driver/src/driver_info.hpp | 6 +++--- cpp-driver/src/encode.hpp | 4 ++-- cpp-driver/src/error_response.hpp | 4 ++-- cpp-driver/src/event_loop.hpp | 6 +++--- cpp-driver/src/event_response.hpp | 4 ++-- cpp-driver/src/execute_request.hpp | 4 ++-- cpp-driver/src/execution_profile.hpp | 6 +++--- cpp-driver/src/external.hpp | 4 ++-- cpp-driver/src/fixed_allocator.hpp | 4 ++-- cpp-driver/src/future.hpp | 4 ++-- cpp-driver/src/get_time.hpp | 4 ++-- cpp-driver/src/hash.hpp | 4 ++-- cpp-driver/src/hash_table.hpp | 4 ++-- cpp-driver/src/histogram_wrapper.hpp | 4 ++-- cpp-driver/src/host.hpp | 4 ++-- cpp-driver/src/host_targeting_policy.hpp | 4 ++-- cpp-driver/src/iterator.hpp | 4 ++-- cpp-driver/src/json.hpp | 6 +++--- cpp-driver/src/latency_aware_policy.hpp | 4 ++-- cpp-driver/src/list.hpp | 4 ++-- cpp-driver/src/list_policy.hpp | 4 ++-- cpp-driver/src/load_balancing.hpp | 4 ++-- cpp-driver/src/logger.hpp | 4 ++-- cpp-driver/src/loop_watcher.hpp | 4 ++-- cpp-driver/src/macros.hpp | 4 ++-- cpp-driver/src/map.hpp | 4 ++-- cpp-driver/src/map_iterator.hpp | 4 ++-- cpp-driver/src/md5.hpp | 4 ++-- cpp-driver/src/memory.hpp | 4 ++-- cpp-driver/src/metadata.hpp | 4 ++-- cpp-driver/src/metrics.hpp | 4 ++-- cpp-driver/src/micro_timer.hpp | 6 +++--- cpp-driver/src/monitor_reporting.hpp | 6 +++--- cpp-driver/src/mpmc_queue.hpp | 6 +++--- cpp-driver/src/murmur3.hpp | 4 ++-- cpp-driver/src/name_resolver.hpp | 4 ++-- cpp-driver/src/options_request.hpp | 4 ++-- cpp-driver/src/pooled_connection.hpp | 4 ++-- cpp-driver/src/prepare_all_handler.hpp | 4 ++-- cpp-driver/src/prepare_host_handler.hpp | 4 ++-- cpp-driver/src/prepare_request.hpp | 4 ++-- cpp-driver/src/prepared.hpp | 4 ++-- cpp-driver/src/protocol.hpp | 4 ++-- cpp-driver/src/query_request.hpp | 4 ++-- cpp-driver/src/random.cpp | 2 +- cpp-driver/src/random.hpp | 4 ++-- cpp-driver/src/ready_response.hpp | 4 ++-- cpp-driver/src/ref_counted.hpp | 4 ++-- cpp-driver/src/register_request.hpp | 4 ++-- cpp-driver/src/request.hpp | 4 ++-- cpp-driver/src/request_callback.hpp | 4 ++-- cpp-driver/src/request_handler.hpp | 4 ++-- cpp-driver/src/request_processor.hpp | 6 +++--- cpp-driver/src/request_processor_initializer.hpp | 4 ++-- cpp-driver/src/resolver.hpp | 4 ++-- cpp-driver/src/response.hpp | 4 ++-- cpp-driver/src/result_iterator.hpp | 4 ++-- cpp-driver/src/result_metadata.hpp | 4 ++-- cpp-driver/src/result_response.hpp | 4 ++-- cpp-driver/src/retry_policy.hpp | 4 ++-- cpp-driver/src/ring_buffer.hpp | 4 ++-- cpp-driver/src/round_robin_policy.hpp | 4 ++-- cpp-driver/src/row.hpp | 4 ++-- cpp-driver/src/row_iterator.hpp | 4 ++-- cpp-driver/src/schema_agreement_handler.hpp | 4 ++-- cpp-driver/src/scoped_lock.hpp | 4 ++-- cpp-driver/src/scoped_ptr.hpp | 4 ++-- cpp-driver/src/serialization.hpp | 4 ++-- cpp-driver/src/session.hpp | 4 ++-- cpp-driver/src/session_base.hpp | 4 ++-- cpp-driver/src/set.hpp | 4 ++-- cpp-driver/src/small_dense_hash_map.hpp | 4 ++-- cpp-driver/src/small_vector.hpp | 4 ++-- cpp-driver/src/socket.hpp | 4 ++-- cpp-driver/src/socket_connector.hpp | 4 ++-- cpp-driver/src/speculative_execution.hpp | 4 ++-- cpp-driver/src/spin_lock.hpp | 4 ++-- cpp-driver/src/spsc_queue.hpp | 6 +++--- cpp-driver/src/ssl.hpp | 6 +++--- cpp-driver/src/ssl/ring_buffer_bio.hpp | 4 ++-- cpp-driver/src/ssl/ssl_no_impl.hpp | 4 ++-- cpp-driver/src/ssl/ssl_openssl_impl.hpp | 4 ++-- cpp-driver/src/stack.hpp | 4 ++-- cpp-driver/src/startup_request.hpp | 4 ++-- cpp-driver/src/statement.hpp | 4 ++-- cpp-driver/src/stream_manager.hpp | 4 ++-- cpp-driver/src/string.hpp | 6 +++--- cpp-driver/src/string_ref.hpp | 4 ++-- cpp-driver/src/supported_response.hpp | 4 ++-- cpp-driver/src/tcp_connector.hpp | 4 ++-- cpp-driver/src/testing.hpp | 4 ++-- cpp-driver/src/timer.hpp | 4 ++-- cpp-driver/src/timestamp_generator.hpp | 4 ++-- cpp-driver/src/token_aware_policy.hpp | 4 ++-- cpp-driver/src/token_map.hpp | 4 ++-- cpp-driver/src/token_map_impl.hpp | 4 ++-- cpp-driver/src/tracing_data_handler.hpp | 4 ++-- cpp-driver/src/tuple.hpp | 4 ++-- cpp-driver/src/types.hpp | 4 ++-- cpp-driver/src/user_type_field_iterator.hpp | 4 ++-- cpp-driver/src/user_type_value.hpp | 4 ++-- cpp-driver/src/utils.hpp | 4 ++-- cpp-driver/src/uuids.hpp | 4 ++-- cpp-driver/src/value.hpp | 4 ++-- cpp-driver/src/vector.hpp | 4 ++-- cpp-driver/src/wait_for_handler.hpp | 4 ++-- cpp-driver/src/whitelist_dc_policy.hpp | 4 ++-- cpp-driver/src/whitelist_policy.hpp | 4 ++-- packaging/build_deb.sh | 2 +- packaging/build_rpm.sh | 2 +- src/client_insights.hpp | 6 +++--- src/date_range.hpp | 4 ++-- src/dse_auth.hpp | 4 ++-- src/graph.hpp | 4 ++-- src/line_string.hpp | 4 ++-- src/point.hpp | 4 ++-- src/polygon.hpp | 4 ++-- src/serialization.hpp | 4 ++-- src/validate.hpp | 4 ++-- src/wkt.hpp | 4 ++-- 170 files changed, 349 insertions(+), 349 deletions(-) rename cpp-driver/{cassconfig.hpp.in => driver_config.hpp.in} (78%) diff --git a/cpp-driver/.gitignore b/cpp-driver/.gitignore index 460003e24..0060e3e0f 100644 --- a/cpp-driver/.gitignore +++ b/cpp-driver/.gitignore @@ -50,7 +50,7 @@ Testing Debug demo/cassandra_demo test/unit_tests/cassandra_test -src/cassconfig.hpp +src/driver_config.hpp # API docs files Doxyfile diff --git a/cpp-driver/cmake/modules/CppDriver.cmake b/cpp-driver/cmake/modules/CppDriver.cmake index 7572656d8..9d6972fcb 100644 --- a/cpp-driver/cmake/modules/CppDriver.cmake +++ b/cpp-driver/cmake/modules/CppDriver.cmake @@ -998,7 +998,7 @@ endmacro() #------------------------ # CassConfigure # -# Generate cassconfig.hpp from cassconfig.hpp.in +# Generate driver_config.hpp from driver_config.hpp.in # # Input: CASS_ROOT_DIR, CASS_SRC_DIR #------------------------ @@ -1034,6 +1034,6 @@ macro(CassConfigure) check_cxx_source_compiles("int main() { return __builtin_bswap64(42); }" HAVE_BUILTIN_BSWAP64) endif() - # Generate the cassconfig.hpp file - configure_file(${CASS_ROOT_DIR}/cassconfig.hpp.in ${CASS_SRC_DIR}/cassconfig.hpp) + # Generate the driver_config.hpp file + configure_file(${CASS_ROOT_DIR}/driver_config.hpp.in ${CASS_SRC_DIR}/driver_config.hpp) endmacro() diff --git a/cpp-driver/cassconfig.hpp.in b/cpp-driver/driver_config.hpp.in similarity index 78% rename from cpp-driver/cassconfig.hpp.in rename to cpp-driver/driver_config.hpp.in index a1c1c8b89..43d8a6df2 100644 --- a/cpp-driver/cassconfig.hpp.in +++ b/cpp-driver/driver_config.hpp.in @@ -1,5 +1,5 @@ -#ifndef __CASSANDRA_CONFIG_HPP_INCLUDED__ -#define __CASSANDRA_CONFIG_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DRIVER_CONFIG_HPP +#define DATASTAX_INTERNAL_DRIVER_CONFIG_HPP #cmakedefine HAVE_OPENSSL #cmakedefine HAVE_STD_ATOMIC diff --git a/cpp-driver/gtests/src/unit/test_token_map_utils.hpp b/cpp-driver/gtests/src/unit/test_token_map_utils.hpp index 179f26069..df0cee965 100644 --- a/cpp-driver/gtests/src/unit/test_token_map_utils.hpp +++ b/cpp-driver/gtests/src/unit/test_token_map_utils.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TEST_TOKEN_MAP_UTILS_HPP_INCLUDED__ -#define __CASS_TEST_TOKEN_MAP_UTILS_HPP_INCLUDED__ +#ifndef DATASTAX_TEST_TOKEN_MAP_UTILS_HPP +#define DATASTAX_TEST_TOKEN_MAP_UTILS_HPP #include "constants.hpp" #include "decoder.hpp" diff --git a/cpp-driver/packaging/build_deb.sh b/cpp-driver/packaging/build_deb.sh index 822463016..75b5cbab6 100755 --- a/cpp-driver/packaging/build_deb.sh +++ b/cpp-driver/packaging/build_deb.sh @@ -39,7 +39,7 @@ release=1 dist=$(lsb_release -s -c) base="cassandra-cpp-driver-$version" archive="$base.tar.gz" -files="CMakeLists.txt cmake cmake_uninstall.cmake.in cassconfig.hpp.in include src" +files="CMakeLists.txt cmake cmake_uninstall.cmake.in driver_config.hpp.in include src" echo "Building version $version" diff --git a/cpp-driver/packaging/build_rpm.sh b/cpp-driver/packaging/build_rpm.sh index fa5817ac5..aa491feda 100755 --- a/cpp-driver/packaging/build_rpm.sh +++ b/cpp-driver/packaging/build_rpm.sh @@ -42,7 +42,7 @@ fi version=$(header_version "../include/cassandra.h") base="cassandra-cpp-driver-$version" archive="$base.tar.gz" -files="CMakeLists.txt cmake cmake_uninstall.cmake.in cassconfig.hpp.in include src README.md LICENSE.txt" +files="CMakeLists.txt cmake cmake_uninstall.cmake.in driver_config.hpp.in include src README.md LICENSE.txt" echo "Building version $version" diff --git a/cpp-driver/src/abstract_data.hpp b/cpp-driver/src/abstract_data.hpp index 9ce52453b..f977b1e42 100644 --- a/cpp-driver/src/abstract_data.hpp +++ b/cpp-driver/src/abstract_data.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ABSTRACT_DATA_HPP_INCLUDED__ -#define __CASS_ABSTRACT_DATA_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ABSTRACT_DATA_HPP +#define DATASTAX_INTERNAL_ABSTRACT_DATA_HPP #include "allocated.hpp" #include "buffer.hpp" diff --git a/cpp-driver/src/address.hpp b/cpp-driver/src/address.hpp index 7ebbc6ea4..764b861d4 100644 --- a/cpp-driver/src/address.hpp +++ b/cpp-driver/src/address.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ADDRESS_HPP_INCLUDED__ -#define __CASS_ADDRESS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ADDRESS_HPP +#define DATASTAX_INTERNAL_ADDRESS_HPP #include "allocated.hpp" #include "hash.hpp" diff --git a/cpp-driver/src/aligned_storage.hpp b/cpp-driver/src/aligned_storage.hpp index 96c37254d..16c306a4f 100644 --- a/cpp-driver/src/aligned_storage.hpp +++ b/cpp-driver/src/aligned_storage.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ALIGNED_STORAGE_HPP_INCLUDED__ -#define __CASS_ALIGNED_STORAGE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ALIGNED_STORAGE_HPP +#define DATASTAX_INTERNAL_ALIGNED_STORAGE_HPP #include diff --git a/cpp-driver/src/allocated.hpp b/cpp-driver/src/allocated.hpp index 5aa0d89e7..df29c6bed 100644 --- a/cpp-driver/src/allocated.hpp +++ b/cpp-driver/src/allocated.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ALLOCATED_HPP_INCLUDED__ -#define __CASS_ALLOCATED_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ALLOCATED_HPP +#define DATASTAX_INTERNAL_ALLOCATED_HPP #include diff --git a/cpp-driver/src/allocator.hpp b/cpp-driver/src/allocator.hpp index 2df22832f..c0d1bb569 100644 --- a/cpp-driver/src/allocator.hpp +++ b/cpp-driver/src/allocator.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_ALLOCATOR_HPP_INCLUDED__ -#define __DSE_ALLOCATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ALLOCATOR_HPP +#define DATASTAX_INTERNAL_ALLOCATOR_HPP #include "memory.hpp" diff --git a/cpp-driver/src/async.hpp b/cpp-driver/src/async.hpp index 725c45c8c..a24e7881c 100644 --- a/cpp-driver/src/async.hpp +++ b/cpp-driver/src/async.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ASYNC_HPP_INCLUDED__ -#define __CASS_ASYNC_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ASYNC_HPP +#define DATASTAX_INTERNAL_ASYNC_HPP #include "allocated.hpp" #include "callback.hpp" diff --git a/cpp-driver/src/atomic.hpp b/cpp-driver/src/atomic.hpp index 3f96cf9aa..f501a487a 100644 --- a/cpp-driver/src/atomic.hpp +++ b/cpp-driver/src/atomic.hpp @@ -14,10 +14,10 @@ limitations under the License. */ -#ifndef __CASS_ATOMIC_HPP_INCLUDED__ -#define __CASS_ATOMIC_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_HPP +#define DATASTAX_INTERNAL_ATOMIC_HPP -#include "cassconfig.hpp" +#include "driver_config.hpp" #if defined(HAVE_BOOST_ATOMIC) #include "atomic/atomic_boost.hpp" diff --git a/cpp-driver/src/atomic/atomic_boost.hpp b/cpp-driver/src/atomic/atomic_boost.hpp index 202da4485..e484f75a8 100644 --- a/cpp-driver/src/atomic/atomic_boost.hpp +++ b/cpp-driver/src/atomic/atomic_boost.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ATOMIC_BOOST_HPP_INCLUDED__ -#define __CASS_ATOMIC_BOOST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_BOOST_HPP +#define DATASTAX_INTERNAL_ATOMIC_BOOST_HPP #include diff --git a/cpp-driver/src/atomic/atomic_intrinsics.hpp b/cpp-driver/src/atomic/atomic_intrinsics.hpp index 8a6c82a04..ec3eae8c0 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics.hpp @@ -28,8 +28,8 @@ * Copyright (c) 2014 Andrey Semashev */ -#ifndef __CASS_ATOMIC_INTRINSICS_HPP_INCLUDED__ -#define __CASS_ATOMIC_INTRINSICS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_INTRINSICS_HPP +#define DATASTAX_INTERNAL_ATOMIC_INTRINSICS_HPP // The slower, intrinsics-based implemenations of Atomic<>. diff --git a/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp b/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp index a9cea519b..6abdac1b0 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics_gcc.hpp @@ -28,8 +28,8 @@ * Copyright (c) 2014 Andrey Semashev */ -#ifndef __CASS_ATOMIC_INTRINSICS_GCC_HPP_INCLUDED__ -#define __CASS_ATOMIC_INTRINSICS_GCC_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_INTRINSICS_GCC_HPP +#define DATASTAX_INTERNAL_ATOMIC_INTRINSICS_GCC_HPP #include diff --git a/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp b/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp index 786cf4176..4eec942b2 100644 --- a/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp +++ b/cpp-driver/src/atomic/atomic_intrinsics_msvc.hpp @@ -28,8 +28,8 @@ * Copyright (c) 2014 Andrey Semashev */ -#ifndef __CASS_ATOMIC_BASE_MSVC_HPP_INCLUDED__ -#define __CASS_ATOMIC_BASE_MSVC_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_BASE_MSVC_HPP +#define DATASTAX_INTERNAL_ATOMIC_BASE_MSVC_HPP #ifndef _WINSOCKAPI_ #define _WINSOCKAPI_ diff --git a/cpp-driver/src/atomic/atomic_std.hpp b/cpp-driver/src/atomic/atomic_std.hpp index 2c8d69fdc..5dca5e456 100644 --- a/cpp-driver/src/atomic/atomic_std.hpp +++ b/cpp-driver/src/atomic/atomic_std.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ATOMIC_STD_HPP_INCLUDED__ -#define __CASS_ATOMIC_STD_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ATOMIC_STD_HPP +#define DATASTAX_INTERNAL_ATOMIC_STD_HPP #include diff --git a/cpp-driver/src/auth.hpp b/cpp-driver/src/auth.hpp index 6adeeaf24..c2a426576 100644 --- a/cpp-driver/src/auth.hpp +++ b/cpp-driver/src/auth.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_AUTH_HPP_INCLUDED__ -#define __CASS_AUTH_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_AUTH_HPP +#define DATASTAX_INTERNAL_AUTH_HPP #include "buffer.hpp" #include "external.hpp" diff --git a/cpp-driver/src/auth_requests.hpp b/cpp-driver/src/auth_requests.hpp index b9afbc6bb..5309b2137 100644 --- a/cpp-driver/src/auth_requests.hpp +++ b/cpp-driver/src/auth_requests.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_AUTH_REQUESTS_HPP_INCLUDED__ -#define __CASS_AUTH_REQUESTS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_AUTH_REQUESTS_HPP +#define DATASTAX_INTERNAL_AUTH_REQUESTS_HPP #include "auth.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/auth_responses.hpp b/cpp-driver/src/auth_responses.hpp index 550896482..a81a15039 100644 --- a/cpp-driver/src/auth_responses.hpp +++ b/cpp-driver/src/auth_responses.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_AUTH_RESPONSES_HPP_INCLUDED__ -#define __CASS_AUTH_RESPONSES_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_AUTH_RESPONSES_HPP +#define DATASTAX_INTERNAL_AUTH_RESPONSES_HPP #include "constants.hpp" #include "response.hpp" diff --git a/cpp-driver/src/batch_request.hpp b/cpp-driver/src/batch_request.hpp index 2566735ba..330fd2e5b 100644 --- a/cpp-driver/src/batch_request.hpp +++ b/cpp-driver/src/batch_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_BATCH_REQUEST_HPP_INCLUDED__ -#define __CASS_BATCH_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_BATCH_REQUEST_HPP +#define DATASTAX_INTERNAL_BATCH_REQUEST_HPP #include "cassandra.h" #include "constants.hpp" diff --git a/cpp-driver/src/blacklist_dc_policy.hpp b/cpp-driver/src/blacklist_dc_policy.hpp index f2532c14d..7583216aa 100644 --- a/cpp-driver/src/blacklist_dc_policy.hpp +++ b/cpp-driver/src/blacklist_dc_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_BLACKLIST_DC_POLICY_HPP_INCLUDED__ -#define __CASS_BLACKLIST_DC_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_BLACKLIST_DC_POLICY_HPP +#define DATASTAX_INTERNAL_BLACKLIST_DC_POLICY_HPP #include "load_balancing.hpp" #include "host.hpp" diff --git a/cpp-driver/src/blacklist_policy.hpp b/cpp-driver/src/blacklist_policy.hpp index 2ece32df2..10bb2edc0 100644 --- a/cpp-driver/src/blacklist_policy.hpp +++ b/cpp-driver/src/blacklist_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_BLACKLIST_POLICY_HPP_INCLUDED__ -#define __CASS_BLACKLIST_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_BLACKLIST_POLICY_HPP +#define DATASTAX_INTERNAL_BLACKLIST_POLICY_HPP #include "load_balancing.hpp" #include "host.hpp" diff --git a/cpp-driver/src/buffer.hpp b/cpp-driver/src/buffer.hpp index 20bd93cfd..fb5e8ae7d 100644 --- a/cpp-driver/src/buffer.hpp +++ b/cpp-driver/src/buffer.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_BUFFER_HPP_INCLUDED__ -#define __CASS_BUFFER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_BUFFER_HPP +#define DATASTAX_INTERNAL_BUFFER_HPP #include "ref_counted.hpp" #include "serialization.hpp" diff --git a/cpp-driver/src/callback.hpp b/cpp-driver/src/callback.hpp index 8de616cef..2e52c1af9 100644 --- a/cpp-driver/src/callback.hpp +++ b/cpp-driver/src/callback.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CALLBACK_HPP_INCLUDED__ -#define __CASS_CALLBACK_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CALLBACK_HPP +#define DATASTAX_INTERNAL_CALLBACK_HPP #include "aligned_storage.hpp" #include "macros.hpp" diff --git a/cpp-driver/src/cluster.hpp b/cpp-driver/src/cluster.hpp index 8cd0496b9..7e3b6de5a 100644 --- a/cpp-driver/src/cluster.hpp +++ b/cpp-driver/src/cluster.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CLUSTER_HPP_INCLUDED__ -#define __CASS_CLUSTER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CLUSTER_HPP +#define DATASTAX_INTERNAL_CLUSTER_HPP #include "monitor_reporting.hpp" #include "config.hpp" diff --git a/cpp-driver/src/cluster_config.hpp b/cpp-driver/src/cluster_config.hpp index 6718c8ae0..4cb8525db 100644 --- a/cpp-driver/src/cluster_config.hpp +++ b/cpp-driver/src/cluster_config.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CLUSTER_CONFIG_HPP_INCLUDED__ -#define __CASS_CLUSTER_CONFIG_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CLUSTER_CONFIG_HPP +#define DATASTAX_INTERNAL_CLUSTER_CONFIG_HPP #include "allocated.hpp" #include "config.hpp" diff --git a/cpp-driver/src/cluster_connector.hpp b/cpp-driver/src/cluster_connector.hpp index 4de29f8c3..a79097bf0 100644 --- a/cpp-driver/src/cluster_connector.hpp +++ b/cpp-driver/src/cluster_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CLUSTER_CONNECTOR_HPP_INCLUDED__ -#define __CASS_CLUSTER_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CLUSTER_CONNECTOR_HPP +#define DATASTAX_INTERNAL_CLUSTER_CONNECTOR_HPP #include "callback.hpp" #include "cluster.hpp" diff --git a/cpp-driver/src/collection.hpp b/cpp-driver/src/collection.hpp index 9bf5117d2..1408c1835 100644 --- a/cpp-driver/src/collection.hpp +++ b/cpp-driver/src/collection.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_COLLECTION_HPP_INCLUDED__ -#define __CASS_COLLECTION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_COLLECTION_HPP +#define DATASTAX_INTERNAL_COLLECTION_HPP #include "cassandra.h" #include "data_type.hpp" diff --git a/cpp-driver/src/collection_iterator.hpp b/cpp-driver/src/collection_iterator.hpp index 2217ff8db..f7ed534eb 100644 --- a/cpp-driver/src/collection_iterator.hpp +++ b/cpp-driver/src/collection_iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_VALUE_ITERATOR_HPP_INCLUDED__ -#define __CASS_VALUE_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_VALUE_ITERATOR_HPP +#define DATASTAX_INTERNAL_VALUE_ITERATOR_HPP #include "cassandra.h" #include "iterator.hpp" diff --git a/cpp-driver/src/config.hpp b/cpp-driver/src/config.hpp index 588106c96..600bf1168 100644 --- a/cpp-driver/src/config.hpp +++ b/cpp-driver/src/config.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONFIG_HPP_INCLUDED__ -#define __CASS_CONFIG_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONFIG_HPP +#define DATASTAX_INTERNAL_CONFIG_HPP #include "auth.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/connection.hpp b/cpp-driver/src/connection.hpp index 7543671e5..5a79e6ff4 100644 --- a/cpp-driver/src/connection.hpp +++ b/cpp-driver/src/connection.hpp @@ -19,8 +19,8 @@ #include "socket.hpp" #include "stream_manager.hpp" -#ifndef __CASS_CONNECTION_HPP_INCLUDED__ -#define __CASS_CONNECTION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_HPP +#define DATASTAX_INTERNAL_CONNECTION_HPP namespace datastax { namespace internal { namespace core { diff --git a/cpp-driver/src/connection_pool.hpp b/cpp-driver/src/connection_pool.hpp index 4869be938..d2525fe4b 100644 --- a/cpp-driver/src/connection_pool.hpp +++ b/cpp-driver/src/connection_pool.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONNECTION_POOL_HPP_INCLUDED__ -#define __CASS_CONNECTION_POOL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_POOL_HPP +#define DATASTAX_INTERNAL_CONNECTION_POOL_HPP #include "address.hpp" #include "delayed_connector.hpp" diff --git a/cpp-driver/src/connection_pool_connector.hpp b/cpp-driver/src/connection_pool_connector.hpp index d3ee49602..69646abd3 100644 --- a/cpp-driver/src/connection_pool_connector.hpp +++ b/cpp-driver/src/connection_pool_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONNECTION_POOL_CONNECTOR_HPP_INCLUDED__ -#define __CASS_CONNECTION_POOL_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_POOL_CONNECTOR_HPP +#define DATASTAX_INTERNAL_CONNECTION_POOL_CONNECTOR_HPP #include "address.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/connection_pool_manager.hpp b/cpp-driver/src/connection_pool_manager.hpp index 413850fe6..38dfc0c0f 100644 --- a/cpp-driver/src/connection_pool_manager.hpp +++ b/cpp-driver/src/connection_pool_manager.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONNECTION_POOL_MANAGER_HPP_INCLUDED__ -#define __CASS_CONNECTION_POOL_MANAGER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_POOL_MANAGER_HPP +#define DATASTAX_INTERNAL_CONNECTION_POOL_MANAGER_HPP #include "address.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/connection_pool_manager_initializer.hpp b/cpp-driver/src/connection_pool_manager_initializer.hpp index 9b2b86b01..df6873791 100644 --- a/cpp-driver/src/connection_pool_manager_initializer.hpp +++ b/cpp-driver/src/connection_pool_manager_initializer.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONNECTION_POOL_MANAGER_INITIALIZER_HPP_INCLUDED__ -#define __CASS_CONNECTION_POOL_MANAGER_INITIALIZER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_POOL_MANAGER_INITIALIZER_HPP +#define DATASTAX_INTERNAL_CONNECTION_POOL_MANAGER_INITIALIZER_HPP #include "address.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/connector.hpp b/cpp-driver/src/connector.hpp index 82f4c1e18..9b29716c0 100644 --- a/cpp-driver/src/connector.hpp +++ b/cpp-driver/src/connector.hpp @@ -19,8 +19,8 @@ #include "connection.hpp" #include "socket_connector.hpp" -#ifndef __CASS_CONNECTION_CONNECTOR_HPP_INCLUDED__ -#define __CASS_CONNECTION_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTION_CONNECTOR_HPP +#define DATASTAX_INTERNAL_CONNECTION_CONNECTOR_HPP namespace datastax { namespace internal { namespace core { diff --git a/cpp-driver/src/constants.hpp b/cpp-driver/src/constants.hpp index f4157bb90..3e77cca6a 100644 --- a/cpp-driver/src/constants.hpp +++ b/cpp-driver/src/constants.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONSTANTS_HPP_INCLUDED__ -#define __CASS_CONSTANTS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONSTANTS_HPP +#define DATASTAX_INTERNAL_CONSTANTS_HPP #define CASS_UINT32_MAX 4294967295UL diff --git a/cpp-driver/src/control_connection.hpp b/cpp-driver/src/control_connection.hpp index 392daf92f..dc693a318 100644 --- a/cpp-driver/src/control_connection.hpp +++ b/cpp-driver/src/control_connection.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONTROL_CONNECTION_HPP_INCLUDED__ -#define __CASS_CONTROL_CONNECTION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONTROL_CONNECTION_HPP +#define DATASTAX_INTERNAL_CONTROL_CONNECTION_HPP #include "address.hpp" #include "config.hpp" diff --git a/cpp-driver/src/control_connector.hpp b/cpp-driver/src/control_connector.hpp index e86ed3672..f6874d93b 100644 --- a/cpp-driver/src/control_connector.hpp +++ b/cpp-driver/src/control_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONTROL_CONNECTOR_HPP_INCLUDED__ -#define __CASS_CONTROL_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONTROL_CONNECTOR_HPP +#define DATASTAX_INTERNAL_CONTROL_CONNECTOR_HPP #include "callback.hpp" #include "control_connection.hpp" diff --git a/cpp-driver/src/copy_on_write_ptr.hpp b/cpp-driver/src/copy_on_write_ptr.hpp index e4c7012ca..216d59075 100644 --- a/cpp-driver/src/copy_on_write_ptr.hpp +++ b/cpp-driver/src/copy_on_write_ptr.hpp @@ -16,8 +16,8 @@ #include "ref_counted.hpp" -#ifndef __CASS_COPY_ON_WRITE_PTR_HPP_INCLUDED__ -#define __CASS_COPY_ON_WRITE_PTR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_COPY_ON_WRITE_PTR_HPP +#define DATASTAX_INTERNAL_COPY_ON_WRITE_PTR_HPP #include diff --git a/cpp-driver/src/data_type.hpp b/cpp-driver/src/data_type.hpp index d078919ea..9e5548b77 100644 --- a/cpp-driver/src/data_type.hpp +++ b/cpp-driver/src/data_type.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_DATA_TYPE_HPP_INCLUDED__ -#define __CASS_DATA_TYPE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DATA_TYPE_HPP +#define DATASTAX_INTERNAL_DATA_TYPE_HPP #include "cassandra.h" #include "external.hpp" diff --git a/cpp-driver/src/data_type_parser.hpp b/cpp-driver/src/data_type_parser.hpp index ae1b6fb76..cca569864 100644 --- a/cpp-driver/src/data_type_parser.hpp +++ b/cpp-driver/src/data_type_parser.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TYPE_PARSER_HPP_INCLUDED__ -#define __CASS_TYPE_PARSER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TYPE_PARSER_HPP +#define DATASTAX_INTERNAL_TYPE_PARSER_HPP #include "cassandra.h" #include "data_type.hpp" diff --git a/cpp-driver/src/dc_aware_policy.hpp b/cpp-driver/src/dc_aware_policy.hpp index d8f4d973f..7947e81c1 100644 --- a/cpp-driver/src/dc_aware_policy.hpp +++ b/cpp-driver/src/dc_aware_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_DC_AWARE_POLICY_HPP_INCLUDED__ -#define __CASS_DC_AWARE_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DC_AWARE_POLICY_HPP +#define DATASTAX_INTERNAL_DC_AWARE_POLICY_HPP #include "load_balancing.hpp" #include "host.hpp" diff --git a/cpp-driver/src/decoder.hpp b/cpp-driver/src/decoder.hpp index 77b65f77e..b5435f9c9 100644 --- a/cpp-driver/src/decoder.hpp +++ b/cpp-driver/src/decoder.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_DECODER_HPP_INCLUDED__ -#define __CASS_DECODER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DECODER_HPP +#define DATASTAX_INTERNAL_DECODER_HPP #include "constants.hpp" #include "data_type.hpp" @@ -587,4 +587,4 @@ friend class Value; #undef CHECK_REMAINING -#endif // __CASS_DECODER_HPP_INCLUDED__ +#endif // DATASTAX_INTERNAL_DECODER_HPP diff --git a/cpp-driver/src/delayed_connector.hpp b/cpp-driver/src/delayed_connector.hpp index df2df4983..8f1b9c94c 100644 --- a/cpp-driver/src/delayed_connector.hpp +++ b/cpp-driver/src/delayed_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_DELAYED_CONNECTOR_HPP_INCLUDED__ -#define __CASS_DELAYED_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DELAYED_CONNECTOR_HPP +#define DATASTAX_INTERNAL_DELAYED_CONNECTOR_HPP #include "callback.hpp" #include "connector.hpp" diff --git a/cpp-driver/src/dense_hash_map.hpp b/cpp-driver/src/dense_hash_map.hpp index a48ba3937..67187820d 100644 --- a/cpp-driver/src/dense_hash_map.hpp +++ b/cpp-driver/src/dense_hash_map.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_DENSE_HASH_MAP_HPP_INCLUDED__ -#define __DSE_DENSE_HASH_MAP_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DENSE_HASH_MAP_HPP +#define DATASTAX_INTERNAL_DENSE_HASH_MAP_HPP #include "allocator.hpp" diff --git a/cpp-driver/src/dense_hash_set.hpp b/cpp-driver/src/dense_hash_set.hpp index 5fcda7080..46eab182e 100644 --- a/cpp-driver/src/dense_hash_set.hpp +++ b/cpp-driver/src/dense_hash_set.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_DENSE_HASH_SET_HPP_INCLUDED__ -#define __DSE_DENSE_HASH_SET_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DENSE_HASH_SET_HPP +#define DATASTAX_INTERNAL_DENSE_HASH_SET_HPP #include "allocator.hpp" diff --git a/cpp-driver/src/deque.hpp b/cpp-driver/src/deque.hpp index 1fcc8953c..61efc5013 100644 --- a/cpp-driver/src/deque.hpp +++ b/cpp-driver/src/deque.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_DEQUE_HPP_INCLUDED__ -#define __DSE_DEQUE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DEQUE_HPP +#define DATASTAX_INTERNAL_DEQUE_HPP #include "allocator.hpp" diff --git a/cpp-driver/src/driver_info.hpp b/cpp-driver/src/driver_info.hpp index 00ab7bc7d..bdcdfe1fc 100644 --- a/cpp-driver/src/driver_info.hpp +++ b/cpp-driver/src/driver_info.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_DRIVER_INFO_HPP_INCLUDED__ -#define __CASS_DRIVER_INFO_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_DRIVER_INFO_HPP +#define DATASTAX_INTERNAL_DRIVER_INFO_HPP namespace datastax { namespace internal { @@ -24,4 +24,4 @@ const char* driver_version(); } } // namespace datastax::internal -#endif // __CASS_DRIVER_INFO_HPP_INCLUDED__ +#endif // DATASTAX_INTERNAL_DRIVER_INFO_HPP diff --git a/cpp-driver/src/encode.hpp b/cpp-driver/src/encode.hpp index 6644194df..a976e17db 100644 --- a/cpp-driver/src/encode.hpp +++ b/cpp-driver/src/encode.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ENCODING_HPP_INCLUDED__ -#define __CASS_ENCODING_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ENCODING_HPP +#define DATASTAX_INTERNAL_ENCODING_HPP #include "buffer.hpp" #include "types.hpp" diff --git a/cpp-driver/src/error_response.hpp b/cpp-driver/src/error_response.hpp index c02f439df..b50cb962f 100644 --- a/cpp-driver/src/error_response.hpp +++ b/cpp-driver/src/error_response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ERROR_RESPONSE_HPP_INCLUDED__ -#define __CASS_ERROR_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ERROR_RESPONSE_HPP +#define DATASTAX_INTERNAL_ERROR_RESPONSE_HPP #include "external.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/event_loop.hpp b/cpp-driver/src/event_loop.hpp index 77f85d5c9..e309bf4e1 100644 --- a/cpp-driver/src/event_loop.hpp +++ b/cpp-driver/src/event_loop.hpp @@ -14,13 +14,13 @@ limitations under the License. */ -#ifndef __CASS_THREAD_HPP_INCLUDED__ -#define __CASS_THREAD_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_THREAD_HPP +#define DATASTAX_INTERNAL_THREAD_HPP #include "allocated.hpp" #include "async.hpp" #include "atomic.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "deque.hpp" #include "logger.hpp" #include "macros.hpp" diff --git a/cpp-driver/src/event_response.hpp b/cpp-driver/src/event_response.hpp index 218cb9aa1..93feca198 100644 --- a/cpp-driver/src/event_response.hpp +++ b/cpp-driver/src/event_response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_EVENT_RESPONSE_HPP_INCLUDED__ -#define __CASS_EVENT_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_EVENT_RESPONSE_HPP +#define DATASTAX_INTERNAL_EVENT_RESPONSE_HPP #include "address.hpp" #include "response.hpp" diff --git a/cpp-driver/src/execute_request.hpp b/cpp-driver/src/execute_request.hpp index 7f9be105b..e04c9aa71 100644 --- a/cpp-driver/src/execute_request.hpp +++ b/cpp-driver/src/execute_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_EXECUTE_REQUEST_HPP_INCLUDED__ -#define __CASS_EXECUTE_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_EXECUTE_REQUEST_HPP +#define DATASTAX_INTERNAL_EXECUTE_REQUEST_HPP #include "statement.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/execution_profile.hpp b/cpp-driver/src/execution_profile.hpp index 532c861a2..fb6adf44b 100644 --- a/cpp-driver/src/execution_profile.hpp +++ b/cpp-driver/src/execution_profile.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __CASS_EXECUTION_PROFILE_HPP_INCLUDED__ -#define __CASS_EXECUTION_PROFILE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_EXECUTION_PROFILE_HPP +#define DATASTAX_INTERNAL_EXECUTION_PROFILE_HPP #include "allocated.hpp" #include "blacklist_policy.hpp" @@ -201,4 +201,4 @@ class ExecutionProfile : public Allocated { EXTERNAL_TYPE(datastax::internal::core::ExecutionProfile, CassExecProfile) -#endif // __CASS_EXECUTION_PROFILE_HPP_INCLUDED__ +#endif // DATASTAX_INTERNAL_EXECUTION_PROFILE_HPP diff --git a/cpp-driver/src/external.hpp b/cpp-driver/src/external.hpp index 395cdba9d..39a00a7b3 100644 --- a/cpp-driver/src/external.hpp +++ b/cpp-driver/src/external.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_EXTERNAL_HPP_INCLUDED__ -#define __CASS_EXTERNAL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_EXTERNAL_HPP +#define DATASTAX_INTERNAL_EXTERNAL_HPP // This abstraction allows us to separate internal types from the // external opaque pointers that we expose. diff --git a/cpp-driver/src/fixed_allocator.hpp b/cpp-driver/src/fixed_allocator.hpp index be93ad731..a6edfc051 100644 --- a/cpp-driver/src/fixed_allocator.hpp +++ b/cpp-driver/src/fixed_allocator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_FIXED_ALLOCATOR_HPP_INCLUDED__ -#define __CASS_FIXED_ALLOCATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_FIXED_ALLOCATOR_HPP +#define DATASTAX_INTERNAL_FIXED_ALLOCATOR_HPP #include "aligned_storage.hpp" #include "macros.hpp" diff --git a/cpp-driver/src/future.hpp b/cpp-driver/src/future.hpp index d8a1e32d9..3ffbb4c41 100644 --- a/cpp-driver/src/future.hpp +++ b/cpp-driver/src/future.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_FUTURE_HPP_INCLUDED__ -#define __CASS_FUTURE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_FUTURE_HPP +#define DATASTAX_INTERNAL_FUTURE_HPP #include "atomic.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/get_time.hpp b/cpp-driver/src/get_time.hpp index 0c8ed4098..37bda7781 100644 --- a/cpp-driver/src/get_time.hpp +++ b/cpp-driver/src/get_time.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_GET_TIME_HPP_INCLUDED__ -#define __CASS_GET_TIME_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_GET_TIME_HPP +#define DATASTAX_INTERNAL_GET_TIME_HPP #include diff --git a/cpp-driver/src/hash.hpp b/cpp-driver/src/hash.hpp index f58db20ce..beac62b55 100644 --- a/cpp-driver/src/hash.hpp +++ b/cpp-driver/src/hash.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_HASH_HPP_INCLUDED__ -#define __CASS_HASH_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_HASH_HPP +#define DATASTAX_INTERNAL_HASH_HPP #include #include diff --git a/cpp-driver/src/hash_table.hpp b/cpp-driver/src/hash_table.hpp index 961e25682..5c748f0b7 100644 --- a/cpp-driver/src/hash_table.hpp +++ b/cpp-driver/src/hash_table.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_HASH_INDEX_HPP_INCLUDED__ -#define __CASS_HASH_INDEX_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_HASH_INDEX_HPP +#define DATASTAX_INTERNAL_HASH_INDEX_HPP #include "allocated.hpp" #include "hash.hpp" diff --git a/cpp-driver/src/histogram_wrapper.hpp b/cpp-driver/src/histogram_wrapper.hpp index 25dee9008..3784b54a3 100644 --- a/cpp-driver/src/histogram_wrapper.hpp +++ b/cpp-driver/src/histogram_wrapper.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_HISTOGRAM_WRAPPER_HPP_INCLUDED__ -#define __CASS_HISTOGRAM_WRAPPER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_HISTOGRAM_WRAPPER_HPP +#define DATASTAX_INTERNAL_HISTOGRAM_WRAPPER_HPP #ifdef CASS_INTERNAL_DIAGNOSTICS #include "string.hpp" diff --git a/cpp-driver/src/host.hpp b/cpp-driver/src/host.hpp index 68d93a1d0..25a81f9c6 100644 --- a/cpp-driver/src/host.hpp +++ b/cpp-driver/src/host.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_HOST_HPP_INCLUDED__ -#define __CASS_HOST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_HOST_HPP +#define DATASTAX_INTERNAL_HOST_HPP #include "address.hpp" #include "allocated.hpp" diff --git a/cpp-driver/src/host_targeting_policy.hpp b/cpp-driver/src/host_targeting_policy.hpp index 2fecd4dfd..2ded53487 100644 --- a/cpp-driver/src/host_targeting_policy.hpp +++ b/cpp-driver/src/host_targeting_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_HOST_TARGETING_POLICY_HPP_INCLUDED__ -#define __CASS_HOST_TARGETING_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_HOST_TARGETING_POLICY_HPP +#define DATASTAX_INTERNAL_HOST_TARGETING_POLICY_HPP #include "address.hpp" #include "dense_hash_map.hpp" diff --git a/cpp-driver/src/iterator.hpp b/cpp-driver/src/iterator.hpp index 4e69f3d65..a73e01fd4 100644 --- a/cpp-driver/src/iterator.hpp +++ b/cpp-driver/src/iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ITERATOR_HPP_INCLUDED__ -#define __CASS_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ITERATOR_HPP +#define DATASTAX_INTERNAL_ITERATOR_HPP #include "allocated.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/json.hpp b/cpp-driver/src/json.hpp index 89d1214f1..1e870ce60 100644 --- a/cpp-driver/src/json.hpp +++ b/cpp-driver/src/json.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_JSON_HPP_INCLUDED__ -#define __CASS_JSON_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_JSON_HPP +#define DATASTAX_INTERNAL_JSON_HPP #include "memory.hpp" @@ -89,4 +89,4 @@ class Writer : public datastax::rapidjson::JSON_WRITE_TYPE diff --git a/cpp-driver/src/map.hpp b/cpp-driver/src/map.hpp index 20624d3aa..9079bfee6 100644 --- a/cpp-driver/src/map.hpp +++ b/cpp-driver/src/map.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_MAP_HPP_INCLUDED__ -#define __DSE_MAP_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MAP_HPP +#define DATASTAX_INTERNAL_MAP_HPP #include "allocated.hpp" #include "allocator.hpp" diff --git a/cpp-driver/src/map_iterator.hpp b/cpp-driver/src/map_iterator.hpp index 67210f4ea..4fc16373c 100644 --- a/cpp-driver/src/map_iterator.hpp +++ b/cpp-driver/src/map_iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_MAP_ITERATOR_HPP_INCLUDED__ -#define __CASS_MAP_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MAP_ITERATOR_HPP +#define DATASTAX_INTERNAL_MAP_ITERATOR_HPP #include "cassandra.h" #include "iterator.hpp" diff --git a/cpp-driver/src/md5.hpp b/cpp-driver/src/md5.hpp index 47642d726..2e35d813e 100644 --- a/cpp-driver/src/md5.hpp +++ b/cpp-driver/src/md5.hpp @@ -17,8 +17,8 @@ // Based on public domain source found here: // http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 -#ifndef __CASS_MD5_HPP_INCLUDED__ -#define __CASS_MD5_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MD5_HPP +#define DATASTAX_INTERNAL_MD5_HPP #include "macros.hpp" diff --git a/cpp-driver/src/memory.hpp b/cpp-driver/src/memory.hpp index 588235474..45c7f4911 100644 --- a/cpp-driver/src/memory.hpp +++ b/cpp-driver/src/memory.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_MEMORY_HPP_INCLUDED__ -#define __DSE_MEMORY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MEMORY_HPP +#define DATASTAX_INTERNAL_MEMORY_HPP #include "cassandra.h" #include diff --git a/cpp-driver/src/metadata.hpp b/cpp-driver/src/metadata.hpp index 5d093fbbf..8d41cef7a 100644 --- a/cpp-driver/src/metadata.hpp +++ b/cpp-driver/src/metadata.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SCHEMA_METADATA_HPP_INCLUDED__ -#define __CASS_SCHEMA_METADATA_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SCHEMA_METADATA_HPP +#define DATASTAX_INTERNAL_SCHEMA_METADATA_HPP #include "allocated.hpp" #include "copy_on_write_ptr.hpp" diff --git a/cpp-driver/src/metrics.hpp b/cpp-driver/src/metrics.hpp index 68a6bd9f7..576d37b36 100644 --- a/cpp-driver/src/metrics.hpp +++ b/cpp-driver/src/metrics.hpp @@ -17,8 +17,8 @@ // Based on implemenations of metrics (especially Meter) from Java library // com.codehale.Metrics (https://github.com/dropwizard/metrics) -#ifndef __CASS_METRICS_HPP_INCLUDED__ -#define __CASS_METRICS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_METRICS_HPP +#define DATASTAX_INTERNAL_METRICS_HPP #include "allocated.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/micro_timer.hpp b/cpp-driver/src/micro_timer.hpp index 362c32167..3fbf22097 100644 --- a/cpp-driver/src/micro_timer.hpp +++ b/cpp-driver/src/micro_timer.hpp @@ -14,12 +14,12 @@ limitations under the License. */ -#ifndef __CASS_MICRO_TIMER_HPP_INCLUDED__ -#define __CASS_MICRO_TIMER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MICRO_TIMER_HPP +#define DATASTAX_INTERNAL_MICRO_TIMER_HPP #include "allocated.hpp" #include "callback.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "macros.hpp" #ifndef HAVE_TIMERFD diff --git a/cpp-driver/src/monitor_reporting.hpp b/cpp-driver/src/monitor_reporting.hpp index e2a16a297..c49a1f836 100644 --- a/cpp-driver/src/monitor_reporting.hpp +++ b/cpp-driver/src/monitor_reporting.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_MONITOR_REPORTING_HPP_INCLUDED__ -#define __CASS_MONITOR_REPORTING_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MONITOR_REPORTING_HPP +#define DATASTAX_INTERNAL_MONITOR_REPORTING_HPP #include "connection.hpp" #include "host.hpp" @@ -55,4 +55,4 @@ MonitorReporting* create_monitor_reporting(const String& client_id, } } } // namespace datastax::internal::core -#endif // __CASS_MONITOR_REPORTING_HPP_INCLUDED__ +#endif // DATASTAX_INTERNAL_MONITOR_REPORTING_HPP diff --git a/cpp-driver/src/mpmc_queue.hpp b/cpp-driver/src/mpmc_queue.hpp index 8a31673fd..61e320b51 100644 --- a/cpp-driver/src/mpmc_queue.hpp +++ b/cpp-driver/src/mpmc_queue.hpp @@ -19,12 +19,12 @@ http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue */ -#ifndef __CASS_MPMC_QUEUE_INCLUDED__ -#define __CASS_MPMC_QUEUE_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MPMC_QUEUE +#define DATASTAX_INTERNAL_MPMC_QUEUE #include "allocated.hpp" #include "atomic.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "macros.hpp" #include "scoped_ptr.hpp" #include "utils.hpp" diff --git a/cpp-driver/src/murmur3.hpp b/cpp-driver/src/murmur3.hpp index 8e016df25..3baa4dd40 100644 --- a/cpp-driver/src/murmur3.hpp +++ b/cpp-driver/src/murmur3.hpp @@ -19,8 +19,8 @@ * domain. The author hereby disclaims copyright to this source code. */ -#ifndef __CASS_MURMUR3_HPP_INCLUDED__ -#define __CASS_MURMUR3_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_MURMUR3_HPP +#define DATASTAX_INTERNAL_MURMUR3_HPP #include "macros.hpp" diff --git a/cpp-driver/src/name_resolver.hpp b/cpp-driver/src/name_resolver.hpp index 2329338e6..d5e13f9ea 100644 --- a/cpp-driver/src/name_resolver.hpp +++ b/cpp-driver/src/name_resolver.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_NAME_RESOLVER_HPP_INCLUDED__ -#define __CASS_NAME_RESOLVER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_NAME_RESOLVER_HPP +#define DATASTAX_INTERNAL_NAME_RESOLVER_HPP #include "address.hpp" #include "callback.hpp" diff --git a/cpp-driver/src/options_request.hpp b/cpp-driver/src/options_request.hpp index ecd4a0497..8479caecf 100644 --- a/cpp-driver/src/options_request.hpp +++ b/cpp-driver/src/options_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_OPTIONS_REQUEST_HPP_INCLUDED__ -#define __CASS_OPTIONS_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_OPTIONS_REQUEST_HPP +#define DATASTAX_INTERNAL_OPTIONS_REQUEST_HPP #include "request.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/pooled_connection.hpp b/cpp-driver/src/pooled_connection.hpp index c99f60d83..cbda10888 100644 --- a/cpp-driver/src/pooled_connection.hpp +++ b/cpp-driver/src/pooled_connection.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_POOLED_CONNECTION_HPP_INCLUDED__ -#define __CASS_POOLED_CONNECTION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_POOLED_CONNECTION_HPP +#define DATASTAX_INTERNAL_POOLED_CONNECTION_HPP #include "atomic.hpp" #include "connection.hpp" diff --git a/cpp-driver/src/prepare_all_handler.hpp b/cpp-driver/src/prepare_all_handler.hpp index 7fb07339a..84a4369a8 100644 --- a/cpp-driver/src/prepare_all_handler.hpp +++ b/cpp-driver/src/prepare_all_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_PREPARE_ALL_HANDLER_HPP_INCLUDED__ -#define __CASS_PREPARE_ALL_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_PREPARE_ALL_HANDLER_HPP +#define DATASTAX_INTERNAL_PREPARE_ALL_HANDLER_HPP #include "address.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/prepare_host_handler.hpp b/cpp-driver/src/prepare_host_handler.hpp index f9c585597..db19766ef 100644 --- a/cpp-driver/src/prepare_host_handler.hpp +++ b/cpp-driver/src/prepare_host_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_PREPARE_HOST_HANDLER_HPP_INCLUDED__ -#define __CASS_PREPARE_HOST_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_PREPARE_HOST_HANDLER_HPP +#define DATASTAX_INTERNAL_PREPARE_HOST_HANDLER_HPP #include "callback.hpp" #include "connector.hpp" diff --git a/cpp-driver/src/prepare_request.hpp b/cpp-driver/src/prepare_request.hpp index 0d7be9f42..d97d6e999 100644 --- a/cpp-driver/src/prepare_request.hpp +++ b/cpp-driver/src/prepare_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_PREPARE_REQUEST_HPP_INCLUDED__ -#define __CASS_PREPARE_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_PREPARE_REQUEST_HPP +#define DATASTAX_INTERNAL_PREPARE_REQUEST_HPP #include "constants.hpp" #include "request.hpp" diff --git a/cpp-driver/src/prepared.hpp b/cpp-driver/src/prepared.hpp index 2fef42749..9440f178b 100644 --- a/cpp-driver/src/prepared.hpp +++ b/cpp-driver/src/prepared.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_PREPARED_HPP_INCLUDED__ -#define __CASS_PREPARED_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_PREPARED_HPP +#define DATASTAX_INTERNAL_PREPARED_HPP #include "buffer.hpp" #include "external.hpp" diff --git a/cpp-driver/src/protocol.hpp b/cpp-driver/src/protocol.hpp index 2a2bee76f..8ec815bc7 100644 --- a/cpp-driver/src/protocol.hpp +++ b/cpp-driver/src/protocol.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_PROTOCOL_HPP_INCLUDED__ -#define __CASS_PROTOCOL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_PROTOCOL_HPP +#define DATASTAX_INTERNAL_PROTOCOL_HPP #include "cassandra.h" #include "constants.hpp" diff --git a/cpp-driver/src/query_request.hpp b/cpp-driver/src/query_request.hpp index 69d0b6037..4c79b7dcc 100644 --- a/cpp-driver/src/query_request.hpp +++ b/cpp-driver/src/query_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_QUERY_REQUEST_HPP_INCLUDED__ -#define __CASS_QUERY_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_QUERY_REQUEST_HPP +#define DATASTAX_INTERNAL_QUERY_REQUEST_HPP #include "constants.hpp" #include "hash_table.hpp" diff --git a/cpp-driver/src/random.cpp b/cpp-driver/src/random.cpp index a3fc97ebb..f3e5115d7 100644 --- a/cpp-driver/src/random.cpp +++ b/cpp-driver/src/random.cpp @@ -16,7 +16,7 @@ #include "random.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "cassandra.h" #include "logger.hpp" #include "scoped_lock.hpp" diff --git a/cpp-driver/src/random.hpp b/cpp-driver/src/random.hpp index ffa1c6d82..7d0850ff7 100644 --- a/cpp-driver/src/random.hpp +++ b/cpp-driver/src/random.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RANDOM_HPP_INCLUDED__ -#define __CASS_RANDOM_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RANDOM_HPP +#define DATASTAX_INTERNAL_RANDOM_HPP #include "allocated.hpp" #include "third_party/mt19937_64/mt19937_64.hpp" diff --git a/cpp-driver/src/ready_response.hpp b/cpp-driver/src/ready_response.hpp index e4642cb2e..abaf48c0b 100644 --- a/cpp-driver/src/ready_response.hpp +++ b/cpp-driver/src/ready_response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_READY_RESPONSE_HPP_INCLUDED__ -#define __CASS_READY_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_READY_RESPONSE_HPP +#define DATASTAX_INTERNAL_READY_RESPONSE_HPP #include "response.hpp" diff --git a/cpp-driver/src/ref_counted.hpp b/cpp-driver/src/ref_counted.hpp index 7f6f609e5..4abdfd6ab 100644 --- a/cpp-driver/src/ref_counted.hpp +++ b/cpp-driver/src/ref_counted.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REF_COUNTED_HPP_INCLUDED__ -#define __CASS_REF_COUNTED_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REF_COUNTED_HPP +#define DATASTAX_INTERNAL_REF_COUNTED_HPP #include "allocated.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/register_request.hpp b/cpp-driver/src/register_request.hpp index 7d1c47ff1..320cfa224 100644 --- a/cpp-driver/src/register_request.hpp +++ b/cpp-driver/src/register_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REGISTER_REQUEST_HPP_INCLUDED__ -#define __CASS_REGISTER_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REGISTER_REQUEST_HPP +#define DATASTAX_INTERNAL_REGISTER_REQUEST_HPP #include "request.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/request.hpp b/cpp-driver/src/request.hpp index f48fe3f0b..838d3b765 100644 --- a/cpp-driver/src/request.hpp +++ b/cpp-driver/src/request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REQUEST_HPP_INCLUDED__ -#define __CASS_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REQUEST_HPP +#define DATASTAX_INTERNAL_REQUEST_HPP #include "buffer.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/request_callback.hpp b/cpp-driver/src/request_callback.hpp index f085e0d94..5a9a9304f 100644 --- a/cpp-driver/src/request_callback.hpp +++ b/cpp-driver/src/request_callback.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REQUEST_CALLBACK_HPP_INCLUDED__ -#define __CASS_REQUEST_CALLBACK_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REQUEST_CALLBACK_HPP +#define DATASTAX_INTERNAL_REQUEST_CALLBACK_HPP #include "buffer.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/request_handler.hpp b/cpp-driver/src/request_handler.hpp index 69af18453..b4ce701a9 100644 --- a/cpp-driver/src/request_handler.hpp +++ b/cpp-driver/src/request_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REQUEST_HANDLER_HPP_INCLUDED__ -#define __CASS_REQUEST_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REQUEST_HANDLER_HPP +#define DATASTAX_INTERNAL_REQUEST_HANDLER_HPP #include "constants.hpp" #include "error_response.hpp" diff --git a/cpp-driver/src/request_processor.hpp b/cpp-driver/src/request_processor.hpp index 034e1af6d..95fddea64 100644 --- a/cpp-driver/src/request_processor.hpp +++ b/cpp-driver/src/request_processor.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REQUEST_PROCESSOR_HPP_INCLUDED__ -#define __CASS_REQUEST_PROCESSOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REQUEST_PROCESSOR_HPP +#define DATASTAX_INTERNAL_REQUEST_PROCESSOR_HPP #include "atomic.hpp" #include "config.hpp" @@ -375,4 +375,4 @@ class RequestProcessor : public RefCounted } } } // namespace datastax::internal::core -#endif // __CASS_REQUEST_PROCESSOR_HPP_INCLUDED__ +#endif // DATASTAX_INTERNAL_REQUEST_PROCESSOR_HPP diff --git a/cpp-driver/src/request_processor_initializer.hpp b/cpp-driver/src/request_processor_initializer.hpp index 85cb43706..1a2d46070 100644 --- a/cpp-driver/src/request_processor_initializer.hpp +++ b/cpp-driver/src/request_processor_initializer.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_REQUEST_PROCESSOR_INITIALIZER_HPP_INCLUDED__ -#define __CASS_REQUEST_PROCESSOR_INITIALIZER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_REQUEST_PROCESSOR_INITIALIZER_HPP +#define DATASTAX_INTERNAL_REQUEST_PROCESSOR_INITIALIZER_HPP #include "atomic.hpp" #include "callback.hpp" diff --git a/cpp-driver/src/resolver.hpp b/cpp-driver/src/resolver.hpp index 0fc359443..a134c53fd 100644 --- a/cpp-driver/src/resolver.hpp +++ b/cpp-driver/src/resolver.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RESOLVER_HPP_INCLUDED__ -#define __CASS_RESOLVER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RESOLVER_HPP +#define DATASTAX_INTERNAL_RESOLVER_HPP #include "address.hpp" #include "callback.hpp" diff --git a/cpp-driver/src/response.hpp b/cpp-driver/src/response.hpp index 282c7428b..9f52cf996 100644 --- a/cpp-driver/src/response.hpp +++ b/cpp-driver/src/response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RESPONSE_HPP_INCLUDED__ -#define __CASS_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RESPONSE_HPP +#define DATASTAX_INTERNAL_RESPONSE_HPP #include "allocated.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/result_iterator.hpp b/cpp-driver/src/result_iterator.hpp index 11880c0ba..88905f5cd 100644 --- a/cpp-driver/src/result_iterator.hpp +++ b/cpp-driver/src/result_iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RESULT_ITERATOR_HPP_INCLUDED__ -#define __CASS_RESULT_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RESULT_ITERATOR_HPP +#define DATASTAX_INTERNAL_RESULT_ITERATOR_HPP #include "iterator.hpp" #include "result_response.hpp" diff --git a/cpp-driver/src/result_metadata.hpp b/cpp-driver/src/result_metadata.hpp index d0b4400d9..bf40b03b8 100644 --- a/cpp-driver/src/result_metadata.hpp +++ b/cpp-driver/src/result_metadata.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RESULT_METADATA_HPP_INCLUDED__ -#define __CASS_RESULT_METADATA_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RESULT_METADATA_HPP +#define DATASTAX_INTERNAL_RESULT_METADATA_HPP #include "cassandra.h" #include "data_type.hpp" diff --git a/cpp-driver/src/result_response.hpp b/cpp-driver/src/result_response.hpp index c1e5098a2..ff6550df1 100644 --- a/cpp-driver/src/result_response.hpp +++ b/cpp-driver/src/result_response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RESULT_RESPONSE_HPP_INCLUDED__ -#define __CASS_RESULT_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RESULT_RESPONSE_HPP +#define DATASTAX_INTERNAL_RESULT_RESPONSE_HPP #include "constants.hpp" #include "data_type.hpp" diff --git a/cpp-driver/src/retry_policy.hpp b/cpp-driver/src/retry_policy.hpp index 925f973c3..0a7f1bffc 100644 --- a/cpp-driver/src/retry_policy.hpp +++ b/cpp-driver/src/retry_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_RETRY_POLICY_HPP_INCLUDED__ -#define __CASS_RETRY_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RETRY_POLICY_HPP +#define DATASTAX_INTERNAL_RETRY_POLICY_HPP #include "cassandra.h" #include "error_response.hpp" diff --git a/cpp-driver/src/ring_buffer.hpp b/cpp-driver/src/ring_buffer.hpp index c68ac1e56..5f8d8a22e 100644 --- a/cpp-driver/src/ring_buffer.hpp +++ b/cpp-driver/src/ring_buffer.hpp @@ -39,8 +39,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -#ifndef __CASS_RING_BUFFER_HPP_INCLUDED__ -#define __CASS_RING_BUFFER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RING_BUFFER_HPP +#define DATASTAX_INTERNAL_RING_BUFFER_HPP #include "allocated.hpp" #include "small_vector.hpp" diff --git a/cpp-driver/src/round_robin_policy.hpp b/cpp-driver/src/round_robin_policy.hpp index 6eed4c966..031b23e75 100644 --- a/cpp-driver/src/round_robin_policy.hpp +++ b/cpp-driver/src/round_robin_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ROUND_ROBIN_POLICY_HPP_INCLUDED__ -#define __CASS_ROUND_ROBIN_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ROUND_ROBIN_POLICY_HPP +#define DATASTAX_INTERNAL_ROUND_ROBIN_POLICY_HPP #include "cassandra.h" #include "copy_on_write_ptr.hpp" diff --git a/cpp-driver/src/row.hpp b/cpp-driver/src/row.hpp index ceb78859d..e7b614284 100644 --- a/cpp-driver/src/row.hpp +++ b/cpp-driver/src/row.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ROW_HPP_INCLUDED__ -#define __CASS_ROW_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ROW_HPP +#define DATASTAX_INTERNAL_ROW_HPP #include "decoder.hpp" #include "external.hpp" diff --git a/cpp-driver/src/row_iterator.hpp b/cpp-driver/src/row_iterator.hpp index d566ce393..66d132905 100644 --- a/cpp-driver/src/row_iterator.hpp +++ b/cpp-driver/src/row_iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_ROW_ITERATOR_HPP_INCLUDED__ -#define __CASS_ROW_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_ROW_ITERATOR_HPP +#define DATASTAX_INTERNAL_ROW_ITERATOR_HPP #include "iterator.hpp" #include "row.hpp" diff --git a/cpp-driver/src/schema_agreement_handler.hpp b/cpp-driver/src/schema_agreement_handler.hpp index 19bce432a..b6edb6ea4 100644 --- a/cpp-driver/src/schema_agreement_handler.hpp +++ b/cpp-driver/src/schema_agreement_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SCHEMA_CHANGE_HANDLER_HPP_INCLUDED__ -#define __CASS_SCHEMA_CHANGE_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SCHEMA_CHANGE_HANDLER_HPP +#define DATASTAX_INTERNAL_SCHEMA_CHANGE_HANDLER_HPP #include "wait_for_handler.hpp" diff --git a/cpp-driver/src/scoped_lock.hpp b/cpp-driver/src/scoped_lock.hpp index dd7130968..1f6504753 100644 --- a/cpp-driver/src/scoped_lock.hpp +++ b/cpp-driver/src/scoped_lock.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SCOPED_LOCK_HPP_INCLUDED__ -#define __CASS_SCOPED_LOCK_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SCOPED_LOCK_HPP +#define DATASTAX_INTERNAL_SCOPED_LOCK_HPP #include "macros.hpp" diff --git a/cpp-driver/src/scoped_ptr.hpp b/cpp-driver/src/scoped_ptr.hpp index 9bef65cd8..05c33c3ff 100644 --- a/cpp-driver/src/scoped_ptr.hpp +++ b/cpp-driver/src/scoped_ptr.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SCOPED_PTR_HPP_INCLUDED__ -#define __CASS_SCOPED_PTR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SCOPED_PTR_HPP +#define DATASTAX_INTERNAL_SCOPED_PTR_HPP #include "macros.hpp" #include "utils.hpp" diff --git a/cpp-driver/src/serialization.hpp b/cpp-driver/src/serialization.hpp index df766874a..3a9c52458 100644 --- a/cpp-driver/src/serialization.hpp +++ b/cpp-driver/src/serialization.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SERIALIZATION_HPP_INCLUDED__ -#define __CASS_SERIALIZATION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SERIALIZATION_HPP +#define DATASTAX_INTERNAL_SERIALIZATION_HPP #include "address.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/session.hpp b/cpp-driver/src/session.hpp index 91ffb2553..74fa09548 100644 --- a/cpp-driver/src/session.hpp +++ b/cpp-driver/src/session.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SESSION_HPP_INCLUDED__ -#define __CASS_SESSION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SESSION_HPP +#define DATASTAX_INTERNAL_SESSION_HPP #include "allocated.hpp" #include "metrics.hpp" diff --git a/cpp-driver/src/session_base.hpp b/cpp-driver/src/session_base.hpp index a99b26ba0..c413f2ec4 100644 --- a/cpp-driver/src/session_base.hpp +++ b/cpp-driver/src/session_base.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SESSION_BASE_HPP_INCLUDED__ -#define __CASS_SESSION_BASE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SESSION_BASE_HPP +#define DATASTAX_INTERNAL_SESSION_BASE_HPP #include "cluster_connector.hpp" #include "prepared.hpp" diff --git a/cpp-driver/src/set.hpp b/cpp-driver/src/set.hpp index 091b12eac..d1b06426e 100644 --- a/cpp-driver/src/set.hpp +++ b/cpp-driver/src/set.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_SET_HPP_INCLUDED__ -#define __DSE_SET_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SET_HPP +#define DATASTAX_INTERNAL_SET_HPP #include "allocated.hpp" #include "allocator.hpp" diff --git a/cpp-driver/src/small_dense_hash_map.hpp b/cpp-driver/src/small_dense_hash_map.hpp index 5239cdc98..816eee27b 100644 --- a/cpp-driver/src/small_dense_hash_map.hpp +++ b/cpp-driver/src/small_dense_hash_map.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SMALL_DENSE_HASH_MAP_HPP_INCLUDED__ -#define __CASS_SMALL_DENSE_HASH_MAP_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SMALL_DENSE_HASH_MAP_HPP +#define DATASTAX_INTERNAL_SMALL_DENSE_HASH_MAP_HPP #include "fixed_allocator.hpp" #include "macros.hpp" diff --git a/cpp-driver/src/small_vector.hpp b/cpp-driver/src/small_vector.hpp index f24fd3bf7..41debf8b6 100644 --- a/cpp-driver/src/small_vector.hpp +++ b/cpp-driver/src/small_vector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SMALL_VECTOR_HPP_INCLUDED__ -#define __CASS_SMALL_VECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SMALL_VECTOR_HPP +#define DATASTAX_INTERNAL_SMALL_VECTOR_HPP #include "fixed_allocator.hpp" diff --git a/cpp-driver/src/socket.hpp b/cpp-driver/src/socket.hpp index 91010b31c..36749ca8e 100644 --- a/cpp-driver/src/socket.hpp +++ b/cpp-driver/src/socket.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SOCKET_HPP_INCLUDED__ -#define __CASS_SOCKET_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SOCKET_HPP +#define DATASTAX_INTERNAL_SOCKET_HPP #include "allocated.hpp" #include "buffer.hpp" diff --git a/cpp-driver/src/socket_connector.hpp b/cpp-driver/src/socket_connector.hpp index 662974e8a..d5ab07866 100644 --- a/cpp-driver/src/socket_connector.hpp +++ b/cpp-driver/src/socket_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SOCKET_CONNECTOR_HPP_INCLUDED__ -#define __CASS_SOCKET_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SOCKET_CONNECTOR_HPP +#define DATASTAX_INTERNAL_SOCKET_CONNECTOR_HPP #include "callback.hpp" #include "name_resolver.hpp" diff --git a/cpp-driver/src/speculative_execution.hpp b/cpp-driver/src/speculative_execution.hpp index ccec31675..52855adf9 100644 --- a/cpp-driver/src/speculative_execution.hpp +++ b/cpp-driver/src/speculative_execution.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SPECULATIVE_EXECUTION_HPP_INCLUDED__ -#define __CASS_SPECULATIVE_EXECUTION_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SPECULATIVE_EXECUTION_HPP +#define DATASTAX_INTERNAL_SPECULATIVE_EXECUTION_HPP #include "allocated.hpp" #include "host.hpp" diff --git a/cpp-driver/src/spin_lock.hpp b/cpp-driver/src/spin_lock.hpp index a07258820..8caf3c2db 100644 --- a/cpp-driver/src/spin_lock.hpp +++ b/cpp-driver/src/spin_lock.hpp @@ -17,8 +17,8 @@ #include "atomic.hpp" #include "macros.hpp" -#ifndef __CASS_SPINLOCK_HPP_INCLUDED__ -#define __CASS_SPINLOCK_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SPINLOCK_HPP +#define DATASTAX_INTERNAL_SPINLOCK_HPP namespace datastax { namespace internal { namespace core { diff --git a/cpp-driver/src/spsc_queue.hpp b/cpp-driver/src/spsc_queue.hpp index 865f20b53..a0fba4a02 100644 --- a/cpp-driver/src/spsc_queue.hpp +++ b/cpp-driver/src/spsc_queue.hpp @@ -23,13 +23,13 @@ http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue */ -#ifndef __CASS_SPSC_QUEUE_HPP_INCLUDED__ -#define __CASS_SPSC_QUEUE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SPSC_QUEUE_HPP +#define DATASTAX_INTERNAL_SPSC_QUEUE_HPP #include #include "atomic.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "macros.hpp" #include "scoped_ptr.hpp" #include "utils.hpp" diff --git a/cpp-driver/src/ssl.hpp b/cpp-driver/src/ssl.hpp index 158a45f87..e1855e1ba 100644 --- a/cpp-driver/src/ssl.hpp +++ b/cpp-driver/src/ssl.hpp @@ -14,13 +14,13 @@ limitations under the License. */ -#ifndef __CASS_SSL_HPP_INCLUDED__ -#define __CASS_SSL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SSL_HPP +#define DATASTAX_INTERNAL_SSL_HPP #include "allocated.hpp" #include "address.hpp" #include "cassandra.h" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "external.hpp" #include "ref_counted.hpp" #include "ring_buffer.hpp" diff --git a/cpp-driver/src/ssl/ring_buffer_bio.hpp b/cpp-driver/src/ssl/ring_buffer_bio.hpp index 6b63ecddf..03cdf23a1 100644 --- a/cpp-driver/src/ssl/ring_buffer_bio.hpp +++ b/cpp-driver/src/ssl/ring_buffer_bio.hpp @@ -39,8 +39,8 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -#ifndef __CASS_RING_BUFFER_BIO_HPP_INCLUDED__ -#define __CASS_RING_BUFFER_BIO_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_RING_BUFFER_BIO_HPP +#define DATASTAX_INTERNAL_RING_BUFFER_BIO_HPP #include "ring_buffer.hpp" diff --git a/cpp-driver/src/ssl/ssl_no_impl.hpp b/cpp-driver/src/ssl/ssl_no_impl.hpp index f6213473c..253cc1c7c 100644 --- a/cpp-driver/src/ssl/ssl_no_impl.hpp +++ b/cpp-driver/src/ssl/ssl_no_impl.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SSL_NO_IMPL_HPP_INCLUDED__ -#define __CASS_SSL_NO_IMPL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SSL_NO_IMPL_HPP +#define DATASTAX_INTERNAL_SSL_NO_IMPL_HPP namespace datastax { namespace internal { namespace core { diff --git a/cpp-driver/src/ssl/ssl_openssl_impl.hpp b/cpp-driver/src/ssl/ssl_openssl_impl.hpp index a037dc65c..5764f3343 100644 --- a/cpp-driver/src/ssl/ssl_openssl_impl.hpp +++ b/cpp-driver/src/ssl/ssl_openssl_impl.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SSL_OPENSSL_IMPL_HPP_INCLUDED__ -#define __CASS_SSL_OPENSSL_IMPL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SSL_OPENSSL_IMPL_HPP +#define DATASTAX_INTERNAL_SSL_OPENSSL_IMPL_HPP #include "ssl/ring_buffer_bio.hpp" diff --git a/cpp-driver/src/stack.hpp b/cpp-driver/src/stack.hpp index d7ae87745..3de6f7e9d 100644 --- a/cpp-driver/src/stack.hpp +++ b/cpp-driver/src/stack.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_STACK_HPP_INCLUDED__ -#define __DSE_STACK_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STACK_HPP +#define DATASTAX_INTERNAL_STACK_HPP #include "deque.hpp" diff --git a/cpp-driver/src/startup_request.hpp b/cpp-driver/src/startup_request.hpp index d24c6e80d..b36349063 100644 --- a/cpp-driver/src/startup_request.hpp +++ b/cpp-driver/src/startup_request.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_STARTUP_REQUEST_HPP_INCLUDED__ -#define __CASS_STARTUP_REQUEST_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STARTUP_REQUEST_HPP +#define DATASTAX_INTERNAL_STARTUP_REQUEST_HPP #include "request.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/statement.hpp b/cpp-driver/src/statement.hpp index 5eecbac84..7123bca29 100644 --- a/cpp-driver/src/statement.hpp +++ b/cpp-driver/src/statement.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_STATEMENT_HPP_INCLUDED__ -#define __CASS_STATEMENT_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STATEMENT_HPP +#define DATASTAX_INTERNAL_STATEMENT_HPP #include "abstract_data.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/stream_manager.hpp b/cpp-driver/src/stream_manager.hpp index a45c0c44f..aefbe9976 100644 --- a/cpp-driver/src/stream_manager.hpp +++ b/cpp-driver/src/stream_manager.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_STREAM_MANAGER_HPP_INCLUDED__ -#define __CASS_STREAM_MANAGER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STREAM_MANAGER_HPP +#define DATASTAX_INTERNAL_STREAM_MANAGER_HPP #include "constants.hpp" #include "dense_hash_map.hpp" diff --git a/cpp-driver/src/string.hpp b/cpp-driver/src/string.hpp index 6b45141a4..5b3c920a0 100644 --- a/cpp-driver/src/string.hpp +++ b/cpp-driver/src/string.hpp @@ -5,11 +5,11 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_STRING_HPP_INCLUDED__ -#define __DSE_STRING_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STRING_HPP +#define DATASTAX_INTERNAL_STRING_HPP #include "allocator.hpp" -#include "cassconfig.hpp" +#include "driver_config.hpp" #include "hash.hpp" #include diff --git a/cpp-driver/src/string_ref.hpp b/cpp-driver/src/string_ref.hpp index ecaa7a975..c8583d47c 100644 --- a/cpp-driver/src/string_ref.hpp +++ b/cpp-driver/src/string_ref.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_STRING_REF_HPP_INCLUDED__ -#define __CASS_STRING_REF_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_STRING_REF_HPP +#define DATASTAX_INTERNAL_STRING_REF_HPP #include "hash.hpp" #include "macros.hpp" diff --git a/cpp-driver/src/supported_response.hpp b/cpp-driver/src/supported_response.hpp index 8bc475b9d..bf8df13a4 100644 --- a/cpp-driver/src/supported_response.hpp +++ b/cpp-driver/src/supported_response.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_SUPPORTED_RESPONSE_HPP_INCLUDED__ -#define __CASS_SUPPORTED_RESPONSE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_SUPPORTED_RESPONSE_HPP +#define DATASTAX_INTERNAL_SUPPORTED_RESPONSE_HPP #include "response.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/tcp_connector.hpp b/cpp-driver/src/tcp_connector.hpp index 4bc2dc7a4..201e3be76 100644 --- a/cpp-driver/src/tcp_connector.hpp +++ b/cpp-driver/src/tcp_connector.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_CONNECTOR_HPP_INCLUDED__ -#define __CASS_CONNECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_CONNECTOR_HPP +#define DATASTAX_INTERNAL_CONNECTOR_HPP #include diff --git a/cpp-driver/src/testing.hpp b/cpp-driver/src/testing.hpp index bfc4c53fe..f35058c71 100644 --- a/cpp-driver/src/testing.hpp +++ b/cpp-driver/src/testing.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TESTING_HPP_INCLUDED__ -#define __CASS_TESTING_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TESTING_HPP +#define DATASTAX_INTERNAL_TESTING_HPP #include "cassandra.h" #include "string.hpp" diff --git a/cpp-driver/src/timer.hpp b/cpp-driver/src/timer.hpp index b9ff0aa6d..e889db2ef 100644 --- a/cpp-driver/src/timer.hpp +++ b/cpp-driver/src/timer.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TIMER_HPP_INCLUDED__ -#define __CASS_TIMER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TIMER_HPP +#define DATASTAX_INTERNAL_TIMER_HPP #include "allocated.hpp" #include "callback.hpp" diff --git a/cpp-driver/src/timestamp_generator.hpp b/cpp-driver/src/timestamp_generator.hpp index 102438b5c..c0b8a3f5f 100644 --- a/cpp-driver/src/timestamp_generator.hpp +++ b/cpp-driver/src/timestamp_generator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TIMESTAMP_GENERATOR_HPP_INCLUDED__ -#define __CASS_TIMESTAMP_GENERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TIMESTAMP_GENERATOR_HPP +#define DATASTAX_INTERNAL_TIMESTAMP_GENERATOR_HPP #include "atomic.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/token_aware_policy.hpp b/cpp-driver/src/token_aware_policy.hpp index 8aabce16b..bbd2a7f96 100644 --- a/cpp-driver/src/token_aware_policy.hpp +++ b/cpp-driver/src/token_aware_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TOKEN_AWARE_POLICY_HPP_INCLUDED__ -#define __CASS_TOKEN_AWARE_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TOKEN_AWARE_POLICY_HPP +#define DATASTAX_INTERNAL_TOKEN_AWARE_POLICY_HPP #include "token_map.hpp" #include "load_balancing.hpp" diff --git a/cpp-driver/src/token_map.hpp b/cpp-driver/src/token_map.hpp index e19097140..27823cc6d 100644 --- a/cpp-driver/src/token_map.hpp +++ b/cpp-driver/src/token_map.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TOKEN_MAP_HPP_INCLUDED__ -#define __CASS_TOKEN_MAP_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TOKEN_MAP_HPP +#define DATASTAX_INTERNAL_TOKEN_MAP_HPP #include "host.hpp" #include "ref_counted.hpp" diff --git a/cpp-driver/src/token_map_impl.hpp b/cpp-driver/src/token_map_impl.hpp index b4cd08f30..8a37f3fbc 100644 --- a/cpp-driver/src/token_map_impl.hpp +++ b/cpp-driver/src/token_map_impl.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TOKEN_MAP_IMPL_HPP_INCLUDED__ -#define __CASS_TOKEN_MAP_IMPL_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TOKEN_MAP_IMPL_HPP +#define DATASTAX_INTERNAL_TOKEN_MAP_IMPL_HPP #include "collection_iterator.hpp" #include "constants.hpp" diff --git a/cpp-driver/src/tracing_data_handler.hpp b/cpp-driver/src/tracing_data_handler.hpp index d9f604fe1..979670238 100644 --- a/cpp-driver/src/tracing_data_handler.hpp +++ b/cpp-driver/src/tracing_data_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TRACING_DATA_HANDLER_HPP_INCLUDED__ -#define __CASS_TRACING_DATA_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TRACING_DATA_HANDLER_HPP +#define DATASTAX_INTERNAL_TRACING_DATA_HANDLER_HPP #include "wait_for_handler.hpp" diff --git a/cpp-driver/src/tuple.hpp b/cpp-driver/src/tuple.hpp index af527223a..75a7103d0 100644 --- a/cpp-driver/src/tuple.hpp +++ b/cpp-driver/src/tuple.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TUPLE_HPP_INCLUDED__ -#define __CASS_TUPLE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TUPLE_HPP +#define DATASTAX_INTERNAL_TUPLE_HPP #include "allocated.hpp" #include "buffer.hpp" diff --git a/cpp-driver/src/types.hpp b/cpp-driver/src/types.hpp index dc8d2d648..296536cb6 100644 --- a/cpp-driver/src/types.hpp +++ b/cpp-driver/src/types.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_TYPES_HPP_INCLUDED__ -#define __CASS_TYPES_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_TYPES_HPP +#define DATASTAX_INTERNAL_TYPES_HPP #include "cassandra.h" #include "string_ref.hpp" diff --git a/cpp-driver/src/user_type_field_iterator.hpp b/cpp-driver/src/user_type_field_iterator.hpp index f7b333eac..8e48b5fbc 100644 --- a/cpp-driver/src/user_type_field_iterator.hpp +++ b/cpp-driver/src/user_type_field_iterator.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_USER_TYPE_ITERATOR_HPP_INCLUDED__ -#define __CASS_USER_TYPE_ITERATOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_USER_TYPE_ITERATOR_HPP +#define DATASTAX_INTERNAL_USER_TYPE_ITERATOR_HPP #include "cassandra.h" #include "data_type.hpp" diff --git a/cpp-driver/src/user_type_value.hpp b/cpp-driver/src/user_type_value.hpp index 718ea0620..c1f2ace58 100644 --- a/cpp-driver/src/user_type_value.hpp +++ b/cpp-driver/src/user_type_value.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_USER_TYPE_VALUE_HPP_INCLUDED__ -#define __CASS_USER_TYPE_VALUE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_USER_TYPE_VALUE_HPP +#define DATASTAX_INTERNAL_USER_TYPE_VALUE_HPP #include "abstract_data.hpp" #include "cassandra.h" diff --git a/cpp-driver/src/utils.hpp b/cpp-driver/src/utils.hpp index e214fd6eb..1d20c1ff7 100644 --- a/cpp-driver/src/utils.hpp +++ b/cpp-driver/src/utils.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_COMMON_HPP_INCLUDED__ -#define __CASS_COMMON_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_COMMON_HPP +#define DATASTAX_INTERNAL_COMMON_HPP #include "cassandra.h" #include "macros.hpp" diff --git a/cpp-driver/src/uuids.hpp b/cpp-driver/src/uuids.hpp index f0f88cce0..10271ec93 100644 --- a/cpp-driver/src/uuids.hpp +++ b/cpp-driver/src/uuids.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_UUIDS_HPP_INCLUDED__ -#define __CASS_UUIDS_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_UUIDS_HPP +#define DATASTAX_INTERNAL_UUIDS_HPP #include "allocated.hpp" #include "atomic.hpp" diff --git a/cpp-driver/src/value.hpp b/cpp-driver/src/value.hpp index ff81d1bbf..fe5f73b08 100644 --- a/cpp-driver/src/value.hpp +++ b/cpp-driver/src/value.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_VALUE_HPP_INCLUDED__ -#define __CASS_VALUE_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_VALUE_HPP +#define DATASTAX_INTERNAL_VALUE_HPP #include "cassandra.h" #include "decoder.hpp" diff --git a/cpp-driver/src/vector.hpp b/cpp-driver/src/vector.hpp index cec9f4a23..809ad5604 100644 --- a/cpp-driver/src/vector.hpp +++ b/cpp-driver/src/vector.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_VECTOR_HPP_INCLUDED__ -#define __DSE_VECTOR_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_VECTOR_HPP +#define DATASTAX_INTERNAL_VECTOR_HPP #include "allocated.hpp" #include "allocator.hpp" diff --git a/cpp-driver/src/wait_for_handler.hpp b/cpp-driver/src/wait_for_handler.hpp index c227e1f5b..989a2224a 100644 --- a/cpp-driver/src/wait_for_handler.hpp +++ b/cpp-driver/src/wait_for_handler.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_WAIT_FOR_HANDLER_HPP_INCLUDED__ -#define __CASS_WAIT_FOR_HANDLER_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_WAIT_FOR_HANDLER_HPP +#define DATASTAX_INTERNAL_WAIT_FOR_HANDLER_HPP #include "connection.hpp" #include "ref_counted.hpp" diff --git a/cpp-driver/src/whitelist_dc_policy.hpp b/cpp-driver/src/whitelist_dc_policy.hpp index 383cc76ba..59ee387d9 100644 --- a/cpp-driver/src/whitelist_dc_policy.hpp +++ b/cpp-driver/src/whitelist_dc_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_WHITELIST_DC_POLICY_HPP_INCLUDED__ -#define __CASS_WHITELIST_DC_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_WHITELIST_DC_POLICY_HPP +#define DATASTAX_INTERNAL_WHITELIST_DC_POLICY_HPP #include "load_balancing.hpp" #include "host.hpp" diff --git a/cpp-driver/src/whitelist_policy.hpp b/cpp-driver/src/whitelist_policy.hpp index 7f9f08e71..590547e07 100644 --- a/cpp-driver/src/whitelist_policy.hpp +++ b/cpp-driver/src/whitelist_policy.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef __CASS_WHITELIST_POLICY_HPP_INCLUDED__ -#define __CASS_WHITELIST_POLICY_HPP_INCLUDED__ +#ifndef DATASTAX_INTERNAL_WHITELIST_POLICY_HPP +#define DATASTAX_INTERNAL_WHITELIST_POLICY_HPP #include "load_balancing.hpp" #include "host.hpp" diff --git a/packaging/build_deb.sh b/packaging/build_deb.sh index 4314aae18..293c2952e 100755 --- a/packaging/build_deb.sh +++ b/packaging/build_deb.sh @@ -39,7 +39,7 @@ release=1 dist=$(lsb_release -s -c) base="dse-cpp-driver-$version" archive="$base.tar.gz" -files="CMakeLists.txt include src cmake cpp-driver/include cpp-driver/src cpp-driver/cmake cpp-driver/cassconfig.hpp.in" +files="CMakeLists.txt include src cmake cpp-driver/include cpp-driver/src cpp-driver/cmake cpp-driver/driver_config.hpp.in" echo "Building version $version" diff --git a/packaging/build_rpm.sh b/packaging/build_rpm.sh index 0467fdf46..220cd94d3 100755 --- a/packaging/build_rpm.sh +++ b/packaging/build_rpm.sh @@ -42,7 +42,7 @@ fi version=$(header_version "../include/dse.h") base="dse-cpp-driver-$version" archive="$base.tar.gz" -files="CMakeLists.txt include src cmake cpp-driver/include cpp-driver/src cpp-driver/cmake cpp-driver/cassconfig.hpp.in README.md" +files="CMakeLists.txt include src cmake cpp-driver/include cpp-driver/src cpp-driver/cmake cpp-driver/driver_config.hpp.in README.md" echo "Building version $version" diff --git a/src/client_insights.hpp b/src/client_insights.hpp index 29774dd41..4a00d31a3 100644 --- a/src/client_insights.hpp +++ b/src/client_insights.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_CLIENT_INSIGHTS_HPP_INCLUDED__ -#define __DSE_CLIENT_INSIGHTS_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_CLIENT_INSIGHTS_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_CLIENT_INSIGHTS_HPP #include "config.hpp" #include "json.hpp" @@ -44,4 +44,4 @@ class ClientInsights : public core::MonitorReporting { } } } // namespace datastax::internal::enterprise -#endif // __DSE_CLIENT_INSIGHTS_HPP_INCLUDED__ +#endif // DATASTAX_ENTERPRISE_INTERNAL_CLIENT_INSIGHTS_HPP diff --git a/src/date_range.hpp b/src/date_range.hpp index fa16b41ca..6de4c7500 100644 --- a/src/date_range.hpp +++ b/src/date_range.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_DATE_RANGE_HPP_INCLUDED__ -#define __DSE_DATE_RANGE_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_DATE_RANGE_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_DATE_RANGE_HPP #include "serialization.hpp" diff --git a/src/dse_auth.hpp b/src/dse_auth.hpp index d9cd9a4b3..698f03076 100644 --- a/src/dse_auth.hpp +++ b/src/dse_auth.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_AUTH_HPP_INCLUDED__ -#define __DSE_AUTH_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_AUTH_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_AUTH_HPP #include "allocated.hpp" #include "dse.h" diff --git a/src/graph.hpp b/src/graph.hpp index 934a4423b..83ef6a435 100644 --- a/src/graph.hpp +++ b/src/graph.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_GRAPH_HPP_INCLUDED__ -#define __DSE_GRAPH_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_GRAPH_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_GRAPH_HPP #include "dse.h" diff --git a/src/line_string.hpp b/src/line_string.hpp index c1a4aef96..66d50ca57 100644 --- a/src/line_string.hpp +++ b/src/line_string.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_LINE_STRING_HPP_INCLUDED__ -#define __DSE_LINE_STRING_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_LINE_STRING_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_LINE_STRING_HPP #include "dse.h" diff --git a/src/point.hpp b/src/point.hpp index 5e2821c6e..8e2e94111 100644 --- a/src/point.hpp +++ b/src/point.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_POINT_HPP_INCLUDED__ -#define __DSE_POINT_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_POINT_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_POINT_HPP #include "serialization.hpp" diff --git a/src/polygon.hpp b/src/polygon.hpp index ff4dbf489..cc368617a 100644 --- a/src/polygon.hpp +++ b/src/polygon.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_POLYGON_HPP_INCLUDED__ -#define __DSE_POLYGON_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_POLYGON_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_POLYGON_HPP #include "dse.h" diff --git a/src/serialization.hpp b/src/serialization.hpp index fee8148ef..a92d9053a 100644 --- a/src/serialization.hpp +++ b/src/serialization.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_SERIALIZATION_HPP_INCLUDED__ -#define __DSE_SERIALIZATION_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_SERIALIZATION_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_SERIALIZATION_HPP #include "dse.h" diff --git a/src/validate.hpp b/src/validate.hpp index 9a732e4a9..91b22c92b 100644 --- a/src/validate.hpp +++ b/src/validate.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_VALIDATE_HPP_INCLUDED__ -#define __DSE_VALIDATE_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_VALIDATE_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_VALIDATE_HPP #include "dse.h" diff --git a/src/wkt.hpp b/src/wkt.hpp index 338f4dfda..3b5fc498a 100644 --- a/src/wkt.hpp +++ b/src/wkt.hpp @@ -5,8 +5,8 @@ license at http://www.datastax.com/terms/datastax-dse-driver-license-terms */ -#ifndef __DSE_WKT_HPP_INCLUDED__ -#define __DSE_WKT_HPP_INCLUDED__ +#ifndef DATASTAX_ENTERPRISE_INTERNAL_WKT_HPP +#define DATASTAX_ENTERPRISE_INTERNAL_WKT_HPP #include From a90986b03231ca826ef347c1909b997ba5843e5c Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Wed, 1 May 2019 09:13:56 -0400 Subject: [PATCH 05/27] Manual formatting fixes before clang-format --- cpp-driver/src/.clang-format | 64 ++++++++++-------------------------- cpp-driver/src/json.hpp | 11 ++++--- cpp-driver/src/utils.cpp | 4 +-- cpp-driver/src/uuids.cpp | 2 ++ 4 files changed, 29 insertions(+), 52 deletions(-) diff --git a/cpp-driver/src/.clang-format b/cpp-driver/src/.clang-format index 57d419637..0afdb96fd 100644 --- a/cpp-driver/src/.clang-format +++ b/cpp-driver/src/.clang-format @@ -1,55 +1,27 @@ --- +BasedOnStyle: LLVM Language: Cpp AccessModifierOffset: -2 -AlignEscapedNewlinesLeft: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortIfStatementsOnASingleLine: true -AllowShortLoopsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Inline -AlwaysBreakTemplateDeclarations: true -AlwaysBreakBeforeMultilineStrings: true -BreakBeforeBinaryOperators: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -BinPackParameters: true -ColumnLimit: 80 -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -DerivePointerBinding: true -ExperimentalAutoDetectBinPacking: false -IndentCaseLabels: true -MaxEmptyLinesToKeep: 1 -KeepEmptyLinesAtTheStartOfBlocks: true -NamespaceIndentation: None -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: false -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakString: 1000 -PenaltyBreakFirstLessLess: 120 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerBindsToType: true -SpacesBeforeTrailingComments: 1 -Cpp11BracedListStyle: true -Standard: Auto IndentWidth: 2 TabWidth: 8 +ColumnLimit: 100 UseTab: Never -BreakBeforeBraces: Attach -IndentFunctionDeclarationAfterType: true -SpacesInParentheses: false -SpacesInAngles: false -SpaceInEmptyParentheses: false -SpacesInCStyleCastParentheses: false +IndentCaseLabels: true +AlignAfterOpenBracket: true +AlignEscapedNewlines: Left +BreakConstructorInitializers: BeforeComma +AllowShortBlocksOnASingleLine: false +DerivePointerAlignment: false +PointerAlignment: Left +BinPackParameters: true +BinPackArguments: true +AllowShortIfStatementsOnASingleLine: true +CompactNamespaces: true +AlignOperands: true SpacesInContainerLiterals: true -SpaceBeforeAssignmentOperators: true -ContinuationIndentWidth: 4 -CommentPragmas: '^ IWYU pragma:' -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -SpaceBeforeParens: ControlStatements -DisableFormat: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +Cpp11BracedListStyle: false +AlwaysBreakTemplateDeclarations: true +BreakBeforeInheritanceComma: true ... diff --git a/cpp-driver/src/json.hpp b/cpp-driver/src/json.hpp index 1e870ce60..dc396d009 100644 --- a/cpp-driver/src/json.hpp +++ b/cpp-driver/src/json.hpp @@ -71,11 +71,14 @@ class Allocator { } }; -typedef datastax::rapidjson::GenericDocument, datastax::rapidjson::MemoryPoolAllocator, json::Allocator> Document; -typedef datastax::rapidjson::GenericValue, datastax::rapidjson::MemoryPoolAllocator > Value; -typedef datastax::rapidjson::GenericStringBuffer, json::Allocator> StringBuffer; +typedef datastax::rapidjson::UTF8<> UTF8; +typedef datastax::rapidjson::MemoryPoolAllocator MemoryPoolAllocator; -template, typename TargetEncoding = datastax::rapidjson::UTF8<>, typename StackAllocator = json::Allocator, unsigned writeFlags = datastax::rapidjson::kWriteDefaultFlags> +typedef datastax::rapidjson::GenericDocument Document; +typedef datastax::rapidjson::GenericValue Value; +typedef datastax::rapidjson::GenericStringBuffer StringBuffer; + +template class Writer : public datastax::rapidjson::JSON_WRITE_TYPE { public: typedef datastax::rapidjson::JSON_WRITE_TYPE Type; diff --git a/cpp-driver/src/utils.cpp b/cpp-driver/src/utils.cpp index 4f30a3a4d..295d10a07 100644 --- a/cpp-driver/src/utils.cpp +++ b/cpp-driver/src/utils.cpp @@ -197,8 +197,8 @@ void thread_yield() { #endif } -// Code was taken from MSDN documentation -// see https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code +// Code was taken from MSDN documentation see: +// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code #if defined(_MSC_VER) && defined(_DEBUG) const DWORD MS_VC_EXCEPTION = 0x406D1388; #pragma pack(push,8) diff --git a/cpp-driver/src/uuids.cpp b/cpp-driver/src/uuids.cpp index 8ac6154c3..652a05d5f 100644 --- a/cpp-driver/src/uuids.cpp +++ b/cpp-driver/src/uuids.cpp @@ -124,6 +124,7 @@ CassError cass_uuid_from_string_n(const char* str, const char* pos = str; char buf[16]; +// clang-format off static const signed char hex_to_half_byte[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -142,6 +143,7 @@ CassError cass_uuid_from_string_n(const char* str, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; +// clang-format on if (str == NULL || str_length != 36) { return CASS_ERROR_LIB_BAD_PARAMS; From 4b8ab03c6faf1c768e390d000c7f78c67ae9aa53 Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Wed, 1 May 2019 11:31:58 -0400 Subject: [PATCH 06/27] Add basic support for clang-format --- cpp-driver/src/.clang-format => .clang-format | 1 - CMakeLists.txt | 1 + cpp-driver/.clang-format | 26 ++++++++++ cpp-driver/cmake/modules/ClangFormat.cmake | 49 +++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) rename cpp-driver/src/.clang-format => .clang-format (99%) create mode 100644 cpp-driver/.clang-format create mode 100644 cpp-driver/cmake/modules/ClangFormat.cmake diff --git a/cpp-driver/src/.clang-format b/.clang-format similarity index 99% rename from cpp-driver/src/.clang-format rename to .clang-format index 0afdb96fd..9e95db6a3 100644 --- a/cpp-driver/src/.clang-format +++ b/.clang-format @@ -24,4 +24,3 @@ Cpp11BracedListStyle: false AlwaysBreakTemplateDeclarations: true BreakBeforeInheritanceComma: true ... - diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e478fd36..40605cf86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ list(APPEND CMAKE_MODULE_PATH ${CASS_ROOT_DIR}/cmake/modules ) include(CppDriver) +include(ClangFormat) CassInitProject(dse) CassRapidJson() diff --git a/cpp-driver/.clang-format b/cpp-driver/.clang-format new file mode 100644 index 000000000..9e95db6a3 --- /dev/null +++ b/cpp-driver/.clang-format @@ -0,0 +1,26 @@ +--- +BasedOnStyle: LLVM +Language: Cpp +AccessModifierOffset: -2 +IndentWidth: 2 +TabWidth: 8 +ColumnLimit: 100 +UseTab: Never +IndentCaseLabels: true +AlignAfterOpenBracket: true +AlignEscapedNewlines: Left +BreakConstructorInitializers: BeforeComma +AllowShortBlocksOnASingleLine: false +DerivePointerAlignment: false +PointerAlignment: Left +BinPackParameters: true +BinPackArguments: true +AllowShortIfStatementsOnASingleLine: true +CompactNamespaces: true +AlignOperands: true +SpacesInContainerLiterals: true +ConstructorInitializerAllOnOneLineOrOnePerLine: false +Cpp11BracedListStyle: false +AlwaysBreakTemplateDeclarations: true +BreakBeforeInheritanceComma: true +... diff --git a/cpp-driver/cmake/modules/ClangFormat.cmake b/cpp-driver/cmake/modules/ClangFormat.cmake new file mode 100644 index 000000000..2f700a4da --- /dev/null +++ b/cpp-driver/cmake/modules/ClangFormat.cmake @@ -0,0 +1,49 @@ +# +# Format and verify formatting using clang-format +# +cmake_minimum_required(VERSION 2.6.4) + +include(FindPackageHandleStandardArgs) + +if(NOT CLANG_FORMAT_EXE_NAME) + set(CLANG_FORMAT_EXE_NAME clang-format) +endif() + +if(CLANG_FORMAT_ROOT_DIR) + find_program(CLANG_FORMAT_EXE + NAMES ${CLANG_FORMAT_EXE_NAME} + PATHS ${CLANG_FORMAT_ROOT_DIR} + NO_DEFAULT_PATH) +endif() + +find_program(CLANG_FORMAT_EXE NAMES ${CLANG_FORMAT_EXE_NAME}) + +find_package_handle_standard_args(CLANG_FORMAT DEFAULT_MSG CLANG_FORMAT_EXE) + +mark_as_advanced(CLANG_FORMAT_EXE) + +if(CLANG_FORMAT_FOUND) + set(CLANG_FORMAT_FILE_EXTENSIONS ${CLANG_FORMAT_CXX_FILE_EXTENSIONS} *.cpp *.hpp *.c *.h) + file(GLOB_RECURSE CLANG_FORMAT_ALL_SOURCE_FILES ${CLANG_FORMAT_FILE_EXTENSIONS}) + + set(CLANG_FORMAT_EXCLUDE_PATTERNS ${CLANG_FORMAT_EXCLUDE_PATTERNS} "/CMakeFiles/" "cmake" "/build/" "/vendor/" "/third_party/" "cassandra.h" "dse.h") + + foreach (SOURCE_FILE ${CLANG_FORMAT_ALL_SOURCE_FILES}) + foreach (EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS}) + string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND) + if (NOT ${EXCLUDE_FOUND} EQUAL -1) + list(REMOVE_ITEM CLANG_FORMAT_ALL_SOURCE_FILES ${SOURCE_FILE}) + endif () + endforeach () + endforeach () + + add_custom_target(format + COMMENT "Format source files using clang-format" + COMMAND ${CLANG_FORMAT_EXE} -i -fallback-style=none -style=file ${CLANG_FORMAT_ALL_SOURCE_FILES}) + + add_custom_target(format-check + COMMENT "Verify source files formatting using clang-format" + COMMAND ! ${CLANG_FORMAT_EXE} -output-replacements-xml -fallback-style=none -style=file ${CLANG_FORMAT_ALL_SOURCE_FILES} | tee replacements.xml | grep -q "replacement offset") +else() + message(STATUS "Unable to find clang-format. Not creating format targets.") +endif() From 47628154e36450af166260511925e4bbe0db2ae2 Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Wed, 1 May 2019 11:57:16 -0400 Subject: [PATCH 07/27] Add format check to Jenkins CI --- cpp-driver/.build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp-driver/.build.sh b/cpp-driver/.build.sh index 1070cf9b0..1f9c3fcdb 100644 --- a/cpp-driver/.build.sh +++ b/cpp-driver/.build.sh @@ -73,6 +73,7 @@ build_driver() { ( cd build cmake -DCMAKE_BUILD_TYPE=Release -D${driver_prefix}_BUILD_SHARED=On -D${driver_prefix}_BUILD_STATIC=On -D${driver_prefix}_BUILD_EXAMPLES=On -D${driver_prefix}_BUILD_UNIT_TESTS=On .. + [[ -x $(which clang-format) ]] && make format-check make -j${PROCS} ) } From 183e10fc847d2dacb85d10a51bab0540ffa2544b Mon Sep 17 00:00:00 2001 From: Michael Penick Date: Wed, 1 May 2019 12:44:14 -0400 Subject: [PATCH 08/27] Run clang-format --- cpp-driver/examples/async/async.c | 12 +- cpp-driver/examples/auth/auth.c | 38 +- cpp-driver/examples/basic/basic.c | 12 +- cpp-driver/examples/batch/batch.c | 25 +- .../examples/bind_by_name/bind_by_name.c | 25 +- cpp-driver/examples/callbacks/callbacks.c | 18 +- cpp-driver/examples/collections/collections.c | 9 +- cpp-driver/examples/date_time/data_time.c | 9 +- cpp-driver/examples/duration/duration.c | 16 +- .../execution_profiles/execution_profiles.c | 27 +- .../examples/host_listener/host_listener.c | 5 +- cpp-driver/examples/logging/logging.c | 11 +- cpp-driver/examples/maps/maps.c | 17 +- .../named_parameters/named_parameters.c | 17 +- cpp-driver/examples/paging/paging.c | 9 +- cpp-driver/examples/perf/perf.c | 58 +- cpp-driver/examples/prepared/prepared.c | 15 +- cpp-driver/examples/schema_meta/schema_meta.c | 35 +- cpp-driver/examples/simple/simple.c | 11 +- cpp-driver/examples/ssl/ssl.c | 25 +- cpp-driver/examples/tracing/tracing.c | 40 +- cpp-driver/examples/tuple/tuple.c | 13 +- cpp-driver/examples/udt/udt.c | 23 +- cpp-driver/examples/uuids/uuids.c | 14 +- .../gtests/src/integration/bignumber.hpp | 26 +- .../gtests/src/integration/driver_utils.cpp | 22 +- .../gtests/src/integration/driver_utils.hpp | 8 +- .../gtests/src/integration/exception.hpp | 18 +- .../gtests/src/integration/integration.cpp | 164 +- .../gtests/src/integration/integration.hpp | 106 +- cpp-driver/gtests/src/integration/logger.cpp | 36 +- cpp-driver/gtests/src/integration/logger.hpp | 7 +- cpp-driver/gtests/src/integration/main.cpp | 25 +- .../gtests/src/integration/nullable_value.hpp | 96 +- .../src/integration/objects/cluster.hpp | 74 +- .../src/integration/objects/collection.hpp | 33 +- .../integration/objects/custom_payload.hpp | 33 +- .../integration/objects/execution_profile.hpp | 98 +- .../gtests/src/integration/objects/future.hpp | 33 +- .../src/integration/objects/iterator.hpp | 12 +- .../src/integration/objects/object_base.hpp | 28 +- .../src/integration/objects/prepared.hpp | 24 +- .../gtests/src/integration/objects/result.hpp | 93 +- .../src/integration/objects/retry_policy.hpp | 18 +- .../gtests/src/integration/objects/schema.hpp | 59 +- .../src/integration/objects/session.hpp | 49 +- .../src/integration/objects/statement.cpp | 4 +- .../src/integration/objects/statement.hpp | 64 +- .../gtests/src/integration/objects/tuple.hpp | 35 +- .../src/integration/objects/user_type.hpp | 37 +- .../src/integration/objects/uuid_gen.hpp | 14 +- cpp-driver/gtests/src/integration/options.cpp | 316 ++- cpp-driver/gtests/src/integration/options.hpp | 3 +- .../gtests/src/integration/policies.hpp | 1 - .../policies/ignore_retry_policy.hpp | 24 +- .../policies/next_host_retry_policy.hpp | 24 +- .../gtests/src/integration/rest_client.cpp | 44 +- .../gtests/src/integration/rest_client.hpp | 18 +- .../gtests/src/integration/shared_ptr.hpp | 37 +- .../simulacron/priming_requests.hpp | 28 +- .../integration/simulacron/priming_rows.hpp | 80 +- .../simulacron/results/close_connection.hpp | 38 +- .../integration/simulacron/results/result.hpp | 12 +- .../simulacron/results/success.hpp | 82 +- .../simulacron/results/write_timeout.hpp | 27 +- .../simulacron/simulacron_cluster.cpp | 137 +- .../simulacron/simulacron_cluster.hpp | 71 +- .../simulacron/simulacron_integration.cpp | 29 +- .../simulacron/simulacron_integration.hpp | 15 +- .../gtests/src/integration/strptime.cpp | 254 ++- .../gtests/src/integration/strptime.hpp | 2 +- .../gtests/src/integration/test_category.cpp | 67 +- .../gtests/src/integration/test_category.hpp | 6 +- .../gtests/src/integration/test_utils.cpp | 37 +- .../gtests/src/integration/test_utils.hpp | 21 +- .../simulacron/test_simulacron_connect.cpp | 64 +- .../simulacron/test_simulacron_idempotent.cpp | 12 +- .../src/integration/tests/test_async.cpp | 7 +- .../src/integration/tests/test_auth.cpp | 43 +- .../src/integration/tests/test_basics.cpp | 102 +- .../src/integration/tests/test_batch.cpp | 36 +- .../src/integration/tests/test_by_name.cpp | 74 +- .../tests/test_cassandra_types.cpp | 480 ++-- .../src/integration/tests/test_cluster.cpp | 2 +- .../src/integration/tests/test_config.cpp | 33 +- .../integration/tests/test_consistency.cpp | 46 +- .../tests/test_control_connection.cpp | 150 +- .../integration/tests/test_custom_payload.cpp | 3 +- .../tests/test_dc_aware_policy.cpp | 26 +- .../integration/tests/test_exec_profile.cpp | 128 +- .../tests/test_null_string_params.cpp | 368 ++- .../tests/test_schema_metadata.cpp | 120 +- .../src/integration/tests/test_session.cpp | 23 +- .../tests/test_startup_options.cpp | 15 +- .../src/integration/tests/test_statement.cpp | 33 +- .../src/integration/tests/test_tracing.cpp | 4 +- cpp-driver/gtests/src/integration/tlog.hpp | 7 +- cpp-driver/gtests/src/integration/values.hpp | 6 +- .../gtests/src/integration/values/ascii.hpp | 68 +- .../gtests/src/integration/values/blob.hpp | 77 +- .../gtests/src/integration/values/boolean.hpp | 60 +- .../gtests/src/integration/values/date.hpp | 56 +- .../gtests/src/integration/values/decimal.hpp | 66 +- .../gtests/src/integration/values/double.hpp | 61 +- .../src/integration/values/duration.hpp | 100 +- .../gtests/src/integration/values/float.hpp | 61 +- .../gtests/src/integration/values/inet.hpp | 56 +- .../gtests/src/integration/values/integer.hpp | 246 +- .../gtests/src/integration/values/list.hpp | 78 +- .../gtests/src/integration/values/map.hpp | 87 +- .../gtests/src/integration/values/set.hpp | 89 +- .../gtests/src/integration/values/time.hpp | 45 +- .../src/integration/values/timestamp.hpp | 35 +- .../gtests/src/integration/values/uuid.hpp | 95 +- .../gtests/src/integration/values/varchar.hpp | 75 +- .../gtests/src/integration/values/varint.hpp | 74 +- .../gtests/src/integration/win_debug.cpp | 55 +- .../gtests/src/integration/win_debug.hpp | 20 +- .../gtests/src/unit/event_loop_test.hpp | 6 +- cpp-driver/gtests/src/unit/loop_test.hpp | 6 +- cpp-driver/gtests/src/unit/main.cpp | 70 +- cpp-driver/gtests/src/unit/mockssandra.cpp | 743 +++---- cpp-driver/gtests/src/unit/mockssandra.hpp | 458 ++-- .../gtests/src/unit/test_token_map_utils.hpp | 135 +- .../gtests/src/unit/tests/test_async.cpp | 8 +- .../gtests/src/unit/tests/test_atomic.cpp | 4 +- .../src/unit/tests/test_class_type_parser.cpp | 163 +- .../gtests/src/unit/tests/test_cluster.cpp | 341 ++- .../gtests/src/unit/tests/test_connection.cpp | 100 +- .../unit/tests/test_control_connection.cpp | 235 +- .../src/unit/tests/test_copy_on_write.cpp | 12 +- .../gtests/src/unit/tests/test_data_type.cpp | 102 +- .../gtests/src/unit/tests/test_date_time.cpp | 6 +- .../gtests/src/unit/tests/test_decoder.cpp | 182 +- .../gtests/src/unit/tests/test_encode.cpp | 6 +- .../gtests/src/unit/tests/test_event_loop.cpp | 39 +- .../src/unit/tests/test_exec_profile.cpp | 130 +- .../gtests/src/unit/tests/test_get_time.cpp | 2 +- .../gtests/src/unit/tests/test_hash_table.cpp | 2 +- .../gtests/src/unit/tests/test_inet.cpp | 4 +- .../src/unit/tests/test_load_balancing.cpp | 188 +- .../src/unit/tests/test_loop_watcher.cpp | 12 +- cpp-driver/gtests/src/unit/tests/test_md5.cpp | 33 +- .../gtests/src/unit/tests/test_metadata.cpp | 8 +- .../gtests/src/unit/tests/test_metrics.cpp | 10 +- .../src/unit/tests/test_micro_timer.cpp | 73 +- .../src/unit/tests/test_name_resolver.cpp | 15 +- .../gtests/src/unit/tests/test_pool.cpp | 366 ++- .../src/unit/tests/test_protocol_version.cpp | 12 +- .../gtests/src/unit/tests/test_random.cpp | 289 ++- .../unit/tests/test_replication_strategy.cpp | 39 +- .../src/unit/tests/test_request_processor.cpp | 254 +-- .../gtests/src/unit/tests/test_resolver.cpp | 43 +- .../src/unit/tests/test_retry_policies.cpp | 142 +- .../src/unit/tests/test_routing_key.cpp | 11 +- .../src/unit/tests/test_scoped_lock.cpp | 14 +- .../src/unit/tests/test_serialization.cpp | 43 +- .../gtests/src/unit/tests/test_session.cpp | 170 +- .../src/unit/tests/test_session_base.cpp | 26 +- .../src/unit/tests/test_small_vector.cpp | 3 +- .../gtests/src/unit/tests/test_socket.cpp | 114 +- .../src/unit/tests/test_startup_options.cpp | 22 +- .../gtests/src/unit/tests/test_statement.cpp | 9 +- .../src/unit/tests/test_stream_manager.cpp | 49 +- .../gtests/src/unit/tests/test_string_ref.cpp | 19 +- .../src/unit/tests/test_tcp_connector.cpp | 14 +- .../gtests/src/unit/tests/test_timer.cpp | 77 +- .../src/unit/tests/test_timestamp_gen.cpp | 16 +- .../gtests/src/unit/tests/test_token.cpp | 88 +- .../gtests/src/unit/tests/test_token_map.cpp | 84 +- .../gtests/src/unit/tests/test_tracing.cpp | 5 +- .../gtests/src/unit/tests/test_utils.cpp | 14 +- .../gtests/src/unit/tests/test_uuids.cpp | 38 +- .../gtests/src/unit/tests/test_value.cpp | 62 +- .../src/unit/tests/test_wait_for_handler.cpp | 38 +- cpp-driver/gtests/src/unit/uint128.hpp | 688 +++--- cpp-driver/gtests/src/unit/unit.cpp | 50 +- cpp-driver/gtests/src/unit/unit.hpp | 34 +- cpp-driver/src/abstract_data.cpp | 9 +- cpp-driver/src/abstract_data.hpp | 52 +- cpp-driver/src/address.cpp | 50 +- cpp-driver/src/address.hpp | 69 +- cpp-driver/src/aligned_storage.hpp | 7 +- cpp-driver/src/allocated.cpp | 16 +- cpp-driver/src/allocated.hpp | 11 +- cpp-driver/src/allocator.hpp | 41 +- cpp-driver/src/async.cpp | 6 +- cpp-driver/src/async.hpp | 2 +- cpp-driver/src/atomic/atomic_boost.hpp | 14 +- cpp-driver/src/atomic/atomic_intrinsics.hpp | 2 +- .../src/atomic/atomic_intrinsics_gcc.hpp | 14 +- .../src/atomic/atomic_intrinsics_msvc.hpp | 96 +- cpp-driver/src/atomic/atomic_std.hpp | 11 +- cpp-driver/src/auth.cpp | 47 +- cpp-driver/src/auth.hpp | 60 +- cpp-driver/src/auth_requests.cpp | 3 +- cpp-driver/src/auth_requests.hpp | 11 +- cpp-driver/src/auth_responses.hpp | 8 +- cpp-driver/src/batch_request.cpp | 58 +- cpp-driver/src/batch_request.hpp | 6 +- cpp-driver/src/blacklist_dc_policy.cpp | 3 +- cpp-driver/src/blacklist_dc_policy.hpp | 13 +- cpp-driver/src/blacklist_policy.cpp | 4 +- cpp-driver/src/blacklist_policy.hpp | 13 +- cpp-driver/src/buffer.hpp | 31 +- cpp-driver/src/callback.hpp | 48 +- cpp-driver/src/cluster.cpp | 307 +-- cpp-driver/src/cluster.hpp | 69 +- cpp-driver/src/cluster_config.cpp | 275 +-- cpp-driver/src/cluster_config.hpp | 2 +- cpp-driver/src/cluster_connector.cpp | 134 +- cpp-driver/src/cluster_connector.hpp | 9 +- cpp-driver/src/collection.cpp | 59 +- cpp-driver/src/collection.hpp | 32 +- cpp-driver/src/collection_iterator.cpp | 4 +- cpp-driver/src/collection_iterator.hpp | 15 +- cpp-driver/src/config.cpp | 6 +- cpp-driver/src/config.hpp | 152 +- cpp-driver/src/connection.cpp | 90 +- cpp-driver/src/connection.hpp | 34 +- cpp-driver/src/connection_pool.cpp | 125 +- cpp-driver/src/connection_pool.hpp | 34 +- cpp-driver/src/connection_pool_connector.cpp | 75 +- cpp-driver/src/connection_pool_connector.hpp | 5 +- cpp-driver/src/connection_pool_manager.cpp | 74 +- cpp-driver/src/connection_pool_manager.hpp | 21 +- .../connection_pool_manager_initializer.cpp | 56 +- .../connection_pool_manager_initializer.hpp | 12 +- cpp-driver/src/connector.cpp | 184 +- cpp-driver/src/connector.hpp | 36 +- cpp-driver/src/control_connection.cpp | 331 ++- cpp-driver/src/control_connection.hpp | 80 +- cpp-driver/src/control_connector.cpp | 123 +- cpp-driver/src/control_connector.hpp | 29 +- cpp-driver/src/copy_on_write_ptr.hpp | 26 +- cpp-driver/src/data_type.cpp | 164 +- cpp-driver/src/data_type.hpp | 237 +- cpp-driver/src/data_type_parser.cpp | 78 +- cpp-driver/src/data_type_parser.hpp | 93 +- cpp-driver/src/dc_aware_policy.cpp | 68 +- cpp-driver/src/dc_aware_policy.hpp | 23 +- cpp-driver/src/decoder.cpp | 32 +- cpp-driver/src/decoder.hpp | 53 +- cpp-driver/src/delayed_connector.cpp | 32 +- cpp-driver/src/delayed_connector.hpp | 5 +- cpp-driver/src/dense_hash_map.hpp | 38 +- cpp-driver/src/dense_hash_set.hpp | 35 +- cpp-driver/src/deque.hpp | 21 +- cpp-driver/src/driver_info.cpp | 12 +- cpp-driver/src/driver_info.hpp | 2 +- cpp-driver/src/encode.cpp | 12 +- cpp-driver/src/encode.hpp | 2 +- cpp-driver/src/error_response.cpp | 25 +- cpp-driver/src/error_response.hpp | 12 +- cpp-driver/src/event_loop.cpp | 31 +- cpp-driver/src/event_loop.hpp | 21 +- cpp-driver/src/event_response.cpp | 6 +- cpp-driver/src/event_response.hpp | 37 +- cpp-driver/src/execute_request.cpp | 7 +- cpp-driver/src/execute_request.hpp | 6 +- cpp-driver/src/execution_profile.cpp | 101 +- cpp-driver/src/execution_profile.hpp | 102 +- cpp-driver/src/external.cpp | 15 +- cpp-driver/src/external.hpp | 12 +- cpp-driver/src/fixed_allocator.hpp | 41 +- cpp-driver/src/future.cpp | 53 +- cpp-driver/src/future.hpp | 12 +- cpp-driver/src/get_time-mac.cpp | 7 +- cpp-driver/src/get_time-unix.cpp | 12 +- cpp-driver/src/get_time-win.cpp | 15 +- cpp-driver/src/get_time.hpp | 8 +- cpp-driver/src/hash.hpp | 5 +- cpp-driver/src/hash_table.hpp | 37 +- cpp-driver/src/histogram_wrapper.hpp | 24 +- cpp-driver/src/host.cpp | 23 +- cpp-driver/src/host.hpp | 99 +- cpp-driver/src/host_targeting_policy.cpp | 13 +- cpp-driver/src/host_targeting_policy.hpp | 16 +- cpp-driver/src/iterator.cpp | 39 +- cpp-driver/src/iterator.hpp | 2 +- cpp-driver/src/json.hpp | 61 +- cpp-driver/src/latency_aware_policy.cpp | 35 +- cpp-driver/src/latency_aware_policy.hpp | 33 +- cpp-driver/src/list.hpp | 5 +- cpp-driver/src/list_policy.cpp | 14 +- cpp-driver/src/list_policy.hpp | 10 +- cpp-driver/src/load_balancing.hpp | 24 +- cpp-driver/src/logger.cpp | 34 +- cpp-driver/src/logger.hpp | 49 +- cpp-driver/src/loop_watcher.hpp | 28 +- cpp-driver/src/macros.hpp | 40 +- cpp-driver/src/map.hpp | 26 +- cpp-driver/src/map_iterator.hpp | 2 +- cpp-driver/src/md5.cpp | 71 +- cpp-driver/src/md5.hpp | 5 +- cpp-driver/src/memory.cpp | 10 +- cpp-driver/src/memory.hpp | 3 +- cpp-driver/src/metadata.cpp | 673 +++--- cpp-driver/src/metadata.hpp | 296 ++- cpp-driver/src/metrics.hpp | 264 +-- cpp-driver/src/micro_timer.cpp | 41 +- cpp-driver/src/micro_timer.hpp | 12 +- cpp-driver/src/monitor_reporting.cpp | 3 +- cpp-driver/src/monitor_reporting.hpp | 21 +- cpp-driver/src/mpmc_queue.hpp | 2 +- cpp-driver/src/murmur3.cpp | 142 +- cpp-driver/src/murmur3.hpp | 5 +- cpp-driver/src/name_resolver.hpp | 14 +- cpp-driver/src/options_request.hpp | 8 +- cpp-driver/src/pooled_connection.cpp | 65 +- cpp-driver/src/pooled_connection.hpp | 10 +- cpp-driver/src/prepare_all_handler.cpp | 32 +- cpp-driver/src/prepare_all_handler.hpp | 8 +- cpp-driver/src/prepare_host_handler.cpp | 81 +- cpp-driver/src/prepare_host_handler.hpp | 16 +- cpp-driver/src/prepare_request.cpp | 5 +- cpp-driver/src/prepare_request.hpp | 8 +- cpp-driver/src/prepared.cpp | 31 +- cpp-driver/src/prepared.hpp | 34 +- cpp-driver/src/protocol.cpp | 33 +- cpp-driver/src/protocol.hpp | 2 +- cpp-driver/src/query_request.cpp | 8 +- cpp-driver/src/query_request.hpp | 25 +- cpp-driver/src/random.cpp | 131 +- cpp-driver/src/random.hpp | 6 +- cpp-driver/src/ready_response.hpp | 2 +- cpp-driver/src/ref_counted.hpp | 57 +- cpp-driver/src/register_request.cpp | 3 +- cpp-driver/src/register_request.hpp | 4 +- cpp-driver/src/request.cpp | 30 +- cpp-driver/src/request.hpp | 67 +- cpp-driver/src/request_callback.cpp | 61 +- cpp-driver/src/request_callback.hpp | 79 +- cpp-driver/src/request_handler.cpp | 264 +-- cpp-driver/src/request_handler.hpp | 91 +- cpp-driver/src/request_processor.cpp | 288 ++- cpp-driver/src/request_processor.hpp | 71 +- .../src/request_processor_initializer.cpp | 62 +- .../src/request_processor_initializer.hpp | 11 +- cpp-driver/src/resolver.hpp | 38 +- cpp-driver/src/response.cpp | 19 +- cpp-driver/src/response.hpp | 11 +- cpp-driver/src/result_iterator.hpp | 2 +- cpp-driver/src/result_metadata.cpp | 13 +- cpp-driver/src/result_metadata.hpp | 5 +- cpp-driver/src/result_response.cpp | 42 +- cpp-driver/src/result_response.hpp | 16 +- cpp-driver/src/retry_policy.cpp | 178 +- cpp-driver/src/retry_policy.hpp | 138 +- cpp-driver/src/ring_buffer.cpp | 33 +- cpp-driver/src/ring_buffer.hpp | 33 +- cpp-driver/src/round_robin_policy.cpp | 27 +- cpp-driver/src/round_robin_policy.hpp | 18 +- cpp-driver/src/row.cpp | 11 +- cpp-driver/src/row.hpp | 9 +- cpp-driver/src/row_iterator.hpp | 2 +- cpp-driver/src/schema_agreement_handler.cpp | 25 +- cpp-driver/src/schema_agreement_handler.hpp | 10 +- cpp-driver/src/scoped_lock.hpp | 16 +- cpp-driver/src/scoped_ptr.hpp | 8 +- cpp-driver/src/serialization.hpp | 11 +- cpp-driver/src/session.cpp | 170 +- cpp-driver/src/session.hpp | 16 +- cpp-driver/src/session_base.cpp | 58 +- cpp-driver/src/session_base.hpp | 15 +- cpp-driver/src/set.hpp | 20 +- cpp-driver/src/small_dense_hash_map.hpp | 18 +- cpp-driver/src/small_vector.hpp | 10 +- cpp-driver/src/socket.cpp | 58 +- cpp-driver/src/socket.hpp | 24 +- cpp-driver/src/socket_connector.cpp | 82 +- cpp-driver/src/socket_connector.hpp | 13 +- cpp-driver/src/speculative_execution.hpp | 35 +- cpp-driver/src/spin_lock.hpp | 8 +- cpp-driver/src/spsc_queue.hpp | 15 +- cpp-driver/src/ssl.cpp | 34 +- cpp-driver/src/ssl.hpp | 54 +- cpp-driver/src/ssl/ring_buffer_bio.cpp | 40 +- cpp-driver/src/ssl/ring_buffer_bio.hpp | 10 +- cpp-driver/src/ssl/ssl_no_impl.cpp | 16 +- cpp-driver/src/ssl/ssl_no_impl.hpp | 13 +- cpp-driver/src/ssl/ssl_openssl_impl.cpp | 126 +- cpp-driver/src/ssl/ssl_openssl_impl.hpp | 17 +- cpp-driver/src/stack.hpp | 12 +- cpp-driver/src/startup_request.cpp | 8 +- cpp-driver/src/startup_request.hpp | 16 +- cpp-driver/src/statement.cpp | 224 +- cpp-driver/src/statement.hpp | 26 +- cpp-driver/src/stream_manager.hpp | 12 +- cpp-driver/src/string.hpp | 91 +- cpp-driver/src/string_ref.hpp | 84 +- cpp-driver/src/supported_response.hpp | 4 +- cpp-driver/src/tcp_connector.hpp | 14 +- cpp-driver/src/testing.cpp | 21 +- cpp-driver/src/testing.hpp | 4 +- cpp-driver/src/timer.cpp | 8 +- cpp-driver/src/timer.hpp | 8 +- cpp-driver/src/timestamp_generator.cpp | 12 +- cpp-driver/src/timestamp_generator.hpp | 24 +- cpp-driver/src/token_aware_policy.cpp | 31 +- cpp-driver/src/token_aware_policy.hpp | 27 +- cpp-driver/src/token_map.hpp | 12 +- cpp-driver/src/token_map_impl.cpp | 22 +- cpp-driver/src/token_map_impl.hpp | 188 +- cpp-driver/src/tracing_data_handler.cpp | 12 +- cpp-driver/src/tracing_data_handler.hpp | 14 +- cpp-driver/src/tuple.cpp | 61 +- cpp-driver/src/tuple.hpp | 30 +- cpp-driver/src/types.hpp | 40 +- cpp-driver/src/user_type_field_iterator.hpp | 2 +- cpp-driver/src/user_type_value.cpp | 106 +- cpp-driver/src/user_type_value.hpp | 6 +- cpp-driver/src/utils.cpp | 56 +- cpp-driver/src/utils.hpp | 18 +- cpp-driver/src/uuids.cpp | 59 +- cpp-driver/src/uuids.hpp | 4 +- cpp-driver/src/value.cpp | 53 +- cpp-driver/src/value.hpp | 27 +- cpp-driver/src/vector.hpp | 14 +- cpp-driver/src/wait_for_handler.cpp | 45 +- cpp-driver/src/wait_for_handler.hpp | 12 +- cpp-driver/src/whitelist_dc_policy.cpp | 3 +- cpp-driver/src/whitelist_dc_policy.hpp | 13 +- cpp-driver/src/whitelist_policy.cpp | 4 +- cpp-driver/src/whitelist_policy.hpp | 13 +- .../ccm_bridge/src/authentication_type.cpp | 35 +- .../ccm_bridge/src/authentication_type.hpp | 228 +- cpp-driver/test/ccm_bridge/src/bridge.cpp | 538 +++-- cpp-driver/test/ccm_bridge/src/bridge.hpp | 1970 ++++++++--------- .../test/ccm_bridge/src/bridge_exception.hpp | 68 +- .../test/ccm_bridge/src/cass_version.hpp | 883 ++++---- .../test/ccm_bridge/src/deployment_type.cpp | 36 +- .../test/ccm_bridge/src/deployment_type.hpp | 218 +- .../ccm_bridge/src/dse_credentials_type.cpp | 35 +- .../ccm_bridge/src/dse_credentials_type.hpp | 230 +- cpp-driver/test/ccm_bridge/src/process.cpp | 23 +- cpp-driver/test/ccm_bridge/src/process.hpp | 20 +- .../test/ccm_bridge/src/socket_exception.hpp | 6 +- cpp-driver/test/ccm_bridge/src/tsocket.cpp | 38 +- cpp-driver/test/ccm_bridge/src/tsocket.hpp | 8 +- .../test/integration_tests/src/main.cpp | 3 +- .../integration_tests/src/policy_tools.cpp | 102 +- .../integration_tests/src/policy_tools.hpp | 22 +- .../integration_tests/src/pretty_print.cpp | 12 +- .../integration_tests/src/pretty_print.hpp | 19 +- .../test/integration_tests/src/test_async.cpp | 64 +- .../src/test_authentication.cpp | 64 +- .../integration_tests/src/test_basics.cpp | 292 ++- .../test/integration_tests/src/test_batch.cpp | 148 +- .../integration_tests/src/test_by_name.cpp | 121 +- .../src/test_collections.cpp | 235 +- .../integration_tests/src/test_config.cpp | 16 +- .../src/test_consistency.cpp | 154 +- .../src/test_control_connection.cpp | 115 +- .../src/test_custom_payload.cpp | 22 +- .../integration_tests/src/test_datatypes.cpp | 70 +- .../integration_tests/src/test_future.cpp | 48 +- .../src/test_future_callbacks.cpp | 38 +- .../integration_tests/src/test_heartbeat.cpp | 5 +- .../integration_tests/src/test_iterators.cpp | 198 +- .../src/test_latency_aware_policy.cpp | 45 +- .../src/test_load_balancing.cpp | 27 +- .../integration_tests/src/test_logging.cpp | 21 +- .../integration_tests/src/test_metrics.cpp | 56 +- .../src/test_named_parameters.cpp | 334 ++- .../integration_tests/src/test_outage.cpp | 81 +- .../integration_tests/src/test_paging.cpp | 45 +- .../test/integration_tests/src/test_pool.cpp | 39 +- .../src/test_prepare_on_all.cpp | 28 +- .../src/test_prepare_on_up_or_add_host.cpp | 41 +- .../integration_tests/src/test_prepared.cpp | 253 ++- .../src/test_prepared_batch.cpp | 31 +- .../src/test_prepared_existing.cpp | 48 +- .../src/test_prepared_metadata.cpp | 29 +- .../src/test_prepared_outage.cpp | 48 +- .../src/test_schema_agreement.cpp | 59 +- .../src/test_schema_metadata.cpp | 947 ++++---- .../src/test_serial_consistency.cpp | 43 +- .../src/test_server_failures.cpp | 65 +- .../integration_tests/src/test_sessions.cpp | 213 +- .../src/test_set_keyspace.cpp | 109 +- .../src/test_speculative_execution_policy.cpp | 100 +- .../test/integration_tests/src/test_ssl.cpp | 153 +- .../integration_tests/src/test_stress.cpp | 215 +- .../integration_tests/src/test_timestamps.cpp | 65 +- .../src/test_token_aware_policy.cpp | 151 +- .../integration_tests/src/test_tuples.cpp | 406 ++-- .../test/integration_tests/src/test_udts.cpp | 233 +- .../test/integration_tests/src/test_utils.cpp | 359 +-- .../test/integration_tests/src/test_utils.hpp | 377 ++-- .../integration_tests/src/test_warnings.cpp | 15 +- .../alloc-linter-tool/alloc_linter_tool.cpp | 29 +- examples/date_range/date_range.c | 86 +- examples/geotypes/geotypes.c | 125 +- examples/graph/graph.c | 101 +- examples/gssapi/gssapi.c | 3 +- examples/gssapi/gssapi_proxy.c | 10 +- examples/plaintext/plaintext.c | 3 +- examples/plaintext/plaintext_proxy.c | 15 +- examples/proxy_execution/proxy_execution.c | 10 +- src/batch_request.cpp | 8 +- src/client_insights.cpp | 305 ++- src/client_insights.hpp | 11 +- src/cluster_config.cpp | 129 +- src/collection.cpp | 16 +- src/date_range.cpp | 18 +- src/date_range.hpp | 4 +- src/driver_info.cpp | 12 +- src/dse_auth.cpp | 248 +-- src/dse_auth.hpp | 30 +- src/graph.cpp | 427 ++-- src/graph.hpp | 102 +- src/line_string.cpp | 59 +- src/line_string.hpp | 34 +- src/point.cpp | 6 +- src/point.hpp | 2 +- src/polygon.cpp | 69 +- src/polygon.hpp | 59 +- src/protocol.cpp | 38 +- src/serialization.hpp | 69 +- src/session.cpp | 4 +- src/statement.cpp | 103 +- src/tuple.cpp | 32 +- src/user_type_value.cpp | 113 +- src/validate.hpp | 6 +- src/value.cpp | 27 +- src/wkt.cpp | 607 ++--- src/wkt.hpp | 43 +- tests/src/integration/dse_integration.cpp | 70 +- tests/src/integration/dse_integration.hpp | 28 +- tests/src/integration/dse_nullable_value.hpp | 26 +- tests/src/integration/dse_objects.hpp | 4 +- tests/src/integration/dse_values.hpp | 8 +- tests/src/integration/embedded_ads.hpp | 122 +- tests/src/integration/main.cpp | 30 +- tests/src/integration/objects/dse_cluster.hpp | 51 +- .../integration/objects/dse_graph_array.hpp | 62 +- .../integration/objects/dse_graph_edge.cpp | 12 +- .../integration/objects/dse_graph_edge.hpp | 10 +- .../integration/objects/dse_graph_object.hpp | 87 +- .../integration/objects/dse_graph_options.hpp | 14 +- .../integration/objects/dse_graph_path.cpp | 8 +- .../integration/objects/dse_graph_path.hpp | 10 +- .../integration/objects/dse_graph_result.hpp | 78 +- .../objects/dse_graph_result_set.hpp | 37 +- .../objects/dse_graph_statement.hpp | 20 +- .../integration/objects/dse_graph_vertex.cpp | 12 +- .../integration/objects/dse_graph_vertex.hpp | 10 +- tests/src/integration/objects/dse_session.hpp | 70 +- .../src/integration/objects/dse_statement.hpp | 24 +- tests/src/integration/tests/test_auth.cpp | 98 +- .../src/integration/tests/test_dse_types.cpp | 224 +- .../tests/test_dse_types_graph.cpp | 24 +- tests/src/integration/tests/test_graph.cpp | 108 +- .../tests/test_graph_consistency.cpp | 20 +- .../tests/test_graph_data_type.cpp | 116 +- .../src/integration/tests/test_graph_olap.cpp | 47 +- .../src/integration/tests/test_proxy_auth.cpp | 168 +- .../src/integration/values/dse_date_range.hpp | 98 +- .../integration/values/dse_line_string.hpp | 81 +- tests/src/integration/values/dse_point.hpp | 78 +- tests/src/integration/values/dse_polygon.hpp | 83 +- tests/src/unit/main.cpp | 75 +- tests/src/unit/tests/test_client_insights.cpp | 195 +- tests/src/unit/tests/test_graph_object.cpp | 32 +- tests/src/unit/tests/test_line_string.cpp | 49 +- tests/src/unit/tests/test_point.cpp | 2 +- tests/src/unit/tests/test_polygon.cpp | 83 +- .../src/unit/tests/test_protocol_version.cpp | 12 +- 569 files changed, 17783 insertions(+), 21836 deletions(-) diff --git a/cpp-driver/examples/async/async.c b/cpp-driver/examples/async/async.c index 50428510f..1c7382a75 100644 --- a/cpp-driver/examples/async/async.c +++ b/cpp-driver/examples/async/async.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -41,7 +41,6 @@ void print_error(CassFuture* future) { fprintf(stderr, "Error: %.*s\n", (int)message_length, message); } - CassCluster* create_cluster(const char* hosts) { CassCluster* cluster = cass_cluster_new(); cass_cluster_set_contact_points(cluster, hosts); @@ -90,7 +89,7 @@ void insert_into_async(CassSession* session, const char* key) { size_t i; for (i = 0; i < NUM_CONCURRENT_REQUESTS; ++i) { - char key_buffer[64]; + char key_buffer[64]; statement = cass_statement_new(query, 6); sprintf(key_buffer, "%s%u", key, (unsigned int)i); @@ -135,13 +134,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.async (key text, \ + execute_query(session, "CREATE TABLE examples.async (key text, \ bln boolean, \ flt float, dbl double,\ i32 int, i64 bigint, \ diff --git a/cpp-driver/examples/auth/auth.c b/cpp-driver/examples/auth/auth.c index cdfa27bc7..7cc8491e3 100644 --- a/cpp-driver/examples/auth/auth.c +++ b/cpp-driver/examples/auth/auth.c @@ -35,8 +35,7 @@ typedef struct Credentials_ { const char* username; } Credentials; -void on_auth_initial(CassAuthenticator* auth, - void* data) { +void on_auth_initial(CassAuthenticator* auth, void* data) { /* * This callback is used to initiate a request to begin an authentication * exchange. Required resources can be acquired and initialized here. @@ -52,7 +51,7 @@ void on_auth_initial(CassAuthenticator* auth, * authentication callbacks were set and is available to all * authentication exchanges. */ - const Credentials* credentials = (const Credentials *)data; + const Credentials* credentials = (const Credentials*)data; size_t username_size = strlen(credentials->username); size_t password_size = strlen(credentials->password); @@ -68,20 +67,14 @@ void on_auth_initial(CassAuthenticator* auth, memcpy(response + username_size + 2, credentials->password, password_size); } -void on_auth_challenge(CassAuthenticator* auth, - void* data, - const char* token, - size_t token_size) { +void on_auth_challenge(CassAuthenticator* auth, void* data, const char* token, size_t token_size) { /* * Not used for plain text authentication, but this is to be used * for handling an authentication challenge initiated by the server. */ } -void on_auth_success(CassAuthenticator* auth, - void* data, - const char* token, - size_t token_size ) { +void on_auth_success(CassAuthenticator* auth, void* data, const char* token, size_t token_size) { /* * Not used for plain text authentication, but this is to be used * for handling the success phase of an exchange. @@ -104,17 +97,10 @@ int main(int argc, char* argv[]) { char* hosts = "127.0.0.1,127.0.0.2,127.0.0.3"; /* Setup authentication callbacks and credentials */ - CassAuthenticatorCallbacks auth_callbacks = { - on_auth_initial, - on_auth_challenge, - on_auth_success, - on_auth_cleanup - }; - - Credentials credentials = { - "cassandra", - "cassandra" - }; + CassAuthenticatorCallbacks auth_callbacks = { on_auth_initial, on_auth_challenge, on_auth_success, + on_auth_cleanup }; + + Credentials credentials = { "cassandra", "cassandra" }; /* Add contact points */ if (argc > 1) { @@ -123,10 +109,7 @@ int main(int argc, char* argv[]) { cass_cluster_set_contact_points(cluster, hosts); /* Set custom authentication callbacks and credentials */ - cass_cluster_set_authenticator_callbacks(cluster, - &auth_callbacks, - NULL, - &credentials); + cass_cluster_set_authenticator_callbacks(cluster, &auth_callbacks, NULL, &credentials); /* Provide the cluster object as configuration to connect the session */ connect_future = cass_session_connect(session, cluster); @@ -138,8 +121,7 @@ int main(int argc, char* argv[]) { const char* message; size_t message_length; cass_future_error_message(connect_future, &message, &message_length); - fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, - message); + fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message); } cass_future_free(connect_future); diff --git a/cpp-driver/examples/basic/basic.c b/cpp-driver/examples/basic/basic.c index 60cea5566..29fb73f71 100644 --- a/cpp-driver/examples/basic/basic.c +++ b/cpp-driver/examples/basic/basic.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -92,7 +92,8 @@ CassError insert_into_basic(CassSession* session, const char* key, const Basic* CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; - const char* query = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; + const char* query = + "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; statement = cass_statement_new(query, 6); @@ -175,13 +176,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.basic (key text, \ + execute_query(session, "CREATE TABLE examples.basic (key text, \ bln boolean, \ flt float, dbl double,\ i32 int, i64 bigint, \ diff --git a/cpp-driver/examples/batch/batch.c b/cpp-driver/examples/batch/batch.c index e91296e93..e1b0efb9b 100644 --- a/cpp-driver/examples/batch/batch.c +++ b/cpp-driver/examples/batch/batch.c @@ -26,15 +26,15 @@ */ #include -#include #include #include +#include #include "cassandra.h" struct Pair_ { - const char* key; - const char* value; + const char* key; + const char* value; }; typedef struct Pair_ Pair; @@ -105,7 +105,8 @@ CassError prepare_insert_into_batch(CassSession* session, const CassPrepared** p return rc; } -CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepared* prepared, const Pair* pairs) { +CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepared* prepared, + const Pair* pairs) { CassError rc = CASS_OK; CassFuture* future = NULL; CassBatch* batch = cass_batch_new(CASS_BATCH_TYPE_LOGGED); @@ -120,13 +121,15 @@ CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepar } { - CassStatement* statement = cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES ('c', '3')", 0); + CassStatement* statement = + cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES ('c', '3')", 0); cass_batch_add_statement(batch, statement); cass_statement_free(statement); } { - CassStatement* statement = cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES (?, ?)", 2); + CassStatement* statement = + cass_statement_new("INSERT INTO examples.pairs (key, value) VALUES (?, ?)", 2); cass_statement_bind_string(statement, 0, "d"); cass_statement_bind_string(statement, 1, "4"); cass_batch_add_statement(batch, statement); @@ -147,14 +150,13 @@ CassError insert_into_batch_with_prepared(CassSession* session, const CassPrepar return rc; } - int main(int argc, char* argv[]) { CassCluster* cluster = NULL; CassSession* session = cass_session_new(); const CassPrepared* prepared = NULL; char* hosts = "127.0.0.1"; - Pair pairs[] = { {"a", "1"}, {"b", "2"}, { NULL, NULL} }; + Pair pairs[] = { { "a", "1" }, { "b", "2" }, { NULL, NULL } }; if (argc > 1) { hosts = argv[1]; @@ -167,13 +169,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.pairs (key text, \ + execute_query(session, "CREATE TABLE examples.pairs (key text, \ value text, \ PRIMARY KEY (key));"); diff --git a/cpp-driver/examples/bind_by_name/bind_by_name.c b/cpp-driver/examples/bind_by_name/bind_by_name.c index b364ba1ce..c5d7c2b83 100644 --- a/cpp-driver/examples/bind_by_name/bind_by_name.c +++ b/cpp-driver/examples/bind_by_name/bind_by_name.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -106,7 +106,8 @@ CassError prepare_query(CassSession* session, const char* query, const CassPrepa return rc; } -CassError insert_into_basic(CassSession* session, const CassPrepared* prepared, const char* key, const Basic* basic) { +CassError insert_into_basic(CassSession* session, const CassPrepared* prepared, const char* key, + const Basic* basic) { CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; @@ -135,7 +136,8 @@ CassError insert_into_basic(CassSession* session, const CassPrepared* prepared, return rc; } -CassError select_from_basic(CassSession* session, const CassPrepared * prepared, const char* key, Basic* basic) { +CassError select_from_basic(CassSession* session, const CassPrepared* prepared, const char* key, + Basic* basic) { CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; @@ -183,10 +185,9 @@ int main(int argc, char* argv[]) { const CassPrepared* select_prepared = NULL; char* hosts = "127.0.0.1"; - const char* insert_query - = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; - const char* select_query - = "SELECT * FROM examples.basic WHERE key = ?"; + const char* insert_query = + "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; + const char* select_query = "SELECT * FROM examples.basic WHERE key = ?"; if (argc > 1) { hosts = argv[1]; @@ -199,25 +200,21 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.basic (key text, \ + execute_query(session, "CREATE TABLE examples.basic (key text, \ bln boolean, \ flt float, dbl double,\ i32 int, i64 bigint, \ PRIMARY KEY (key));"); - if (prepare_query(session, insert_query, &insert_prepared) == CASS_OK) { insert_into_basic(session, insert_prepared, "prepared_test", &input); cass_prepared_free(insert_prepared); } - if (prepare_query(session, select_query, &select_prepared) == CASS_OK) { + if (prepare_query(session, select_query, &select_prepared) == CASS_OK) { select_from_basic(session, select_prepared, "prepared_test", &output); assert(input.bln == output.bln); diff --git a/cpp-driver/examples/callbacks/callbacks.c b/cpp-driver/examples/callbacks/callbacks.c index 28ae3bdbd..d388dcd8e 100644 --- a/cpp-driver/examples/callbacks/callbacks.c +++ b/cpp-driver/examples/callbacks/callbacks.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include @@ -76,14 +76,14 @@ CassCluster* create_cluster(const char* hosts) { return cluster; } -void connect_session(CassSession* session, const CassCluster* cluster, CassFutureCallback callback) { +void connect_session(CassSession* session, const CassCluster* cluster, + CassFutureCallback callback) { CassFuture* future = cass_session_connect(session, cluster); cass_future_set_callback(future, callback, session); cass_future_free(future); } -void execute_query(CassSession* session, const char* query, - CassFutureCallback callback) { +void execute_query(CassSession* session, const char* query, CassFutureCallback callback) { CassStatement* statement = cass_statement_new(query, 0); CassFuture* future = cass_session_execute(session, statement); cass_future_set_callback(future, callback, session); @@ -113,9 +113,7 @@ void on_create_keyspace(CassFuture* future, void* data) { print_error(future); } - execute_query((CassSession*)data, - "USE examples", - on_set_keyspace); + execute_query((CassSession*)data, "USE examples", on_set_keyspace); } void on_set_keyspace(CassFuture* future, void* data) { @@ -163,10 +161,8 @@ void on_insert(CassFuture* future, void* data) { signal_exit(); } else { const char* select_query = "SELECT * FROM callbacks"; - CassStatement* statement - = cass_statement_new(select_query, 0); - CassFuture* select_future - = cass_session_execute((CassSession*)data, statement); + CassStatement* statement = cass_statement_new(select_query, 0); + CassFuture* select_future = cass_session_execute((CassSession*)data, statement); cass_future_set_callback(select_future, on_select, data); diff --git a/cpp-driver/examples/collections/collections.c b/cpp-driver/examples/collections/collections.c index cdfee3b0a..9256474b3 100644 --- a/cpp-driver/examples/collections/collections.c +++ b/cpp-driver/examples/collections/collections.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -175,16 +175,13 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '1' };"); - execute_query(session, - "CREATE TABLE examples.collections (key text, \ + execute_query(session, "CREATE TABLE examples.collections (key text, \ items set, \ PRIMARY KEY (key))"); - insert_into_collections(session, "test", items); select_from_collections(session, "test"); diff --git a/cpp-driver/examples/date_time/data_time.c b/cpp-driver/examples/date_time/data_time.c index 78d4b9e44..c721bedf3 100644 --- a/cpp-driver/examples/date_time/data_time.c +++ b/cpp-driver/examples/date_time/data_time.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include #include "cassandra.h" @@ -169,13 +169,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.date_time (key text PRIMARY KEY, d date, t time)"); + execute_query(session, "CREATE TABLE examples.date_time (key text PRIMARY KEY, d date, t time)"); insert_into(session, "test"); select_from(session, "test"); diff --git a/cpp-driver/examples/duration/duration.c b/cpp-driver/examples/duration/duration.c index 0dc34cf62..d9c161a2c 100644 --- a/cpp-driver/examples/duration/duration.c +++ b/cpp-driver/examples/duration/duration.c @@ -25,8 +25,8 @@ For more information, please refer to */ -#include #include "cassandra.h" +#include #define NANOS_IN_A_SEC (1000LL * 1000LL * 1000LL) @@ -76,7 +76,8 @@ CassError execute_query(CassSession* session, const char* query) { return rc; } -CassError insert_into(CassSession* session, const char* key, cass_int32_t months, cass_int32_t days, cass_int64_t nanos) { +CassError insert_into(CassSession* session, const char* key, cass_int32_t months, cass_int32_t days, + cass_int64_t nanos) { CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; @@ -156,14 +157,11 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = { " - "'class': 'SimpleStrategy', 'replication_factor': '3' };"); - + execute_query(session, "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = { " + "'class': 'SimpleStrategy', 'replication_factor': '3' };"); - execute_query(session, - "CREATE TABLE IF NOT EXISTS examples.duration " - "(key text PRIMARY KEY, d duration)"); + execute_query(session, "CREATE TABLE IF NOT EXISTS examples.duration " + "(key text PRIMARY KEY, d duration)"); /* Insert some rows into the table and read them back out */ diff --git a/cpp-driver/examples/execution_profiles/execution_profiles.c b/cpp-driver/examples/execution_profiles/execution_profiles.c index fbf322bc7..91b97546e 100644 --- a/cpp-driver/examples/execution_profiles/execution_profiles.c +++ b/cpp-driver/examples/execution_profiles/execution_profiles.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -98,9 +98,7 @@ CassError execute_query(CassSession* session, const char* query) { return rc; } -CassError insert_into_examples(CassSession* session, - const char* profile_name, - const char* key, +CassError insert_into_examples(CassSession* session, const char* profile_name, const char* key, const cass_bool_t value) { CassError rc = CASS_OK; CassStatement* statement = NULL; @@ -134,9 +132,7 @@ CassError insert_into_examples(CassSession* session, return rc; } -CassError select_from_examples(CassSession* session, - const char* profile_name, - const char* key, +CassError select_from_examples(CassSession* session, const char* profile_name, const char* key, cass_bool_t* return_value) { CassError rc = CASS_OK; CassStatement* statement = NULL; @@ -165,8 +161,7 @@ CassError select_from_examples(CassSession* session, if (row) { const CassValue* value = cass_row_get_column_by_name(row, "value"); cass_value_get_bool(value, return_value); - printf("SELECT: Key = %s | Value = %s\n", - key, + printf("SELECT: Key = %s | Value = %s\n", key, (*return_value == cass_true ? "true" : "false")); } @@ -195,14 +190,10 @@ int main(int argc, char* argv[]) { /* Create and set execution profiles; freeing once added to configuration */ profile = create_reduced_latency_write_execution_profile(); - cass_cluster_set_execution_profile(cluster, - "reduced_latency", - profile); + cass_cluster_set_execution_profile(cluster, "reduced_latency", profile); cass_execution_profile_free(profile); profile = create_quorum_execution_profile(); - cass_cluster_set_execution_profile(cluster, - "quorum", - profile); + cass_cluster_set_execution_profile(cluster, "quorum", profile); cass_execution_profile_free(profile); /* Provide the cluster object as configuration to connect the session */ @@ -213,12 +204,10 @@ int main(int argc, char* argv[]) { } /* Create a keyspace and table for the execution profile example */ - execute_query(session, - "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE IF NOT EXISTS examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' \ }"); - execute_query(session, - "CREATE TABLE IF NOT EXISTS examples.execution_profiles ( \ + execute_query(session, "CREATE TABLE IF NOT EXISTS examples.execution_profiles ( \ key text PRIMARY KEY, \ value boolean \ )"); diff --git a/cpp-driver/examples/host_listener/host_listener.c b/cpp-driver/examples/host_listener/host_listener.c index 6186a001c..e7b83ccc3 100644 --- a/cpp-driver/examples/host_listener/host_listener.c +++ b/cpp-driver/examples/host_listener/host_listener.c @@ -27,13 +27,10 @@ #include - #include #include -void on_signal(uv_signal_t* handle, int signum) { - uv_signal_stop(handle); -} +void on_signal(uv_signal_t* handle, int signum) { uv_signal_stop(handle); } void on_host_listener(CassHostListenerEvent event, CassInet inet, void* data); diff --git a/cpp-driver/examples/logging/logging.c b/cpp-driver/examples/logging/logging.c index edc0509c0..1643822fb 100644 --- a/cpp-driver/examples/logging/logging.c +++ b/cpp-driver/examples/logging/logging.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -61,12 +61,9 @@ CassError connect_session(CassSession* session, const CassCluster* cluster) { void on_log(const CassLogMessage* message, void* data) { FILE* log_file = (FILE*)data; - fprintf(log_file, "%u.%03u [%s] (%s:%d:%s): %s\n", - (unsigned int)(message->time_ms / 1000), - (unsigned int)(message->time_ms % 1000), - cass_log_level_string(message->severity), - message->file, message->line, message->function, - message->message); + fprintf(log_file, "%u.%03u [%s] (%s:%d:%s): %s\n", (unsigned int)(message->time_ms / 1000), + (unsigned int)(message->time_ms % 1000), cass_log_level_string(message->severity), + message->file, message->line, message->function, message->message); } int main(int argc, char* argv[]) { diff --git a/cpp-driver/examples/maps/maps.c b/cpp-driver/examples/maps/maps.c index 2575b6081..b940c20b1 100644 --- a/cpp-driver/examples/maps/maps.c +++ b/cpp-driver/examples/maps/maps.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -139,9 +139,7 @@ CassError select_from_maps(CassSession* session, const char* key) { if (cass_result_row_count(result) > 0) { const CassRow* row = cass_result_first_row(result); - CassIterator* iterator - = cass_iterator_from_map( - cass_row_get_column(row, 0)); + CassIterator* iterator = cass_iterator_from_map(cass_row_get_column(row, 0)); while (cass_iterator_next(iterator)) { const char* key; @@ -168,7 +166,9 @@ int main(int argc, char* argv[]) { CassSession* session = cass_session_new(); char* hosts = "127.0.0.1"; - const Pair items[] = { { "apple", 1 }, { "orange", 2 }, { "banana", 3 }, { "mango", 4 }, { NULL, 0 } }; + const Pair items[] = { + { "apple", 1 }, { "orange", 2 }, { "banana", 3 }, { "mango", 4 }, { NULL, 0 } + }; if (argc > 1) { hosts = argv[1]; @@ -181,16 +181,13 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - execute_query(session, - "CREATE TABLE examples.maps (key text, \ + execute_query(session, "CREATE TABLE examples.maps (key text, \ items map, \ PRIMARY KEY (key))"); - insert_into_maps(session, "test", items); select_from_maps(session, "test"); diff --git a/cpp-driver/examples/named_parameters/named_parameters.c b/cpp-driver/examples/named_parameters/named_parameters.c index de6774fd0..67892f5b4 100644 --- a/cpp-driver/examples/named_parameters/named_parameters.c +++ b/cpp-driver/examples/named_parameters/named_parameters.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -92,8 +92,8 @@ CassError insert_into_basic(CassSession* session, const char* key, const Basic* CassStatement* statement = NULL; CassFuture* future = NULL; - const char* query - = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (:k, :b, :f, :d, :i32, :i64);"; + const char* query = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (:k, :b, " + ":f, :d, :i32, :i64);"; statement = cass_statement_new(query, 6); @@ -124,8 +124,7 @@ CassError select_from_basic(CassSession* session, const char* key, Basic* basic) CassStatement* statement = NULL; CassFuture* future = NULL; - const char* query - = "SELECT * FROM examples.basic WHERE key = ?"; + const char* query = "SELECT * FROM examples.basic WHERE key = ?"; statement = cass_statement_new(query, 1); @@ -178,19 +177,15 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.basic (key text, \ + execute_query(session, "CREATE TABLE examples.basic (key text, \ bln boolean, \ flt float, dbl double,\ i32 int, i64 bigint, \ PRIMARY KEY (key));"); - insert_into_basic(session, "named_parameters", &input); select_from_basic(session, "named_parameters", &output); diff --git a/cpp-driver/examples/paging/paging.c b/cpp-driver/examples/paging/paging.c index 5f46d6a2f..4276c02fa 100644 --- a/cpp-driver/examples/paging/paging.c +++ b/cpp-driver/examples/paging/paging.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -183,13 +183,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.paging (key timeuuid, \ + execute_query(session, "CREATE TABLE examples.paging (key timeuuid, \ value text, \ PRIMARY KEY (key));"); diff --git a/cpp-driver/examples/perf/perf.c b/cpp-driver/examples/perf/perf.c index 90004b8fb..ec90c2455 100644 --- a/cpp-driver/examples/perf/perf.c +++ b/cpp-driver/examples/perf/perf.c @@ -26,10 +26,10 @@ */ #include -#include +#include #include #include -#include +#include #include @@ -51,12 +51,12 @@ #if defined(_MSC_VER) && defined(_DEBUG) #include const DWORD MS_VC_EXCEPTION = 0x406D1388; -#pragma pack(push,8) +#pragma pack(push, 8) typedef struct tagTHREADNAME_INFO { - DWORD dwType; /* Must be 0x1000. */ - LPCSTR szName; /* Pointer to name (in user addr space). */ + DWORD dwType; /* Must be 0x1000. */ + LPCSTR szName; /* Pointer to name (in user addr space). */ DWORD dwThreadID; /* Thread ID (-1=caller thread). */ - DWORD dwFlags; /* Reserved for future use, must be zero. */ + DWORD dwFlags; /* Reserved for future use, must be zero. */ } THREADNAME_INFO; #pragma pack(pop) void set_thread_name(const char* thread_name) { @@ -66,13 +66,11 @@ void set_thread_name(const char* thread_name) { info.dwThreadID = -1; info.dwFlags = 0; #pragma warning(push) -#pragma warning(disable: 6320 6322) +#pragma warning(disable : 6320 6322) __try { - RaiseException(MS_VC_EXCEPTION, - 0, - sizeof(info) / sizeof(ULONG_PTR), - (ULONG_PTR*) &info); - } __except (EXCEPTION_EXECUTE_HANDLER) { } + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info); + } __except (EXCEPTION_EXECUTE_HANDLER) { + } #pragma warning(pop) } #endif @@ -256,7 +254,8 @@ void run_insert_queries(void* data) { CassSession* session = (CassSession*)data; const CassPrepared* insert_prepared = NULL; - const char* insert_query = "INSERT INTO stress.songs (id, title, album, artist, tags) VALUES (?, ?, ?, ?, ?);"; + const char* insert_query = + "INSERT INTO stress.songs (id, title, album, artist, tags) VALUES (?, ?, ?, ?, ?);"; #if USE_PREPARED if (prepare_query(session, insert_query, &insert_prepared) == CASS_OK) { @@ -310,11 +309,12 @@ void run_select_queries(void* data) { int i; CassSession* session = (CassSession*)data; const CassPrepared* select_prepared = NULL; - const char* select_query = "SELECT * FROM stress.songs WHERE id = a98d21b2-1900-11e4-b97b-e5e358e71e0d"; + const char* select_query = + "SELECT * FROM stress.songs WHERE id = a98d21b2-1900-11e4-b97b-e5e358e71e0d"; #if defined(_MSC_VER) && defined(_DEBUG) char thread_name[32]; - sprintf(thread_name, "Perf - %lu", (unsigned long) (GetThreadId(uv_thread_self()))); + sprintf(thread_name, "Perf - %lu", (unsigned long)(GetThreadId(uv_thread_self()))); set_thread_name(thread_name); #endif @@ -367,11 +367,11 @@ int main(int argc, char* argv[]) { "title text, album text, artist text, " "tags set, data blob)"); - execute_query(session, - "INSERT INTO stress.songs (id, title, album, artist, tags) VALUES " - "(a98d21b2-1900-11e4-b97b-e5e358e71e0d, " - "'La Petite Tonkinoise', 'Bye Bye Blackbird', 'Joséphine Baker', { 'jazz', '2013' });"); - + execute_query( + session, + "INSERT INTO stress.songs (id, title, album, artist, tags) VALUES " + "(a98d21b2-1900-11e4-b97b-e5e358e71e0d, " + "'La Petite Tonkinoise', 'Bye Bye Blackbird', 'Joséphine Baker', { 'jazz', '2013' });"); for (i = 0; i < NUM_THREADS; ++i) { #if DO_SELECTS @@ -383,19 +383,21 @@ int main(int argc, char* argv[]) { while (status_wait(&status, 5) > 0) { cass_session_get_metrics(session, &metrics); - printf("rate stats (requests/second): mean %f 1m %f 5m %f 10m %f\n", - metrics.requests.mean_rate, - metrics.requests.one_minute_rate, - metrics.requests.five_minute_rate, + printf("rate stats (requests/second): mean %f 1m %f 5m %f 10m %f\n", metrics.requests.mean_rate, + metrics.requests.one_minute_rate, metrics.requests.five_minute_rate, metrics.requests.fifteen_minute_rate); } cass_session_get_metrics(session, &metrics); - printf("final stats (microseconds): min %llu max %llu median %llu 75th %llu 95th %llu 98th %llu 99th %llu 99.9th %llu\n", + printf("final stats (microseconds): min %llu max %llu median %llu 75th %llu 95th %llu 98th %llu " + "99th %llu 99.9th %llu\n", (unsigned long long int)metrics.requests.min, (unsigned long long int)metrics.requests.max, - (unsigned long long int)metrics.requests.median, (unsigned long long int)metrics.requests.percentile_75th, - (unsigned long long int)metrics.requests.percentile_95th, (unsigned long long int)metrics.requests.percentile_98th, - (unsigned long long int)metrics.requests.percentile_99th, (unsigned long long int)metrics.requests.percentile_999th); + (unsigned long long int)metrics.requests.median, + (unsigned long long int)metrics.requests.percentile_75th, + (unsigned long long int)metrics.requests.percentile_95th, + (unsigned long long int)metrics.requests.percentile_98th, + (unsigned long long int)metrics.requests.percentile_99th, + (unsigned long long int)metrics.requests.percentile_999th); for (i = 0; i < NUM_THREADS; ++i) { uv_thread_join(&threads[i]); diff --git a/cpp-driver/examples/prepared/prepared.c b/cpp-driver/examples/prepared/prepared.c index a11a37686..6d21fff30 100644 --- a/cpp-driver/examples/prepared/prepared.c +++ b/cpp-driver/examples/prepared/prepared.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -91,7 +91,8 @@ CassError insert_into_basic(CassSession* session, const char* key, const Basic* CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; - const char* query = "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; + const char* query = + "INSERT INTO examples.basic (key, bln, flt, dbl, i32, i64) VALUES (?, ?, ?, ?, ?, ?);"; statement = cass_statement_new(query, 6); @@ -137,7 +138,8 @@ CassError prepare_select_from_basic(CassSession* session, const CassPrepared** p return rc; } -CassError select_from_basic(CassSession* session, const CassPrepared * prepared, const char* key, Basic* basic) { +CassError select_from_basic(CassSession* session, const CassPrepared* prepared, const char* key, + Basic* basic) { CassError rc = CASS_OK; CassStatement* statement = NULL; CassFuture* future = NULL; @@ -194,13 +196,10 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.basic (key text, \ + execute_query(session, "CREATE TABLE examples.basic (key text, \ bln boolean, \ flt float, dbl double,\ i32 int, i64 bigint, \ diff --git a/cpp-driver/examples/schema_meta/schema_meta.c b/cpp-driver/examples/schema_meta/schema_meta.c index 4647ef82e..7f0927833 100644 --- a/cpp-driver/examples/schema_meta/schema_meta.c +++ b/cpp-driver/examples/schema_meta/schema_meta.c @@ -25,8 +25,8 @@ For more information, please refer to */ -#include #include +#include void print_keyspace_meta(const CassKeyspaceMeta* meta, int indent); void print_table_meta(const CassTableMeta* meta, int indent); @@ -64,12 +64,14 @@ void print_table(CassSession* session, const char* keyspace, const char* table) cass_schema_meta_free(schema_meta); } -void print_function(CassSession* session, const char* keyspace, const char* function, const char* arguments) { +void print_function(CassSession* session, const char* keyspace, const char* function, + const char* arguments) { const CassSchemaMeta* schema_meta = cass_session_get_schema_meta(session); const CassKeyspaceMeta* keyspace_meta = cass_schema_meta_keyspace_by_name(schema_meta, keyspace); if (keyspace_meta != NULL) { - const CassFunctionMeta* function_meta = cass_keyspace_meta_function_by_name(keyspace_meta, function, arguments); + const CassFunctionMeta* function_meta = + cass_keyspace_meta_function_by_name(keyspace_meta, function, arguments); if (function_meta != NULL) { print_function_meta(function_meta, 0); } else { @@ -82,12 +84,14 @@ void print_function(CassSession* session, const char* keyspace, const char* func cass_schema_meta_free(schema_meta); } -void print_aggregate(CassSession* session, const char* keyspace, const char* aggregate, const char* arguments) { +void print_aggregate(CassSession* session, const char* keyspace, const char* aggregate, + const char* arguments) { const CassSchemaMeta* schema_meta = cass_session_get_schema_meta(session); const CassKeyspaceMeta* keyspace_meta = cass_schema_meta_keyspace_by_name(schema_meta, keyspace); if (keyspace_meta != NULL) { - const CassAggregateMeta* aggregate_meta = cass_keyspace_meta_aggregate_by_name(keyspace_meta, aggregate, arguments); + const CassAggregateMeta* aggregate_meta = + cass_keyspace_meta_aggregate_by_name(keyspace_meta, aggregate, arguments); if (aggregate_meta != NULL) { print_aggregate_meta(aggregate_meta, 0); } else { @@ -144,23 +148,19 @@ int main(int argc, char* argv[]) { execute_query(session, "DROP KEYSPACE IF EXISTS examples;"); - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' }"); print_keyspace(session, "examples"); - execute_query(session, - "CREATE TABLE examples.schema_meta (key text, \ + execute_query(session, "CREATE TABLE examples.schema_meta (key text, \ value bigint, \ PRIMARY KEY (key))"); - execute_query(session, - "CREATE INDEX schema_meta_idx \ + execute_query(session, "CREATE INDEX schema_meta_idx \ ON examples.schema_meta (value)"); - execute_query(session, - "CREATE FUNCTION \ + execute_query(session, "CREATE FUNCTION \ examples.avg_state(state tuple, val int) \ CALLED ON NULL INPUT RETURNS tuple \ LANGUAGE java AS \ @@ -169,8 +169,7 @@ int main(int argc, char* argv[]) { state.setLong(1, state.getLong(1) + val.intValue()); \ } \ return state;'"); - execute_query(session, - "CREATE FUNCTION \ + execute_query(session, "CREATE FUNCTION \ examples.avg_final (state tuple) \ CALLED ON NULL INPUT RETURNS double \ LANGUAGE java AS \ @@ -180,8 +179,7 @@ int main(int argc, char* argv[]) { r /= state.getInt(0); \ return Double.valueOf(r);'"); - execute_query(session, - "CREATE AGGREGATE examples.average(int) \ + execute_query(session, "CREATE AGGREGATE examples.average(int) \ SFUNC avg_state STYPE tuple FINALFUNC avg_final \ INITCOND(0, 0)"); @@ -292,7 +290,8 @@ void print_schema_bytes(const CassValue* value) { cass_value_get_bytes(value, &bytes, &b_length); printf("0x"); - for (i = 0; i < b_length; ++i) printf("%02x", bytes[i]); + for (i = 0; i < b_length; ++i) + printf("%02x", bytes[i]); } void print_schema_list(const CassValue* value) { diff --git a/cpp-driver/examples/simple/simple.c b/cpp-driver/examples/simple/simple.c index 93fd86209..bd7176707 100644 --- a/cpp-driver/examples/simple/simple.c +++ b/cpp-driver/examples/simple/simple.c @@ -25,8 +25,8 @@ For more information, please refer to */ -#include #include +#include int main(int argc, char* argv[]) { /* Setup and connect to cluster */ @@ -62,8 +62,7 @@ int main(int argc, char* argv[]) { const char* release_version; size_t release_version_length; cass_value_get_string(value, &release_version, &release_version_length); - printf("release_version: '%.*s'\n", (int)release_version_length, - release_version); + printf("release_version: '%.*s'\n", (int)release_version_length, release_version); } cass_result_free(result); @@ -72,8 +71,7 @@ int main(int argc, char* argv[]) { const char* message; size_t message_length; cass_future_error_message(result_future, &message, &message_length); - fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length, - message); + fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length, message); } cass_statement_free(statement); @@ -83,8 +81,7 @@ int main(int argc, char* argv[]) { const char* message; size_t message_length; cass_future_error_message(connect_future, &message, &message_length); - fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, - message); + fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message); } cass_future_free(connect_future); diff --git a/cpp-driver/examples/ssl/ssl.c b/cpp-driver/examples/ssl/ssl.c index 3cc7d68af..c6c4b6b1d 100644 --- a/cpp-driver/examples/ssl/ssl.c +++ b/cpp-driver/examples/ssl/ssl.c @@ -25,9 +25,9 @@ For more information, please refer to */ -#include -#include #include +#include +#include int load_trusted_cert_file(const char* file, CassSsl* ssl) { CassError rc; @@ -35,7 +35,7 @@ int load_trusted_cert_file(const char* file, CassSsl* ssl) { long cert_size; size_t bytes_read; - FILE *in = fopen(file, "rb"); + FILE* in = fopen(file, "rb"); if (in == NULL) { fprintf(stderr, "Error loading certificate file '%s'\n", file); return 0; @@ -49,7 +49,7 @@ int load_trusted_cert_file(const char* file, CassSsl* ssl) { bytes_read = fread(cert, 1, cert_size, in); fclose(in); - if (bytes_read == (size_t) cert_size) { + if (bytes_read == (size_t)cert_size) { rc = cass_ssl_add_trusted_cert_n(ssl, cert, cert_size); if (rc != CASS_OK) { fprintf(stderr, "Error loading SSL certificate: %s\n", cass_error_desc(rc)); @@ -105,8 +105,7 @@ int main(int argc, char* argv[]) { const char* release_version; size_t release_version_length; cass_value_get_string(value, &release_version, &release_version_length); - printf("release_version: '%.*s'\n", (int)release_version_length, - release_version); + printf("release_version: '%.*s'\n", (int)release_version_length, release_version); } cass_result_free(result); @@ -115,19 +114,17 @@ int main(int argc, char* argv[]) { const char* message; size_t message_length; cass_future_error_message(result_future, &message, &message_length); - fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length, - message); + fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length, message); } cass_statement_free(statement); cass_future_free(result_future); } else { - /* Handle error */ - const char* message; - size_t message_length; - cass_future_error_message(connect_future, &message, &message_length); - fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, - message); + /* Handle error */ + const char* message; + size_t message_length; + cass_future_error_message(connect_future, &message, &message_length); + fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message); } cass_future_free(connect_future); diff --git a/cpp-driver/examples/tracing/tracing.c b/cpp-driver/examples/tracing/tracing.c index 573b20d3f..4c4c94091 100644 --- a/cpp-driver/examples/tracing/tracing.c +++ b/cpp-driver/examples/tracing/tracing.c @@ -25,8 +25,8 @@ For more information, please refer to */ -#include #include +#include void print_error(const char* context, CassFuture* future) { const char* message; @@ -35,9 +35,7 @@ void print_error(const char* context, CassFuture* future) { fprintf(stderr, "%s: %.*s\n", context, (int)message_length, message); } -const CassResult* run_tracing_query(CassSession* session, - const char* query, - CassUuid tracing_id) { +const CassResult* run_tracing_query(CassSession* session, const char* query, CassUuid tracing_id) { CassError rc = CASS_OK; CassFuture* future = NULL; const CassResult* result = NULL; @@ -74,8 +72,7 @@ void print_tracing_data(CassSession* session, CassFuture* future) { /* Query the tracing tables using the retrieved tracing ID */ /* Get information for the tracing session */ - result = run_tracing_query(session, - "SELECT * FROM system_traces.sessions WHERE session_id = ?", + result = run_tracing_query(session, "SELECT * FROM system_traces.sessions WHERE session_id = ?", tracing_id); if (result) { @@ -86,13 +83,10 @@ void print_tracing_data(CassSession* session, CassFuture* future) { const CassRow* row = cass_result_first_row(result); /* Get the command type that was run and how long it took */ - cass_value_get_string(cass_row_get_column_by_name(row, "command"), - &command, &command_length); - cass_value_get_int32(cass_row_get_column_by_name(row, "duration"), - &duration); + cass_value_get_string(cass_row_get_column_by_name(row, "command"), &command, &command_length); + cass_value_get_int32(cass_row_get_column_by_name(row, "duration"), &duration); - printf("Request command \"%.*s\" took %f milliseconds:\n", - (int)command_length, command, + printf("Request command \"%.*s\" took %f milliseconds:\n", (int)command_length, command, duration / 1000.0); } @@ -100,8 +94,7 @@ void print_tracing_data(CassSession* session, CassFuture* future) { } /* Get the events that happened during the tracing session */ - result = run_tracing_query(session, - "SELECT * FROM system_traces.events WHERE session_id = ?", + result = run_tracing_query(session, "SELECT * FROM system_traces.events WHERE session_id = ?", tracing_id); if (result) { @@ -120,18 +113,14 @@ void print_tracing_data(CassSession* session, CassFuture* future) { /* Get the activity for the event which host happened on, and how long * it took. */ - cass_value_get_string(cass_row_get_column_by_name(row, "activity"), - &activity, &activity_length); - cass_value_get_inet(cass_row_get_column_by_name(row, "source"), - &source); - cass_value_get_int32(cass_row_get_column_by_name(row, "source_elapsed"), - &source_elapsed); + cass_value_get_string(cass_row_get_column_by_name(row, "activity"), &activity, + &activity_length); + cass_value_get_inet(cass_row_get_column_by_name(row, "source"), &source); + cass_value_get_int32(cass_row_get_column_by_name(row, "source_elapsed"), &source_elapsed); cass_inet_string(source, source_str); - printf("%2d) Event on host %s (%f milliseconds): \"%.*s\"\n", - event_count++, - source_str, source_elapsed / 1000.0, - (int)activity_length, activity); + printf("%2d) Event on host %s (%f milliseconds): \"%.*s\"\n", event_count++, source_str, + source_elapsed / 1000.0, (int)activity_length, activity); } cass_iterator_free(iterator); @@ -181,8 +170,7 @@ int main(int argc, char* argv[]) { const char* release_version; size_t release_version_length; cass_value_get_string(value, &release_version, &release_version_length); - printf("release_version: '%.*s'\n", (int)release_version_length, - release_version); + printf("release_version: '%.*s'\n", (int)release_version_length, release_version); } else { printf("No rows returned\n"); } diff --git a/cpp-driver/examples/tuple/tuple.c b/cpp-driver/examples/tuple/tuple.c index 516586c5b..d2522792d 100644 --- a/cpp-driver/examples/tuple/tuple.c +++ b/cpp-driver/examples/tuple/tuple.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -160,7 +160,7 @@ CassError select_from_tuple(CassSession* session) { result = cass_future_get_result(future); rows = cass_iterator_from_result(result); - while(cass_iterator_next(rows)) { + while (cass_iterator_next(rows)) { CassUuid id; char id_str[CASS_UUID_STRING_LENGTH]; const CassRow* row = cass_iterator_get_row(rows); @@ -173,7 +173,7 @@ CassError select_from_tuple(CassSession* session) { printf("id %s ", id_str); - while(cass_iterator_next(item)) { + while (cass_iterator_next(item)) { const CassValue* value = cass_iterator_get_value(item); if (!cass_value_is_null(value)) { @@ -224,12 +224,11 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' }"); - execute_query(session, - "CREATE TABLE examples.tuples (id timeuuid, item frozen>, PRIMARY KEY(id))"); + execute_query(session, "CREATE TABLE examples.tuples (id timeuuid, item frozen>, PRIMARY KEY(id))"); insert_into_tuple(session); select_from_tuple(session); diff --git a/cpp-driver/examples/udt/udt.c b/cpp-driver/examples/udt/udt.c index f49c76daf..391deb3bb 100644 --- a/cpp-driver/examples/udt/udt.c +++ b/cpp-driver/examples/udt/udt.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -166,7 +166,7 @@ CassError select_from_udt(CassSession* session) { result = cass_future_get_result(future); rows = cass_iterator_from_result(result); - while(cass_iterator_next(rows)) { + while (cass_iterator_next(rows)) { CassUuid id; char id_str[CASS_UUID_STRING_LENGTH]; const CassRow* row = cass_iterator_get_row(rows); @@ -179,7 +179,7 @@ CassError select_from_udt(CassSession* session) { printf("id %s ", id_str); - while(fields != NULL && cass_iterator_next(fields)) { + while (fields != NULL && cass_iterator_next(fields)) { const char* field_name; size_t field_name_length; const CassValue* field_value = NULL; @@ -204,7 +204,8 @@ CassError select_from_udt(CassSession* session) { CassIterator* phone_fields = cass_iterator_fields_from_user_type(phone_value); assert(cass_value_type(phone_value) == CASS_VALUE_TYPE_UDT); while (cass_iterator_next(phone_fields)) { - const CassValue* phone_number_value = cass_iterator_get_user_type_field_value(phone_fields); + const CassValue* phone_number_value = + cass_iterator_get_user_type_field_value(phone_fields); cass_int32_t i; cass_value_get_int32(phone_number_value, &i); printf("%d ", i); @@ -248,18 +249,16 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' }"); - execute_query(session, - "CREATE TYPE examples.phone_numbers (phone1 int, phone2 int)"); + execute_query(session, "CREATE TYPE examples.phone_numbers (phone1 int, phone2 int)"); - execute_query(session, - "CREATE TYPE examples.address (street text, city text, zip int, phone set>)"); + execute_query(session, "CREATE TYPE examples.address (street text, city text, zip int, phone " + "set>)"); - execute_query(session, - "CREATE TABLE examples.udt (id timeuuid, address frozen
, PRIMARY KEY(id))"); + execute_query( + session, "CREATE TABLE examples.udt (id timeuuid, address frozen
, PRIMARY KEY(id))"); schema_meta = cass_session_get_schema_meta(session); diff --git a/cpp-driver/examples/uuids/uuids.c b/cpp-driver/examples/uuids/uuids.c index 36e5c2cbd..7161ec06f 100644 --- a/cpp-driver/examples/uuids/uuids.c +++ b/cpp-driver/examples/uuids/uuids.c @@ -26,9 +26,9 @@ */ #include -#include #include #include +#include #include "cassandra.h" @@ -150,9 +150,7 @@ CassError select_from_log(CassSession* session, const char* key) { cass_uuid_string(time, time_str); - printf("%.*s %s %.*s\n", (int)key_length, key, - time_str, - (int)entry_length, entry); + printf("%.*s %s %.*s\n", (int)key_length, key, time_str, (int)entry_length, entry); } cass_result_free(result); @@ -182,16 +180,12 @@ int main(int argc, char* argv[]) { return -1; } - execute_query(session, - "CREATE KEYSPACE examples WITH replication = { \ + execute_query(session, "CREATE KEYSPACE examples WITH replication = { \ 'class': 'SimpleStrategy', 'replication_factor': '3' };"); - - execute_query(session, - "CREATE TABLE examples.log (key text, time timeuuid, entry text, \ + execute_query(session, "CREATE TABLE examples.log (key text, time timeuuid, entry text, \ PRIMARY KEY (key, time));"); - cass_uuid_gen_time(uuid_gen, &uuid); insert_into_log(session, "test", uuid, "Log entry #1"); diff --git a/cpp-driver/gtests/src/integration/bignumber.hpp b/cpp-driver/gtests/src/integration/bignumber.hpp index 5caf8f99a..9b4dfe80a 100644 --- a/cpp-driver/gtests/src/integration/bignumber.hpp +++ b/cpp-driver/gtests/src/integration/bignumber.hpp @@ -24,8 +24,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Helper class for working with Java byte arrays (e.g. BigInteger and @@ -34,11 +33,11 @@ namespace driver { class BigNumber { public: BigNumber() - : scale_(0) { } + : scale_(0) {} BigNumber(const std::string& big_number) - : big_number_(BN_new()) - , scale_(0) { + : big_number_(BN_new()) + , scale_(0) { BIGNUM* bignum = big_number_.get(); std::string copy = test::Utils::trim(big_number); @@ -61,8 +60,8 @@ class BigNumber { } BigNumber(const unsigned char* bytes, size_t bytes_length, int32_t scale) - : big_number_(BN_new()) - , scale_(scale) { + : big_number_(BN_new()) + , scale_(scale) { if (bytes && bytes_length > 0) { // Determine if value is negative and handle two's complement bool is_negative = ((bytes[0] & 0x80) != 0); @@ -141,9 +140,7 @@ class BigNumber { * * @return Scale for number */ - int32_t scale() const { - return scale_; - } + int32_t scale() const { return scale_; } /** * Get the string representation of the big number @@ -158,7 +155,7 @@ class BigNumber { result.assign(decimal); OPENSSL_free(decimal); - //Normalize - strip leading zeros + // Normalize - strip leading zeros result.erase(0, result.find_first_not_of('0')); if (result.size() == 0) { result = "0"; @@ -167,9 +164,7 @@ class BigNumber { // Return the value as integer or decimal (depending) if (scale_ > 0) { size_t decimal_location = result.size() - scale_; - return result.substr(0, decimal_location) - + "." - + result.substr(decimal_location); + return result.substr(0, decimal_location) + "." + result.substr(decimal_location); } return result; } @@ -217,7 +212,6 @@ class BigNumber { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_BIG_NUMBER_HPP__ diff --git a/cpp-driver/gtests/src/integration/driver_utils.cpp b/cpp-driver/gtests/src/integration/driver_utils.cpp index 8ceabc4e4..b507d3e87 100644 --- a/cpp-driver/gtests/src/integration/driver_utils.cpp +++ b/cpp-driver/gtests/src/integration/driver_utils.cpp @@ -27,8 +27,7 @@ using namespace datastax::internal; using namespace datastax::internal::core; -std::vector test::driver::internals::Utils::attempted_hosts( - CassFuture* future) { +std::vector test::driver::internals::Utils::attempted_hosts(CassFuture* future) { std::vector attempted_hosts; if (future) { Future* cass_future = static_cast(future); @@ -36,7 +35,7 @@ std::vector test::driver::internals::Utils::attempted_hosts( ResponseFuture* response = static_cast(cass_future); AddressVec attempted_addresses = response->attempted_addresses(); for (AddressVec::iterator iterator = attempted_addresses.begin(); - iterator != attempted_addresses.end(); ++iterator) { + iterator != attempted_addresses.end(); ++iterator) { attempted_hosts.push_back(iterator->to_string().c_str()); } std::sort(attempted_hosts.begin(), attempted_hosts.end()); @@ -51,8 +50,7 @@ unsigned int test::driver::internals::Utils::connect_timeout(CassCluster* cluste std::string test::driver::internals::Utils::contact_points(CassCluster* cluster) { std::string contact_points; - const ContactPointList& contact_points_list = - cluster->config().contact_points(); + const ContactPointList& contact_points_list = cluster->config().contact_points(); for (ContactPointList::const_iterator it = contact_points_list.begin(); it != contact_points_list.end(); ++it) { if (contact_points.size() > 0) { @@ -81,19 +79,15 @@ std::string test::driver::internals::Utils::host(CassFuture* future) { return ""; } -int64_t test::driver::internals::Utils::murmur3_hash( - const std::string& value) { +int64_t test::driver::internals::Utils::murmur3_hash(const std::string& value) { return MurmurHash3_x64_128(value.data(), value.size(), 0); } -int test::driver::internals::Utils::port(CassCluster* cluster) { - return cluster->config().port(); -} +int test::driver::internals::Utils::port(CassCluster* cluster) { return cluster->config().port(); } -void test::driver::internals::Utils::set_record_attempted_hosts( - CassStatement* statement, bool enable) { +void test::driver::internals::Utils::set_record_attempted_hosts(CassStatement* statement, + bool enable) { if (statement) { - static_cast(statement) - ->set_record_attempted_addresses(enable); + static_cast(statement)->set_record_attempted_addresses(enable); } } diff --git a/cpp-driver/gtests/src/integration/driver_utils.hpp b/cpp-driver/gtests/src/integration/driver_utils.hpp index fd86730a3..f86620ef4 100644 --- a/cpp-driver/gtests/src/integration/driver_utils.hpp +++ b/cpp-driver/gtests/src/integration/driver_utils.hpp @@ -23,9 +23,7 @@ #include #include -namespace test { -namespace driver { -namespace internals { +namespace test { namespace driver { namespace internals { class Utils { public: @@ -101,8 +99,6 @@ class Utils { static void set_record_attempted_hosts(CassStatement* statement, bool enable); }; -} // namespace internals -} // namespace driver -} // namespace test +}}} // namespace test::driver::internals #endif // __TEST_DRIVER_UTILS_HPP__ diff --git a/cpp-driver/gtests/src/integration/exception.hpp b/cpp-driver/gtests/src/integration/exception.hpp index a0b32d669..2500d8991 100644 --- a/cpp-driver/gtests/src/integration/exception.hpp +++ b/cpp-driver/gtests/src/integration/exception.hpp @@ -35,7 +35,7 @@ class Exception : public std::runtime_error { * @param message Exception message */ Exception(const std::string& message) - : std::runtime_error(message) {} + : std::runtime_error(message) {} /** * Destructor @@ -55,8 +55,8 @@ class CassException : public Exception { * @param error_code Error code */ CassException(const std::string& message, const CassError error_code) - : Exception(message) - , error_code_(error_code) {} + : Exception(message) + , error_code_(error_code) {} /** * Exception class that contains an error code @@ -67,14 +67,14 @@ class CassException : public Exception { */ CassException(const std::string& message, const CassError error_code, const std::string& error_message) - : Exception(message) - , error_code_(error_code) - , error_message_(error_message) { } + : Exception(message) + , error_code_(error_code) + , error_message_(error_message) {} /** * Destructor */ - virtual ~CassException() throw() { } + virtual ~CassException() throw() {} /** * Get the error code associated with the exception @@ -88,9 +88,7 @@ class CassException : public Exception { * * @return Error description */ - const std::string error_description() { - return std::string(cass_error_desc(error_code())); - } + const std::string error_description() { return std::string(cass_error_desc(error_code())); } /** * Get the error message associated with the exception diff --git a/cpp-driver/gtests/src/integration/integration.cpp b/cpp-driver/gtests/src/integration/integration.cpp index 827d28f69..3d08f52ab 100644 --- a/cpp-driver/gtests/src/integration/integration.cpp +++ b/cpp-driver/gtests/src/integration/integration.cpp @@ -34,32 +34,32 @@ bool Integration::skipped_message_displayed_ = false; Integration::Integration() - : ccm_(NULL) - , session_() - , keyspace_name_("") - , table_name_("") - , system_schema_keyspaces_("system.schema_keyspaces") - , uuid_generator_() - , server_version_(Options::server_version()) - , number_dc1_nodes_(1) - , number_dc2_nodes_(0) - , replication_factor_(0) - , replication_strategy_("") - , contact_points_("") - , is_password_authenticator_(false) - , is_client_authentication_(false) - , is_ssl_(false) - , is_with_vnodes_(false) - , is_randomized_contact_points_(false) - , is_schema_metadata_(false) - , is_ccm_start_requested_(true) - , is_ccm_start_node_individually_(false) - , is_session_requested_(true) - , is_test_chaotic_(false) - , is_beta_protocol_(Options::is_beta_protocol()) - , protocol_version_(CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION) - , create_keyspace_query_("") - , start_time_(0ull) { + : ccm_(NULL) + , session_() + , keyspace_name_("") + , table_name_("") + , system_schema_keyspaces_("system.schema_keyspaces") + , uuid_generator_() + , server_version_(Options::server_version()) + , number_dc1_nodes_(1) + , number_dc2_nodes_(0) + , replication_factor_(0) + , replication_strategy_("") + , contact_points_("") + , is_password_authenticator_(false) + , is_client_authentication_(false) + , is_ssl_(false) + , is_with_vnodes_(false) + , is_randomized_contact_points_(false) + , is_schema_metadata_(false) + , is_ccm_start_requested_(true) + , is_ccm_start_node_individually_(false) + , is_session_requested_(true) + , is_test_chaotic_(false) + , is_beta_protocol_(Options::is_beta_protocol()) + , protocol_version_(CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION) + , create_keyspace_query_("") + , start_time_(0ull) { // Determine if the schema keyspaces table should be updated // TODO: Make cass_version (and dse_version) available for all tests CCM::CassVersion cass_version = server_version_; @@ -79,7 +79,7 @@ Integration::Integration() if (type_param) { std::vector tokens = explode(test_information->test_case_name(), '/'); for (std::vector::const_iterator iterator = tokens.begin(); - iterator < tokens.end(); ++iterator) { + iterator < tokens.end(); ++iterator) { std::string token = *iterator; // Determine if we are looking at the last token @@ -89,9 +89,7 @@ Integration::Integration() if (!(tokenStream >> number).fail()) { std::vector type_param_tokens = explode(type_param, ':'); size_t size = type_param_tokens.size(); - test_case_name_ += test::Utils::replace_all(type_param_tokens[size - 1], - ">", - ""); + test_case_name_ += test::Utils::replace_all(type_param_tokens[size - 1], ">", ""); } } else { test_case_name_ += token + "_"; @@ -110,7 +108,8 @@ Integration::Integration() Integration::~Integration() { try { session_.close(false); - } catch (...) {} + } catch (...) { + } // Reset the skipped message displayed state skipped_message_displayed_ = false; @@ -130,11 +129,9 @@ void Integration::SetUp() { } replication_strategy_ = default_replication_strategy(); - // Generate the keyspace query - create_keyspace_query_ = format_string(SIMPLE_KEYSPACE_FORMAT, - keyspace_name_.c_str(), - replication_strategy_.c_str()); + create_keyspace_query_ = + format_string(SIMPLE_KEYSPACE_FORMAT, keyspace_name_.c_str(), replication_strategy_.c_str()); // Create the data center nodes vector std::vector data_center_nodes; @@ -142,28 +139,19 @@ void Integration::SetUp() { data_center_nodes.push_back(number_dc2_nodes_); try { - //Create and start the CCM cluster (if not already created) - ccm_ = new CCM::Bridge(server_version_, - Options::use_git(), Options::branch_tag(), - Options::use_install_dir(), Options::install_dir(), - Options::is_dse(), dse_workload_, - Options::cluster_prefix(), - Options::dse_credentials(), - Options::dse_username(), Options::dse_password(), - Options::deployment_type(), Options::authentication_type(), - Options::host(), Options::port(), - Options::username(), Options::password(), - Options::public_key(), Options::private_key(), - Options::is_verbose_ccm()); - if (ccm_->create_cluster(data_center_nodes, - is_with_vnodes_, - is_password_authenticator_, - is_ssl_, - is_client_authentication_)) { + // Create and start the CCM cluster (if not already created) + ccm_ = new CCM::Bridge( + server_version_, Options::use_git(), Options::branch_tag(), Options::use_install_dir(), + Options::install_dir(), Options::is_dse(), dse_workload_, Options::cluster_prefix(), + Options::dse_credentials(), Options::dse_username(), Options::dse_password(), + Options::deployment_type(), Options::authentication_type(), Options::host(), + Options::port(), Options::username(), Options::password(), Options::public_key(), + Options::private_key(), Options::is_verbose_ccm()); + if (ccm_->create_cluster(data_center_nodes, is_with_vnodes_, is_password_authenticator_, + is_ssl_, is_client_authentication_)) { if (is_ccm_start_requested_) { if (is_ccm_start_node_individually_) { - for (unsigned short node = 1; - node <= (number_dc1_nodes_ + number_dc2_nodes_); ++node) { + for (unsigned short node = 1; node <= (number_dc1_nodes_ + number_dc2_nodes_); ++node) { if (is_password_authenticator_) { ccm_->start_node(node, "-Dcassandra.superuser_setup_delay_ms=0"); } else { @@ -181,8 +169,8 @@ void Integration::SetUp() { } // Generate the default contact points - contact_points_ = generate_contact_points(ccm_->get_ip_prefix(), - number_dc1_nodes_ + number_dc2_nodes_); + contact_points_ = + generate_contact_points(ccm_->get_ip_prefix(), number_dc1_nodes_ + number_dc2_nodes_); // Determine if the session connection should be established if (is_session_requested_ && is_ccm_start_requested_) { @@ -210,9 +198,9 @@ void Integration::TearDown() { std::stringstream use_keyspace_query; use_keyspace_query << "DROP KEYSPACE " << keyspace_name_; try { - session_.execute(use_keyspace_query.str(), CASS_CONSISTENCY_ANY, false, - false); - } catch (...) { } + session_.execute(use_keyspace_query.str(), CASS_CONSISTENCY_ANY, false, false); + } catch (...) { + } } // Determine if the CCM cluster should be destroyed @@ -230,13 +218,13 @@ std::string Integration::default_keyspace() { // Clean up the initial keyspace name (remove category information) keyspace_name_ = to_lower(test_case_name_) + "_" + to_lower(test_name_); - keyspace_name_ = replace_all(keyspace_name_, "tests", ""); //TODO: Rename integration tests (remove 's' or add 's') + keyspace_name_ = replace_all(keyspace_name_, "tests", + ""); // TODO: Rename integration tests (remove 's' or add 's') keyspace_name_ = replace_all(keyspace_name_, "test", ""); keyspace_name_ = replace_all(keyspace_name_, "integration", ""); - for (TestCategory::iterator iterator = TestCategory::begin(); - iterator != TestCategory::end(); ++iterator) { - keyspace_name_ = replace_all(keyspace_name_, - "_" + to_lower(iterator->name()) + "_", ""); + for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end(); + ++iterator) { + keyspace_name_ = replace_all(keyspace_name_, "_" + to_lower(iterator->name()) + "_", ""); } // Generate the keyspace name @@ -246,17 +234,15 @@ std::string Integration::default_keyspace() { unsigned short Integration::default_replication_factor() { // Calculate and return the default replication factor - return (number_dc1_nodes_ % 2 == 0) - ? number_dc1_nodes_ / 2 - : (number_dc1_nodes_ + 1) / 2; + return (number_dc1_nodes_ % 2 == 0) ? number_dc1_nodes_ / 2 : (number_dc1_nodes_ + 1) / 2; } std::string Integration::default_replication_strategy() { // Determine the replication strategy std::stringstream replication_strategy_s; if (number_dc2_nodes_ > 0) { - replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': " - << number_dc1_nodes_ << ", " << "'dc2': " << number_dc2_nodes_; + replication_strategy_s << "'NetworkTopologyStrategy', 'dc1': " << number_dc1_nodes_ << ", " + << "'dc2': " << number_dc2_nodes_; } else { replication_strategy_s << "'SimpleStrategy', 'replication_factor': "; @@ -279,10 +265,8 @@ std::string Integration::default_select_all() { } int64_t Integration::default_select_count() { - Result result = session_.execute(format_string(SELECT_COUNT_FORMAT, - table_name_.c_str())); - EXPECT_EQ(CASS_OK, result.error_code()) << "Unable to get Row Count: " - << result.error_message(); + Result result = session_.execute(format_string(SELECT_COUNT_FORMAT, table_name_.c_str())); + EXPECT_EQ(CASS_OK, result.error_code()) << "Unable to get Row Count: " << result.error_message(); return result.first_row().next().as().value(); } @@ -324,7 +308,8 @@ void Integration::connect(Cluster cluster) { } else { server_version_ = ccm_->get_cassandra_version(); } - TEST_LOG("Branch/Tag Option was Used: Retrieved server version is " << server_version_.to_string()); + TEST_LOG("Branch/Tag Option was Used: Retrieved server version is " + << server_version_.to_string()); } // Create the keyspace for the integration test @@ -346,21 +331,19 @@ void Integration::connect() { test::driver::Cluster Integration::default_cluster(bool is_with_default_contact_points /*= true*/) { // Create the default cluster object Cluster cluster = Cluster::build() - .with_randomized_contact_points(is_randomized_contact_points_) - .with_schema_metadata(is_schema_metadata_); + .with_randomized_contact_points(is_randomized_contact_points_) + .with_schema_metadata(is_schema_metadata_); if (is_with_default_contact_points) { cluster.with_contact_points(contact_points_); } - if (server_version_ >= "3.10" && - protocol_version_ == CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION) { + if (server_version_ >= "3.10" && protocol_version_ == CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION) { cluster.with_beta_protocol(is_beta_protocol_); } else { cluster.with_protocol_version(protocol_version_); } // Assign the execution profiles to the cluster object (if available) - for(ExecutionProfile::Map::iterator it = profiles_.begin(); - it != profiles_.end(); ++it) { + for (ExecutionProfile::Map::iterator it = profiles_.begin(); it != profiles_.end(); ++it) { cluster.with_execution_profile(it->first, it->second); } return cluster; @@ -369,7 +352,7 @@ test::driver::Cluster Integration::default_cluster(bool is_with_default_contact_ void Integration::enable_cluster_tracing(bool enable /*= true*/) { std::vector active_nodes = ccm_->cluster_ip_addresses(); for (std::vector::iterator iterator = active_nodes.begin(); - iterator != active_nodes.end(); ++iterator) { + iterator != active_nodes.end(); ++iterator) { // Get the node number from the IP address std::string node_ip_address = *iterator; std::stringstream node_value; @@ -382,8 +365,7 @@ void Integration::enable_cluster_tracing(bool enable /*= true*/) { } } -bool Integration::decommission_node(unsigned int node, - bool is_force /*= false */) { +bool Integration::decommission_node(unsigned int node, bool is_force /*= false */) { // Decommission the requested node bool status = ccm_->decommission_node(node, is_force); if (status) { @@ -401,9 +383,8 @@ bool Integration::start_node(unsigned int node) { // Stop the requested node if (ccm_->is_node_down(node, true)) { bool status = ccm_->start_node(node); - std::vector::iterator it = std::find(stopped_nodes_.begin(), - stopped_nodes_.end(), - node); + std::vector::iterator it = + std::find(stopped_nodes_.begin(), stopped_nodes_.end(), node); if (it != stopped_nodes_.end()) { stopped_nodes_.erase(it); } @@ -450,12 +431,10 @@ std::string Integration::format_string(const char* format, ...) const { return buffer; } -void Integration::maybe_shrink_name(std::string& name) -{ +void Integration::maybe_shrink_name(std::string& name) { if (name.size() > ENTITY_MAXIMUM_LENGTH) { // Update the name with a UUID (first portions of v4 UUID) - std::vector uuid_octets = explode( - uuid_generator_.generate_timeuuid().str(), '-'); + std::vector uuid_octets = explode(uuid_generator_.generate_timeuuid().str(), '-'); std::string id = uuid_octets[0] + uuid_octets[3]; name = name.substr(0, ENTITY_MAXIMUM_LENGTH - id.size()) + id; } @@ -463,8 +442,7 @@ void Integration::maybe_shrink_name(std::string& name) bool Integration::wait_for_logger(size_t expected_count) { start_timer(); - while (elapsed_time() < LOGGER_MAXIMUM_WAIT_TIME_MS - && logger_.count() < expected_count) { + while (elapsed_time() < LOGGER_MAXIMUM_WAIT_TIME_MS && logger_.count() < expected_count) { msleep(LOGGER_WAIT_FOR_NAP_MS); } return logger_.count() >= expected_count; diff --git a/cpp-driver/gtests/src/integration/integration.hpp b/cpp-driver/gtests/src/integration/integration.hpp index c88fee7a3..683803278 100644 --- a/cpp-driver/gtests/src/integration/integration.hpp +++ b/cpp-driver/gtests/src/integration/integration.hpp @@ -36,14 +36,12 @@ #include "values.hpp" // Macros for grouping tests together -#define GROUP_TEST_F(group_name, test_case, test_name) \ - TEST_F(test_case, group_name##_##test_name) +#define GROUP_TEST_F(group_name, test_case, test_name) TEST_F(test_case, group_name##_##test_name) #define GROUP_TYPED_TEST_P(group_name, test_case, test_name) \ TYPED_TEST_P(test_case, group_name##_##test_name) // Macros to use for grouping integration tests together -#define GROUP_INTEGRATION_TEST(server_type) \ - GROUP_CONCAT(Integration, server_type) +#define GROUP_INTEGRATION_TEST(server_type) GROUP_CONCAT(Integration, server_type) #define INTEGRATION_TEST_F(server_type, test_case, test_name) \ GROUP_TEST_F(Integration##_##server_type, test_case, test_name) #define INTEGRATION_TYPED_TEST_P(server_type, test_case, test_name) \ @@ -64,52 +62,50 @@ #define CASSANDRA_INTEGRATION_DISABLED_TYPED_TEST_P(test_case, test_name) \ INTEGRATION_DISABLED_TYPED_TEST_P(Cassandra, test_case, test_name) -//TODO: Create SKIP_SUITE macro; reduces noise and makes sense for certain suites +// TODO: Create SKIP_SUITE macro; reduces noise and makes sense for certain suites -#define SKIP_TEST(message) \ - if (!Integration::skipped_message_displayed_) { \ +#define SKIP_TEST(message) \ + if (!Integration::skipped_message_displayed_) { \ std::cout << "[ SKIPPED ] " << message << std::endl; \ - Integration::skipped_message_displayed_ = true; \ - } \ + Integration::skipped_message_displayed_ = true; \ + } \ return; -#define CHECK_FAILURE \ +#define CHECK_FAILURE \ if (this->HasFailure()) { \ - return; \ + return; \ } #define SKIP_TEST_VERSION(server_version_string, version_string) \ - SKIP_TEST("Unsupported for Apache Cassandra Version " \ - << server_version_string << ": Server version " \ - << version_string << "+ is required") - -#define CHECK_VERSION(version) do { \ - CCM::CassVersion cass_version = this->server_version_; \ - if (Options::is_dse()) { \ - cass_version = static_cast(cass_version).get_cass_version(); \ - } \ - if (cass_version < #version) { \ - SKIP_TEST_VERSION(cass_version.to_string(), #version) \ - } \ -} while(0) - -#define CHECK_OPTIONS_VERSION(version) \ - if (Options::server_version() < #version) { \ + SKIP_TEST("Unsupported for Apache Cassandra Version " \ + << server_version_string << ": Server version " << version_string << "+ is required") + +#define CHECK_VERSION(version) \ + do { \ + CCM::CassVersion cass_version = this->server_version_; \ + if (Options::is_dse()) { \ + cass_version = static_cast(cass_version).get_cass_version(); \ + } \ + if (cass_version < #version) { \ + SKIP_TEST_VERSION(cass_version.to_string(), #version) \ + } \ + } while (0) + +#define CHECK_OPTIONS_VERSION(version) \ + if (Options::server_version() < #version) { \ SKIP_TEST_VERSION(Options::server_version().to_string(), #version) \ } -#define CHECK_VALUE_TYPE_VERSION(type) \ - CCM::CassVersion cass_version = this->server_version_; \ - if (Options::is_dse()) { \ +#define CHECK_VALUE_TYPE_VERSION(type) \ + CCM::CassVersion cass_version = this->server_version_; \ + if (Options::is_dse()) { \ cass_version = static_cast(cass_version).get_cass_version(); \ - } \ - if (cass_version < type::supported_server_version()) { \ - SKIP_TEST_VERSION(cass_version.to_string(), \ - type::supported_server_version()) \ + } \ + if (cass_version < type::supported_server_version()) { \ + SKIP_TEST_VERSION(cass_version.to_string(), type::supported_server_version()) \ } -#define CHECK_CONTINUE(flag, message) \ - ASSERT_TRUE(flag) << message; \ +#define CHECK_CONTINUE(flag, message) ASSERT_TRUE(flag) << message; #define CASSANDRA_KEY_VALUE_TABLE_FORMAT "CREATE TABLE %s (key %s PRIMARY KEY, value %s)" #define CASSANDRA_KEY_VALUE_INSERT_FORMAT "INSERT INTO %s (key, value) VALUES(%s, %s)" @@ -162,7 +158,7 @@ class Integration : public testing::Test { /** * Handle for interacting with CCM */ - SharedPtr > ccm_; + SharedPtr> ccm_; /** * Logger instance for handling driver log messages */ @@ -455,8 +451,7 @@ class Integration : public testing::Test { * @param number_of_nodes Total number of nodes in the cluster * @return Comma delimited IP address (e.g. contact points) */ - std::string generate_contact_points(const std::string& ip_prefix, - size_t number_of_nodes); + std::string generate_contact_points(const std::string& ip_prefix, size_t number_of_nodes); /** * Variable argument string formatter @@ -481,9 +476,7 @@ class Integration : public testing::Test { /** * Start the timer to calculate the elapsed time */ - inline void start_timer() { - start_time_ = uv_hrtime(); - } + inline void start_timer() { start_time_ = uv_hrtime(); } /** * Stop the timer - Calculate the elapsed time and reset the timer @@ -501,9 +494,7 @@ class Integration : public testing::Test { * * @return Current working directory */ - inline static std::string cwd() { - return Utils::cwd(); - } + inline static std::string cwd() { return Utils::cwd(); } /** * Determine if a string contains another string @@ -512,8 +503,7 @@ class Integration : public testing::Test { * @param search String to find * @return True if string is contained in other string; false otherwise */ - inline static bool contains(const std::string& input, - const std::string& search) { + inline static bool contains(const std::string& input, const std::string& search) { return Utils::contains(input, search); } @@ -525,7 +515,7 @@ class Integration : public testing::Test { * @return An array/vector representation of the string */ inline static std::vector explode(const std::string& input, - const char delimiter = ' ') { + const char delimiter = ' ') { return Utils::explode(input, delimiter); } @@ -557,18 +547,14 @@ class Integration : public testing::Test { * * @param path Directory/Path to create */ - inline static void mkdir(const std::string& path) { - Utils::mkdir(path); - } + inline static void mkdir(const std::string& path) { Utils::mkdir(path); } /** * Cross platform millisecond granularity sleep * * @param milliseconds Time in milliseconds to sleep */ - inline static void msleep(unsigned int milliseconds) { - Utils::msleep(milliseconds); - } + inline static void msleep(unsigned int milliseconds) { Utils::msleep(milliseconds); } /** * Replace all occurrences of a string from the input string @@ -578,8 +564,8 @@ class Integration : public testing::Test { * @param to String to replace with * @return Input string with replacement */ - inline static std::string replace_all(const std::string& input, - const std::string& from, const std::string& to) { + inline static std::string replace_all(const std::string& input, const std::string& from, + const std::string& to) { return Utils::replace_all(input, from, to); } @@ -588,9 +574,7 @@ class Integration : public testing::Test { * * @param input String to convert to lowercase */ - inline static std::string to_lower(const std::string& input) { - return Utils::to_lower(input); - } + inline static std::string to_lower(const std::string& input) { return Utils::to_lower(input); } /** * Remove the leading and trailing whitespace from a string @@ -598,9 +582,7 @@ class Integration : public testing::Test { * @param input String to trim * @return Trimmed string */ - inline static std::string trim(const std::string& input) { - return Utils::trim(input); - } + inline static std::string trim(const std::string& input) { return Utils::trim(input); } /** * Shrink the given name if the name is longer than allowable by the server diff --git a/cpp-driver/gtests/src/integration/logger.cpp b/cpp-driver/gtests/src/integration/logger.cpp index d9d5ed4d7..e8ad5008e 100644 --- a/cpp-driver/gtests/src/integration/logger.cpp +++ b/cpp-driver/gtests/src/integration/logger.cpp @@ -30,15 +30,15 @@ using namespace test::driver; #define LOGGER_DIRECTORY "log" #ifdef _WIN32 -# define FILE_MODE 0 -# define LOCALTIME(tm, time) localtime_s(tm, time) +#define FILE_MODE 0 +#define LOCALTIME(tm, time) localtime_s(tm, time) #else -# define FILE_MODE S_IRWXU | S_IRWXG | S_IROTH -# define LOCALTIME(tm, time) localtime_r(time, tm) +#define FILE_MODE S_IRWXU | S_IRWXG | S_IROTH +#define LOCALTIME(tm, time) localtime_r(time, tm) #endif Logger::Logger() - : count_(0) { } + : count_(0) {} Logger::~Logger() { if (output_.is_open()) { @@ -53,7 +53,7 @@ void Logger::initialize(const std::string& test_case, const std::string& test_na std::vector path_tokens = Utils::explode(path, Utils::PATH_SEPARATOR); std::string mkdir_path; for (std::vector::const_iterator iterator = path_tokens.begin(); - iterator < path_tokens.end(); ++iterator) { + iterator < path_tokens.end(); ++iterator) { mkdir_path += *iterator + Utils::PATH_SEPARATOR; Utils::mkdir(mkdir_path); } @@ -85,9 +85,7 @@ void test::driver::Logger::clear_critera() { search_criteria_.clear(); } -size_t Logger::count() { - return count_; -} +size_t Logger::count() { return count_; } void Logger::log(const CassLogMessage* log, void* data) { Logger* logger = static_cast(data); @@ -106,27 +104,24 @@ void Logger::log(const CassLogMessage* log, void* data) { // Create the date formatted output std::stringstream date; int month = (date_time.tm_mon + 1); - date << date_time.tm_year + 1900 << "/" - << (month < 10 ? "0" : "") << month << "/" - << (date_time.tm_mday < 10 ? "0" : "") << date_time.tm_mday; + date << date_time.tm_year + 1900 << "/" << (month < 10 ? "0" : "") << month << "/" + << (date_time.tm_mday < 10 ? "0" : "") << date_time.tm_mday; // Create the formatted time std::stringstream time; time << (date_time.tm_hour < 10 ? "0" : "") << date_time.tm_hour << ":" - << (date_time.tm_min < 10 ? "0" : "") << date_time.tm_min << ":" - << (date_time.tm_sec < 10 ? "0" : "") << date_time.tm_sec << "." - << std::setfill('0') << std::setw(3) << milliseconds; + << (date_time.tm_min < 10 ? "0" : "") << date_time.tm_min << ":" + << (date_time.tm_sec < 10 ? "0" : "") << date_time.tm_sec << "." << std::setfill('0') + << std::setw(3) << milliseconds; // Create the formatted log message and output to the file std::string severity = cass_log_level_string(log->severity); - logger->output_ << date.str() << " " << time.str() << " " - << severity << ": " << message - << " (" << log->file << ":" << log->line << ") " << std::endl; - + logger->output_ << date.str() << " " << time.str() << " " << severity << ": " << message << " (" + << log->file << ":" << log->line << ") " << std::endl; // Determine if the log message matches any of the criteria for (std::vector::const_iterator iterator = logger->search_criteria_.begin(); - iterator != logger->search_criteria_.end(); ++iterator) { + iterator != logger->search_criteria_.end(); ++iterator) { if (message.find(*iterator) != std::string::npos) { ++logger->count_; } @@ -143,4 +138,3 @@ void test::driver::Logger::reset_count() { ScopedMutex lock(&mutex_); count_ = 0; } - diff --git a/cpp-driver/gtests/src/integration/logger.hpp b/cpp-driver/gtests/src/integration/logger.hpp index f8694080d..82ea20233 100644 --- a/cpp-driver/gtests/src/integration/logger.hpp +++ b/cpp-driver/gtests/src/integration/logger.hpp @@ -26,8 +26,7 @@ #include #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Logger class for handling log messages from the driver @@ -108,8 +107,6 @@ class Logger { static void log(const CassLogMessage* log, void* data); }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_LOGGER_HPP__ - diff --git a/cpp-driver/gtests/src/integration/main.cpp b/cpp-driver/gtests/src/integration/main.cpp index 6ea5ca1e3..c9b2bcdd4 100644 --- a/cpp-driver/gtests/src/integration/main.cpp +++ b/cpp-driver/gtests/src/integration/main.cpp @@ -31,23 +31,19 @@ class BootstrapListener : public testing::EmptyTestEventListener { public: BootstrapListener() - : is_settings_displayed_(false) {} + : is_settings_displayed_(false) {} /** * Set the current test category being executed * * @param category Current category */ - void set_category(TestCategory category) { - category_ = category; - } + void set_category(TestCategory category) { category_ = category; } void OnTestProgramStart(const testing::UnitTest& unit_test) { if (!is_settings_displayed_) { std::cout << "Starting DataStax C/C++ Driver Integration Test" << std::endl; - std::cout << " Cassandra driver v" - << CASS_VERSION_MAJOR << "." - << CASS_VERSION_MINOR << "." + std::cout << " Cassandra driver v" << CASS_VERSION_MAJOR << "." << CASS_VERSION_MINOR << "." << CASS_VERSION_PATCH; if (!std::string(CASS_VERSION_SUFFIX).empty()) { std::cout << "-" << CASS_VERSION_SUFFIX; @@ -88,12 +84,11 @@ class BootstrapListener : public testing::EmptyTestEventListener { * @param base_filter Base filter being applied to exclusion * @return Filter pattern to execute for the given category */ -std::string generate_filter(TestCategory category, - const std::string& base_filter) { +std::string generate_filter(TestCategory category, const std::string& base_filter) { // Create the exclusion filter by iterating over the available categories std::string exclude_filter; - for (TestCategory::iterator iterator = TestCategory::begin(); - iterator != TestCategory::end(); ++iterator) { + for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end(); + ++iterator) { if (category != *iterator) { exclude_filter += ":" + iterator->filter(); } @@ -120,10 +115,10 @@ int main(int argc, char* argv[]) { #if defined(_WIN32) && defined(_DEBUG) // Add the memory leak checking to the listener callbacks listeners.Append(new MemoryLeakListener()); -# ifdef USE_VISUAL_LEAK_DETECTOR +#ifdef USE_VISUAL_LEAK_DETECTOR // Google test statically initializes heap objects; mark all leaks as reported VLDMarkAllLeaksAsReported(); -# endif +#endif #endif // Initialize the options for the integration test @@ -133,7 +128,7 @@ int main(int argc, char* argv[]) { const std::string base_filter = ::testing::GTEST_FLAG(filter); std::set categories = Options::categories(); for (std::set::iterator iterator = categories.begin(); - iterator != categories.end(); ++iterator) { + iterator != categories.end(); ++iterator) { // Update the filtering based on the current category ::testing::GTEST_FLAG(filter) = generate_filter(*iterator, base_filter); listener->set_category(*iterator); @@ -143,7 +138,7 @@ int main(int argc, char* argv[]) { exit_status = 1; } } - //TODO: Write a custom start and end report for all categories executed + // TODO: Write a custom start and end report for all categories executed std::cout << "Finishing DataStax C/C++ Driver Integration Test" << std::endl; return exit_status; } diff --git a/cpp-driver/gtests/src/integration/nullable_value.hpp b/cpp-driver/gtests/src/integration/nullable_value.hpp index 65c7093dd..4c617b2b8 100644 --- a/cpp-driver/gtests/src/integration/nullable_value.hpp +++ b/cpp-driver/gtests/src/integration/nullable_value.hpp @@ -27,30 +27,21 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Create a comparable template to act as an interface for comparing * values. */ -template +template class Comparable { - friend bool operator==(const T& lhs, const T& rhs) { - return lhs.compare(rhs) == 0; - } + friend bool operator==(const T& lhs, const T& rhs) { return lhs.compare(rhs) == 0; } - friend bool operator!=(const T& lhs, const T& rhs) { - return lhs.compare(rhs) != 0; - } + friend bool operator!=(const T& lhs, const T& rhs) { return lhs.compare(rhs) != 0; } - friend bool operator<(const T& lhs, const T& rhs) { - return lhs.compare(rhs) <= -1; - } + friend bool operator<(const T& lhs, const T& rhs) { return lhs.compare(rhs) <= -1; } - friend bool operator>(const T& lhs, const T& rhs) { - return lhs.compare(rhs) >= -1; - } + friend bool operator>(const T& lhs, const T& rhs) { return lhs.compare(rhs) >= -1; } }; /** @@ -59,14 +50,14 @@ class Comparable { * value type and other miscellaneous needs for testing; while also allowing the * value to be NULL. */ -template -class NullableValue : public Comparable > { +template +class NullableValue : public Comparable> { public: /** * Constructor for a NULL value */ NullableValue() - : is_null_(true) { }; + : is_null_(true){}; /** * Constructor for a nullable value; convenience constructor @@ -74,8 +65,8 @@ class NullableValue : public Comparable > { * @param value Typed value */ explicit NullableValue(const typename T::ConvenienceType& value) - : is_null_(false) - , value_(value) { } + : is_null_(false) + , value_(value) {} /** * Constructor for a nullable value using the wrapped type @@ -83,8 +74,8 @@ class NullableValue : public Comparable > { * @param value Wrapped type value */ explicit NullableValue(const T& value) - : is_null_(false) - , value_(value) { } + : is_null_(false) + , value_(value) {} /** * Constructor for a nullable value using the drivers primitive/collection @@ -93,7 +84,7 @@ class NullableValue : public Comparable > { * @param value CassValue from driver query */ explicit NullableValue(const CassValue* value) - : is_null_(false) { + : is_null_(false) { initialize(value); } @@ -102,27 +93,21 @@ class NullableValue : public Comparable > { * * @param collection Collection to append the value to */ - void append(Collection collection) { - value_.append(collection); - } + void append(Collection collection) { value_.append(collection); } /** * Get the CQL type * * @return CQL type name */ - std::string cql_type() const { - return value_.cql_type(); - } + std::string cql_type() const { return value_.cql_type(); } /** * Get the CQL value (for embedded simple statements) * * @return CQL type value */ - std::string cql_value() const { - return value_.cql_value(); - } + std::string cql_value() const { return value_.cql_value(); } /** * Comparison operation for Comparable template @@ -172,27 +157,21 @@ class NullableValue : public Comparable > { * * @return True if value is NULL; false otherwise */ - bool is_null() const { - return is_null_; - } + bool is_null() const { return is_null_; } /** * Get the maximum value * * @return Maximum value */ - static NullableValue max() { - return NullableValue(T::max()); - } + static NullableValue max() { return NullableValue(T::max()); } /** * Get the minimum value * * @return Minimum value */ - static NullableValue min() { - return NullableValue(T::min()); - } + static NullableValue min() { return NullableValue(T::min()); } /** * Set the value to a index in the tuple @@ -216,8 +195,7 @@ class NullableValue : public Comparable > { */ void set(UserType user_type, const std::string& name) { if (is_null_) { - ASSERT_EQ(CASS_OK, - cass_user_type_set_null_by_name(user_type.get(), name.c_str())); + ASSERT_EQ(CASS_OK, cass_user_type_set_null_by_name(user_type.get(), name.c_str())); } else { value_.set(user_type, name); } @@ -246,8 +224,7 @@ class NullableValue : public Comparable > { */ void statement_bind(Statement statement, const std::string& name) { if (is_null_) { - ASSERT_EQ(CASS_OK, cass_statement_bind_null_by_name(statement.get(), - name.c_str())); + ASSERT_EQ(CASS_OK, cass_statement_bind_null_by_name(statement.get(), name.c_str())); } else { value_.statement_bind(statement, name); } @@ -269,42 +246,34 @@ class NullableValue : public Comparable > { * * @return Minimum server version allowed for value */ - static std::string supported_server_version() { - return T::supported_server_version(); - } + static std::string supported_server_version() { return T::supported_server_version(); } /** * Get the driver value * * @return Driver value */ - typename T::ValueType value() const { - return value_.value(); - } + typename T::ValueType value() const { return value_.value(); } /** * Get the wrapped value * * @return Wrapped value type (templated type) */ - T wrapped_value() const { - return value_; - } + T wrapped_value() const { return value_; } /** * Get the type of value the native driver value is * * @return Value type of the native driver value */ - CassValueType value_type() const { - return value_.value_type(); - } + CassValueType value_type() const { return value_.value_type(); } - NullableValue operator -(const NullableValue& rhs) { + NullableValue operator-(const NullableValue& rhs) { return NullableValue(value_ - rhs.value_); } - NullableValue operator +(const NullableValue& rhs) { + NullableValue operator+(const NullableValue& rhs) { return NullableValue(value_ + rhs.value_); } @@ -319,15 +288,12 @@ class NullableValue : public Comparable > { T value_; }; -template -inline std::ostream& operator<<(std::ostream& output_stream, - const NullableValue& value) { +template +inline std::ostream& operator<<(std::ostream& output_stream, const NullableValue& value) { output_stream << value.cql_value(); return output_stream; } - -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_NULLBALE_VALUE_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/cluster.hpp b/cpp-driver/gtests/src/integration/objects/cluster.hpp index 50a572a1e..2db77dc3d 100644 --- a/cpp-driver/gtests/src/integration/objects/cluster.hpp +++ b/cpp-driver/gtests/src/integration/objects/cluster.hpp @@ -26,8 +26,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped cluster object (builder) @@ -38,7 +37,7 @@ class Cluster : public Object { * Create the cluster for the builder object */ Cluster() - : Object(cass_cluster_new()) { } + : Object(cass_cluster_new()) {} /** * Create the cluster for the builder object @@ -46,7 +45,7 @@ class Cluster : public Object { * @param cluster Already defined cluster object to utilize */ Cluster(CassCluster* cluster) - : Object(cluster) { } + : Object(cluster) {} /** * Create the cluster object from a shared reference @@ -54,21 +53,19 @@ class Cluster : public Object { * @param cluster Shared reference */ Cluster(Ptr cluster) - : Object(cluster) { } + : Object(cluster) {} /** * Destroy the cluster */ - virtual ~Cluster() {}; + virtual ~Cluster(){}; /** * Build/Create the cluster * * @return Cluster object */ - static Cluster build() { - return Cluster(); - } + static Cluster build() { return Cluster(); } /** * Sets the custom authenticator @@ -76,8 +73,8 @@ class Cluster : public Object { Cluster& with_authenticator_callbacks(const CassAuthenticatorCallbacks* exchange_callbacks, CassAuthenticatorDataCleanupCallback cleanup_callback, void* data) { - EXPECT_EQ(CASS_OK, cass_cluster_set_authenticator_callbacks(get(), - exchange_callbacks, cleanup_callback, data)); + EXPECT_EQ(CASS_OK, cass_cluster_set_authenticator_callbacks(get(), exchange_callbacks, + cleanup_callback, data)); return *this; } @@ -89,8 +86,8 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_beta_protocol(bool enable = false) { - EXPECT_EQ(CASS_OK, cass_cluster_set_use_beta_protocol_version(get(), - (enable == true ? cass_true : cass_false))); + EXPECT_EQ(CASS_OK, cass_cluster_set_use_beta_protocol_version( + get(), (enable == true ? cass_true : cass_false))); return *this; } @@ -129,8 +126,7 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_contact_points(const std::string& contact_points) { - EXPECT_EQ(CASS_OK, cass_cluster_set_contact_points(get(), - contact_points.c_str())); + EXPECT_EQ(CASS_OK, cass_cluster_set_contact_points(get(), contact_points.c_str())); return *this; } @@ -142,8 +138,7 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_local_address(const std::string& name) { - EXPECT_EQ(CASS_OK, cass_cluster_set_local_address(get(), - name.c_str())); + EXPECT_EQ(CASS_OK, cass_cluster_set_local_address(get(), name.c_str())); return *this; } @@ -157,8 +152,7 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_core_connections_per_host(unsigned int connections = 1u) { - EXPECT_EQ(CASS_OK, cass_cluster_set_core_connections_per_host(get(), - connections)); + EXPECT_EQ(CASS_OK, cass_cluster_set_core_connections_per_host(get(), connections)); return *this; } @@ -169,8 +163,7 @@ class Cluster : public Object { * param password Password * @return Cluster object */ - Cluster& with_credentials(const char* username, - const char* password) { + Cluster& with_credentials(const char* username, const char* password) { cass_cluster_set_credentials(get(), username, password); return *this; } @@ -182,10 +175,8 @@ class Cluster : public Object { * @param profile Execution profile to add to the cluster * @return Cluster object */ - Cluster& with_execution_profile(const std::string& name, - ExecutionProfile profile) { - EXPECT_EQ(CASS_OK, cass_cluster_set_execution_profile(get(), - name.c_str(), profile.get())); + Cluster& with_execution_profile(const std::string& name, ExecutionProfile profile) { + EXPECT_EQ(CASS_OK, cass_cluster_set_execution_profile(get(), name.c_str(), profile.get())); return *this; } @@ -196,11 +187,8 @@ class Cluster : public Object { * @param data User data supplied to the callback (default: NULL) * @return Cluster object */ - Cluster& with_host_listener_callback(CassHostListenerCallback callback, - void* data = NULL) { - EXPECT_EQ(CASS_OK, cass_cluster_set_host_listener_callback(get(), - callback, - data)); + Cluster& with_host_listener_callback(CassHostListenerCallback callback, void* data = NULL) { + EXPECT_EQ(CASS_OK, cass_cluster_set_host_listener_callback(get(), callback, data)); return *this; } @@ -215,8 +203,8 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_hostname_resolution(bool enable = true) { - EXPECT_EQ(CASS_OK, cass_cluster_set_use_hostname_resolution(get(), - (enable == true ? cass_true : cass_false))); + EXPECT_EQ(CASS_OK, cass_cluster_set_use_hostname_resolution( + get(), (enable == true ? cass_true : cass_false))); return *this; } @@ -246,13 +234,11 @@ class Cluster : public Object { * otherwise false * @return Cluster object */ - Cluster& with_load_balance_dc_aware(const std::string& local_dc, - size_t used_hosts_per_remote_dc, + Cluster& with_load_balance_dc_aware(const std::string& local_dc, size_t used_hosts_per_remote_dc, bool allow_remote_dcs_for_local_cl) { - EXPECT_EQ(CASS_OK, - cass_cluster_set_load_balance_dc_aware(get(), local_dc.c_str(), - used_hosts_per_remote_dc, - (allow_remote_dcs_for_local_cl == true ? cass_true : cass_false))); + EXPECT_EQ(CASS_OK, cass_cluster_set_load_balance_dc_aware( + get(), local_dc.c_str(), used_hosts_per_remote_dc, + (allow_remote_dcs_for_local_cl == true ? cass_true : cass_false))); return *this; } @@ -274,9 +260,7 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_no_compact(bool enable = true) { - EXPECT_EQ(CASS_OK, - cass_cluster_set_no_compact(get(), - enable == true ? cass_true : cass_false)); + EXPECT_EQ(CASS_OK, cass_cluster_set_no_compact(get(), enable == true ? cass_true : cass_false)); return *this; } @@ -300,8 +284,7 @@ class Cluster : public Object { * @return Cluster object */ Cluster& with_protocol_version(int protocol_version) { - EXPECT_EQ(CASS_OK, cass_cluster_set_protocol_version(get(), - protocol_version)); + EXPECT_EQ(CASS_OK, cass_cluster_set_protocol_version(get(), protocol_version)); return *this; } @@ -314,7 +297,7 @@ class Cluster : public Object { */ Cluster& with_randomized_contact_points(bool enable = true) { cass_cluster_set_use_randomized_contact_points(get(), - (enable == true ? cass_true : cass_false)); + (enable == true ? cass_true : cass_false)); return *this; } @@ -381,7 +364,6 @@ class Cluster : public Object { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_CLUSTER_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/collection.hpp b/cpp-driver/gtests/src/integration/objects/collection.hpp index 3da79a8ac..2d6332289 100644 --- a/cpp-driver/gtests/src/integration/objects/collection.hpp +++ b/cpp-driver/gtests/src/integration/objects/collection.hpp @@ -27,8 +27,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped collection object @@ -38,7 +37,7 @@ class Collection : public Object { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; /** @@ -47,7 +46,7 @@ class Collection : public Object { * @param column Column to retrieve collection from */ Collection(const CassValue* column) - : is_null_(true) { + : is_null_(true) { initialize(column); } @@ -57,8 +56,7 @@ class Collection : public Object { * @param collection Collection to append the value to */ void append(Collection collection) { - ASSERT_EQ(CASS_OK, - cass_collection_append_collection(collection.get(), get())); + ASSERT_EQ(CASS_OK, cass_collection_append_collection(collection.get(), get())); } /** @@ -96,12 +94,10 @@ class Collection : public Object { */ void set(UserType user_type, const std::string& name) { if (is_null_) { - ASSERT_EQ(CASS_OK, - cass_user_type_set_null_by_name(user_type.get(), name.c_str())); + ASSERT_EQ(CASS_OK, cass_user_type_set_null_by_name(user_type.get(), name.c_str())); } else { ASSERT_EQ(CASS_OK, - cass_user_type_set_collection_by_name(user_type.get(), name.c_str(), - get())); + cass_user_type_set_collection_by_name(user_type.get(), name.c_str(), get())); } } @@ -113,8 +109,7 @@ class Collection : public Object { * statement */ void statement_bind(Statement statement, size_t index) { - ASSERT_EQ(CASS_OK, - cass_statement_bind_collection(statement.get(), index, get())); + ASSERT_EQ(CASS_OK, cass_statement_bind_collection(statement.get(), index, get())); } protected: @@ -152,9 +147,9 @@ class Collection : public Object { * @param count Size of the collection (default: 1) */ Collection(CassCollectionType collection_type, size_t count = 1) - : Object(cass_collection_new(collection_type, count)) - , collection_type_(collection_type) - , is_null_(true) { } + : Object(cass_collection_new(collection_type, count)) + , collection_type_(collection_type) + , is_null_(true) {} /** * Append the value to the collection @@ -163,7 +158,7 @@ class Collection : public Object { * @throws Exception If collection is not able to have values added to it * (e.g. The collection was generated from server result) */ - template + template void append(T value) { ASSERT_TRUE(!value.is_null()); value.append(*this); @@ -181,7 +176,8 @@ class Collection : public Object { // Ensure the value is a collection ASSERT_TRUE(value != NULL) << "Invalid CassValue: Value should not be null"; if (!cass_value_is_null(value)) { - ASSERT_TRUE(cass_value_is_collection(value)) << "Invalid CassValue: Value is not a collection"; + ASSERT_TRUE(cass_value_is_collection(value)) + << "Invalid CassValue: Value is not a collection"; // Determine the type of collection from the value type CassValueType value_type = cass_value_type(value); @@ -211,7 +207,6 @@ class Collection : public Object { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_COLLECTION_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/custom_payload.hpp b/cpp-driver/gtests/src/integration/objects/custom_payload.hpp index 53b845a24..dc2d55d35 100644 --- a/cpp-driver/gtests/src/integration/objects/custom_payload.hpp +++ b/cpp-driver/gtests/src/integration/objects/custom_payload.hpp @@ -29,26 +29,24 @@ #include #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Custom payload object */ -class CustomPayload - : public Object { +class CustomPayload : public Object { public: class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; /** * Create an empty custom payload object */ CustomPayload() - : Object(cass_custom_payload_new()) { } + : Object(cass_custom_payload_new()) {} /** * Create the custom payload from a response future @@ -56,7 +54,7 @@ class CustomPayload * @param column Column to retrieve custom payload from */ CustomPayload(Future future) - : Object(cass_custom_payload_new()) { + : Object(cass_custom_payload_new()) { initialize(future); } @@ -67,9 +65,7 @@ class CustomPayload * @param value Blob/Bytes to set to the custom payload */ void set(const std::string& name, Blob value) { - cass_custom_payload_set(get(), - name.c_str(), - value.wrapped_value().data(), + cass_custom_payload_set(get(), name.c_str(), value.wrapped_value().data(), value.wrapped_value().size()); // Update the local items map and the count @@ -81,9 +77,7 @@ class CustomPayload * * @return The number of items in the custom payload */ - size_t item_count() { - return items_.size(); - } + size_t item_count() { return items_.size(); } /** * Get the item from the custom payload at the specified index @@ -106,9 +100,7 @@ class CustomPayload * * @return The custom payload as a map of key/value pairs */ - std::map items() { - return items_; - } + std::map items() { return items_; } protected: /** @@ -132,17 +124,16 @@ class CustomPayload size_t name_length; const cass_byte_t* value; size_t value_size; - ASSERT_EQ(CASS_OK, cass_future_custom_payload_item(future.get(), - i, &name, &name_length, &value, &value_size)); + ASSERT_EQ(CASS_OK, cass_future_custom_payload_item(future.get(), i, &name, &name_length, + &value, &value_size)); // Add the item to the map of items for the custom payload items_[std::string(name, name_length)] = - Blob(std::string(reinterpret_cast(value), value_size)); + Blob(std::string(reinterpret_cast(value), value_size)); } } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_CUSTOM_PAYLOAD_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/execution_profile.hpp b/cpp-driver/gtests/src/integration/objects/execution_profile.hpp index 2ba909762..27ec94b58 100644 --- a/cpp-driver/gtests/src/integration/objects/execution_profile.hpp +++ b/cpp-driver/gtests/src/integration/objects/execution_profile.hpp @@ -16,8 +16,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped execution profile object (builder) @@ -30,7 +29,7 @@ class ExecutionProfile : public Object(cass_execution_profile_new()) { } + : Object(cass_execution_profile_new()) {} /** * Create the execution profile for the builder object @@ -38,7 +37,7 @@ class ExecutionProfile : public Object(profile) {} + : Object(profile) {} /** * Create the execution profile object from a shared reference @@ -46,16 +45,14 @@ class ExecutionProfile : public Object(profile) {} + : Object(profile) {} /** * Build/Create the execution profile * * @return Execution profile object */ - static ExecutionProfile build() { - return ExecutionProfile(); - } + static ExecutionProfile build() { return ExecutionProfile(); } /** * Append/Assign/Set the blacklist hosts for statement/batch execution @@ -64,22 +61,18 @@ class ExecutionProfile : public Object -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped future object @@ -38,7 +37,7 @@ class Future : public Object { * Create the empty future object */ Future() - : Object() {} + : Object() {} /** * Create the future object from the native driver object @@ -46,7 +45,7 @@ class Future : public Object { * @param future Native driver object */ Future(CassFuture* future) - : Object(future) {} + : Object(future) {} /** * Create the future object from a shared reference @@ -54,7 +53,7 @@ class Future : public Object { * @param future Shared reference */ Future(Ptr future) - : Object(future) {} + : Object(future) {} /** * Get the attempted hosts/addresses of the future (sorted) @@ -70,18 +69,14 @@ class Future : public Object { * * @return Error code of the future */ - CassError error_code() { - return cass_future_error_code(get()); - } + CassError error_code() { return cass_future_error_code(get()); } /** * Get the human readable description of the error code * * @return Error description */ - const std::string error_description() { - return std::string(cass_error_desc(error_code())); - } + const std::string error_description() { return std::string(cass_error_desc(error_code())); } /** * Get the error message of the future if an error occurred @@ -100,18 +95,14 @@ class Future : public Object { * * @return Host/Address */ - const std::string host() { - return internals::Utils::host(get()); - } + const std::string host() { return internals::Utils::host(get()); } /** * Get the result from the future * * @return Result from future */ - const CassResult* result() { - return cass_future_get_result(get()); - } + const CassResult* result() { return cass_future_get_result(get()); } /** * Wait for the future to resolve itself @@ -122,8 +113,7 @@ class Future : public Object { void wait(bool assert_ok = true) { CassError wait_code = error_code(); if (assert_ok) { - ASSERT_EQ(CASS_OK, wait_code) - << error_description() << ": " << error_message(); + ASSERT_EQ(CASS_OK, wait_code) << error_description() << ": " << error_message(); } } @@ -134,7 +124,7 @@ class Future : public Object { * @param timeout Timeout (in microseconds) for the future to resolve itself * (default: 60s) * @param assert_true True if timeout should be asserted; false otherwise - * (default: true) + * (default: true) */ void wait_timed(cass_duration_t timeout = 60000000, bool assert_true = true) { cass_bool_t timed_out = cass_future_wait_timed(get(), timeout); @@ -144,7 +134,6 @@ class Future : public Object { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_FUTURE_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/iterator.hpp b/cpp-driver/gtests/src/integration/objects/iterator.hpp index a7c056627..695fe9851 100644 --- a/cpp-driver/gtests/src/integration/objects/iterator.hpp +++ b/cpp-driver/gtests/src/integration/objects/iterator.hpp @@ -22,8 +22,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { class Iterator : public Object { public: @@ -31,7 +30,7 @@ class Iterator : public Object { * Create the empty iterator object */ Iterator() - : Object() {} + : Object() {} /** * Create the iterator object from the native driver object @@ -39,7 +38,7 @@ class Iterator : public Object { * @param iterator Native driver object */ Iterator(CassIterator* iterator) - : Object(iterator) {} + : Object(iterator) {} /** * Create the future object from a shared reference @@ -47,10 +46,9 @@ class Iterator : public Object { * @param future Shared reference */ Iterator(Ptr iterator) - : Object(iterator) {} + : Object(iterator) {} }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_ITERATOR_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/object_base.hpp b/cpp-driver/gtests/src/integration/objects/object_base.hpp index 0da3c9480..5f7d94fc5 100644 --- a/cpp-driver/gtests/src/integration/objects/object_base.hpp +++ b/cpp-driver/gtests/src/integration/objects/object_base.hpp @@ -20,13 +20,12 @@ #include "shared_ptr.hpp" #include "tlog.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Template deleter class for driver objects that utilize a freeing function */ -template +template class Deleter { public: void operator()(T* object) { @@ -39,7 +38,7 @@ class Deleter { /** * Template object class for driver objects */ -template +template class Object { public: typedef Deleter Dtor; @@ -49,7 +48,7 @@ class Object { * Create an empty object */ Object() - : object_(NULL) { } + : object_(NULL) {} /** * Create the object with the native pointer object @@ -57,7 +56,7 @@ class Object { * @param object Native pointer object */ Object(T* object) - : object_(object) { } + : object_(object) {} /** * Create the object with the reference pointer object @@ -65,7 +64,7 @@ class Object { * @param object Shared reference pointer object */ Object(Ptr object) - : object_(object) { } + : object_(object) {} /** * Get the object pointer @@ -95,9 +94,7 @@ class Object { * * @return True if object pointer is valid; false otherwise */ - operator bool() const { - return object_.get() != NULL; - } + operator bool() const { return object_.get() != NULL; } /** * Conversion operator for determining if the pointer used for the object is @@ -105,9 +102,7 @@ class Object { * * @return True if object pointer is valid; false otherwise */ - operator bool() { - return object_.get() != NULL; - } + operator bool() { return object_.get() != NULL; } protected: /** @@ -126,9 +121,7 @@ class Object { * * @param object Object reference */ - void set(T* object) { - object_ = object; - } + void set(T* object) { object_ = object; } private: /** @@ -137,7 +130,6 @@ class Object { Ptr object_; }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_OBJECT_BASE_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/prepared.hpp b/cpp-driver/gtests/src/integration/objects/prepared.hpp index 3a373d253..8d51e09b5 100644 --- a/cpp-driver/gtests/src/integration/objects/prepared.hpp +++ b/cpp-driver/gtests/src/integration/objects/prepared.hpp @@ -22,8 +22,7 @@ #include "objects/statement.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped prepared object @@ -34,7 +33,7 @@ class Prepared : public Object { * Create the empty prepared object */ Prepared() - : Object() {} + : Object() {} /** * Create the prepared object from the native driver object @@ -42,7 +41,7 @@ class Prepared : public Object { * @param prepared Native driver object */ Prepared(const CassPrepared* prepared) - : Object(prepared) {} + : Object(prepared) {} /** * Create the prepared object from a shared reference @@ -50,16 +49,14 @@ class Prepared : public Object { * @param prepared Shared reference */ Prepared(Ptr prepared) - : Object(prepared) {} + : Object(prepared) {} /** * Bind the prepared object and create a statement * * @return Statement */ - Statement bind() { - return Statement(cass_prepared_bind(get())); - } + Statement bind() { return Statement(cass_prepared_bind(get())); } /** * Get the data type for a given column index @@ -87,9 +84,7 @@ class Prepared : public Object { * @param index The column index to retrieve the value type * @return Value type at the specified column index */ - CassValueType value_type(size_t index) { - return cass_data_type_type(data_type(index)); - } + CassValueType value_type(size_t index) { return cass_data_type_type(data_type(index)); } /** * Get the value type for a given column name @@ -97,12 +92,9 @@ class Prepared : public Object { * @param name The column name to retrieve the value type * @return Value type at the specified column index */ - CassValueType value_type(const std::string& name) { - return cass_data_type_type(data_type(name)); - } + CassValueType value_type(const std::string& name) { return cass_data_type_type(data_type(name)); } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_PREPARED_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/result.hpp b/cpp-driver/gtests/src/integration/objects/result.hpp index 68908ffc8..da70ad06d 100644 --- a/cpp-driver/gtests/src/integration/objects/result.hpp +++ b/cpp-driver/gtests/src/integration/objects/result.hpp @@ -30,8 +30,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { // Forward declarations class Row; @@ -45,13 +44,13 @@ class Result : public Object { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; /** * Create an empty result object */ - Result() { } + Result() {} /** * Create the result object from the native driver object @@ -59,7 +58,7 @@ class Result : public Object { * @param result Native driver object */ Result(const CassResult* result) - : Object(result) { } + : Object(result) {} /** * Create the result object from a shared reference @@ -67,7 +66,7 @@ class Result : public Object { * @param result Shared reference */ Result(Ptr result) - : Object(result) { } + : Object(result) {} /** * Create the result object from a future object @@ -75,63 +74,51 @@ class Result : public Object { * @param future Wrapped driver object */ Result(Future future) - : Object(future.result()) - , future_(future) - , custom_payload_(future) { } + : Object(future.result()) + , future_(future) + , custom_payload_(future) {} /** * Get the attempted host/address of the future * * @return Attempted host/address */ - const std::vector attempted_hosts() { - return future_.attempted_hosts(); - } + const std::vector attempted_hosts() { return future_.attempted_hosts(); } /** * Get the error code from the future * * @return Error code of the future */ - CassError error_code() { - return future_.error_code(); - } + CassError error_code() { return future_.error_code(); } /** * Get the human readable description of the error code * * @return Error description */ - const std::string error_description() { - return future_.error_description(); - } + const std::string error_description() { return future_.error_description(); } /** * Get the error message of the future if an error occurred * * @return Error message */ - const std::string error_message() { - return future_.error_message(); - } + const std::string error_message() { return future_.error_message(); } /** * Get the host/address of the future * * @return Host/Address */ - const std::string host() { - return future_.host(); - } + const std::string host() { return future_.host(); } /** * Get the number of columns from the result * * @return The number of columns in the result */ - size_t column_count() { - return cass_result_column_count(get()); - } + size_t column_count() { return cass_result_column_count(get()); } /** * Get the column names from the result @@ -162,9 +149,7 @@ class Result : public Object { * * @return The number of rows in the result */ - size_t row_count() { - return cass_result_row_count(get()); - } + size_t row_count() { return cass_result_row_count(get()); } /** * Get the rows from the result @@ -179,18 +164,14 @@ class Result : public Object { * * @return True if result is empty; false otherwise */ - bool is_empty() { - return row_count() == 0; - } + bool is_empty() { return row_count() == 0; } /** * Get the custom payload associated with the result * * @return Custom payload */ - CustomPayload custom_payload() { - return custom_payload_; - } + CustomPayload custom_payload() { return custom_payload_; } /** * Get the tracing ID from the result's future. @@ -228,15 +209,15 @@ class Column { * @param parent The result object for the column */ Column(const CassValue* value, const Result& parent) - : value_(value) - , parent_(parent) { } + : value_(value) + , parent_(parent) {} /** * Get the value as a specific type * * @return The value as a value type */ - template + template T as() const { return T(value_); } @@ -264,8 +245,8 @@ class Row { * @param parent The result object for the row */ Row(const CassRow* row, const Result& parent) - : row_(row) - , parent_(parent) { + : row_(row) + , parent_(parent) { if (row != NULL) { iterator_ = cass_iterator_from_row(row); } else { @@ -279,7 +260,7 @@ class Row { * @param name Name of the column to retrieve * @return The value as a value type */ - template + template T column_by_name(const std::string& name) { return T(cass_row_get_column_by_name(row_, name.c_str())); } @@ -289,13 +270,9 @@ class Row { * * @return The total number of columns in a row */ - size_t column_count() { - return parent_.column_count(); - } + size_t column_count() { return parent_.column_count(); } - const CassRow* get() { - return row_; - } + const CassRow* get() { return row_; } /** * Get the next column @@ -337,26 +314,22 @@ class Rows { * @param parent The result object for these rows */ Rows(Iterator iterator, Result parent) - : iterator_(iterator) - , parent_(parent) { } + : iterator_(iterator) + , parent_(parent) {} /** * Get the total number of columns in a row * * @return The total number of columns in a row */ - size_t column_count() { - return parent_.column_count(); - } + size_t column_count() { return parent_.column_count(); } /** * Get the total number of rows * * @return The total number of rows */ - size_t row_count() { - return parent_.row_count(); - } + size_t row_count() { return parent_.row_count(); } /** * Get the next row @@ -382,7 +355,6 @@ class Rows { Result parent_; }; - inline Row Result::first_row() { if (cass_result_row_count(get()) == 0) { throw Exception("No first row available"); @@ -390,11 +362,8 @@ inline Row Result::first_row() { return Row(cass_result_first_row(get()), *this); } -inline Rows Result::rows() { - return Rows(cass_iterator_from_result(get()), *this); -} +inline Rows Result::rows() { return Rows(cass_iterator_from_result(get()), *this); } -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_RESULT_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/retry_policy.hpp b/cpp-driver/gtests/src/integration/objects/retry_policy.hpp index ef59e1402..0d51d0486 100644 --- a/cpp-driver/gtests/src/integration/objects/retry_policy.hpp +++ b/cpp-driver/gtests/src/integration/objects/retry_policy.hpp @@ -20,8 +20,7 @@ #include "objects/object_base.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped retry policy object @@ -34,7 +33,7 @@ class RetryPolicy : public Object { * @param retry_policy Native driver object */ RetryPolicy(CassRetryPolicy* retry_policy) - : Object(retry_policy) {} + : Object(retry_policy) {} /** * Create the retry policy object from the shared reference @@ -42,7 +41,7 @@ class RetryPolicy : public Object { * @param retry_policy Shared reference */ RetryPolicy(Ptr retry_policy) - : Object(retry_policy) {} + : Object(retry_policy) {} }; /** @@ -55,7 +54,7 @@ class DefaultRetryPolicy : public RetryPolicy { * policy object */ DefaultRetryPolicy() - : RetryPolicy(cass_retry_policy_default_new()) {} + : RetryPolicy(cass_retry_policy_default_new()) {} }; /** @@ -68,7 +67,7 @@ class DowngradingConsistencyRetryPolicy : public RetryPolicy { * driver downgrading consistency retry policy object */ DowngradingConsistencyRetryPolicy() - : RetryPolicy(cass_retry_policy_downgrading_consistency_new()) {} + : RetryPolicy(cass_retry_policy_downgrading_consistency_new()) {} }; /** @@ -81,7 +80,7 @@ class FallthroughRetryPolicy : public RetryPolicy { * fallthrough retry policy object */ FallthroughRetryPolicy() - : RetryPolicy(cass_retry_policy_fallthrough_new()) {} + : RetryPolicy(cass_retry_policy_fallthrough_new()) {} }; /** @@ -96,10 +95,9 @@ class LoggingRetryPolicy : public RetryPolicy { * @param child_policy Child retry policy being logged (CASS_LOG_INFO) */ LoggingRetryPolicy(RetryPolicy child_policy) - : RetryPolicy(cass_retry_policy_logging_new(child_policy.get())) {} + : RetryPolicy(cass_retry_policy_logging_new(child_policy.get())) {} }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_RETRY_POLICY_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/schema.hpp b/cpp-driver/gtests/src/integration/objects/schema.hpp index dc22bf512..e5273d63f 100644 --- a/cpp-driver/gtests/src/integration/objects/schema.hpp +++ b/cpp-driver/gtests/src/integration/objects/schema.hpp @@ -21,8 +21,7 @@ #include "objects/object_base.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { // Forward declarations class Keyspace; @@ -37,13 +36,14 @@ class Schema : public Object { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; /** * Default constructor */ - Schema() : Object(NULL) {} + Schema() + : Object(NULL) {} /** * Create a schema object @@ -51,7 +51,7 @@ class Schema : public Object { * @param schema_meta Native driver object */ Schema(const CassSchemaMeta* schema_meta) - : Object(schema_meta) {} + : Object(schema_meta) {} /** * Get the keyspace metadata for a given keyspace @@ -62,9 +62,7 @@ class Schema : public Object { */ Keyspace keyspace(const std::string& name); - const CassVersion version() const { - return cass_schema_meta_version(get()); - } + const CassVersion version() const { return cass_schema_meta_version(get()); } }; /** @@ -75,14 +73,14 @@ class Keyspace { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; /** * Default constructor */ Keyspace() - : keyspace_meta_(NULL) {} + : keyspace_meta_(NULL) {} /** * Create the keyspace object @@ -91,18 +89,15 @@ class Keyspace { * @param parent The schema object for the keyspace metadata */ Keyspace(const CassKeyspaceMeta* keyspace_meta, const Schema& parent) - : keyspace_meta_(keyspace_meta) - , parent_(parent) {} - + : keyspace_meta_(keyspace_meta) + , parent_(parent) {} /** * Determine if the keyspace is virtual * * @return true if virtual, otherwise false */ - bool is_virtual() const { - return cass_keyspace_meta_is_virtual(keyspace_meta_) == cass_true; - } + bool is_virtual() const { return cass_keyspace_meta_is_virtual(keyspace_meta_) == cass_true; } /** * Get the UserType type object for a given user type @@ -144,7 +139,7 @@ class Table { * Default constructor */ Table() - : table_meta_(NULL) {} + : table_meta_(NULL) {} /** * Create the table object @@ -153,17 +148,15 @@ class Table { * @param parent The keyspace object that owns the table */ Table(const CassTableMeta* table_meta, const Keyspace& parent) - : table_meta_(table_meta) - , parent_(parent) {} + : table_meta_(table_meta) + , parent_(parent) {} /** * Determine if the table is virtual * * @return true if virtual, otherwise false */ - bool is_virtual() const { - return cass_table_meta_is_virtual(table_meta_) == cass_true; - } + bool is_virtual() const { return cass_table_meta_is_virtual(table_meta_) == cass_true; } const CassTableMeta* get() const { return table_meta_; } @@ -192,17 +185,15 @@ class UserTypeType { * @param parent The keyspace object for the UserType type */ UserTypeType(const CassDataType* data_type, const Keyspace& parent) - : data_type_(data_type) - , parent_(parent) {} + : data_type_(data_type) + , parent_(parent) {} /** * Get the data type * * @return Native driver data type */ - const CassDataType* data_type() const { - return data_type_; - } + const CassDataType* data_type() const { return data_type_; } private: /** @@ -215,10 +206,8 @@ class UserTypeType { Keyspace parent_; }; - inline Keyspace Schema::keyspace(const std::string& name) { - const CassKeyspaceMeta* keyspace_meta - = cass_schema_meta_keyspace_by_name(get(), name.c_str()); + const CassKeyspaceMeta* keyspace_meta = cass_schema_meta_keyspace_by_name(get(), name.c_str()); if (keyspace_meta == NULL) { throw Exception("Unable to get metadata for keyspace: " + name); } @@ -226,8 +215,8 @@ inline Keyspace Schema::keyspace(const std::string& name) { } inline UserTypeType Keyspace::user_type(const std::string& name) { - const CassDataType* data_type - = cass_keyspace_meta_user_type_by_name(keyspace_meta_, name.c_str()); + const CassDataType* data_type = + cass_keyspace_meta_user_type_by_name(keyspace_meta_, name.c_str()); if (data_type == NULL) { throw Exception("Unable to get metadata for user type: " + name); } @@ -235,15 +224,13 @@ inline UserTypeType Keyspace::user_type(const std::string& name) { } inline Table Keyspace::table(const std::string& name) { - const CassTableMeta* table = - cass_keyspace_meta_table_by_name(keyspace_meta_, name.c_str()); + const CassTableMeta* table = cass_keyspace_meta_table_by_name(keyspace_meta_, name.c_str()); if (table == NULL) { throw Exception("Unable to get metadata for table: " + name); } return Table(table, *this); } -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_SCHEMA_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/session.hpp b/cpp-driver/gtests/src/integration/objects/session.hpp index 706a6ac6f..f15e3e2f6 100644 --- a/cpp-driver/gtests/src/integration/objects/session.hpp +++ b/cpp-driver/gtests/src/integration/objects/session.hpp @@ -28,27 +28,27 @@ #include "exception.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped session object */ class Session : public Object { -friend class Cluster; + friend class Cluster; + public: class Exception : public test::CassException { public: Exception(const std::string& message, const CassError error_code, const std::string& error_message) - : test::CassException(message, error_code, error_message) { } + : test::CassException(message, error_code, error_message) {} }; /** * Create the default session object */ Session() - : Object(cass_session_new()) { } + : Object(cass_session_new()) {} /** * Create the session object from the native driver object @@ -56,7 +56,7 @@ friend class Cluster; * @param session Native driver object */ Session(CassSession* session) - : Object(session) { } + : Object(session) {} /** * Create the session object from a shared reference @@ -64,7 +64,7 @@ friend class Cluster; * @param session Shared reference */ Session(Ptr session) - : Object(session) { } + : Object(session) {} /** * Close the active session @@ -82,27 +82,21 @@ friend class Cluster; * * @return Error code of the future */ - CassError connect_error_code() { - return connect_future_.error_code(); - } + CassError connect_error_code() { return connect_future_.error_code(); } /** * Get the human readable description of the error code during the connection * * @return Error description */ - const std::string connect_error_description() { - return connect_future_.error_description(); - } + const std::string connect_error_description() { return connect_future_.error_description(); } /** * Get the error message that occurred during the connection * * @return Error message */ - const std::string connect_error_message() { - return connect_future_.error_message(); - } + const std::string connect_error_message() { return connect_future_.error_message(); } /** * Execute a batch statement synchronously @@ -144,9 +138,8 @@ friend class Cluster; * CASS_OK; false otherwise (default: true) * @return Result object */ - Result execute(const std::string& query, - CassConsistency consistency = CASS_CONSISTENCY_LOCAL_ONE, - bool is_idempotent = false, bool assert_ok = true) { + Result execute(const std::string& query, CassConsistency consistency = CASS_CONSISTENCY_LOCAL_ONE, + bool is_idempotent = false, bool assert_ok = true) { Statement statement(query); statement.set_consistency(consistency); statement.set_idempotent(is_idempotent); @@ -184,8 +177,8 @@ friend class Cluster; * @return Future object */ Future execute_async(const std::string& query, - CassConsistency consistency = CASS_CONSISTENCY_LOCAL_ONE, - bool is_idempotent = false) { + CassConsistency consistency = CASS_CONSISTENCY_LOCAL_ONE, + bool is_idempotent = false) { Statement statement(query); statement.set_consistency(consistency); statement.set_idempotent(is_idempotent); @@ -235,15 +228,14 @@ friend class Cluster; if (keyspace.empty()) { session.connect_future_ = cass_session_connect(session.get(), cluster); } else { - session.connect_future_ = cass_session_connect_keyspace(session.get(), - cluster, keyspace.c_str()); + session.connect_future_ = + cass_session_connect_keyspace(session.get(), cluster, keyspace.c_str()); } session.connect_future_.wait(false); if (assert_ok && session.connect_error_code() != CASS_OK) { - throw Exception("Unable to Establish Session Connection: " - + session.connect_error_description(), - session.connect_error_code(), - session.connect_error_message()); + throw Exception("Unable to Establish Session Connection: " + + session.connect_error_description(), + session.connect_error_code(), session.connect_error_message()); } return session; } @@ -252,7 +244,6 @@ friend class Cluster; Future connect_future_; }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_SESSION_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/statement.cpp b/cpp-driver/gtests/src/integration/objects/statement.cpp index 2f9940b60..b00a663b0 100644 --- a/cpp-driver/gtests/src/integration/objects/statement.cpp +++ b/cpp-driver/gtests/src/integration/objects/statement.cpp @@ -19,7 +19,5 @@ #include "objects/custom_payload.hpp" void test::driver::Statement::set_custom_payload(CustomPayload custom_payload) { - ASSERT_EQ(CASS_OK, cass_statement_set_custom_payload(get(), - custom_payload.get())); + ASSERT_EQ(CASS_OK, cass_statement_set_custom_payload(get(), custom_payload.get())); } - diff --git a/cpp-driver/gtests/src/integration/objects/statement.hpp b/cpp-driver/gtests/src/integration/objects/statement.hpp index 6d444ef67..4a80e3402 100644 --- a/cpp-driver/gtests/src/integration/objects/statement.hpp +++ b/cpp-driver/gtests/src/integration/objects/statement.hpp @@ -28,8 +28,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { // Forward declaration for circular dependency class CustomPayload; @@ -43,14 +42,14 @@ class Statement : public Object { * Create an empty statement */ Statement() - : Object() { } + : Object() {} /** * Create the statement object from the native driver statement object * * @param statement Native driver object */ Statement(CassStatement* statement) - : Object(statement) { } + : Object(statement) {} /** * Create the statement object from the shared reference @@ -58,7 +57,7 @@ class Statement : public Object { * @param statement Shared reference */ Statement(Ptr statement) - : Object(statement) { } + : Object(statement) {} /** * Create the statement object from a query @@ -68,8 +67,8 @@ class Statement : public Object { * (default: 0) */ Statement(const std::string& query, size_t parameter_count = 0) - : Object(cass_statement_new(query.c_str(), - parameter_count)) { } + : Object( + cass_statement_new(query.c_str(), parameter_count)) {} /** * Add a key index specifier to the statement. @@ -90,7 +89,7 @@ class Statement : public Object { * @param index Index to bind the value to * @param value Value to bind to the statement at given index */ - template + template void bind(size_t index, T value) { value.statement_bind(*this, index); } @@ -101,7 +100,7 @@ class Statement : public Object { * @param name Column name to bind the value to * @param value Value to bind to the statement at given index */ - template + template void bind(const std::string& name, T value) { value.statement_bind(*this, name); } @@ -139,8 +138,7 @@ class Statement : public Object { * @param enable True if statement is idempotent; false otherwise */ void set_idempotent(bool enable) { - ASSERT_EQ(CASS_OK, cass_statement_set_is_idempotent(get(), - enable ? cass_true : cass_false)); + ASSERT_EQ(CASS_OK, cass_statement_set_is_idempotent(get(), enable ? cass_true : cass_false)); } /** @@ -159,8 +157,7 @@ class Statement : public Object { * @param enable True if attempted host should be recorded; false otherwise */ void set_record_attempted_hosts(bool enable) { - return internals::Utils::set_record_attempted_hosts(get(), - enable); + return internals::Utils::set_record_attempted_hosts(get(), enable); } /** @@ -169,8 +166,7 @@ class Statement : public Object { * @param timeout_ms Timeout in milliseconds */ void set_request_timeout(uint64_t timeout_ms) { - ASSERT_EQ(CASS_OK, cass_statement_set_request_timeout(get(), - timeout_ms)); + ASSERT_EQ(CASS_OK, cass_statement_set_request_timeout(get(), timeout_ms)); } /** @@ -179,8 +175,7 @@ class Statement : public Object { * @param retry_policy Retry policy to use for the statement */ void set_retry_policy(RetryPolicy retry_policy) { - ASSERT_EQ(CASS_OK, cass_statement_set_retry_policy(get(), - retry_policy.get())); + ASSERT_EQ(CASS_OK, cass_statement_set_retry_policy(get(), retry_policy.get())); } /** @@ -189,8 +184,7 @@ class Statement : public Object { * @param serial_consistency Serial consistency to use for the statement */ void set_serial_consistency(CassConsistency serial_consistency) { - ASSERT_EQ(CASS_OK, cass_statement_set_serial_consistency(get(), - serial_consistency)); + ASSERT_EQ(CASS_OK, cass_statement_set_serial_consistency(get(), serial_consistency)); } /** @@ -199,8 +193,7 @@ class Statement : public Object { * @param enabled */ void set_tracing(bool enabled) { - ASSERT_EQ(CASS_OK, - cass_statement_set_tracing(get(), enabled ? cass_true : cass_false)); + ASSERT_EQ(CASS_OK, cass_statement_set_tracing(get(), enabled ? cass_true : cass_false)); } /** @@ -210,8 +203,7 @@ class Statement : public Object { * @param port */ void set_host(const std::string& host, int port) { - ASSERT_EQ(CASS_OK, - cass_statement_set_host(get(), host.c_str(), port)); + ASSERT_EQ(CASS_OK, cass_statement_set_host(get(), host.c_str(), port)); } /** @@ -221,8 +213,7 @@ class Statement : public Object { * @param port */ void set_host(const CassInet* host, int port) { - ASSERT_EQ(CASS_OK, - cass_statement_set_host_inet(get(), host, port)); + ASSERT_EQ(CASS_OK, cass_statement_set_host_inet(get(), host, port)); } }; @@ -237,7 +228,7 @@ class Batch : public Object { * @param batch_type Type of batch to create (default: Unlogged) */ Batch(CassBatchType batch_type = CASS_BATCH_TYPE_UNLOGGED) - : Object(cass_batch_new(batch_type)) {} + : Object(cass_batch_new(batch_type)) {} /** * Create the batch object from the native driver batch object @@ -245,7 +236,7 @@ class Batch : public Object { * @param batch Native driver object */ Batch(CassBatch* batch) - : Object(batch) {} + : Object(batch) {} /** * Create the batch object from the shared reference @@ -253,7 +244,7 @@ class Batch : public Object { * @param batch Shared reference */ Batch(Ptr batch) - : Object(batch) {} + : Object(batch) {} /** * Add a statement (query or bound) to the batch @@ -263,11 +254,10 @@ class Batch : public Object { * CASS_OK; false otherwise (default: true) */ void add(Statement statement, bool assert_ok = true) { - CassError error_code = cass_batch_add_statement(get(), - statement.get()); + CassError error_code = cass_batch_add_statement(get(), statement.get()); if (assert_ok) { ASSERT_EQ(CASS_OK, error_code) - << "Unable to Add Statement to Batch: " << cass_error_desc(error_code); + << "Unable to Add Statement to Batch: " << cass_error_desc(error_code); } } @@ -297,8 +287,7 @@ class Batch : public Object { * @param enable True if statement in a batch is idempotent; false otherwise */ void set_idempotent(bool enable) { - ASSERT_EQ(CASS_OK, cass_batch_set_is_idempotent(get(), - enable ? cass_true : cass_false)); + ASSERT_EQ(CASS_OK, cass_batch_set_is_idempotent(get(), enable ? cass_true : cass_false)); } /** @@ -307,8 +296,7 @@ class Batch : public Object { * @param timeout_ms Timeout in milliseconds */ void set_request_timeout(uint64_t timeout_ms) { - ASSERT_EQ(CASS_OK, cass_batch_set_request_timeout(get(), - timeout_ms)); + ASSERT_EQ(CASS_OK, cass_batch_set_request_timeout(get(), timeout_ms)); } /** @@ -326,12 +314,10 @@ class Batch : public Object { * @param serial_consistency Serial consistency to use for the batch */ void set_serial_consistency(CassConsistency serial_consistency) { - ASSERT_EQ(CASS_OK, cass_batch_set_serial_consistency(get(), - serial_consistency)); + ASSERT_EQ(CASS_OK, cass_batch_set_serial_consistency(get(), serial_consistency)); } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_STATEMENT_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/tuple.hpp b/cpp-driver/gtests/src/integration/objects/tuple.hpp index 3be7985d8..313927baf 100644 --- a/cpp-driver/gtests/src/integration/objects/tuple.hpp +++ b/cpp-driver/gtests/src/integration/objects/tuple.hpp @@ -25,8 +25,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * Tuple object @@ -38,7 +37,7 @@ class Tuple : public Object { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; /** @@ -47,9 +46,9 @@ class Tuple : public Object { * @param size Number of elements in the tuple */ Tuple(size_t size) - : Object(cass_tuple_new(size)) - , size_(size) - , is_null_(true) {} + : Object(cass_tuple_new(size)) + , size_(size) + , is_null_(true) {} /** * Create the tuple from a particular column @@ -57,8 +56,8 @@ class Tuple : public Object { * @param column Column to retrieve tuple from */ Tuple(const CassValue* column) - : size_(0) - , is_null_(true) { + : size_(0) + , is_null_(true) { initialize(column); } @@ -67,9 +66,7 @@ class Tuple : public Object { * * @return True if tuple is NULL; false otherwise */ - bool is_null() { - return is_null_; - } + bool is_null() { return is_null_; } /** * Get the next value @@ -92,7 +89,7 @@ class Tuple : public Object { * @throws Exception If tuple is not able to have values added to it (e.g. * The tuple was generated from server result) */ - template + template void set(T value, size_t index) { value.set(*this, index); is_null_ = false; @@ -103,9 +100,7 @@ class Tuple : public Object { * * @return The number of elements in the tuple */ - size_t size() { - return size_; - } + size_t size() { return size_; } /** * Get the current value from the tuple iterator (retrieved from server) @@ -113,7 +108,7 @@ class Tuple : public Object { * @return Current value in the tuple * @throws Exception If iterator is not valid */ - template + template T value() { if (iterator_) { return T(cass_iterator_get_value(iterator_.get())); @@ -126,7 +121,7 @@ class Tuple : public Object { * * @return The tuple as a vector of a single type */ - template + template std::vector values() { std::vector result; const CassValue* value; @@ -144,8 +139,7 @@ class Tuple : public Object { * statement */ void statement_bind(Statement statement, size_t index) { - ASSERT_EQ(CASS_OK, - cass_statement_bind_tuple(statement.get(), index, get())); + ASSERT_EQ(CASS_OK, cass_statement_bind_tuple(statement.get(), index, get())); } protected: @@ -184,7 +178,6 @@ class Tuple : public Object { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_TUPLE_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/user_type.hpp b/cpp-driver/gtests/src/integration/objects/user_type.hpp index daac83473..8aae29528 100644 --- a/cpp-driver/gtests/src/integration/objects/user_type.hpp +++ b/cpp-driver/gtests/src/integration/objects/user_type.hpp @@ -25,8 +25,7 @@ #include -namespace test { -namespace driver { +namespace test { namespace driver { /** * User type object @@ -41,7 +40,7 @@ class UserType : public Object { * @param data_type The data type that makes up the user type */ UserType(const CassDataType* data_type) - : is_null_(true) { + : is_null_(true) { initialize(data_type); } @@ -51,8 +50,8 @@ class UserType : public Object { * @param column Column to retrieve user type from */ UserType(const CassValue* column) - : size_(0) - , is_null_(true) { + : size_(0) + , is_null_(true) { initialize(column); } @@ -61,9 +60,7 @@ class UserType : public Object { * * @return True if user type is NULL; false otherwise */ - bool is_null() { - return is_null_; - } + bool is_null() { return is_null_; } /** * Set the value in the user type @@ -73,7 +70,7 @@ class UserType : public Object { * @throws Exception If user type is not able to have values added to it (e.g. * The user type was generated from server result) */ - template + template void set(T value, const std::string& name) { value.set(*this, name); is_null_ = false; @@ -84,9 +81,7 @@ class UserType : public Object { * * @return The number of elements in the user type */ - size_t size() { - return size_; - } + size_t size() { return size_; } /** * Get a field value from the user type @@ -94,7 +89,7 @@ class UserType : public Object { * @return Value of the field in the user type * @throws Exception If value is not available */ - template + template T value(const std::string& name) { ValuesMap::iterator iterator = values_.find(name); if (iterator != values_.end()) { @@ -108,7 +103,7 @@ class UserType : public Object { * * @return A map of all the fields where the value is a single type */ - template + template std::map values() { std::map result; while (cass_iterator_next(iterator_.get())) { @@ -124,7 +119,6 @@ class UserType : public Object { return result; } - /** * Bind the user type to a statement at the given index * @@ -133,8 +127,7 @@ class UserType : public Object { * statement */ void statement_bind(Statement statement, size_t index) { - ASSERT_EQ(CASS_OK, - cass_statement_bind_user_type(statement.get(), index, get())); + ASSERT_EQ(CASS_OK, cass_statement_bind_user_type(statement.get(), index, get())); } protected: @@ -173,7 +166,6 @@ class UserType : public Object { iterator_ = cass_iterator_fields_from_user_type(value); } - /** * Initialize the user type from the data type * @@ -188,8 +180,7 @@ class UserType : public Object { // Get the user type field name const char* name; size_t name_length; - ASSERT_EQ(CASS_OK, - cass_data_type_sub_type_name(data_type, i, &name, &name_length)); + ASSERT_EQ(CASS_OK, cass_data_type_sub_type_name(data_type, i, &name, &name_length)); // Create a temporary place holder for the field value std::string field(name, name_length); @@ -198,12 +189,10 @@ class UserType : public Object { } // Create the user type from the data type - Object::set( - cass_user_type_new_from_data_type(data_type)); + Object::set(cass_user_type_new_from_data_type(data_type)); } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_USER_DATA_TYPE_HPP__ diff --git a/cpp-driver/gtests/src/integration/objects/uuid_gen.hpp b/cpp-driver/gtests/src/integration/objects/uuid_gen.hpp index 3082e3867..129c080bd 100644 --- a/cpp-driver/gtests/src/integration/objects/uuid_gen.hpp +++ b/cpp-driver/gtests/src/integration/objects/uuid_gen.hpp @@ -22,8 +22,7 @@ #include "values.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Wrapped UUID generator object @@ -34,7 +33,7 @@ class UuidGen : public Object { * Create the UUID generator object */ UuidGen() - : Object(cass_uuid_gen_new()) {} + : Object(cass_uuid_gen_new()) {} /** * Create the UUID generator object with custom node information @@ -42,7 +41,7 @@ class UuidGen : public Object { * @param node Node to use for custom node information */ UuidGen(cass_uint64_t node) - : Object(cass_uuid_gen_new_with_node(node)) {} + : Object(cass_uuid_gen_new_with_node(node)) {} /** * Create the UUID generator object from the native driver object @@ -50,7 +49,7 @@ class UuidGen : public Object { * @param uuid_gen Native driver object */ UuidGen(CassUuidGen* uuid_gen) - : Object(uuid_gen) {} + : Object(uuid_gen) {} /** * Create the UUID generator object from a shared reference @@ -58,7 +57,7 @@ class UuidGen : public Object { * @param uuid_gen Shared reference */ UuidGen(Ptr uuid_gen) - : Object(uuid_gen) {} + : Object(uuid_gen) {} virtual ~UuidGen() {} @@ -97,7 +96,6 @@ class UuidGen : public Object { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __TEST_UUID_GEN_HPP__ diff --git a/cpp-driver/gtests/src/integration/options.cpp b/cpp-driver/gtests/src/integration/options.cpp index 33e351d9d..cd89b377f 100644 --- a/cpp-driver/gtests/src/integration/options.cpp +++ b/cpp-driver/gtests/src/integration/options.cpp @@ -91,8 +91,7 @@ bool Options::initialize(int argc, char* argv[]) { // Integration test options if (key == "--keep-clusters") { is_keep_clusters_ = true; - } - else if (key == "--log-tests") { + } else if (key == "--log-tests") { if (!value.empty()) { is_log_tests_ = bool_value(value); } else { @@ -104,7 +103,8 @@ bool Options::initialize(int argc, char* argv[]) { if (!value.empty()) { server_version_ = CCM::CassVersion(value); } else { - std::cerr << "Missing Server Version: Using default " << server_version_.to_string() << std::endl; + std::cerr << "Missing Server Version: Using default " << server_version_.to_string() + << std::endl; } } else if (key == "--dse") { is_dse_ = true; @@ -119,7 +119,8 @@ bool Options::initialize(int argc, char* argv[]) { } else if (key == "--dse-credentials") { bool is_found = false; if (!value.empty()) { - for (CCM::DseCredentialsType::iterator iterator = CCM::DseCredentialsType::begin(); iterator != CCM::DseCredentialsType::end(); ++iterator) { + for (CCM::DseCredentialsType::iterator iterator = CCM::DseCredentialsType::begin(); + iterator != CCM::DseCredentialsType::end(); ++iterator) { if (*iterator == value) { dse_credentials_type_ = *iterator; is_found = true; @@ -128,7 +129,8 @@ bool Options::initialize(int argc, char* argv[]) { } } if (!is_found) { - std::cerr << "Invalid DSE Credentials Type: Using default " << dse_credentials_type_.to_string() << std::endl; + std::cerr << "Invalid DSE Credentials Type: Using default " + << dse_credentials_type_.to_string() << std::endl; } } else if (key == "--git") { use_git_ = true; @@ -138,7 +140,9 @@ bool Options::initialize(int argc, char* argv[]) { } else if (key == "--install-dir") { use_install_dir_ = true; if (value.empty()) { - std::cerr << "Disabling the Use of the Installation Directory: Installation directory must not be empty" << std::endl; + std::cerr << "Disabling the Use of the Installation Directory: Installation directory " + "must not be empty" + << std::endl; use_install_dir_ = false; } else { install_dir_ = value; @@ -153,12 +157,12 @@ bool Options::initialize(int argc, char* argv[]) { if (!value.empty()) { std::vector categories = test::Utils::explode(value, ':'); for (std::vector::iterator iterator = categories.begin(); - iterator != categories.end(); ++iterator) { + iterator != categories.end(); ++iterator) { try { categories_.insert(*iterator); } catch (TestCategory::Exception& tce) { std::cerr << "Invalid Category: " << *iterator << " will be ignored" - << " (" << tce.what() << ")" << std::endl; + << " (" << tce.what() << ")" << std::endl; } } } else { @@ -167,15 +171,16 @@ bool Options::initialize(int argc, char* argv[]) { } else if (key == "--verbose") { if (!value.empty() && !bool_value(value)) { std::vector components = test::Utils::explode(value, ','); - for (std::vector::iterator it = components.begin(), - end = components.end(); it != end; ++it) { + for (std::vector::iterator it = components.begin(), end = components.end(); + it != end; ++it) { std::string component = test::Utils::to_lower(*it); if (component == "ccm") { is_verbose_ccm_ = true; } else if (component == "integration") { is_verbose_integration_ = true; } else { - std::cerr << "Invalid Component \"" << *it << "\": Available components are [ccm, integration]" << std::endl; + std::cerr << "Invalid Component \"" << *it + << "\": Available components are [ccm, integration]" << std::endl; } } } else { @@ -189,7 +194,8 @@ bool Options::initialize(int argc, char* argv[]) { else if (key == "--authentication") { bool is_found = false; if (!value.empty()) { - for (CCM::AuthenticationType::iterator iterator = CCM::AuthenticationType::begin(); iterator != CCM::AuthenticationType::end(); ++iterator) { + for (CCM::AuthenticationType::iterator iterator = CCM::AuthenticationType::begin(); + iterator != CCM::AuthenticationType::end(); ++iterator) { if (*iterator == value) { authentication_type_ = *iterator; is_found = true; @@ -198,12 +204,14 @@ bool Options::initialize(int argc, char* argv[]) { } } if (!is_found) { - std::cerr << "Invalid Authentication Type: Using default " << authentication_type_.to_string() << std::endl; + std::cerr << "Invalid Authentication Type: Using default " + << authentication_type_.to_string() << std::endl; } } else if (key == "--deployment") { bool is_found = false; if (!value.empty()) { - for (CCM::DeploymentType::iterator iterator = CCM::DeploymentType::begin(); iterator != CCM::DeploymentType::end(); ++iterator) { + for (CCM::DeploymentType::iterator iterator = CCM::DeploymentType::begin(); + iterator != CCM::DeploymentType::end(); ++iterator) { if (*iterator == value) { deployment_type_ = *iterator; is_found = true; @@ -212,7 +220,8 @@ bool Options::initialize(int argc, char* argv[]) { } } if (!is_found) { - std::cerr << "Invalid Deployment Type: Using default " << deployment_type_.to_string() << std::endl; + std::cerr << "Invalid Deployment Type: Using default " << deployment_type_.to_string() + << std::endl; } } else if (key == "--host") { if (!value.empty()) { @@ -221,7 +230,7 @@ bool Options::initialize(int argc, char* argv[]) { std::cerr << "Missing Host: Using default " << host_ << std::endl; } } else if (key == "--port") { - //Convert the value + // Convert the value if (!value.empty()) { std::stringstream ss(value); if (!(ss >> port_).fail()) { @@ -260,8 +269,8 @@ bool Options::initialize(int argc, char* argv[]) { // Determine if the options should have their defaults reset if (categories_.empty()) { - for (TestCategory::iterator iterator = TestCategory::begin(); - iterator != TestCategory::end(); ++iterator) { + for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end(); + ++iterator) { // Only add the DSE test category if DSE is enabled if (*iterator != TestCategory::DSE || is_dse_) { categories_.insert(*iterator); @@ -277,7 +286,8 @@ bool Options::initialize(int argc, char* argv[]) { // Determine if the DSE credentials type should be updated if (dse_credentials_type_ == CCM::DseCredentialsType::USERNAME_PASSWORD) { if (dse_username_.empty() || dse_password_.empty()) { - std::cerr << "Invalid Username and/or Password: Default to INI_FILE DSE credentials" << std::endl; + std::cerr << "Invalid Username and/or Password: Default to INI_FILE DSE credentials" + << std::endl; dse_credentials_type_ = CCM::DseCredentialsType::INI_FILE; } } @@ -292,75 +302,102 @@ bool Options::initialize(int argc, char* argv[]) { void Options::print_help() { std::cout << std::endl << "Integration Test Options:" << std::endl; - std::cout << " --log-tests=(yes|no)" << std::endl << " " - << "Enable/Disable logging of driver messages per test to a file." << std::endl - << " The default is " << (log_tests() ? "yes" : "no") << "." << std::endl; + std::cout << " --log-tests=(yes|no)" << std::endl + << " " + << "Enable/Disable logging of driver messages per test to a file." << std::endl + << " The default is " << (log_tests() ? "yes" : "no") << "." << std::endl; std::cout << std::endl << "CCM Options:" << std::endl; - std::cout << " --version=[VERSION]" << std::endl << " " - << "Cassandra/DSE version to use." << std::endl - << " Default:" << std::endl - << " Cassandra Version: " << server_version().to_string() << std::endl - << " DSE Version: " << DEFAULT_OPTIONS_DSE_VERSION.to_string() << std::endl; + std::cout << " --version=[VERSION]" << std::endl + << " " + << "Cassandra/DSE version to use." << std::endl + << " Default:" << std::endl + << " Cassandra Version: " << server_version().to_string() << std::endl + << " DSE Version: " << DEFAULT_OPTIONS_DSE_VERSION.to_string() << std::endl; std::string categories; - for (TestCategory::iterator iterator = TestCategory::begin(); - iterator != TestCategory::end(); ++iterator) { + for (TestCategory::iterator iterator = TestCategory::begin(); iterator != TestCategory::end(); + ++iterator) { if (iterator != TestCategory::begin()) { categories += "|"; } categories += iterator->name(); } - std::cout << " --category=[" << categories << "]" << std::endl << " " - << "Run only the categories whose name matches one of the available" << std::endl - << " categories; ':' separates two categories. The default is all categories" << std::endl - << " being executed." << std::endl; - std::cout << " --dse" << std::endl << " " - << "Indicate server version supplied is DSE." << std::endl; - std::cout << " --dse-credentials=(USERNAME_PASSWORD|INI_FILE)" << std::endl << " " - << "DSE credentials to use for download authentication. The default is " << std::endl - << " " << dse_credentials().to_string() << "." << std::endl; - std::cout << " --dse-username=[USERNAME]" << std::endl << " " - << "Username to use for DSE download authentication." << std::endl; - std::cout << " --dse-password=[PASSWORD]" << std::endl << " " - << "Password to use for DSE download authentication." << std::endl; - std::cout << " --git" << std::endl << " " - << "Indicate Cassandra/DSE server download should be obtained from" << std::endl - << " ASF/GitHub." << std::endl; - std::cout << " --git=[BRANCH_OR_TAG]" << std::endl << " " - << "Indicate Cassandra/DSE server branch/tag should be obtained from" << std::endl - << " ASF/GitHub." << std::endl; - std::cout << " --install-dir=[INSTALL_DIR]" << std::endl << " " - << "Indicate Cassandra/DSE installation directory to use." << std::endl; - std::cout << " --prefix=[PREFIX]" << std::endl << " " - << "CCM cluster prefix. The default is " << cluster_prefix() << "." << std::endl; + std::cout << " --category=[" << categories << "]" << std::endl + << " " + << "Run only the categories whose name matches one of the available" << std::endl + << " categories; ':' separates two categories. The default is all categories" + << std::endl + << " being executed." << std::endl; + std::cout << " --dse" << std::endl + << " " + << "Indicate server version supplied is DSE." << std::endl; + std::cout << " --dse-credentials=(USERNAME_PASSWORD|INI_FILE)" << std::endl + << " " + << "DSE credentials to use for download authentication. The default is " << std::endl + << " " << dse_credentials().to_string() << "." << std::endl; + std::cout << " --dse-username=[USERNAME]" << std::endl + << " " + << "Username to use for DSE download authentication." << std::endl; + std::cout << " --dse-password=[PASSWORD]" << std::endl + << " " + << "Password to use for DSE download authentication." << std::endl; + std::cout << " --git" << std::endl + << " " + << "Indicate Cassandra/DSE server download should be obtained from" << std::endl + << " ASF/GitHub." << std::endl; + std::cout << " --git=[BRANCH_OR_TAG]" << std::endl + << " " + << "Indicate Cassandra/DSE server branch/tag should be obtained from" << std::endl + << " ASF/GitHub." << std::endl; + std::cout << " --install-dir=[INSTALL_DIR]" << std::endl + << " " + << "Indicate Cassandra/DSE installation directory to use." << std::endl; + std::cout << " --prefix=[PREFIX]" << std::endl + << " " + << "CCM cluster prefix. The default is " << cluster_prefix() << "." << std::endl; #ifdef CASS_USE_LIBSSH2 - std::cout << " --authentication=(USERNAME_PASSWORD|PUBLIC_KEY)" << std::endl << " " - << "Authentication to use for remote deployment. The default is" << std::endl - << " " << authentication_type().to_string() << "." << std::endl; - std::cout << " --deployment=(LOCAL|REMOTE)" << std::endl << " " - << "Deployment to use. The default is " << deployment_type().to_string() << "." << std::endl; - std::cout << " --host=[IP_ADDRESS]" << std::endl << " " - << "IP address to use for remote deployment. The default is " << host() << "." << std::endl; - std::cout << " --port=[PORT]" << std::endl << " " - << "Port to use for remote deployment. The default is " << port() << "." << std::endl; - std::cout << " --username=[USERNAME]" << std::endl << " " - << "Username to use for remote deployment. The default is " << username() << "." << std::endl; - std::cout << " --password=[PASSWORD]" << std::endl << " " - << "Password to use for remote deployment. The default is " << password() << "." << std::endl; - std::cout << " --public-key=[FILENAME]" << std::endl << " " - << "Public key filename to use for remote deployment. The default is" << std::endl - << " " << public_key() << "." << std::endl; - std::cout << " --private-key=[FILENAME]" << std::endl << " " - << "Private key filename to use for remote deployment. The default is" << std::endl - << " " << private_key() << "." << std::endl; + std::cout << " --authentication=(USERNAME_PASSWORD|PUBLIC_KEY)" << std::endl + << " " + << "Authentication to use for remote deployment. The default is" << std::endl + << " " << authentication_type().to_string() << "." << std::endl; + std::cout << " --deployment=(LOCAL|REMOTE)" << std::endl + << " " + << "Deployment to use. The default is " << deployment_type().to_string() << "." + << std::endl; + std::cout << " --host=[IP_ADDRESS]" << std::endl + << " " + << "IP address to use for remote deployment. The default is " << host() << "." + << std::endl; + std::cout << " --port=[PORT]" << std::endl + << " " + << "Port to use for remote deployment. The default is " << port() << "." << std::endl; + std::cout << " --username=[USERNAME]" << std::endl + << " " + << "Username to use for remote deployment. The default is " << username() << "." + << std::endl; + std::cout << " --password=[PASSWORD]" << std::endl + << " " + << "Password to use for remote deployment. The default is " << password() << "." + << std::endl; + std::cout << " --public-key=[FILENAME]" << std::endl + << " " + << "Public key filename to use for remote deployment. The default is" << std::endl + << " " << public_key() << "." << std::endl; + std::cout << " --private-key=[FILENAME]" << std::endl + << " " + << "Private key filename to use for remote deployment. The default is" << std::endl + << " " << private_key() << "." << std::endl; #endif - std::cout << " --keep-clusters" << std::endl << " " - << "Indicate CCM clusters should not be removed after tests terminate." - << std::endl; - std::cout << " --verbose(=ccm,integration)" << std::endl << " " - << "Enable verbose output for component(s)." << std::endl; - std::cout << " --disable-beta-protocol" << std::endl << " " - << "Disable beta protocol use by default." << std::endl << " " - << "NOTE: Individual tests may override this setting." << std::endl; + std::cout << " --keep-clusters" << std::endl + << " " + << "Indicate CCM clusters should not be removed after tests terminate." << std::endl; + std::cout << " --verbose(=ccm,integration)" << std::endl + << " " + << "Enable verbose output for component(s)." << std::endl; + std::cout << " --disable-beta-protocol" << std::endl + << " " + << "Disable beta protocol use by default." << std::endl + << " " + << "NOTE: Individual tests may override this setting." << std::endl; std::cout << std::endl; } @@ -411,25 +448,15 @@ void Options::print_settings() { #endif } -bool Options::is_help() { - return is_help_; -} +bool Options::is_help() { return is_help_; } -bool Options::keep_clusters() { - return is_keep_clusters_; -} +bool Options::keep_clusters() { return is_keep_clusters_; } -bool Options::log_tests() { - return is_log_tests_; -} +bool Options::log_tests() { return is_log_tests_; } -CCM::CassVersion Options::server_version() { - return server_version_; -} +CCM::CassVersion Options::server_version() { return server_version_; } -bool Options::is_dse() { - return is_dse_; -} +bool Options::is_dse() { return is_dse_; } CCM::DseCredentialsType Options::dse_credentials() { // Static initialization cannot be guaranteed @@ -439,33 +466,19 @@ CCM::DseCredentialsType Options::dse_credentials() { return dse_credentials_type_; } -const std::string& Options::dse_username() { - return dse_username_; -} +const std::string& Options::dse_username() { return dse_username_; } -const std::string& Options::dse_password() { - return dse_password_; -} +const std::string& Options::dse_password() { return dse_password_; } -bool Options::use_git() { - return use_git_; -} +bool Options::use_git() { return use_git_; } -const std::string& Options::branch_tag() { - return branch_tag_; -} +const std::string& Options::branch_tag() { return branch_tag_; } -bool Options::use_install_dir() { - return use_install_dir_; -} +bool Options::use_install_dir() { return use_install_dir_; } -const std::string& Options::install_dir() { - return install_dir_; -} +const std::string& Options::install_dir() { return install_dir_; } -const std::string& Options::cluster_prefix() { - return cluster_prefix_; -} +const std::string& Options::cluster_prefix() { return cluster_prefix_; } CCM::DeploymentType Options::deployment_type() { // Static initialization cannot be guaranteed @@ -483,73 +496,44 @@ CCM::AuthenticationType Options::authentication_type() { return authentication_type_; } -std::set Options::categories() { - return categories_; -} +std::set Options::categories() { return categories_; } -const std::string& Options::host() { - return host_; -} +const std::string& Options::host() { return host_; } -std::string Options::host_prefix() { - return host_.substr(0, host_.size() - 1); -} +std::string Options::host_prefix() { return host_.substr(0, host_.size() - 1); } -short Options::port() { - return port_; -} +short Options::port() { return port_; } -const std::string& Options::username() { - return username_; -} +const std::string& Options::username() { return username_; } -const std::string& Options::password() { - return password_; -} +const std::string& Options::password() { return password_; } -const std::string& Options::public_key() { - return public_key_; -} +const std::string& Options::public_key() { return public_key_; } -const std::string& Options::private_key() { - return private_key_; -} +const std::string& Options::private_key() { return private_key_; } -SharedPtr > Options::ccm() { - return new CCM::Bridge( \ - Options::server_version(), - Options::use_git(), Options::branch_tag(), \ - Options::use_install_dir(), Options::install_dir(), \ - Options::is_dse(), CCM::Bridge::DEFAULT_DSE_WORKLOAD, \ - Options::cluster_prefix(), \ - Options::dse_credentials(), \ - Options::dse_username(), Options::dse_password(), \ - Options::deployment_type(), Options::authentication_type(), \ - Options::host(), Options::port(), \ - Options::username(), Options::password(), \ - Options::public_key(), Options::private_key(), - Options::is_verbose_ccm()); +SharedPtr> Options::ccm() { + return new CCM::Bridge(Options::server_version(), Options::use_git(), Options::branch_tag(), + Options::use_install_dir(), Options::install_dir(), Options::is_dse(), + CCM::Bridge::DEFAULT_DSE_WORKLOAD, Options::cluster_prefix(), + Options::dse_credentials(), Options::dse_username(), + Options::dse_password(), Options::deployment_type(), + Options::authentication_type(), Options::host(), Options::port(), + Options::username(), Options::password(), Options::public_key(), + Options::private_key(), Options::is_verbose_ccm()); } -bool Options::is_verbose_ccm() { - return is_verbose_ccm_; -} +bool Options::is_verbose_ccm() { return is_verbose_ccm_; } -bool Options::is_verbose_integration() { - return is_verbose_integration_; -} +bool Options::is_verbose_integration() { return is_verbose_integration_; } -bool Options::is_beta_protocol() { - return is_beta_protocol_; -} +bool Options::is_beta_protocol() { return is_beta_protocol_; } -Options::Options() { -} +Options::Options() {} bool Options::bool_value(const std::string& value) { std::string lower_value = test::Utils::to_lower(value); - if (lower_value == "yes" || lower_value == "true" || - lower_value == "on" || lower_value == "0") { + if (lower_value == "yes" || lower_value == "true" || lower_value == "on" || lower_value == "0") { return true; } return false; diff --git a/cpp-driver/gtests/src/integration/options.hpp b/cpp-driver/gtests/src/integration/options.hpp index 583797bcc..0ad9531eb 100644 --- a/cpp-driver/gtests/src/integration/options.hpp +++ b/cpp-driver/gtests/src/integration/options.hpp @@ -220,7 +220,7 @@ class Options { * * @return CCM instance */ - static SharedPtr > ccm(); + static SharedPtr> ccm(); private: /** @@ -354,4 +354,3 @@ class Options { }; #endif // __OPTIONS_HPP__ - diff --git a/cpp-driver/gtests/src/integration/policies.hpp b/cpp-driver/gtests/src/integration/policies.hpp index 61a66c87b..0a7f3a5f9 100644 --- a/cpp-driver/gtests/src/integration/policies.hpp +++ b/cpp-driver/gtests/src/integration/policies.hpp @@ -21,4 +21,3 @@ #include "policies/next_host_retry_policy.hpp" #endif // __TEST_POLICIES_HPP__ - diff --git a/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp b/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp index 983978a29..c22f9be13 100644 --- a/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp +++ b/cpp-driver/gtests/src/integration/policies/ignore_retry_policy.hpp @@ -21,8 +21,7 @@ #include "retry_policy.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Retry policy that will create an ignore decision for retry @@ -30,7 +29,7 @@ namespace driver { class IgnoreRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { public: IgnoreRetryPolicy() - : datastax::internal::core::DefaultRetryPolicy() { } + : datastax::internal::core::DefaultRetryPolicy() {} /** * Create an instance of the retry policy for use with the driver @@ -44,25 +43,17 @@ class IgnoreRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { } RetryDecision on_read_timeout(const datastax::internal::core::Request* request, - CassConsistency cl, - int received, - int required, - bool data_recevied, + CassConsistency cl, int received, int required, bool data_recevied, int num_retries) const { return RetryDecision::ignore(); } RetryDecision on_write_timeout(const datastax::internal::core::Request* request, - CassConsistency cl, - int received, - int required, - CassWriteType write_type, - int num_retries) const { + CassConsistency cl, int received, int required, + CassWriteType write_type, int num_retries) const { return RetryDecision::ignore(); } virtual RetryDecision on_unavailable(const datastax::internal::core::Request* request, - CassConsistency cl, - int required, - int alive, + CassConsistency cl, int required, int alive, int num_retries) const { return RetryDecision::ignore(); } @@ -74,7 +65,6 @@ class IgnoreRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __ALWAYS_IGNORE_RETRY_POLICY_HPP__ diff --git a/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp b/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp index 0ebf05eaa..59d3fe90d 100644 --- a/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp +++ b/cpp-driver/gtests/src/integration/policies/next_host_retry_policy.hpp @@ -21,8 +21,7 @@ #include "retry_policy.hpp" -namespace test { -namespace driver { +namespace test { namespace driver { /** * Retry policy that will retry the statement on the next host @@ -30,7 +29,7 @@ namespace driver { class NextHostRetryPolicy : public datastax::internal::core::DefaultRetryPolicy { public: NextHostRetryPolicy() - : datastax::internal::core::DefaultRetryPolicy() { } + : datastax::internal::core::DefaultRetryPolicy() {} /** * Create an instance of the retry policy for use with the driver @@ -44,25 +43,17 @@ class NextHostRetryPolicy : public datastax::internal::core::DefaultRetryPolicy } RetryDecision on_read_timeout(const datastax::internal::core::Request* request, - CassConsistency cl, - int received, - int required, - bool data_recevied, + CassConsistency cl, int received, int required, bool data_recevied, int num_retries) const { return RetryDecision::retry_next_host(cl); } RetryDecision on_write_timeout(const datastax::internal::core::Request* request, - CassConsistency cl, - int received, - int required, - CassWriteType write_type, - int num_retries) const { + CassConsistency cl, int received, int required, + CassWriteType write_type, int num_retries) const { return RetryDecision::retry_next_host(cl); } virtual RetryDecision on_unavailable(const datastax::internal::core::Request* request, - CassConsistency cl, - int required, - int alive, + CassConsistency cl, int required, int alive, int num_retries) const { return RetryDecision::retry_next_host(cl); } @@ -74,7 +65,6 @@ class NextHostRetryPolicy : public datastax::internal::core::DefaultRetryPolicy } }; -} // namespace driver -} // namespace test +}} // namespace test::driver #endif // __NEXT_HOST_RETRY_POLICY_HPP__ diff --git a/cpp-driver/gtests/src/integration/rest_client.cpp b/cpp-driver/gtests/src/integration/rest_client.cpp index f7e380c56..2e36de389 100644 --- a/cpp-driver/gtests/src/integration/rest_client.cpp +++ b/cpp-driver/gtests/src/integration/rest_client.cpp @@ -50,12 +50,11 @@ struct HttpRequest { }; const Response RestClient::send_request(const Request& request) { - // Initialize the loop + // Initialize the loop uv_loop_t loop; int error_code = uv_loop_init(&loop); - if(error_code != 0) { - throw Exception("Unable to Send Request: " + - std::string(uv_strerror(error_code))); + if (error_code != 0) { + throw Exception("Unable to Send Request: " + std::string(uv_strerror(error_code))); }; // Initialize the HTTP request @@ -64,40 +63,33 @@ const Response RestClient::send_request(const Request& request) { http_request.loop = &loop; // Create the IPv4 socket address - const Address address(request.address.c_str(), - static_cast(request.port)); + const Address address(request.address.c_str(), static_cast(request.port)); // Initialize the client TCP request uv_tcp_t tcp; tcp.data = &http_request; error_code = uv_tcp_init(&loop, &tcp); if (error_code != 0) { - TEST_LOG_ERROR("Unable to Initialize TCP Request: " + - std::string(uv_strerror(error_code))); + TEST_LOG_ERROR("Unable to Initialize TCP Request: " + std::string(uv_strerror(error_code))); } error_code = uv_tcp_keepalive(&tcp, 1, 60); if (error_code != 0) { - TEST_LOG_ERROR("Unable to Set TCP KeepAlive: " + - std::string(uv_strerror(error_code))); + TEST_LOG_ERROR("Unable to Set TCP KeepAlive: " + std::string(uv_strerror(error_code))); } // Start the request and attach the HTTP request to send to the REST server uv_connect_t connect; connect.data = &http_request; - uv_tcp_connect(&connect, &tcp, - address.addr(), - handle_connected); + uv_tcp_connect(&connect, &tcp, address.addr(), handle_connected); - uv_run(&loop, UV_RUN_DEFAULT); - uv_loop_close(&loop); + uv_run(&loop, UV_RUN_DEFAULT); + uv_loop_close(&loop); // Return the response from the request return http_request.response; } -void RestClient::handle_allocation(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buffer) { +void RestClient::handle_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer) { buffer->base = new char[OUTPUT_BUFFER_SIZE]; buffer->len = OUTPUT_BUFFER_SIZE; } @@ -106,8 +98,7 @@ void RestClient::handle_connected(uv_connect_t* req, int status) { HttpRequest* request = static_cast(req->data); if (status < 0) { - TEST_LOG_ERROR("Unable to Connect to HTTP Server: " - << uv_strerror(status)); + TEST_LOG_ERROR("Unable to Connect to HTTP Server: " << uv_strerror(status)); uv_close(reinterpret_cast(req->handle), NULL); } else { // Create the buffer to write to the stream @@ -120,8 +111,7 @@ void RestClient::handle_connected(uv_connect_t* req, int status) { } } -void RestClient::handle_response(uv_stream_t* stream, - ssize_t buffer_length, +void RestClient::handle_response(uv_stream_t* stream, ssize_t buffer_length, const uv_buf_t* buffer) { HttpRequest* request = static_cast(stream->data); @@ -172,12 +162,10 @@ const std::string RestClient::generate_http_message(const Request& request) { // Generate the headers bool is_post = request.method == Request::HTTP_METHOD_POST; - message - << "Host: " << request.address << ":" << request.port << HTTP_EOL - << (is_post ? "Content-Type: application/json" HTTP_EOL : "") - << "Content-Length: "<< ((is_post) ? request.content.size() : 0) << HTTP_EOL - << "Connection: close" << HTTP_EOL << HTTP_EOL - << (is_post ? request.content : ""); + message << "Host: " << request.address << ":" << request.port << HTTP_EOL + << (is_post ? "Content-Type: application/json" HTTP_EOL : "") + << "Content-Length: " << ((is_post) ? request.content.size() : 0) << HTTP_EOL + << "Connection: close" << HTTP_EOL << HTTP_EOL << (is_post ? request.content : ""); // Return the HTTP message TEST_LOG("[HTTP Message]: " << message.str()); diff --git a/cpp-driver/gtests/src/integration/rest_client.hpp b/cpp-driver/gtests/src/integration/rest_client.hpp index 99a18b165..76638818b 100644 --- a/cpp-driver/gtests/src/integration/rest_client.hpp +++ b/cpp-driver/gtests/src/integration/rest_client.hpp @@ -30,11 +30,7 @@ struct Request { /** * HTTP request method */ - enum Method { - HTTP_METHOD_DELETE = 0, - HTTP_METHOD_GET, - HTTP_METHOD_POST - }; + enum Method { HTTP_METHOD_DELETE = 0, HTTP_METHOD_GET, HTTP_METHOD_POST }; /** * Host address IPv4 @@ -72,7 +68,7 @@ struct Response { int status_code; Response() - : status_code(200 /* OK */) { } + : status_code(200 /* OK */) {} }; /** @@ -84,7 +80,7 @@ class RestClient { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; /** @@ -117,8 +113,7 @@ class RestClient { * @param suggested_size The size (in bytes) to allocate for the buffer * @param buf Buffer to be allocated */ - static void handle_allocation(uv_handle_t* handle, size_t suggested_size, - uv_buf_t* buffer); + static void handle_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer); /** * Handle the connect (callback) when the connection has been established to @@ -138,9 +133,7 @@ class RestClient { * will equal UV_EOF * @param buf Buffer to read from */ - static void handle_response(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); + static void handle_response(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); /** * Generate the HTTP message for the REST request. @@ -149,7 +142,6 @@ class RestClient { * @return String representing the REST request HTTP message */ static const std::string generate_http_message(const Request& request); - }; #endif // __TEST_REST_CLIENT_HPP__ diff --git a/cpp-driver/gtests/src/integration/shared_ptr.hpp b/cpp-driver/gtests/src/integration/shared_ptr.hpp index ac202786c..39f579952 100644 --- a/cpp-driver/gtests/src/integration/shared_ptr.hpp +++ b/cpp-driver/gtests/src/integration/shared_ptr.hpp @@ -16,8 +16,8 @@ #ifndef __SHARED_PTR_HPP__ #define __SHARED_PTR_HPP__ -#include "scoped_ptr.hpp" #include "ref_counted.hpp" +#include "scoped_ptr.hpp" template struct StdDeleter { @@ -27,24 +27,20 @@ struct StdDeleter { /** * Reference counted objects container */ -template > -class ObjectRef : public datastax::internal::RefCounted< ObjectRef > { +template > +class ObjectRef : public datastax::internal::RefCounted> { public: ObjectRef(T* ptr) - : ptr_(ptr) {} + : ptr_(ptr) {} - virtual ~ObjectRef() { - D()(ptr_); - } + virtual ~ObjectRef() { D()(ptr_); } /** * Get the native object * * @return The native object */ - T* get() { - return ptr_; - } + T* get() { return ptr_; } private: /** @@ -56,28 +52,22 @@ class ObjectRef : public datastax::internal::RefCounted< ObjectRef > { /** * Shared pointer for object references */ -template > +template > class SharedPtr { public: SharedPtr(T* ptr = NULL) - : object_(NULL) { + : object_(NULL) { if (ptr) { ObjectRef* object_ref = new ObjectRef(ptr); - object_ = datastax::internal::SharedRefPtr >(object_ref); + object_ = datastax::internal::SharedRefPtr>(object_ref); } } - T* operator->() { - return get(); - } + T* operator->() { return get(); } - T& operator*() { - return *get(); - } + T& operator*() { return *get(); } - operator bool() const { - return object_; - } + operator bool() const { return object_; } /** * Get the native object from the object reference @@ -97,11 +87,12 @@ class SharedPtr { } return NULL; } + private: /** * Object reference */ - datastax::internal::SharedRefPtr > object_; + datastax::internal::SharedRefPtr> object_; }; #endif // __SHARED_PTR_HPP__ diff --git a/cpp-driver/gtests/src/integration/simulacron/priming_requests.hpp b/cpp-driver/gtests/src/integration/simulacron/priming_requests.hpp index 9ab1716ee..f5bb950ba 100644 --- a/cpp-driver/gtests/src/integration/simulacron/priming_requests.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/priming_requests.hpp @@ -35,11 +35,11 @@ class Request { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; Request() - : then_(new Success()) { }; + : then_(new Success()){}; /** * Generate the JSON for the priming request @@ -80,8 +80,7 @@ class Request { * @param consistency Consistency levels for the request * @return PrimingRequest instance */ - Request& with_consistencies( - const std::vector& consistency) { + Request& with_consistencies(const std::vector& consistency) { when_.with_consistencies(consistency); return *this; } @@ -98,11 +97,11 @@ class Request { } /** - * Set a response for the request - * - * @param result Response to the request - * @return PrimingRequest instance - */ + * Set a response for the request + * + * @param result Response to the request + * @return PrimingRequest instance + */ Request& with_result(Result* result) { then_ = result; return *this; @@ -110,7 +109,8 @@ class Request { private: class When { - friend class Request; + friend class Request; + private: /** * Consistency levels @@ -121,7 +121,7 @@ class Request { */ std::string query_; - When() {}; + When(){}; /** * Build the when section for the priming request @@ -136,7 +136,7 @@ class Request { writer.Key("consistency"); writer.StartArray(); for (std::vector::iterator iterator = consistencies_.begin(); - iterator != consistencies_.end(); ++iterator) { + iterator != consistencies_.end(); ++iterator) { writer.String(cass_consistency_string(*iterator)); } writer.EndArray(); @@ -171,9 +171,7 @@ class Request { * * @param query Query for the request */ - void with_query(const std::string& query) { - query_ = query; - } + void with_query(const std::string& query) { query_ = query; } }; private: diff --git a/cpp-driver/gtests/src/integration/simulacron/priming_rows.hpp b/cpp-driver/gtests/src/integration/simulacron/priming_rows.hpp index 41d2d5b41..e9791b029 100644 --- a/cpp-driver/gtests/src/integration/simulacron/priming_rows.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/priming_rows.hpp @@ -22,12 +22,12 @@ #include "cassandra.h" -#include #include +#include #include -#include #include +#include #include namespace prime { @@ -38,16 +38,17 @@ class Rows; * Priming row */ class Row { -friend class Rows; + friend class Rows; + public: class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; typedef std::pair Column; - Row() { }; + Row(){}; /** * Add a column|value pair @@ -57,22 +58,19 @@ friend class Rows; * @param value Value for the column * @return PrimingRow instance */ - Row& add_column(const std::string& name, - const CassValueType value_type, + Row& add_column(const std::string& name, const CassValueType value_type, const std::string& value) { std::string cql_type = test::Utils::scalar_cql_type(value_type); - if (value_type == CASS_VALUE_TYPE_LIST || - value_type == CASS_VALUE_TYPE_MAP || - value_type == CASS_VALUE_TYPE_SET) { - throw Exception("Value Type " + cql_type + "Needs to be Parameterized: " - "Use add_column(string name, string cql_value_type, string value) instead"); - } - - //TODO: Add types when supported by Simulacron - if (value_type == CASS_VALUE_TYPE_CUSTOM || - value_type == CASS_VALUE_TYPE_UDT) { - throw Exception("Value Type is not Supported by Simulacron: " - + cql_type); + if (value_type == CASS_VALUE_TYPE_LIST || value_type == CASS_VALUE_TYPE_MAP || + value_type == CASS_VALUE_TYPE_SET) { + throw Exception("Value Type " + cql_type + + "Needs to be Parameterized: " + "Use add_column(string name, string cql_value_type, string value) instead"); + } + + // TODO: Add types when supported by Simulacron + if (value_type == CASS_VALUE_TYPE_CUSTOM || value_type == CASS_VALUE_TYPE_UDT) { + throw Exception("Value Type is not Supported by Simulacron: " + cql_type); } return add_column(name, cql_type, value); @@ -86,10 +84,9 @@ friend class Rows; * @param value Value for the column * @return PrimingRow instance */ - Row& add_column(const std::string& name, - const std::string& cql_value_type, + Row& add_column(const std::string& name, const std::string& cql_value_type, const std::string& value) { - //TODO: Add validation (mainly for parameterized types) + // TODO: Add validation (mainly for parameterized types) // Ensure the column doesn't already exist if (columns_.find(name) != columns_.end()) { throw Exception("Unable to Add Column: Already Exists [" + name + "]"); @@ -107,13 +104,10 @@ friend class Rows; * otherwise */ bool operator==(const Row& rhs) const { - return columns_.size() == rhs.columns_.size() - && std::equal(columns_.begin(), columns_.end(), rhs.columns_.begin(), - ColumnsKeyEquality()); - } - bool operator!=(const Row& rhs) const { - return !(*this == rhs); + return columns_.size() == rhs.columns_.size() && + std::equal(columns_.begin(), columns_.end(), rhs.columns_.begin(), ColumnsKeyEquality()); } + bool operator!=(const Row& rhs) const { return !(*this == rhs); } protected: /** @@ -125,8 +119,7 @@ friend class Rows; writer.Key("column_types"); writer.StartObject(); - for (Map::iterator iterator = columns_.begin(); iterator != columns_.end(); - ++iterator) { + for (Map::iterator iterator = columns_.begin(); iterator != columns_.end(); ++iterator) { std::string name = iterator->first; std::string cql_type = iterator->second.first; writer.Key(name.c_str()); @@ -144,21 +137,19 @@ friend class Rows; void build_row(rapidjson::PrettyWriter& writer) { writer.StartObject(); - for (Map::iterator iterator = columns_.begin(); iterator != columns_.end(); - ++iterator) { + for (Map::iterator iterator = columns_.begin(); iterator != columns_.end(); ++iterator) { std::string name = iterator->first; std::string value = iterator->second.second; // Add the column|value pair writer.Key(name.c_str()); - bool is_array = value.compare(0, 1, "[") == 0 && - value.compare(value.size() - 1, 1, "]") == 0; + bool is_array = value.compare(0, 1, "[") == 0 && value.compare(value.size() - 1, 1, "]") == 0; if (is_array) { value = value.substr(1, value.size() - 2); writer.StartArray(); std::vector values = test::Utils::explode(value, ','); - for (std::vector::iterator iterator = values.begin(); - iterator != values.end(); ++iterator) { + for (std::vector::iterator iterator = values.begin(); iterator != values.end(); + ++iterator) { writer.String((*iterator).c_str()); } writer.EndArray(); @@ -200,15 +191,16 @@ friend class Rows; * Priming rows */ class Rows { -friend class Success; + friend class Success; + public: class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; - Rows() { }; + Rows(){}; /** * Add a row @@ -219,8 +211,7 @@ friend class Success; */ Rows& add_row(const Row& columns) { if (!rows_.empty() && rows_.front() != columns) { - throw Exception( - "Unable to Add Row: Columns are incompatible with previous row(s)"); + throw Exception("Unable to Add Row: Columns are incompatible with previous row(s)"); } rows_.push_back(columns); return *this; @@ -231,9 +222,7 @@ friend class Success; * * @return True if rows are empty; false otherwise */ - bool empty() const { - return rows_.empty(); - } + bool empty() const { return rows_.empty(); } protected: /** @@ -254,8 +243,7 @@ friend class Success; // Iterate over the rows and add each row to the rows object array rows.Key("rows"); rows.StartArray(); - for (std::vector::iterator iterator = rows_.begin(); - iterator != rows_.end(); ++iterator) { + for (std::vector::iterator iterator = rows_.begin(); iterator != rows_.end(); ++iterator) { iterator->build_row(rows); } rows.EndArray(); diff --git a/cpp-driver/gtests/src/integration/simulacron/results/close_connection.hpp b/cpp-driver/gtests/src/integration/simulacron/results/close_connection.hpp index 1182baaa6..52305e0ff 100644 --- a/cpp-driver/gtests/src/integration/simulacron/results/close_connection.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/results/close_connection.hpp @@ -26,11 +26,7 @@ /** * Enumeration for 'close_type' property */ -enum CloseType { - CLOSE_TYPE_DISCONNECT, - CLOSE_TYPE_SHUTDOWN_READ, - CLOSE_TYPE_SHUTDOWN_WRITE -}; +enum CloseType { CLOSE_TYPE_DISCONNECT, CLOSE_TYPE_SHUTDOWN_READ, CLOSE_TYPE_SHUTDOWN_WRITE }; /** * Enumeration for disconnect 'scope' property @@ -55,13 +51,13 @@ class CloseConnection : public Result { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; CloseConnection() - : Result("close_connection") - , close_type_(CLOSE_TYPE_DISCONNECT) - , scope_(DISCONNECT_SCOPE_CONNECTION) { } + : Result("close_connection") + , close_type_(CLOSE_TYPE_DISCONNECT) + , scope_(DISCONNECT_SCOPE_CONNECTION) {} /** * Fully construct the 'close_connection' result @@ -71,12 +67,10 @@ class CloseConnection : public Result { * @param scope The scope (connection, node, data center, cluster) at which to * close the associated connection(s) */ - CloseConnection(unsigned long delay_in_ms, - CloseType close_type, - DisconnectScope scope) - : Result("close_connection", delay_in_ms) - , close_type_(close_type) - , scope_(scope) { } + CloseConnection(unsigned long delay_in_ms, CloseType close_type, DisconnectScope scope) + : Result("close_connection", delay_in_ms) + , close_type_(close_type) + , scope_(scope) {} /** * Set a fixed delay to the response time of a result @@ -135,7 +129,7 @@ class CloseConnection : public Result { * @return String representation of the close type property */ std::string get_close_type(CloseType type) const { - switch(type) { + switch (type) { case CLOSE_TYPE_DISCONNECT: return "disconnect"; case CLOSE_TYPE_SHUTDOWN_READ: @@ -144,11 +138,10 @@ class CloseConnection : public Result { return "shutdown_write"; default: std::stringstream message; - message << "Unsupported Close Type: " << type - << " will need to be added"; + message << "Unsupported Close Type: " << type << " will need to be added"; throw Exception(message.str()); break; - } + } } /** @@ -158,7 +151,7 @@ class CloseConnection : public Result { * @return String representation of the disconnect scope property */ std::string get_disconnect_scope(DisconnectScope disconnect_scope) const { - switch(disconnect_scope) { + switch (disconnect_scope) { case DISCONNECT_SCOPE_CONNECTION: return "connection"; case DISCONNECT_SCOPE_NODE: @@ -169,11 +162,10 @@ class CloseConnection : public Result { return "cluster"; default: std::stringstream message; - message << "Unsupported Disconnect Scope: " << disconnect_scope - << " will need to be added"; + message << "Unsupported Disconnect Scope: " << disconnect_scope << " will need to be added"; throw Exception(message.str()); break; - } + } } private: diff --git a/cpp-driver/gtests/src/integration/simulacron/results/result.hpp b/cpp-driver/gtests/src/integration/simulacron/results/result.hpp index f5380ec42..ba303c7df 100644 --- a/cpp-driver/gtests/src/integration/simulacron/results/result.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/results/result.hpp @@ -19,8 +19,8 @@ #include -#include #include +#include namespace prime { @@ -29,7 +29,7 @@ namespace prime { */ class Result { public: - virtual ~Result() { } + virtual ~Result() {} /** * Generate the JSON for the base result @@ -55,8 +55,8 @@ class Result { * @param result String value for the JSON result value */ Result(const std::string& result) - : delay_in_ms_(0) - , result_(result) { } + : delay_in_ms_(0) + , result_(result) {} /** * Protected constructor for base result type @@ -65,8 +65,8 @@ class Result { * @param delay_in_ms Delay in milliseconds before forwarding result */ Result(const std::string& result, unsigned long delay_in_ms) - : delay_in_ms_(delay_in_ms) - , result_(result) { } + : delay_in_ms_(delay_in_ms) + , result_(result) {} private: /** diff --git a/cpp-driver/gtests/src/integration/simulacron/results/success.hpp b/cpp-driver/gtests/src/integration/simulacron/results/success.hpp index 85f3e4584..891e7eae8 100644 --- a/cpp-driver/gtests/src/integration/simulacron/results/success.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/results/success.hpp @@ -41,11 +41,11 @@ class Row { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; typedef std::pair Column; - Row() { } + Row() {} /** * Add a column|value pair @@ -55,22 +55,19 @@ class Row { * @param value Value for the column * @return PrimingRow instance */ - Row& add_column(const std::string& name, - const CassValueType value_type, + Row& add_column(const std::string& name, const CassValueType value_type, const std::string& value) { std::string cql_type = test::Utils::scalar_cql_type(value_type); - if (value_type == CASS_VALUE_TYPE_LIST || - value_type == CASS_VALUE_TYPE_MAP || - value_type == CASS_VALUE_TYPE_SET) { - throw Exception("Value Type " + cql_type + "Needs to be Parameterized: " - "Use add_column(string name, string cql_value_type, string value) instead"); - } - - //TODO: Add types when supported by Simulacron - if (value_type == CASS_VALUE_TYPE_CUSTOM || - value_type == CASS_VALUE_TYPE_UDT) { - throw Exception("Value Type is not Supported by Simulacron: " - + cql_type); + if (value_type == CASS_VALUE_TYPE_LIST || value_type == CASS_VALUE_TYPE_MAP || + value_type == CASS_VALUE_TYPE_SET) { + throw Exception("Value Type " + cql_type + + "Needs to be Parameterized: " + "Use add_column(string name, string cql_value_type, string value) instead"); + } + + // TODO: Add types when supported by Simulacron + if (value_type == CASS_VALUE_TYPE_CUSTOM || value_type == CASS_VALUE_TYPE_UDT) { + throw Exception("Value Type is not Supported by Simulacron: " + cql_type); } return add_column(name, cql_type, value); @@ -84,10 +81,9 @@ class Row { * @param value Value for the column * @return PrimingRow instance */ - Row& add_column(const std::string& name, - const std::string& cql_value_type, + Row& add_column(const std::string& name, const std::string& cql_value_type, const std::string& value) { - //TODO: Add validation (mainly for parameterized types) + // TODO: Add validation (mainly for parameterized types) // Ensure the column doesn't already exist if (columns_.find(name) != columns_.end()) { throw Exception("Unable to Add Column: Already Exists [" + name + "]"); @@ -105,15 +101,10 @@ class Row { * otherwise */ bool operator==(const Row& rhs) const { - return columns_.size() == rhs.columns_.size() - && std::equal(columns_.begin(), - columns_.end(), - rhs.columns_.begin(), - ColumnsKeyEquality()); - } - bool operator!=(const Row& rhs) const { - return !(*this == rhs); + return columns_.size() == rhs.columns_.size() && + std::equal(columns_.begin(), columns_.end(), rhs.columns_.begin(), ColumnsKeyEquality()); } + bool operator!=(const Row& rhs) const { return !(*this == rhs); } /** * Build the column types for the column used by the row @@ -124,8 +115,7 @@ class Row { writer.Key("column_types"); writer.StartObject(); - for (Map::const_iterator iterator = columns_.begin(); iterator != columns_.end(); - ++iterator) { + for (Map::const_iterator iterator = columns_.begin(); iterator != columns_.end(); ++iterator) { std::string name = iterator->first; std::string cql_type = iterator->second.first; writer.Key(name.c_str()); @@ -143,21 +133,19 @@ class Row { void build_row(rapidjson::PrettyWriter& writer) const { writer.StartObject(); - for (Map::const_iterator iterator = columns_.begin(); iterator != columns_.end(); - ++iterator) { + for (Map::const_iterator iterator = columns_.begin(); iterator != columns_.end(); ++iterator) { std::string name = iterator->first; std::string value = iterator->second.second; // Add the column|value pair writer.Key(name.c_str()); - bool is_array = value.compare(0, 1, "[") == 0 && - value.compare(value.size() - 1, 1, "]") == 0; + bool is_array = value.compare(0, 1, "[") == 0 && value.compare(value.size() - 1, 1, "]") == 0; if (is_array) { value = value.substr(1, value.size() - 2); writer.StartArray(); std::vector values = test::Utils::explode(value, ','); - for (std::vector::iterator iterator = values.begin(); - iterator != values.end(); ++iterator) { + for (std::vector::iterator iterator = values.begin(); iterator != values.end(); + ++iterator) { writer.String((*iterator).c_str()); } writer.EndArray(); @@ -204,10 +192,10 @@ class Rows { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; - Rows() { } + Rows() {} /** * Add a row @@ -218,8 +206,7 @@ class Rows { */ Rows& add_row(const Row& columns) { if (!rows_.empty() && rows_.front() != columns) { - throw Exception( - "Unable to Add Row: Columns are incompatible with previous row(s)"); + throw Exception("Unable to Add Row: Columns are incompatible with previous row(s)"); } rows_.push_back(columns); return *this; @@ -230,9 +217,7 @@ class Rows { * * @return True if rows are empty; false otherwise */ - bool empty() const { - return rows_.empty(); - } + bool empty() const { return rows_.empty(); } /** * Build the column types for the column used by the rows @@ -251,8 +236,8 @@ class Rows { void build_rows(rapidjson::PrettyWriter& rows) const { rows.Key("rows"); rows.StartArray(); - for (std::vector::const_iterator iterator = rows_.begin(); - iterator != rows_.end(); ++iterator) { + for (std::vector::const_iterator iterator = rows_.begin(); iterator != rows_.end(); + ++iterator) { iterator->build_row(rows); } rows.EndArray(); @@ -271,7 +256,7 @@ class Rows { class Success : public Result { public: Success() - : Result("success") { } + : Result("success") {} /** * Fully construct the 'success' result @@ -279,10 +264,9 @@ class Success : public Result { * @param delay_in_ms Delay in milliseconds before forwarding result * @param rows Rows to return when responding to the request */ - Success(unsigned long delay_in_ms, - const Rows& rows) - : Result("success", delay_in_ms) - , rows_(rows) { } + Success(unsigned long delay_in_ms, const Rows& rows) + : Result("success", delay_in_ms) + , rows_(rows) {} /** * Set a fixed delay to the response time of a result diff --git a/cpp-driver/gtests/src/integration/simulacron/results/write_timeout.hpp b/cpp-driver/gtests/src/integration/simulacron/results/write_timeout.hpp index a899d2df1..4509aaec7 100644 --- a/cpp-driver/gtests/src/integration/simulacron/results/write_timeout.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/results/write_timeout.hpp @@ -23,7 +23,6 @@ #include "cassandra.h" - namespace prime { /** @@ -32,11 +31,11 @@ namespace prime { class WriteTimeout : public Result { public: WriteTimeout() - : Result("write_timeout") - , consistency_(CASS_CONSISTENCY_LOCAL_ONE) - , received_responses_(0) - , required_responses_(1) - , write_type_(CASS_WRITE_TYPE_SIMPLE) { } + : Result("write_timeout") + , consistency_(CASS_CONSISTENCY_LOCAL_ONE) + , received_responses_(0) + , required_responses_(1) + , write_type_(CASS_WRITE_TYPE_SIMPLE) {} /** * Fully construct the 'write_timeout' result @@ -47,16 +46,14 @@ class WriteTimeout : public Result { * @param required_responses Number of responses required from replicas * @param write_type The type of write that resulted in write timeout */ - WriteTimeout(unsigned long delay_in_ms, - CassConsistency consistency, - unsigned int received_responses, - unsigned int required_responses, + WriteTimeout(unsigned long delay_in_ms, CassConsistency consistency, + unsigned int received_responses, unsigned int required_responses, CassWriteType write_type) - : Result("write_timeout", delay_in_ms) - , consistency_(consistency) - , received_responses_(received_responses) - , required_responses_(required_responses) - , write_type_(write_type) { } + : Result("write_timeout", delay_in_ms) + , consistency_(consistency) + , received_responses_(received_responses) + , required_responses_(required_responses) + , write_type_(write_type) {} /** * Set a fixed delay to the response time of a result diff --git a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp index 2de4967a0..31632dc52 100644 --- a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp +++ b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.cpp @@ -19,10 +19,10 @@ #include "test_utils.hpp" #include "tlog.hpp" +#include "objects/uuid_gen.hpp" #include "scoped_lock.hpp" #include "tsocket.hpp" #include "values/uuid.hpp" -#include "objects/uuid_gen.hpp" #include #include @@ -35,7 +35,7 @@ #define OUTPUT_BUFFER_SIZE 10240ul #define SIMULACRON_NAP 100 #define SIMULACRON_CONNECTION_RETRIES 600 // Up to 60 seconds for retry based on SIMULACRON_NAP -#define SIMULACRON_PROCESS_RETRIS 100 // Up to 10 seconds for retry based on SIMULACRON_NAP +#define SIMULACRON_PROCESS_RETRIS 100 // Up to 10 seconds for retry based on SIMULACRON_NAP #define MAX_TOKEN static_cast(INT64_MAX) - 1 #define DATA_CENTER_PREFIX "dc" @@ -48,21 +48,19 @@ bool test::SimulacronCluster::is_running_ = false; uv_thread_t test::SimulacronCluster::thread_; const unsigned int DEFAULT_NODE[] = { 1 }; const std::vector test::SimulacronCluster::DEFAULT_DATA_CENTER_NODES( - DEFAULT_NODE, DEFAULT_NODE + sizeof(DEFAULT_NODE) / sizeof(DEFAULT_NODE[0])); + DEFAULT_NODE, DEFAULT_NODE + sizeof(DEFAULT_NODE) / sizeof(DEFAULT_NODE[0])); test::SimulacronCluster::SimulacronCluster() - : dse_version_("") - , cassandra_version_("") - , current_cluster_id_(-1) -{ + : dse_version_("") + , cassandra_version_("") + , current_cluster_id_(-1) { // Initialize the mutex uv_mutex_init(&mutex_); // Determine if Simulacron file exists if (!test::Utils::file_exists(SIMULACRON_SERVER_JAR)) { std::stringstream message; - message << "Unable to find Simulacron JAR file [" - << SIMULACRON_SERVER_JAR << "]"; + message << "Unable to find Simulacron JAR file [" << SIMULACRON_SERVER_JAR << "]"; throw Exception(message.str()); } @@ -74,11 +72,9 @@ test::SimulacronCluster::SimulacronCluster() if (cassandra_version == "0.0.0") { throw Exception("Unable to determine Cassandra version from DSE version"); } - dse_version_ = test::Utils::replace_all(dse_version.to_string(), "-", - "."); + dse_version_ = test::Utils::replace_all(dse_version.to_string(), "-", "."); } - cassandra_version_ = test::Utils::replace_all(cassandra_version.to_string(), - "-", "."); + cassandra_version_ = test::Utils::replace_all(cassandra_version.to_string(), "-", "."); // Create Simulacron process (threaded) and wait for completely availability uv_thread_create(&thread_, handle_thread_create, NULL); @@ -93,17 +89,15 @@ test::SimulacronCluster::SimulacronCluster() test::Utils::wait_for_port(SIMULACRON_LISTEN_ADDRESS, SIMULACRON_ADMIN_PORT); } -test::SimulacronCluster::~SimulacronCluster() { - remove_cluster(); -} +test::SimulacronCluster::~SimulacronCluster() { remove_cluster(); } std::string test::SimulacronCluster::cluster_contact_points(bool is_all /*= true*/) { // Iterate over each node and collect the list of active contact points std::vector cluster_nodes = nodes(); size_t index = 1; std::stringstream contact_points; - for (std::vector::iterator it = - cluster_nodes.begin(); it != cluster_nodes.end(); ++it) { + for (std::vector::iterator it = cluster_nodes.begin(); + it != cluster_nodes.end(); ++it) { if (is_all || is_node_up(index++)) { if (!contact_points.str().empty()) { contact_points << ","; @@ -114,16 +108,16 @@ std::string test::SimulacronCluster::cluster_contact_points(bool is_all /*= true return contact_points.str(); } -void test::SimulacronCluster::create_cluster(const std::vector& data_center_nodes /*= DEFAULT_DATA_CENTER_NODES*/, - bool with_vnodes /*= false */) { +void test::SimulacronCluster::create_cluster( + const std::vector& data_center_nodes /*= DEFAULT_DATA_CENTER_NODES*/, + bool with_vnodes /*= false */) { std::stringstream paramters; std::stringstream cluster_name; cluster_name << DEFAULT_CLUSTER_PREFIX << "_"; // Add the data centers, Cassandra version, and token/vnodes parameters - paramters << "data_centers=" - << test::Utils::implode(data_center_nodes, ',') - << "&cassandra_version=" << cassandra_version_; + paramters << "data_centers=" << test::Utils::implode(data_center_nodes, ',') + << "&cassandra_version=" << cassandra_version_; // Update the cluster configuration (set num_tokens) if (with_vnodes) { // Maximum number of tokens is 1536 @@ -141,8 +135,7 @@ void test::SimulacronCluster::create_cluster(const std::vector& da } // Add the cluster name - cluster_name << "_" - << test::Utils::implode(data_center_nodes, '-'); + cluster_name << "_" << test::Utils::implode(data_center_nodes, '-'); if (with_vnodes) { cluster_name << "-vnodes"; } @@ -157,8 +150,8 @@ void test::SimulacronCluster::create_cluster(const std::vector& da } void test::SimulacronCluster::create_cluster(unsigned int data_center_one_nodes, - unsigned int data_center_two_nodes /*= 0*/, - bool with_vnodes /*=false */) { + unsigned int data_center_two_nodes /*= 0*/, + bool with_vnodes /*=false */) { std::vector data_center_nodes; if (data_center_one_nodes > 0) { data_center_nodes.push_back(data_center_one_nodes); @@ -169,9 +162,7 @@ void test::SimulacronCluster::create_cluster(unsigned int data_center_one_nodes, create_cluster(data_center_nodes, with_vnodes); } -void test::SimulacronCluster::remove_cluster() { - send_delete("cluster"); -} +void test::SimulacronCluster::remove_cluster() { send_delete("cluster"); } std::string test::SimulacronCluster::get_ip_address(unsigned int node) { std::vector current_nodes = nodes(); @@ -188,9 +179,8 @@ bool test::SimulacronCluster::is_node_down(unsigned int node) { if (!is_node_available(node)) { return true; } else { - TEST_LOG("Connected to Node " << node - << " in Cluster: Rechecking node down status [" - << number_of_retries << "]"); + TEST_LOG("Connected to Node " << node << " in Cluster: Rechecking node down status [" + << number_of_retries << "]"); test::Utils::msleep(SIMULACRON_NAP); } } @@ -206,9 +196,8 @@ bool test::SimulacronCluster::is_node_up(unsigned int node) { if (is_node_available(node)) { return true; } else { - TEST_LOG("Unable to Connect to Node " << node - << " in Cluster: Rechecking node up status [" - << number_of_retries << "]"); + TEST_LOG("Unable to Connect to Node " << node << " in Cluster: Rechecking node up status [" + << number_of_retries << "]"); test::Utils::msleep(SIMULACRON_NAP); } } @@ -235,14 +224,13 @@ std::vector test::SimulacronCluste return current_cluster.data_centers; } -std::vector -test::SimulacronCluster::nodes() { +std::vector test::SimulacronCluster::nodes() { // Get the cluster object and retrieve the nodes from the data center(s) Cluster current_cluster = cluster(); std::vector nodes; std::vector data_centers = current_cluster.data_centers; - for (std::vector::iterator it = - data_centers.begin(); it != data_centers.end(); ++it) { + for (std::vector::iterator it = data_centers.begin(); + it != data_centers.end(); ++it) { std::vector dc_nodes = it->nodes; nodes.insert(nodes.end(), dc_nodes.begin(), dc_nodes.end()); } @@ -257,12 +245,9 @@ unsigned int test::SimulacronCluster::active_connections(unsigned int node) { return 0; } -unsigned int test::SimulacronCluster::active_connections() { - return cluster().active_connections; -} +unsigned int test::SimulacronCluster::active_connections() { return cluster().active_connections; } -void test::SimulacronCluster::prime_query(prime::Request& request, - unsigned int node /*= 0*/) { +void test::SimulacronCluster::prime_query(prime::Request& request, unsigned int node /*= 0*/) { std::stringstream endpoint; endpoint << "prime/" << current_cluster_id_ << generate_node_endpoint(node); send_post(endpoint.str(), request.json()); @@ -274,16 +259,14 @@ void test::SimulacronCluster::remove_primed_queries(unsigned int node /*= 0*/) { send_delete(endpoint.str()); } -void test::SimulacronCluster::handle_exit(uv_process_t* process, - int64_t error_code, +void test::SimulacronCluster::handle_exit(uv_process_t* process, int64_t error_code, int term_signal) { ScopedMutex lock(&mutex_); TEST_LOG("Process " << process->pid << " Terminated: " << error_code); uv_close(reinterpret_cast(process), NULL); } -void test::SimulacronCluster::handle_allocation(uv_handle_t* handle, - size_t suggested_size, +void test::SimulacronCluster::handle_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer) { ScopedMutex lock(&mutex_); buffer->base = new char[OUTPUT_BUFFER_SIZE]; @@ -293,9 +276,9 @@ void test::SimulacronCluster::handle_allocation(uv_handle_t* handle, void test::SimulacronCluster::handle_thread_create(void* arg) { // Initialize the loop and process arguments uv_loop_t loop; - if(uv_loop_init(&loop) != 0) { - throw Exception("Unable to Create Simulacron Process: libuv loop " \ - "initialization failed"); + if (uv_loop_init(&loop) != 0) { + throw Exception("Unable to Create Simulacron Process: libuv loop " + "initialization failed"); }; uv_process_options_t options; memset(&options, 0, sizeof(uv_process_options_t)); @@ -310,9 +293,9 @@ void test::SimulacronCluster::handle_thread_create(void* arg) { options.stdio = stdio; options.stdio[0].flags = UV_IGNORE; options.stdio[1].flags = static_cast(UV_CREATE_PIPE | UV_WRITABLE_PIPE); - options.stdio[1].data.stream = (uv_stream_t*) &standard_output; + options.stdio[1].data.stream = (uv_stream_t*)&standard_output; options.stdio[2].flags = static_cast(UV_CREATE_PIPE | UV_WRITABLE_PIPE); - options.stdio[2].data.stream = (uv_stream_t*) &error_output; + options.stdio[2].data.stream = (uv_stream_t*)&error_output; // Generate the spawn command for use with uv_spawn const char* spawn_command[7]; @@ -333,14 +316,11 @@ void test::SimulacronCluster::handle_thread_create(void* arg) { uv_process_t process; int error_code = uv_spawn(&loop, &process, &options); if (error_code == 0) { - TEST_LOG("Launched " << spawn_command[0] << " with ID " - << process.pid); + TEST_LOG("Launched " << spawn_command[0] << " with ID " << process.pid); // Start the output thread loops - uv_read_start(reinterpret_cast(&standard_output), - handle_allocation, handle_read); - uv_read_start(reinterpret_cast(&error_output), - handle_allocation, handle_read); + uv_read_start(reinterpret_cast(&standard_output), handle_allocation, handle_read); + uv_read_start(reinterpret_cast(&error_output), handle_allocation, handle_read); // Start the process loop is_running_ = true; @@ -352,8 +332,8 @@ void test::SimulacronCluster::handle_thread_create(void* arg) { } } -void test::SimulacronCluster::handle_read(uv_stream_t* stream, - ssize_t buffer_length, const uv_buf_t* buffer) { +void test::SimulacronCluster::handle_read(uv_stream_t* stream, ssize_t buffer_length, + const uv_buf_t* buffer) { ScopedMutex lock(&mutex_); if (buffer_length > 0) { // Process the buffer and log it @@ -377,39 +357,36 @@ void test::SimulacronCluster::send_delete(const std::string& endpoint) { if (response.status_code != 202) { std::stringstream message; message << "DELETE Operation " << endpoint - << " did not Complete Successfully: " << response.status_code; + << " did not Complete Successfully: " << response.status_code; throw Exception(message.str()); } } -const std::string test::SimulacronCluster::send_get( - const std::string& endpoint) { +const std::string test::SimulacronCluster::send_get(const std::string& endpoint) { Response response = send_request(Request::HTTP_METHOD_GET, endpoint); if (response.status_code != 200) { std::stringstream message; message << "GET Operation " << endpoint - << " did not Complete Successfully: " << response.status_code; + << " did not Complete Successfully: " << response.status_code; throw Exception(message.str()); } return response.message; } -const std::string test::SimulacronCluster::send_post( - const std::string& endpoint, const std::string& content /*= ""*/) { - Response response = send_request(Request::HTTP_METHOD_POST, endpoint, - content); +const std::string test::SimulacronCluster::send_post(const std::string& endpoint, + const std::string& content /*= ""*/) { + Response response = send_request(Request::HTTP_METHOD_POST, endpoint, content); if (response.status_code != 201) { std::stringstream message; message << "POST Operation " << endpoint - << " did not Complete Successfully: " << response.status_code; + << " did not Complete Successfully: " << response.status_code; throw Exception(message.str()); } return response.message; } -Response test::SimulacronCluster::send_request(Request::Method method, - const std::string& endpoint, - const std::string& content /*= ""*/) { +Response test::SimulacronCluster::send_request(Request::Method method, const std::string& endpoint, + const std::string& content /*= ""*/) { // Create and send the request to the REST server Request request; request.method = method; @@ -427,8 +404,7 @@ bool test::SimulacronCluster::is_node_available(unsigned int node) { std::vector cluster_nodes = nodes(); if (node > cluster_nodes.size()) { std::stringstream message; - message << "Unable to Check Availability of Node: Node " << node - << " is not a valid node"; + message << "Unable to Check Availability of Node: Node " << node << " is not a valid node"; throw test::Exception(message.str()); } @@ -440,7 +416,7 @@ bool test::SimulacronCluster::is_node_available(unsigned int node) { } bool test::SimulacronCluster::is_node_available(const std::string& ip_address, - unsigned short port) { + unsigned short port) { Socket socket; try { socket.establish_connection(ip_address, port); @@ -459,12 +435,11 @@ const std::string test::SimulacronCluster::generate_node_endpoint(unsigned int n std::vector current_nodes = nodes(); if (node > current_nodes.size()) { std::stringstream message; - message << "Insufficient Nodes in Cluster: Cluster contains " - << current_nodes.size() << "; " << node << " is invalid"; + message << "Insufficient Nodes in Cluster: Cluster contains " << current_nodes.size() << "; " + << node << " is invalid"; throw Exception(message.str()); } - endpoint << "/" << current_nodes[node - 1].data_center_id << "/" - << current_nodes[node - 1].id; + endpoint << "/" << current_nodes[node - 1].data_center_id << "/" << current_nodes[node - 1].id; } return endpoint.str(); } diff --git a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.hpp b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.hpp index 9dd06904f..3a8ac4708 100644 --- a/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/simulacron_cluster.hpp @@ -21,11 +21,11 @@ #ifdef USE_SIMULACRON_SERVER #include "exception.hpp" #include "priming_requests.hpp" -#include "shared_ptr.hpp" #include "rest_client.hpp" +#include "shared_ptr.hpp" #ifdef _CRT_SECURE_NO_WARNINGS -# undef _CRT_SECURE_NO_WARNINGS +#undef _CRT_SECURE_NO_WARNINGS #endif #include #include @@ -33,8 +33,8 @@ #include #include #include -#include #include +#include #include namespace test { @@ -47,7 +47,7 @@ class SimulacronCluster { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) { } + : test::Exception(message) {} }; /** @@ -59,7 +59,7 @@ class SimulacronCluster { struct PeerInfo { std::vector tokens; - PeerInfo() { }; + PeerInfo(){}; PeerInfo(const rapidjson::Value& peer_info) { if (peer_info.IsObject()) { if (peer_info.HasMember("tokens")) { @@ -83,18 +83,17 @@ class SimulacronCluster { PeerInfo peer_info; Node(const rapidjson::Value& node, unsigned int dc_id) - : data_center_id(dc_id) { + : data_center_id(dc_id) { if (node.IsObject()) { if (node.HasMember("name") && node.HasMember("id") && - node.HasMember("active_connections") && - node.HasMember("address") && node.HasMember("peer_info")) { + node.HasMember("active_connections") && node.HasMember("address") && + node.HasMember("peer_info")) { name = node["name"].GetString(); id = node["id"].GetUint(); active_connections = node["active_connections"].GetUint(); const rapidjson::Value& address = node["address"]; - std::vector tokens = test::Utils::explode( - address.GetString(), ':'); + std::vector tokens = test::Utils::explode(address.GetString(), ':'); if (tokens.size() == 2) { ip_address = tokens[0]; std::stringstream valueStream(tokens[1]); @@ -114,9 +113,7 @@ class SimulacronCluster { } } - bool operator< (const Node& rhs) const { - return id < rhs.id; - } + bool operator<(const Node& rhs) const { return id < rhs.id; } }; std::string name; @@ -127,7 +124,7 @@ class SimulacronCluster { DataCenter(const rapidjson::Value& data_center) { if (data_center.IsObject()) { if (data_center.HasMember("name") && data_center.HasMember("id") && - data_center.HasMember("active_connections")) { + data_center.HasMember("active_connections")) { name = data_center["name"].GetString(); id = data_center["id"].GetUint(); active_connections = data_center["active_connections"].GetUint(); @@ -137,8 +134,7 @@ class SimulacronCluster { if (dc_nodes.IsArray()) { for (rapidjson::SizeType i = 0; i < dc_nodes.Size(); ++i) { Node node(dc_nodes[i], id); - nodes.insert(std::lower_bound(nodes.begin(), nodes.end(), - node), node); + nodes.insert(std::lower_bound(nodes.begin(), nodes.end(), node), node); } } else { throw Exception("Nodes are not valid for the data center object"); @@ -152,9 +148,7 @@ class SimulacronCluster { } } - bool operator< (const DataCenter& rhs) const { - return id < rhs.id; - } + bool operator<(const DataCenter& rhs) const { return id < rhs.id; } }; std::string name; @@ -164,12 +158,11 @@ class SimulacronCluster { std::string dse_version; std::vector data_centers; - Cluster(const rapidjson::Document *cluster) { + Cluster(const rapidjson::Document* cluster) { if (cluster) { if (cluster->IsObject()) { if (cluster->HasMember("name") && cluster->HasMember("id") && - cluster->HasMember("active_connections") && - cluster->HasMember("data_centers")) { + cluster->HasMember("active_connections") && cluster->HasMember("data_centers")) { name = (*cluster)["name"].GetString(); id = (*cluster)["id"].GetUint(); active_connections = (*cluster)["active_connections"].GetUint(); @@ -185,12 +178,12 @@ class SimulacronCluster { if (dcs.IsArray()) { for (rapidjson::SizeType i = 0; i < dcs.Size(); ++i) { DataCenter dc(dcs[i]); - data_centers.insert(std::lower_bound(data_centers.begin(), - data_centers.end(), dc), dc); + data_centers.insert(std::lower_bound(data_centers.begin(), data_centers.end(), dc), + dc); } } else { - throw Exception("Data centers are not valid for the cluster " \ - "object"); + throw Exception("Data centers are not valid for the cluster " + "object"); } } else { throw Exception("JSON object is not a cluster object"); @@ -241,8 +234,9 @@ class SimulacronCluster { * @param with_vnode True if vnodes should be enabled; false otherwise * (default: false) */ - void create_cluster(const std::vector& data_center_nodes = DEFAULT_DATA_CENTER_NODES, - bool with_vnodes = false); + void + create_cluster(const std::vector& data_center_nodes = DEFAULT_DATA_CENTER_NODES, + bool with_vnodes = false); /** * Create the Simulacron cluster; number of nodes in data center 1 and 2 @@ -252,8 +246,7 @@ class SimulacronCluster { * @param with_vnode True if vnodes should be enabled; false otherwise * (default: false) */ - void create_cluster(unsigned int data_center_one_nodes, - unsigned int data_center_two_nodes = 0, + void create_cluster(unsigned int data_center_one_nodes, unsigned int data_center_two_nodes = 0, bool with_vnodes = false); /** @@ -383,9 +376,7 @@ class SimulacronCluster { * @param suggested_size Suggested size for the buffer * @param buffer Buffer to allocate bytes for */ - static void handle_allocation(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buffer); + static void handle_allocation(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buffer); /** * uv_spawn callback for handling the completion of the process @@ -394,9 +385,7 @@ class SimulacronCluster { * @param error_code Error/Exit code * @param term_signal Terminating signal */ - static void handle_exit(uv_process_t* process, - int64_t error_code, - int term_signal); + static void handle_exit(uv_process_t* process, int64_t error_code, int term_signal); /** * uv_read_start callback for processing the buffer in the pipe @@ -405,9 +394,7 @@ class SimulacronCluster { * @param buffer_length Length of the buffer * @param buffer Buffer to process */ - static void handle_read(uv_stream_t* stream, - ssize_t buffer_length, - const uv_buf_t* buffer); + static void handle_read(uv_stream_t* stream, ssize_t buffer_length, const uv_buf_t* buffer); /** * uv_thread_create callback for executing the Simulacron process @@ -440,8 +427,7 @@ class SimulacronCluster { * @return REST server response * @throws SimulacronCluster::Exception If status code is not 201 */ - const std::string send_post(const std::string& endpoint, - const std::string& content = ""); + const std::string send_post(const std::string& endpoint, const std::string& content = ""); /** * Send the request to the Simulacron REST server @@ -452,8 +438,7 @@ class SimulacronCluster { * @return REST server response * @throws SimulacronCluster::Exception */ - Response send_request(Request::Method method, - const std::string& endpoint, + Response send_request(Request::Method method, const std::string& endpoint, const std::string& content = ""); /** diff --git a/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.cpp b/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.cpp index 3eec4ac56..cbb02bceb 100644 --- a/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.cpp +++ b/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.cpp @@ -24,12 +24,10 @@ SharedPtr SimulacronIntegration::sc_ = NULL; bool SimulacronIntegration::is_sc_started_ = false; SimulacronIntegration::SimulacronIntegration() - : is_sc_start_requested_(true) - , is_sc_for_test_case_(false) { -} + : is_sc_start_requested_(true) + , is_sc_for_test_case_(false) {} -SimulacronIntegration::~SimulacronIntegration() { -} +SimulacronIntegration::~SimulacronIntegration() {} void SimulacronIntegration::SetUpTestCase() { try { @@ -74,8 +72,7 @@ void SimulacronIntegration::TearDown() { } test::driver::Cluster SimulacronIntegration::default_cluster() { - return Integration::default_cluster() - .with_connection_heartbeat_interval(0); + return Integration::default_cluster().with_connection_heartbeat_interval(0); } void SimulacronIntegration::default_start_sc() { @@ -86,7 +83,9 @@ void SimulacronIntegration::default_start_sc() { start_sc(data_center_nodes); } -void SimulacronIntegration::start_sc(const std::vector& data_center_nodes /*= SimulacronCluster::DEFAULT_DATA_CENTER_NODES*/) { +void SimulacronIntegration::start_sc( + const std::vector& + data_center_nodes /*= SimulacronCluster::DEFAULT_DATA_CENTER_NODES*/) { // Ensure the SC is only started once (process handling) if (!is_sc_started_) { // Create and start the SC @@ -97,26 +96,22 @@ void SimulacronIntegration::start_sc(const std::vector& data_cente } } -test::driver::Result SimulacronIntegration::execute_mock_query( - CassConsistency consistency /*= CASS_CONSISTENCY_ONE*/) { +test::driver::Result +SimulacronIntegration::execute_mock_query(CassConsistency consistency /*= CASS_CONSISTENCY_ONE*/) { return session_.execute("mock query", consistency, false, false); } void SimulacronIntegration::prime_mock_query(unsigned int node /*= 0*/) { prime::Success success = prime::Success(); - success.with_rows(prime::Rows() - .add_row(prime::Row() - .add_column("SUCCESS", CASS_VALUE_TYPE_BOOLEAN, "TRUE"))); + success.with_rows( + prime::Rows().add_row(prime::Row().add_column("SUCCESS", CASS_VALUE_TYPE_BOOLEAN, "TRUE"))); prime_mock_query_with_result(&success, node); } - void SimulacronIntegration::prime_mock_query_with_result(prime::Result* result, unsigned int node /*= 0*/) { // Create the mock query - prime::Request mock_query = prime::Request() - .with_query("mock query") - .with_result(result); + prime::Request mock_query = prime::Request().with_query("mock query").with_result(result); // Prime the mock query with the given error sc_->prime_query(mock_query, node); diff --git a/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.hpp b/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.hpp index a48cc59a6..03b6c69ba 100644 --- a/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.hpp +++ b/cpp-driver/gtests/src/integration/simulacron/simulacron_integration.hpp @@ -29,12 +29,12 @@ INTEGRATION_TYPED_TEST_P(simulacron, test_case, test_name) #define CHECK_SIMULACRON_AVAILABLE \ - if (!sc_) { \ - return; \ + if (!sc_) { \ + return; \ } #define SKIP_TEST_IF_SIMULACRON_UNAVAILABLE \ - if (!sc_) { \ + if (!sc_) { \ SKIP_TEST("Simulacron is unavailable"); \ } @@ -89,7 +89,8 @@ class SimulacronIntegration : public Integration { * @param data_center_nodes Data center(s) to create in the Simulacron cluster * (default: 1 data center with 1 node) */ - void start_sc(const std::vector& data_center_nodes = SimulacronCluster::DEFAULT_DATA_CENTER_NODES); + void start_sc(const std::vector& data_center_nodes = + SimulacronCluster::DEFAULT_DATA_CENTER_NODES); /** * Execute a mock query at a given consistency level @@ -102,7 +103,8 @@ class SimulacronIntegration : public Integration { * remaining nodes with a successful mock * query */ - virtual test::driver::Result execute_mock_query(CassConsistency consistency = CASS_CONSISTENCY_ONE); + virtual test::driver::Result + execute_mock_query(CassConsistency consistency = CASS_CONSISTENCY_ONE); /** * Prime the successful mock query on the given node @@ -123,8 +125,7 @@ class SimulacronIntegration : public Integration { * result will be applied to all nodes in the Simulacron cluster * (DEFAULT: 0 - Apply mock query with result to all nodes) */ - void prime_mock_query_with_result(prime::Result* result, - unsigned int node = 0); + void prime_mock_query_with_result(prime::Result* result, unsigned int node = 0); private: /** diff --git a/cpp-driver/gtests/src/integration/strptime.cpp b/cpp-driver/gtests/src/integration/strptime.cpp index 6389979d3..a1d28ec8c 100644 --- a/cpp-driver/gtests/src/integration/strptime.cpp +++ b/cpp-driver/gtests/src/integration/strptime.cpp @@ -1,8 +1,8 @@ #include "strptime.hpp" -#include #include #include +#include #include #ifndef _WIN32 @@ -37,147 +37,155 @@ namespace test { /* A restricted form of strptime() that doesn't support any locale based format options */ -char *strptime(const char * s, const char * f, struct tm * v) -{ +char* strptime(const char* s, const char* f, struct tm* v) { int i, w, neg, adj, min, range, *dest, dummy; int want_century = 0, century = 0, relyear = 0; while (*f) { if (*f != '%') { - if (isspace(*f)) for (; *s && isspace(*s); s++); - else if (*s != *f) return 0; - else s++; + if (isspace(*f)) + for (; *s && isspace(*s); s++) + ; + else if (*s != *f) + return 0; + else + s++; f++; continue; } f++; if (*f == '+') f++; if (isdigit(*f)) { - char *new_f; - w=strtoul(f, &new_f, 10); + char* new_f; + w = strtoul(f, &new_f, 10); f = new_f; } else { - w=-1; + w = -1; } - adj=0; + adj = 0; switch (*f++) { - case 'C': - dest = ¢ury; - if (w<0) w=2; - want_century |= 2; - goto numeric_digits; - case 'd': case 'e': - dest = &v->tm_mday; - min = 1; - range = 31; - goto numeric_range; - case 'D': - s = test::strptime(s, "%m/%d/%y", v); - if (!s) return 0; - break; - case 'H': - dest = &v->tm_hour; - min = 0; - range = 24; - goto numeric_range; - case 'I': - dest = &v->tm_hour; - min = 1; - range = 12; - goto numeric_range; - case 'j': - dest = &v->tm_yday; - min = 1; - range = 366; - adj = 1; - goto numeric_range; - case 'm': - dest = &v->tm_mon; - min = 1; - range = 12; - adj = 1; - goto numeric_range; - case 'M': - dest = &v->tm_min; - min = 0; - range = 60; - goto numeric_range; - case 'n': case 't': - for (; *s && isspace(*s); s++); - break; - case 'R': - s = test::strptime(s, "%H:%M", v); - if (!s) return 0; - break; - case 'S': - dest = &v->tm_sec; - min = 0; - range = 61; - goto numeric_range; - case 'T': - s = test::strptime(s, "%H:%M:%S", v); - if (!s) return 0; - break; - case 'U': - case 'W': - /* Throw away result, for now. (FIXME?) */ - dest = &dummy; - min = 0; - range = 54; - goto numeric_range; - case 'w': - dest = &v->tm_wday; - min = 0; - range = 7; - goto numeric_range; - case 'y': - dest = &relyear; - w = 2; - want_century |= 1; - goto numeric_digits; - case 'Y': - dest = &v->tm_year; - if (w<0) w=4; - adj = 1900; - want_century = 0; - goto numeric_digits; - case '%': - if (*s++ != '%') return 0; - break; - default: - return 0; - numeric_range: - if (!isdigit(*s)) return 0; - *dest = 0; - for (i=1; i<=min+range && isdigit(*s); i*=10) - *dest = *dest * 10 + *s++ - '0'; - if (*dest - min >= (unsigned)range) return 0; - *dest -= adj; - switch((char *)dest - (char *)v) { - case offsetof(struct tm, tm_yday): - ; - } - goto update; - numeric_digits: - neg = 0; - if (*s == '+') s++; - else if (*s == '-') neg=1, s++; - if (!isdigit(*s)) return 0; - for (*dest=i=0; itm_mday; + min = 1; + range = 31; + goto numeric_range; + case 'D': + s = test::strptime(s, "%m/%d/%y", v); + if (!s) return 0; + break; + case 'H': + dest = &v->tm_hour; + min = 0; + range = 24; + goto numeric_range; + case 'I': + dest = &v->tm_hour; + min = 1; + range = 12; + goto numeric_range; + case 'j': + dest = &v->tm_yday; + min = 1; + range = 366; + adj = 1; + goto numeric_range; + case 'm': + dest = &v->tm_mon; + min = 1; + range = 12; + adj = 1; + goto numeric_range; + case 'M': + dest = &v->tm_min; + min = 0; + range = 60; + goto numeric_range; + case 'n': + case 't': + for (; *s && isspace(*s); s++) + ; + break; + case 'R': + s = test::strptime(s, "%H:%M", v); + if (!s) return 0; + break; + case 'S': + dest = &v->tm_sec; + min = 0; + range = 61; + goto numeric_range; + case 'T': + s = test::strptime(s, "%H:%M:%S", v); + if (!s) return 0; + break; + case 'U': + case 'W': + /* Throw away result, for now. (FIXME?) */ + dest = &dummy; + min = 0; + range = 54; + goto numeric_range; + case 'w': + dest = &v->tm_wday; + min = 0; + range = 7; + goto numeric_range; + case 'y': + dest = &relyear; + w = 2; + want_century |= 1; + goto numeric_digits; + case 'Y': + dest = &v->tm_year; + if (w < 0) w = 4; + adj = 1900; + want_century = 0; + goto numeric_digits; + case '%': + if (*s++ != '%') return 0; + break; + default: + return 0; + numeric_range: + if (!isdigit(*s)) return 0; + *dest = 0; + for (i = 1; i <= min + range && isdigit(*s); i *= 10) + *dest = *dest * 10 + *s++ - '0'; + if (*dest - min >= (unsigned)range) return 0; + *dest -= adj; + switch ((char*)dest - (char*)v) { case offsetof(struct tm, tm_yday):; } + goto update; + numeric_digits: + neg = 0; + if (*s == '+') + s++; + else if (*s == '-') + neg = 1, s++; + if (!isdigit(*s)) return 0; + for (*dest = i = 0; i < w && isdigit(*s); i++) + *dest = *dest * 10 + *s++ - '0'; + if (neg) *dest = -*dest; + *dest -= adj; + goto update; + update + : + // FIXME + ; } } if (want_century) { v->tm_year = relyear; - if (want_century & 2) v->tm_year += century * 100 - 1900; - else if (v->tm_year <= 68) v->tm_year += 100; + if (want_century & 2) + v->tm_year += century * 100 - 1900; + else if (v->tm_year <= 68) + v->tm_year += 100; } - return (char *)s; + return (char*)s; } } // namespace test diff --git a/cpp-driver/gtests/src/integration/strptime.hpp b/cpp-driver/gtests/src/integration/strptime.hpp index ffb9d1b2b..7b8330ab4 100644 --- a/cpp-driver/gtests/src/integration/strptime.hpp +++ b/cpp-driver/gtests/src/integration/strptime.hpp @@ -29,7 +29,7 @@ namespace test { * @param tm The resulting time struct * @return NULL if an error occurred */ -char *strptime(const char *s, const char *f, struct tm *tm); +char* strptime(const char* s, const char* f, struct tm* tm); } // namespace test diff --git a/cpp-driver/gtests/src/integration/test_category.cpp b/cpp-driver/gtests/src/integration/test_category.cpp index a4de871d4..50990b1a0 100644 --- a/cpp-driver/gtests/src/integration/test_category.cpp +++ b/cpp-driver/gtests/src/integration/test_category.cpp @@ -22,7 +22,8 @@ // Constant value definitions for test type const TestCategory TestCategory::CASSANDRA("CASSANDRA", 0, "Cassandra", "*_Cassandra_*"); const TestCategory TestCategory::DSE("DSE", 1, "DataStax Enterprise", "*_DSE_*"); -const TestCategory TestCategory::SIMULACRON("SIMULACRON", SHRT_MAX, "Simulated DSE (and Cassandra)", "*_simulacron_*"); +const TestCategory TestCategory::SIMULACRON("SIMULACRON", SHRT_MAX, "Simulated DSE (and Cassandra)", + "*_simulacron_*"); // Static declarations for test type std::set TestCategory::constants_; @@ -33,40 +34,28 @@ std::ostream& operator<<(std::ostream& os, const TestCategory& object) { } TestCategory::TestCategory() - : name_("INVALID") - , ordinal_(-1) - , display_name_("Invalid test category") - , filter_("*") {} + : name_("INVALID") + , ordinal_(-1) + , display_name_("Invalid test category") + , filter_("*") {} -TestCategory::TestCategory(const std::string& name) { - *this = name; -} +TestCategory::TestCategory(const std::string& name) { *this = name; } -const std::string& TestCategory::name() const { - return name_; -} +const std::string& TestCategory::name() const { return name_; } -short TestCategory::ordinal() const { - return ordinal_; -} +short TestCategory::ordinal() const { return ordinal_; } -const std::string& TestCategory::display_name() const { - return display_name_; -} +const std::string& TestCategory::display_name() const { return display_name_; } -const std::string& TestCategory::filter() const { - return filter_; -} +const std::string& TestCategory::filter() const { return filter_; } -void TestCategory::operator =(const TestCategory& object) { +void TestCategory::operator=(const TestCategory& object) { name_ = object.name_; ordinal_ = object.ordinal_; display_name_ = object.display_name_; } -void TestCategory::operator=(const std::string& name) { - *this = get_enumeration(name); -} +void TestCategory::operator=(const std::string& name) { *this = get_enumeration(name); } bool TestCategory::operator<(const TestCategory& object) const { return ordinal_ < object.ordinal_; @@ -91,28 +80,20 @@ bool TestCategory::operator==(const std::string& object) const { return lhs.compare(rhs) == 0; } -bool TestCategory::operator !=(const TestCategory& object) const { - return !(*this == object); -} +bool TestCategory::operator!=(const TestCategory& object) const { return !(*this == object); } -bool TestCategory::operator !=(const std::string& object) const { - return !(*this == object); -} +bool TestCategory::operator!=(const std::string& object) const { return !(*this == object); } -TestCategory::iterator TestCategory::begin() { - return get_constants().begin(); - } +TestCategory::iterator TestCategory::begin() { return get_constants().begin(); } -TestCategory::iterator TestCategory::end() { - return get_constants().end(); -} +TestCategory::iterator TestCategory::end() { return get_constants().end(); } -TestCategory::TestCategory(const std::string& name, short ordinal, - const std::string& display_name, const std::string& filter) - : name_(name) - , ordinal_(ordinal) - , display_name_(display_name) - , filter_(filter) {} +TestCategory::TestCategory(const std::string& name, short ordinal, const std::string& display_name, + const std::string& filter) + : name_(name) + , ordinal_(ordinal) + , display_name_(display_name) + , filter_(filter) {} const std::set& TestCategory::get_constants() { if (constants_.empty()) { @@ -124,7 +105,7 @@ const std::set& TestCategory::get_constants() { return constants_; } -TestCategory TestCategory::get_enumeration(const std::string& name) const{ +TestCategory TestCategory::get_enumeration(const std::string& name) const { // Iterator over the constants and find the corresponding enumeration if (!name.empty()) { for (iterator iterator = begin(); iterator != end(); ++iterator) { diff --git a/cpp-driver/gtests/src/integration/test_category.hpp b/cpp-driver/gtests/src/integration/test_category.hpp index d507a3923..95136a47b 100644 --- a/cpp-driver/gtests/src/integration/test_category.hpp +++ b/cpp-driver/gtests/src/integration/test_category.hpp @@ -30,7 +30,7 @@ class TestCategory { class Exception : public test::Exception { public: Exception(const std::string& message) - : test::Exception(message) {} + : test::Exception(message) {} }; /** * Iterator @@ -184,8 +184,8 @@ class TestCategory { * @param display_name Display name for enumeration * @param filter Filter for enumeration */ - TestCategory(const std::string& name, short ordinal, - const std::string& display_name, const std::string& filter); + TestCategory(const std::string& name, short ordinal, const std::string& display_name, + const std::string& filter); /** * Get the enumeration constants * diff --git a/cpp-driver/gtests/src/integration/test_utils.cpp b/cpp-driver/gtests/src/integration/test_utils.cpp index ce088948a..b0ba3579d 100644 --- a/cpp-driver/gtests/src/integration/test_utils.cpp +++ b/cpp-driver/gtests/src/integration/test_utils.cpp @@ -26,13 +26,13 @@ #include #include #ifndef _WIN32 -# include +#include #endif #ifdef _WIN32 -# define FILE_MODE 0 +#define FILE_MODE 0 #else -# define FILE_MODE S_IRWXU | S_IRWXG | S_IROTH +#define FILE_MODE S_IRWXU | S_IRWXG | S_IROTH #endif #define FILE_PATH_SIZE 1024 @@ -45,7 +45,7 @@ const char test::Utils::PATH_SEPARATOR = '\\'; const char test::Utils::PATH_SEPARATOR = '/'; #endif -template +template T* test::Utils::addressof(T& value) { return reinterpret_cast(&const_cast(reinterpret_cast(value))); } @@ -128,14 +128,13 @@ std::string test::Utils::scalar_cql_type(CassValueType value_type) { break; default: std::stringstream message; - message << "Unable to Retrieve CQL Type: CassValueType [" << - value_type << "] is not valid"; + message << "Unable to Retrieve CQL Type: CassValueType [" << value_type << "] is not valid"; throw test::Exception(message.str()); } } std::vector test::Utils::explode(const std::string& input, - const char delimiter /*= ' '*/) { + const char delimiter /*= ' '*/) { // Iterate over the input line and parse the tokens std::vector result; std::istringstream parser(input); @@ -159,8 +158,8 @@ std::string test::Utils::indent(const std::string& input, unsigned int indent) { // Iterate over each line in the input string and indent std::vector lines = explode(input, '\n'); - for (std::vector::iterator iterator = lines.begin(); - iterator < lines.end(); ++iterator) { + for (std::vector::iterator iterator = lines.begin(); iterator < lines.end(); + ++iterator) { output << std::setw(indent) << "" << *iterator; if ((iterator + 1) != lines.end()) { output << std::endl; @@ -194,12 +193,12 @@ void test::Utils::msleep(unsigned int milliseconds) { #ifdef _WIN32 Sleep(milliseconds); #else - //Convert the milliseconds into a proper timespec structure + // Convert the milliseconds into a proper timespec structure struct timespec requested; time_t seconds = static_cast(milliseconds / 1000); long int nanoseconds = static_cast((milliseconds - (seconds * 1000)) * 1000000); - //Assign the requested time and perform sleep + // Assign the requested time and perform sleep requested.tv_sec = seconds; requested.tv_nsec = nanoseconds; while (nanosleep(&requested, &requested) == -1) { @@ -208,11 +207,11 @@ void test::Utils::msleep(unsigned int milliseconds) { #endif } -std::string test::Utils::replace_all(const std::string& input, - const std::string& from, const std::string& to) { +std::string test::Utils::replace_all(const std::string& input, const std::string& from, + const std::string& to) { size_t position = 0; std::string result = input; - while((position = result.find(from, position)) != std::string::npos) { + while ((position = result.find(from, position)) != std::string::npos) { result.replace(position, from.length(), to); // Handle the case where 'to' is a substring of 'from' position += to.length(); @@ -221,13 +220,13 @@ std::string test::Utils::replace_all(const std::string& input, } std::string test::Utils::shorten(const std::string& input, - bool add_space_after_newline /*= true*/) { + bool add_space_after_newline /*= true*/) { std::string result = input; // Iterate over each trim delimiter std::string delimiters = TRIM_DELIMETERS; - for (std::string::iterator iterator = delimiters.begin(); - iterator < delimiters.end(); ++iterator) { + for (std::string::iterator iterator = delimiters.begin(); iterator < delimiters.end(); + ++iterator) { // Replace the trim delimiter with empty string (space if EOL) std::string delimiter(1, *iterator); std::string newline_replacement = add_space_after_newline ? " " : ""; @@ -259,8 +258,8 @@ std::string test::Utils::trim(const std::string& input) { } bool test::Utils::wait_for_port(const std::string& ip_address, unsigned short port, - unsigned int number_of_retries /*= 100*/, - unsigned int retry_delay_ms /*= 100*/) { + unsigned int number_of_retries /*= 100*/, + unsigned int retry_delay_ms /*= 100*/) { // Attempt establish a connection to the IP address and port of the node for (unsigned int n = 0; n < number_of_retries; ++n) { Socket socket; diff --git a/cpp-driver/gtests/src/integration/test_utils.hpp b/cpp-driver/gtests/src/integration/test_utils.hpp index 305c5a8c4..fdf28e80e 100644 --- a/cpp-driver/gtests/src/integration/test_utils.hpp +++ b/cpp-driver/gtests/src/integration/test_utils.hpp @@ -77,8 +77,7 @@ class Utils { * @param delimiter Character to use split into elements (default: ) * @return An array/vector representation of the string */ - static std::vector explode(const std::string& input, - const char delimiter = ' '); + static std::vector explode(const std::string& input, const char delimiter = ' '); /** * Check to see if a file exists @@ -105,13 +104,12 @@ class Utils { * @return A string concatenating all the vector elements with delimiter * separation */ - template - inline static std::string implode(const std::vector& elements, - const char delimiter = ' ') { + template + inline static std::string implode(const std::vector& elements, const char delimiter = ' ') { // Iterate through each element in the vector and concatenate the string std::stringstream result; for (typename std::vector::const_iterator iterator = elements.begin(); - iterator < elements.end(); ++iterator) { + iterator < elements.end(); ++iterator) { result << *iterator; if ((iterator + 1) != elements.end()) { result << delimiter; @@ -144,8 +142,8 @@ class Utils { * @param to String to replace with * @return Input string with replacement */ - static std::string replace_all(const std::string& input, - const std::string& from, const std::string& to); + static std::string replace_all(const std::string& input, const std::string& from, + const std::string& to); /** * Reduce/Shorten a multi-line string into a single line string @@ -156,8 +154,7 @@ class Utils { * otherwise * @return Single line string converted from multi-line string */ - static std::string shorten(const std::string& input, - bool add_space_after_newline = true); + static std::string shorten(const std::string& input, bool add_space_after_newline = true); /** * Convert a string to lowercase @@ -186,8 +183,8 @@ class Utils { * @return True if port on IP address is available; false otherwise */ static bool wait_for_port(const std::string& ip_address, unsigned short port, - unsigned int number_of_retries = 100, - unsigned int retry_delay_ms = 100); + unsigned int number_of_retries = 100, + unsigned int retry_delay_ms = 100); }; } // namespace test diff --git a/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_connect.cpp b/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_connect.cpp index f1484b6b5..59a6f19b3 100644 --- a/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_connect.cpp +++ b/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_connect.cpp @@ -22,7 +22,8 @@ * Connection integration tests using Simulacron */ class ConnectionTest : public SimulacronIntegration { -using SimulacronIntegration::connect; + using SimulacronIntegration::connect; + public: void SetUp() { is_sc_start_requested_ = false; @@ -37,8 +38,7 @@ using SimulacronIntegration::connect; * @param is_across_dcs True if connections are going to be made on all DCs; * false otherwise. */ - void assert_active_connections(int host_connections = 1, - bool is_across_dcs = true) { + void assert_active_connections(int host_connections = 1, bool is_across_dcs = true) { std::vector data_centers = sc_->data_centers(); for (std::vector::iterator it = data_centers.begin(); it != data_centers.end(); ++it) { @@ -65,8 +65,7 @@ using SimulacronIntegration::connect; * @param cluster Cluster configuration to use when establishing the * connection (default: NULL; uses default configuration) */ - void connect(std::vector data_center_nodes, - test::driver::Cluster cluster = NULL) { + void connect(std::vector data_center_nodes, test::driver::Cluster cluster = NULL) { // Start the SC, prime the tables, and establish a connection start_sc(data_center_nodes); contact_points_ = sc_->get_ip_address(1); @@ -88,7 +87,7 @@ using SimulacronIntegration::connect; * connection (default: NULL; uses default configuration) */ void connect(unsigned int number_dc1_nodes, unsigned int number_dc2_nodes, - test::driver::Cluster cluster = NULL) { + test::driver::Cluster cluster = NULL) { // Initialize the number of nodes in the standard data centers std::vector data_center_nodes; number_dc1_nodes_ = number_dc1_nodes; @@ -189,13 +188,11 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectOneNodeTwoDataCenters) { * @expected_result Successful connection and validation of active connections * across the data centers */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectOneNodeTwoDataCentersAcrossDCs) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectOneNodeTwoDataCentersAcrossDCs) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_load_balance_round_robin(); + test::driver::Cluster cluster = default_cluster().with_load_balance_round_robin(); connect(1, 1, cluster); assert_active_connections(); } @@ -231,13 +228,11 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectThreeNodesTwoDataCenters) { * @expected_result Successful connection and validation of active connections * across the data centers */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectThreeNodesTwoDataCentersAcrossDCs) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectThreeNodesTwoDataCentersAcrossDCs) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_load_balance_round_robin(); + test::driver::Cluster cluster = default_cluster().with_load_balance_round_robin(); connect(3, 3, cluster); assert_active_connections(); } @@ -253,8 +248,7 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, * @since 1.0.0 * @expected_result Successful connection and validation of active connections */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectFiveHundredNodesTwoDataCenters) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectFiveHundredNodesTwoDataCenters) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established @@ -274,13 +268,11 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, * @expected_result Successful connection and validation of active connections * across the data centers */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectFiveHundredNodesTwoDataCentersAcrossDCs) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectFiveHundredNodesTwoDataCentersAcrossDCs) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_load_balance_round_robin(); + test::driver::Cluster cluster = default_cluster().with_load_balance_round_robin(); connect(500, 500, cluster); assert_active_connections(); } @@ -322,8 +314,7 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectOneNodeNineDataCenters) { * @expected_result Successful connection and validation of active connections * across the data centers */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectOneNodeNineDataCentersAcrossDCs) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectOneNodeNineDataCentersAcrossDCs) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Create the nine data centers @@ -333,8 +324,7 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, } // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_load_balance_round_robin(); + test::driver::Cluster cluster = default_cluster().with_load_balance_round_robin(); connect(data_center_nodes, cluster); assert_active_connections(); } @@ -350,13 +340,12 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, * @since 1.0.0 * @expected_result Successful connection and validation of active connections */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectOneNodeMultipleConnectionsPerHost) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectOneNodeMultipleConnectionsPerHost) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); + test::driver::Cluster cluster = + default_cluster().with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); connect(1, 0, cluster); assert_active_connections(CORE_CONNECTIONS_PER_HOST); } @@ -372,13 +361,12 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, * @since 1.0.0 * @expected_result Successful connection and validation of active connections */ -SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, - ConnectThreeNodesMultipleConnectionsPerHost) { +SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, ConnectThreeNodesMultipleConnectionsPerHost) { SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); + test::driver::Cluster cluster = + default_cluster().with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); connect(3, 0, cluster); assert_active_connections(CORE_CONNECTIONS_PER_HOST); } @@ -399,8 +387,8 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); + test::driver::Cluster cluster = + default_cluster().with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); connect(1, 1, cluster); assert_active_connections(CORE_CONNECTIONS_PER_HOST, false); } @@ -421,8 +409,8 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, SKIP_TEST_IF_SIMULACRON_UNAVAILABLE; // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); + test::driver::Cluster cluster = + default_cluster().with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); connect(3, 3, cluster); assert_active_connections(CORE_CONNECTIONS_PER_HOST, false); } @@ -449,8 +437,8 @@ SIMULACRON_INTEGRATION_TEST_F(ConnectionTest, } // Ensure the control connection and normal node connection is established - test::driver::Cluster cluster = default_cluster() - .with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); + test::driver::Cluster cluster = + default_cluster().with_core_connections_per_host(CORE_CONNECTIONS_PER_HOST); connect(data_center_nodes, cluster); assert_active_connections(CORE_CONNECTIONS_PER_HOST, false); } diff --git a/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_idempotent.cpp b/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_idempotent.cpp index b7e0bd296..8c02a78b4 100644 --- a/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_idempotent.cpp +++ b/cpp-driver/gtests/src/integration/tests/simulacron/test_simulacron_idempotent.cpp @@ -22,7 +22,8 @@ * Idempotent integration tests */ class IdempotentTest : public SimulacronIntegration { -using SimulacronIntegration::execute_mock_query; + using SimulacronIntegration::execute_mock_query; + public: void SetUp() { number_dc1_nodes_ = 3; @@ -44,8 +45,7 @@ using SimulacronIntegration::execute_mock_query; * should be enabled; false otherwise * @return Result from the executed mock query; see Result::error_code() */ - test::driver::Result execute_mock_query(bool is_idempotent, - bool apply_custom_retry_policy) { + test::driver::Result execute_mock_query(bool is_idempotent, bool apply_custom_retry_policy) { // Create the statement with the desired idempotence and custom retry policy test::driver::Statement statement("mock query"); statement.set_consistency(CASS_CONSISTENCY_ONE); @@ -54,8 +54,8 @@ using SimulacronIntegration::execute_mock_query; // Determine if the custom or default retry policy should be applied test::driver::RetryPolicy policy((apply_custom_retry_policy - ? NextHostRetryPolicy::policy() - : test::driver::DefaultRetryPolicy())); + ? NextHostRetryPolicy::policy() + : test::driver::DefaultRetryPolicy())); test::driver::LoggingRetryPolicy logging_policy(policy); statement.set_retry_policy(logging_policy); @@ -92,7 +92,6 @@ SIMULACRON_INTEGRATION_TEST_F(IdempotentTest, WriteTimeoutNonIdempotentNoRetry) } } - /** * Perform query using a idempotent statement; no errors should occur * @@ -154,7 +153,6 @@ SIMULACRON_INTEGRATION_TEST_F(IdempotentTest, ClosedConnectionNonIdempotentNoRet } } - /** * Perform query using a idempotent statement while a connection is closed * diff --git a/cpp-driver/gtests/src/integration/tests/test_async.cpp b/cpp-driver/gtests/src/integration/tests/test_async.cpp index 1e73d0229..1ccf51175 100644 --- a/cpp-driver/gtests/src/integration/tests/test_async.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_async.cpp @@ -28,8 +28,8 @@ class AsyncTests : public Integration { Integration::SetUp(); // Create the table - session_.execute("CREATE TABLE " + table_name_ - + " (key timeuuid PRIMARY KEY, value_number int, value_text text)"); + session_.execute("CREATE TABLE " + table_name_ + + " (key timeuuid PRIMARY KEY, value_number int, value_text text)"); } /** @@ -44,7 +44,8 @@ class AsyncTests : public Integration { for (size_t i = 0; i < NUMBER_OF_CONCURRENT_REQUESTS; ++i) { // Create the insert statement Statement insert("INSERT INTO " + table_name_ + - " (key, value_number, value_text) VALUES (?, ?, ?) IF NOT EXISTS", 3); + " (key, value_number, value_text) VALUES (?, ?, ?) IF NOT EXISTS", + 3); // Bind the values to the insert statement TimeUuid key = uuid_generator_.generate_timeuuid(); diff --git a/cpp-driver/gtests/src/integration/tests/test_auth.cpp b/cpp-driver/gtests/src/integration/tests/test_auth.cpp index 8776914bf..f37b6d3ff 100644 --- a/cpp-driver/gtests/src/integration/tests/test_auth.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_auth.cpp @@ -43,12 +43,10 @@ class AuthenticationTests : public Integration { * @param password Password credentials * @return Session instance */ - Session connect_using_credentials(int protocol_version, - const char* username, - const char* password) { + Session connect_using_credentials(int protocol_version, const char* username, + const char* password) { // Establish a connection using the protocol version - cluster_.with_protocol_version(protocol_version) - .with_credentials(username, password); + cluster_.with_protocol_version(protocol_version).with_credentials(username, password); return cluster_.connect("", false); } @@ -59,8 +57,7 @@ class AuthenticationTests : public Integration { * @param authenticator Driver authenticator * @oaram data Data associated with the callback */ - static void handle_authenticator_initial(CassAuthenticator* authuenticator, - void* data) { + static void handle_authenticator_initial(CassAuthenticator* authuenticator, void* data) { cass_authenticator_set_error(authuenticator, NULL); } }; @@ -80,12 +77,11 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, ProtocolVersions) { CHECK_FAILURE; // Iterate over all known/supported protocol versions - for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; - i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) { + for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; + ++i) { // Establish a connection using the protocol version Session session = connect_using_credentials(i, "cassandra", "cassandra"); - ASSERT_EQ(CASS_OK, session.connect_error_code()) - << session.connect_error_description(); + ASSERT_EQ(CASS_OK, session.connect_error_code()) << session.connect_error_description(); // Execute a query against the schema keyspaces table Result result = session.execute("SELECT * FROM " + system_schema_keyspaces_); @@ -111,8 +107,8 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidEmptyCredentials) { // Iterate over all known/supported protocol versions logger_.add_critera("Key may not be empty"); - for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; - i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) { + for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; + ++i) { /* * This is a case that could be guarded in the API entry point, or error out * in connection. However, auth is subject to major changes and this is just @@ -142,8 +138,8 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidNullUsernameCredentials // Iterate over all known/supported protocol versions logger_.add_critera("Key may not be empty"); - for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; - i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) { + for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; + ++i) { /* * This is a case that could be guarded in the API entry point, or error out * in connection. However, auth is subject to major changes and this is just @@ -173,8 +169,8 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, InvalidNullPasswordCredentials // Iterate over all known/supported protocol versions logger_.add_critera("and/or password are incorrect"); - for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; - i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) { + for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; + ++i) { /* * This is a case that could be guarded in the API entry point, or error out * in connection. However, auth is subject to major changes and this is just @@ -214,8 +210,8 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, BadCredentials) { } // Iterate over all known/supported protocol versions - for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; - i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; ++i) { + for (int i = CASS_LOWEST_SUPPORTED_PROTOCOL_VERSION; i <= CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION; + ++i) { /* * This is a case that could be guarded in the API entry point, or error out * in connection. However, auth is subject to major changes and this is just @@ -257,14 +253,11 @@ CASSANDRA_INTEGRATION_TEST_F(AuthenticationTests, AuthenticatorSetErrorNull) { // Attempt to establish session connection using authentication callback CassAuthenticatorCallbacks authentication_callbacks = { - AuthenticationTests::handle_authenticator_initial, - NULL, - NULL, - NULL + AuthenticationTests::handle_authenticator_initial, NULL, NULL, NULL }; cluster_.with_authenticator_callbacks(&authentication_callbacks, NULL, NULL); - Session session = connect_using_credentials(CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION, - "invalid", "invalid"); + Session session = + connect_using_credentials(CASS_HIGHEST_SUPPORTED_PROTOCOL_VERSION, "invalid", "invalid"); ASSERT_EQ(session.connect_error_code(), CASS_ERROR_SERVER_BAD_CREDENTIALS); ASSERT_GE(logger_.count(), 1u); } diff --git a/cpp-driver/gtests/src/integration/tests/test_basics.cpp b/cpp-driver/gtests/src/integration/tests/test_basics.cpp index f71c2ca18..6145b4393 100644 --- a/cpp-driver/gtests/src/integration/tests/test_basics.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_basics.cpp @@ -19,7 +19,7 @@ /** * Basics integration tests; common operations */ -class BasicsTests : public Integration { }; +class BasicsTests : public Integration {}; /** * Perform inserts and validate the timestamps from the server @@ -36,12 +36,11 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Timestamps) { CHECK_FAILURE; // Create the table, insert and select queries for the test - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", "int")); - std::string insert_query = format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "?", "?"); - Statement select_query = Statement("SELECT WRITETIME (value) FROM " - + table_name_); + session_.execute( + format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", "int")); + std::string insert_query = + format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "?", "?"); + Statement select_query = Statement("SELECT WRITETIME (value) FROM " + table_name_); // Insert a value and get the timestamp from the server Statement statement(insert_query, 2); @@ -69,8 +68,7 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Timestamps) { // Validate the timestamps ASSERT_NE(timestamp_1, timestamp_2); - ASSERT_LT(timestamp_2 - timestamp_1 - BigInteger(pause_duration * 1000), - BigInteger(100000)); + ASSERT_LT(timestamp_2 - timestamp_1 - BigInteger(pause_duration * 1000), BigInteger(100000)); } /** @@ -87,15 +85,13 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, Counters) { CHECK_FAILURE; // Create the table and update/upsert queries for the test - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", "counter")); - std::string update_query = "UPDATE " + table_name_ - + " SET value=value %s ? WHERE key=0"; + session_.execute( + format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", "counter")); + std::string update_query = "UPDATE " + table_name_ + " SET value=value %s ? WHERE key=0"; // Perform multiple upserts against the counter value for (int step = 0; step < 100; ++step) { - Statement statement(format_string(update_query.c_str(), - (step % 2 == 0 ? "-" : "+")), 1); + Statement statement(format_string(update_query.c_str(), (step % 2 == 0 ? "-" : "+")), 1); statement.bind(0, Counter(step)); session_.execute(statement); } @@ -125,14 +121,15 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, RowsInRowsOut) { CHECK_FAILURE; // Create the table, insert, and select statements for the test - session_.execute("CREATE TABLE " + table_name_ - + " (key bigint PRIMARY KEY, " \ + session_.execute("CREATE TABLE " + table_name_ + + " (key bigint PRIMARY KEY, " "value_1 bigint, value_2 bigint, value_3 bigint)"); - Statement insert_statement("INSERT INTO " + table_name_ - + " (key, value_1, value_2, value_3) " \ - "VALUES (?, ?, ?, ?)", 4); - Statement select_statement("SELECT key, value_1, value_2, value_3 FROM " - + table_name_ + " LIMIT 1000"); + Statement insert_statement("INSERT INTO " + table_name_ + + " (key, value_1, value_2, value_3) " + "VALUES (?, ?, ?, ?)", + 4); + Statement select_statement("SELECT key, value_1, value_2, value_3 FROM " + table_name_ + + " LIMIT 1000"); // Create multiple rows with varying data for (int i = 0; i < 1000; ++i) { @@ -177,8 +174,8 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, ColumnNames) { CHECK_FAILURE; // Create the table for the test - session_.execute("CREATE TABLE " + table_name_ - + " (key bigint PRIMARY KEY, " \ + session_.execute("CREATE TABLE " + table_name_ + + " (key bigint PRIMARY KEY, " "value_1 text, value_2 int, value_3 bigint, value_4 float)"); // Validate the column names @@ -210,18 +207,17 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, EmptyResults) { CHECK_FAILURE; // Create the table - Result result = session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", "int")); + Result result = session_.execute( + format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", "int")); ASSERT_TRUE(result.is_empty()); // Insert data into the table - result = session_.execute(format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "0", "0")); + result = session_.execute( + format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "0", "0")); ASSERT_TRUE(result.is_empty()); // Delete data from the table - result = session_.execute(format_string(CASSANDRA_DELETE_ROW_FORMAT, - table_name_.c_str(), "0")); + result = session_.execute(format_string(CASSANDRA_DELETE_ROW_FORMAT, table_name_.c_str(), "0")); ASSERT_TRUE(result.is_empty()); // Select data from the table (all rows have been deleted) @@ -246,12 +242,11 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, UnsetParameters) { CHECK_FAILURE; // Create the table, insert a known value, and create insert statement for the test - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", "int")); - session_.execute(format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "0", "1")); - Prepared insert_prepared = session_.prepare(format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "?", "?")); + session_.execute( + format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", "int")); + session_.execute(format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "0", "1")); + Prepared insert_prepared = session_.prepare( + format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "?", "?")); // Bind a single value and leave one unset Statement insert_statement = insert_prepared.bind(); @@ -287,17 +282,17 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, UnsetParameters) { * @test_category queries:basic * @since core:2.3.0 * @expected_result String will be bound/inserted into blob and values will be - * validated + * validated */ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, BindBlobAsString) { CHECK_FAILURE; // Create the table, prepared and insert statement for the test - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", "blob")); + session_.execute( + format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", "blob")); // Prepared needed to validate bind type information - Prepared insert_prepared = session_.prepare(format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "?", "?")); + Prepared insert_prepared = session_.prepare( + format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "?", "?")); Statement insert_statement = insert_prepared.bind(); // Bind and insert the data into the table @@ -341,33 +336,32 @@ CASSANDRA_INTEGRATION_TEST_F(BasicsTests, NoCompactEnabledConnection) { CCM::CassVersion cass_version = server_version_; if (Options::is_dse()) { if (server_version_ >= "6.0.0") { - SKIP_TEST("Unsupported for DataStax Enterprise Version " << server_version_.to_string() + SKIP_TEST("Unsupported for DataStax Enterprise Version " + << server_version_.to_string() << ": Apache Cassandra server version must be used and less than" << " v4.0.0 and either 3.0.16+ or 3.11.2+ in order to execute"); } cass_version = static_cast(cass_version).get_cass_version(); } if (cass_version >= "4.0.0") { - SKIP_TEST("Unsupported for Apache Cassandra Version " << cass_version.to_string() + SKIP_TEST("Unsupported for Apache Cassandra Version " + << cass_version.to_string() << ": Server version must be less than v4.0.0 and either 3.0.16+" << " or 3.11.2+ in order to execute"); } // Create a session where the NO_COMPACT option is set - Session no_compact_session = default_cluster() - .with_no_compact() - .connect(default_keyspace()); + Session no_compact_session = default_cluster().with_no_compact().connect(default_keyspace()); // Create the table and insert data using the NO_COMPACT session no_compact_session.execute(format_string( - "CREATE TABLE %s (k int PRIMARY KEY, v int) WITH COMPACT STORAGE", - table_name_.c_str())); - no_compact_session.execute(format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", - table_name_.c_str(), "1", "1")); - no_compact_session.execute(format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", - table_name_.c_str(), "2", "2")); - no_compact_session.execute(format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", - table_name_.c_str(), "3", "3")); + "CREATE TABLE %s (k int PRIMARY KEY, v int) WITH COMPACT STORAGE", table_name_.c_str())); + no_compact_session.execute( + format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", table_name_.c_str(), "1", "1")); + no_compact_session.execute( + format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", table_name_.c_str(), "2", "2")); + no_compact_session.execute( + format_string("INSERT INTO %s (k, v) VALUES(%s, %s)", table_name_.c_str(), "3", "3")); // Validate the default session with compact storage enabled Result result = session_.execute(default_select_all()); diff --git a/cpp-driver/gtests/src/integration/tests/test_batch.cpp b/cpp-driver/gtests/src/integration/tests/test_batch.cpp index c42b8258d..62cfce295 100644 --- a/cpp-driver/gtests/src/integration/tests/test_batch.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_batch.cpp @@ -24,15 +24,15 @@ class BatchSingleNodeClusterTests : public Integration { public: BatchSingleNodeClusterTests() - : value_cql_data_type_("text") { } + : value_cql_data_type_("text") {} virtual void SetUp() { // Call the parent setup function Integration::SetUp(); // Create the table, insert and select statements for the test - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", value_cql_data_type_.c_str())); + session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", + value_cql_data_type_.c_str())); create_queries_select_statements(); } @@ -58,12 +58,11 @@ class BatchSingleNodeClusterTests : public Integration { * Create the queries and select statement for the test */ virtual void create_queries_select_statements() { - insert_query_ = format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, - table_name_.c_str(), "?", "?"); - update_query_ = format_string(CASSANDRA_UPDATE_VALUE_FORMAT, - table_name_.c_str(), "value + ?", "?"); - select_prepared_ = session_.prepare(format_string(CASSANDRA_SELECT_VALUE_FORMAT, - table_name_.c_str(), "?")); + insert_query_ = format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "?", "?"); + update_query_ = + format_string(CASSANDRA_UPDATE_VALUE_FORMAT, table_name_.c_str(), "value + ?", "?"); + select_prepared_ = + session_.prepare(format_string(CASSANDRA_SELECT_VALUE_FORMAT, table_name_.c_str(), "?")); } /** @@ -84,8 +83,7 @@ class BatchSingleNodeClusterTests : public Integration { Result result = session_.execute(statement); // Validate the result - ASSERT_EQ(Text(format_string("test data %d", i)), - result.first_row().next().as()); + ASSERT_EQ(Text(format_string("test data %d", i)), result.first_row().next().as()); } } @@ -96,8 +94,7 @@ class BatchSingleNodeClusterTests : public Integration { * @param index The index/row being validated */ virtual void validate_result(Result result, int index) { - ASSERT_EQ(Text(format_string("test data %d", index)), - result.first_row().next().as()); + ASSERT_EQ(Text(format_string("test data %d", index)), result.first_row().next().as()); } }; @@ -108,9 +105,7 @@ class BatchSingleNodeClusterTests : public Integration { */ class BatchCounterSingleNodeClusterTests : public BatchSingleNodeClusterTests { public: - BatchCounterSingleNodeClusterTests() { - value_cql_data_type_ = "counter"; - } + BatchCounterSingleNodeClusterTests() { value_cql_data_type_ = "counter"; } /** * Validate the result for the text data type @@ -264,13 +259,15 @@ CASSANDRA_INTEGRATION_TEST_F(BatchCounterSingleNodeClusterTests, InvalidBatchTyp // Create and add the insert statement Statement statement(insert_query_, 2); - statement.bind(0, Integer(37)); // Attempt to insert a counter value inside a batch statement + statement.bind( + 0, Integer(37)); // Attempt to insert a counter value inside a batch statement statement.bind(1, Counter(37)); batch.add(statement); // Execute the batch statement and verify the server response Result result = session_.execute(batch, false); - ASSERT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, result.error_code()); // Cannot include a counter statement in a logged batch + ASSERT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, + result.error_code()); // Cannot include a counter statement in a logged batch } /** @@ -315,8 +312,7 @@ CASSANDRA_INTEGRATION_TEST_F(BatchCounterThreeNodeClusterTests, MixedPreparedAnd session_.execute(batch); // Validate the updates - Result result = session_.execute(default_select_all(), - CASS_CONSISTENCY_QUORUM); + Result result = session_.execute(default_select_all(), CASS_CONSISTENCY_QUORUM); ASSERT_EQ(number_of_rows, result.row_count()); ASSERT_EQ(2u, result.column_count()); Rows rows = result.rows(); diff --git a/cpp-driver/gtests/src/integration/tests/test_by_name.cpp b/cpp-driver/gtests/src/integration/tests/test_by_name.cpp index 3025112df..17dc07b32 100644 --- a/cpp-driver/gtests/src/integration/tests/test_by_name.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_by_name.cpp @@ -16,27 +16,31 @@ #include "integration.hpp" -#define TABLE_FORMAT "CREATE TABLE %s (" \ - "key timeuuid PRIMARY KEY, " \ - "a int, " \ - "b boolean, " \ - "c text, " \ - "abc float, " \ - "\"ABC\" float, " \ - "\"aBc\" float" \ - ")" -#define TABLE_BYTES_FORMAT "CREATE TABLE %s (" \ - "key timeuuid PRIMARY KEY, " \ - "blobs blob, " \ - "varints varint" \ - ")" +#define TABLE_FORMAT \ + "CREATE TABLE %s (" \ + "key timeuuid PRIMARY KEY, " \ + "a int, " \ + "b boolean, " \ + "c text, " \ + "abc float, " \ + "\"ABC\" float, " \ + "\"aBc\" float" \ + ")" +#define TABLE_BYTES_FORMAT \ + "CREATE TABLE %s (" \ + "key timeuuid PRIMARY KEY, " \ + "blobs blob, " \ + "varints varint" \ + ")" #define INSERT_FORMAT "INSERT INTO %s (key, a, b, c) VALUES (?, ?, ?, ?)" -#define INSERT_CASE_SENSITIVE_FORMAT "INSERT INTO %s " \ - "(key, abc, \"ABC\", \"aBc\") " \ - "VALUES (?, ?, ?, ?)" -#define INSERT_ALL_FORMAT "INSERT INTO %s " \ - "(key, a, b, c, abc, \"ABC\", \"aBc\") " \ - "VALUES (?, ?, ?, ?, ?, ?, ?)" +#define INSERT_CASE_SENSITIVE_FORMAT \ + "INSERT INTO %s " \ + "(key, abc, \"ABC\", \"aBc\") " \ + "VALUES (?, ?, ?, ?)" +#define INSERT_ALL_FORMAT \ + "INSERT INTO %s " \ + "(key, a, b, c, abc, \"ABC\", \"aBc\") " \ + "VALUES (?, ?, ?, ?, ?, ?, ?)" #define INSERT_BYTES_FORMAT "INSERT INTO %s (key, blobs, varints) VALUES (?, ?, ?)" /** @@ -199,8 +203,7 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, Prepared) { CHECK_FAILURE; // Prepare, create, insert and validate - Prepared prepared = session_.prepare(format_string(INSERT_FORMAT, - table_name_.c_str())); + Prepared prepared = session_.prepare(format_string(INSERT_FORMAT, table_name_.c_str())); insert_and_validate(prepared.bind()); } @@ -238,8 +241,8 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, PreparedCaseSensitive) { CHECK_FAILURE; // Prepare, create, insert and validate - Prepared prepared = session_.prepare(format_string(INSERT_CASE_SENSITIVE_FORMAT, - table_name_.c_str())); + Prepared prepared = + session_.prepare(format_string(INSERT_CASE_SENSITIVE_FORMAT, table_name_.c_str())); insert_and_validate_case_sensitive(prepared.bind()); } @@ -261,8 +264,7 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, SimpleCaseSensitive) { CHECK_VERSION(2.1.0); // Prepare, create, insert and validate - Statement statement(format_string(INSERT_CASE_SENSITIVE_FORMAT, - table_name_.c_str()), 4); + Statement statement(format_string(INSERT_CASE_SENSITIVE_FORMAT, table_name_.c_str()), 4); insert_and_validate_case_sensitive(statement); } @@ -282,8 +284,8 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, MultipleBinds) { CHECK_FAILURE; // Prepare, bind, and insert the values into the table - Prepared prepared = session_.prepare(format_string(INSERT_CASE_SENSITIVE_FORMAT, - table_name_.c_str())); + Prepared prepared = + session_.prepare(format_string(INSERT_CASE_SENSITIVE_FORMAT, table_name_.c_str())); Statement statement = prepared.bind(); TimeUuid key = uuid_generator_.generate_timeuuid(); statement.bind("key", key); @@ -311,14 +313,13 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, MultipleBinds) { * @test_category queries:prepared * @since core:1.0.0 * @expected_result Driver error will occur when binding value to invalid column - * name + * name */ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, BindUsingInvalidName) { CHECK_FAILURE; // Prepare and create the insert statement - Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, - table_name_.c_str())); + Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, table_name_.c_str())); Statement statement = prepared.bind(); // Bind values to invalid columns name and validate error @@ -339,14 +340,13 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, BindUsingInvalidName) { * @test_category queries:basic * @since core:1.0.0 * @expected_result Driver error will occur when retrieving value from invalid - * column name + * column name */ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, RetrieveInvalidName) { CHECK_FAILURE; // Prepare, create, insert and validate (all) - Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, - table_name_.c_str())); + Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, table_name_.c_str())); Statement statement = prepared.bind(); insert_and_validate_all(statement); @@ -373,8 +373,7 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameTests, NullPrepared) { CHECK_FAILURE; // Prepare, create, insert and validate - Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, - table_name_.c_str())); + Prepared prepared = session_.prepare(format_string(INSERT_ALL_FORMAT, table_name_.c_str())); insert_and_validate_all_null(prepared.bind()); } @@ -423,8 +422,7 @@ CASSANDRA_INTEGRATION_TEST_F(ByNameBytesTests, Prepared) { Varint varints("1234567890123456789012345678901234567890"); // Prepare, bind, and insert the values into the table - Prepared prepared = session_.prepare(format_string(INSERT_BYTES_FORMAT, - table_name_.c_str())); + Prepared prepared = session_.prepare(format_string(INSERT_BYTES_FORMAT, table_name_.c_str())); Statement statement = prepared.bind(); statement.bind("key", key); statement.bind("blobs", blobs); diff --git a/cpp-driver/gtests/src/integration/tests/test_cassandra_types.cpp b/cpp-driver/gtests/src/integration/tests/test_cassandra_types.cpp index e84f8c0a9..a98fa51e5 100644 --- a/cpp-driver/gtests/src/integration/tests/test_cassandra_types.cpp +++ b/cpp-driver/gtests/src/integration/tests/test_cassandra_types.cpp @@ -19,7 +19,7 @@ /** * Cassandra type integration tests */ -template +template class CassandraTypesTest : public Integration { public: /** @@ -28,7 +28,7 @@ class CassandraTypesTest : public Integration { static const std::vector values_; CassandraTypesTest() - : is_key_allowed_(true) { } + : is_key_allowed_(true) {} void SetUp() { // Enable schema metadata to easily create user type (when needed) @@ -76,11 +76,11 @@ class CassandraTypesTest : public Integration { */ void initialize(const std::string& cql_type) { if (is_key_allowed_) { - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), cql_type.c_str(), cql_type.c_str())); + session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), + cql_type.c_str(), cql_type.c_str())); } else { - session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, - table_name_.c_str(), "int", cql_type.c_str())); + session_.execute(format_string(CASSANDRA_KEY_VALUE_TABLE_FORMAT, table_name_.c_str(), "int", + cql_type.c_str())); } insert_query_ = format_string(CASSANDRA_KEY_VALUE_INSERT_FORMAT, table_name_.c_str(), "?", "?"); select_query_ = format_string(CASSANDRA_SELECT_VALUE_FORMAT, table_name_.c_str(), "?"); @@ -92,7 +92,7 @@ TYPED_TEST_CASE_P(CassandraTypesTest); /** * Specialized duration integration test extension */ -class CassandraTypesDurationTest : public CassandraTypesTest { }; +class CassandraTypesDurationTest : public CassandraTypesTest {}; /** * Perform insert using a simple and prepared statement operation @@ -114,16 +114,14 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Basic) { const std::vector& values = CassandraTypesTest::values_; // Iterate over all the Cassandra type values - for (typename std::vector::const_iterator it = values.begin(); - it != values.end(); ++it) { + for (typename std::vector::const_iterator it = values.begin(); it != values.end(); + ++it) { // Get the current value const TypeParam& value = *it; // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), + this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -173,16 +171,14 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicByName) { const std::vector& values = CassandraTypesTest::values_; // Iterate over all the Cassandra type values - for (typename std::vector::const_iterator it = values.begin(); - it != values.end(); ++it) { + for (typename std::vector::const_iterator it = values.begin(); it != values.end(); + ++it) { // Get the current value const TypeParam& value = *it; // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), + this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -230,10 +226,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullValues) { this->default_setup(); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -276,10 +269,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullList) { this->default_setup(); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -288,7 +278,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullList) { // Bind the NULL collection and insert statement.bind(0, Integer(i)); - statement.bind >(1, value); + statement.bind>(1, value); this->session_.execute(statement); // Validate the insert and result @@ -297,7 +287,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullList) { Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); test::driver::List select_value = - result.first_row().next().as >(); + result.first_row().next().as>(); ASSERT_EQ(value, select_value); ASSERT_TRUE(select_value.is_null()); } @@ -323,10 +313,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullMap) { this->default_setup(); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -335,7 +322,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullMap) { // Bind the NULL collection and insert statement.bind(0, Integer(i)); - statement.bind >(1, value); + statement.bind>(1, value); this->session_.execute(statement); // Validate the insert and result @@ -344,7 +331,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullMap) { Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); test::driver::Map select_value = - result.first_row().next().as >(); + result.first_row().next().as>(); ASSERT_EQ(value, select_value); ASSERT_TRUE(select_value.is_null()); } @@ -370,10 +357,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullSet) { this->default_setup(); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -382,7 +366,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullSet) { // Bind the NULL collection and insert statement.bind(0, Integer(i)); - statement.bind >(1, value); + statement.bind>(1, value); this->session_.execute(statement); // Validate the insert and result @@ -391,7 +375,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, BasicNullSet) { Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); test::driver::Set select_value = - result.first_row().next().as >(); + result.first_row().next().as>(); ASSERT_EQ(value, select_value); ASSERT_TRUE(select_value.is_null()); } @@ -419,10 +403,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, List) { this->initialize("frozen<" + list.cql_type() + ">"); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -430,23 +411,23 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, List) { // Bind both the primary key and the value with the Cassandra type list and insert if (this->is_key_allowed_) { - statement.bind >(0, list); + statement.bind>(0, list); } else { statement.bind(0, Integer(i)); } - statement.bind >(1, list); + statement.bind>(1, list); this->session_.execute(statement); // Validate the result Statement select_statement(this->select_query_, 1); if (this->is_key_allowed_) { - select_statement.bind >(0, list); + select_statement.bind>(0, list); } else { select_statement.bind(0, Integer(i)); } Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); - List result_list(result.first_row().next().as >()); + List result_list(result.first_row().next().as>()); ASSERT_EQ(list.value(), result_list.value()); } } @@ -476,10 +457,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Set) { this->initialize("frozen<" + set.cql_type() + ">"); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate overall all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -487,23 +465,23 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Set) { // Bind both the primary key and the value with the Cassandra type set and insert if (this->is_key_allowed_) { - statement.bind >(0, set); + statement.bind>(0, set); } else { statement.bind(0, Integer(i)); } - statement.bind >(1, set); + statement.bind>(1, set); this->session_.execute(statement); // Validate the result Statement select_statement(this->select_query_, 1); if (this->is_key_allowed_) { - select_statement.bind >(0, set); + select_statement.bind>(0, set); } else { select_statement.bind(0, Integer(i)); } Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); - Set result_set = result.first_row().next().as >(); + Set result_set = result.first_row().next().as>(); ASSERT_EQ(set.value(), result_set.value()); } } @@ -530,35 +508,33 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Map) { // Initialize the table and assign the values for the map std::map map_values; const std::vector& values = CassandraTypesTest::values_; - for (typename std::vector::const_iterator it = values.begin(); - it != values.end(); ++it) { + for (typename std::vector::const_iterator it = values.begin(); it != values.end(); + ++it) { map_values[*it] = *it; } Map map(map_values); this->initialize("frozen<" + map.cql_type() + ">"); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), + this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { Statement& statement = statements[i]; // Bind both the primary key and the value with the Cassandra type map and insert - statement.bind >(0, map); - statement.bind >(1, map); + statement.bind>(0, map); + statement.bind>(1, map); this->session_.execute(statement); // Validate the result Statement select_statement(this->select_query_, 1); - select_statement.bind >(0, map); + select_statement.bind>(0, map); Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); Column column = result.first_row().next(); - Map result_map(column.as >()); + Map result_map(column.as>()); ASSERT_EQ(map_values, result_map.value()); } } else { @@ -566,18 +542,16 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Map) { std::map map_values; const std::vector& values = CassandraTypesTest::values_; cass_int32_t count = 1; - for (typename std::vector::const_iterator it = values.begin(); - it != values.end(); ++it) { + for (typename std::vector::const_iterator it = values.begin(); it != values.end(); + ++it) { map_values[Integer(count++)] = *it; } Map map(map_values); this->initialize("frozen<" + map.cql_type() + ">"); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), + this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -585,7 +559,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Map) { // Bind both the primary key and the value with the Cassandra type map and insert statement.bind(0, Integer(i)); - statement.bind >(1, map); + statement.bind>(1, map); this->session_.execute(statement); // Validate the result @@ -594,7 +568,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Map) { Result result = this->session_.execute(select_statement); ASSERT_EQ(1u, result.row_count()); Column column = result.first_row().next(); - Map result_map(column.as >()); + Map result_map(column.as>()); ASSERT_EQ(map_values, result_map.value()); } } @@ -632,10 +606,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, Tuple) { this->initialize(cql_type); // Create both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; // Iterate over all the statements for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { @@ -703,7 +674,7 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, UDT) { this->session_.execute(create_type); // Initialize the table; NOTE: UDT must be frozen for older versions of Cassandra - this->initialize("frozen<" + cql_type + ">"); + this->initialize("frozen<" + cql_type + ">"); // Build our UDT values and UDT type std::map udt_values; @@ -712,21 +683,17 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, UDT) { field << "field" << i; udt_values[field.str()] = values[i]; } - UserType user_type(this->session_.schema() - .keyspace(this->keyspace_name_) - .user_type(cql_type).data_type()); + UserType user_type( + this->session_.schema().keyspace(this->keyspace_name_).user_type(cql_type).data_type()); // Assign/Set the values in the user type for (typename std::map::const_iterator it = udt_values.begin(); - it != udt_values.end(); ++it) { + it != udt_values.end(); ++it) { user_type.set(it->second, it->first); } // Use both simple and prepared statements - Statement statements[] = { - Statement(this->insert_query_, 2), - this->prepared_statement_.bind() - }; + Statement statements[] = { Statement(this->insert_query_, 2), this->prepared_statement_.bind() }; for (size_t i = 0; i < ARRAY_LEN(statements); ++i) { Statement& statement = statements[i]; @@ -756,16 +723,11 @@ CASSANDRA_INTEGRATION_TYPED_TEST_P(CassandraTypesTest, UDT) { // Register all parameterized test cases for primitives (excludes duration) REGISTER_TYPED_TEST_CASE_P(CassandraTypesTest, Integration_Cassandra_Basic, - Integration_Cassandra_BasicByName, - Integration_Cassandra_BasicNullValues, - Integration_Cassandra_BasicNullList, - Integration_Cassandra_BasicNullMap, - Integration_Cassandra_BasicNullSet, - Integration_Cassandra_List, - Integration_Cassandra_Set, - Integration_Cassandra_Map, - Integration_Cassandra_Tuple, - Integration_Cassandra_UDT); + Integration_Cassandra_BasicByName, Integration_Cassandra_BasicNullValues, + Integration_Cassandra_BasicNullList, Integration_Cassandra_BasicNullMap, + Integration_Cassandra_BasicNullSet, Integration_Cassandra_List, + Integration_Cassandra_Set, Integration_Cassandra_Map, + Integration_Cassandra_Tuple, Integration_Cassandra_UDT); /** * Attempt to utilize an invalid duration value on a statement @@ -800,115 +762,84 @@ CASSANDRA_INTEGRATION_TEST_F(CassandraTypesDurationTest, MixedValues) { } // Instantiate the test case for all the Cassandra data types -typedef testing::Types CassandraTypes; +typedef testing::Types + CassandraTypes; INSTANTIATE_TYPED_TEST_CASE_P(CassandraTypes, CassandraTypesTest, CassandraTypes); /** * Values for ASCII tests */ -const Ascii ASCII_VALUES[] = { - Ascii("DataStax"), - Ascii("C/C++"), - Ascii("Driver"), - Ascii("Cassandra") -}; -template<> const std::vector CassandraTypesTest::values_( - ASCII_VALUES, - ASCII_VALUES + ARRAY_LEN(ASCII_VALUES)); +const Ascii ASCII_VALUES[] = { Ascii("DataStax"), Ascii("C/C++"), Ascii("Driver"), + Ascii("Cassandra") }; +template <> +const std::vector CassandraTypesTest::values_(ASCII_VALUES, + ASCII_VALUES + ARRAY_LEN(ASCII_VALUES)); /** * Values for bigint tests */ -const BigInteger BIGINT_VALUES[] = { - BigInteger::max(), - BigInteger::min(), - BigInteger(static_cast(0)), - BigInteger(37) -}; -template<> const std::vector CassandraTypesTest::values_( - BIGINT_VALUES, - BIGINT_VALUES + ARRAY_LEN(BIGINT_VALUES)); +const BigInteger BIGINT_VALUES[] = { BigInteger::max(), BigInteger::min(), + BigInteger(static_cast(0)), BigInteger(37) }; +template <> +const std::vector CassandraTypesTest::values_(BIGINT_VALUES, + BIGINT_VALUES + + ARRAY_LEN(BIGINT_VALUES)); /** * Values for blob tests */ -const Blob BLOB_VALUES[] = { - Blob("DataStax C/C++ Driver"), - Blob("Cassandra"), - Blob("DataStax Enterprise") -}; -template<> const std::vector CassandraTypesTest::values_( - BLOB_VALUES, - BLOB_VALUES + ARRAY_LEN(BLOB_VALUES)); +const Blob BLOB_VALUES[] = { Blob("DataStax C/C++ Driver"), Blob("Cassandra"), + Blob("DataStax Enterprise") }; +template <> +const std::vector CassandraTypesTest::values_(BLOB_VALUES, + BLOB_VALUES + ARRAY_LEN(BLOB_VALUES)); /** * Values for boolean tests */ -const Boolean BOOLEAN_VALUES[] = { - Boolean(true), - Boolean(false) -}; -template<> const std::vector CassandraTypesTest::values_( - BOOLEAN_VALUES, - BOOLEAN_VALUES + ARRAY_LEN(BOOLEAN_VALUES)); +const Boolean BOOLEAN_VALUES[] = { Boolean(true), Boolean(false) }; +template <> +const std::vector CassandraTypesTest::values_(BOOLEAN_VALUES, + BOOLEAN_VALUES + + ARRAY_LEN(BOOLEAN_VALUES)); /** * Values for date tests */ -const Date DATE_VALUES[] = { - Date::max(), // maximum for strftime - Date::min(), // minimum for strftime - Date(static_cast(0)), - Date(12345u) -}; -template<> const std::vector CassandraTypesTest::values_( - DATE_VALUES, - DATE_VALUES + ARRAY_LEN(DATE_VALUES)); +const Date DATE_VALUES[] = { Date::max(), // maximum for strftime + Date::min(), // minimum for strftime + Date(static_cast(0)), Date(12345u) }; +template <> +const std::vector CassandraTypesTest::values_(DATE_VALUES, + DATE_VALUES + ARRAY_LEN(DATE_VALUES)); /** * Values for decimal tests */ -const Decimal DECIMAL_VALUES[] = { - Decimal("3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"), - Decimal("2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274"), - Decimal("1.6180339887498948482045868343656381177203091798057628621354486227052604628189024497072072041893911374") -}; -template<> const std::vector CassandraTypesTest::values_( - DECIMAL_VALUES, - DECIMAL_VALUES + ARRAY_LEN(DECIMAL_VALUES)); +const Decimal DECIMAL_VALUES[] = { Decimal("3." + "1415926535897932384626433832795028841971693993751058209" + "749445923078164062862089986280348253421170679"), + Decimal("2." + "7182818284590452353602874713526624977572470936999595749" + "669676277240766303535475945713821785251664274"), + Decimal("1." + "6180339887498948482045868343656381177203091798057628621" + "354486227052604628189024497072072041893911374") }; +template <> +const std::vector CassandraTypesTest::values_(DECIMAL_VALUES, + DECIMAL_VALUES + + ARRAY_LEN(DECIMAL_VALUES)); /** * Values for double tests */ -const Double DOUBLE_VALUES[] = { - Double::max(), - Double::min(), - Double(3.1415926535), - Double(2.7182818284), - Double(1.6180339887) -}; -template<> const std::vector CassandraTypesTest::values_( - DOUBLE_VALUES, - DOUBLE_VALUES + ARRAY_LEN(DOUBLE_VALUES)); +const Double DOUBLE_VALUES[] = { Double::max(), Double::min(), Double(3.1415926535), + Double(2.7182818284), Double(1.6180339887) }; +template <> +const std::vector + CassandraTypesTest::values_(DOUBLE_VALUES, DOUBLE_VALUES + ARRAY_LEN(DOUBLE_VALUES)); /** * Values for duration tests @@ -922,168 +853,127 @@ const Duration DURATION_VALUES[] = { Duration(CassDuration(0, std::numeric_limits::max(), 1)), Duration(CassDuration(0, std::numeric_limits::min(), -1)) }; -template<> const std::vector CassandraTypesTest::values_( - DURATION_VALUES, - DURATION_VALUES + ARRAY_LEN(DURATION_VALUES)); +template <> +const std::vector CassandraTypesTest::values_(DURATION_VALUES, + DURATION_VALUES + + ARRAY_LEN(DURATION_VALUES)); /** * Values for float tests */ -const Float FLOAT_VALUES[] = { - Float::max(), - Float::min(), - Float(3.14159f), - Float(2.71828f), - Float(1.61803f) -}; -template<> const std::vector CassandraTypesTest::values_( - FLOAT_VALUES, - FLOAT_VALUES + ARRAY_LEN(FLOAT_VALUES)); +const Float FLOAT_VALUES[] = { Float::max(), Float::min(), Float(3.14159f), Float(2.71828f), + Float(1.61803f) }; +template <> +const std::vector CassandraTypesTest::values_(FLOAT_VALUES, + FLOAT_VALUES + ARRAY_LEN(FLOAT_VALUES)); /** * Values for inet tests */ -const Inet INET_VALUES[] = { - Inet::max(), - Inet::min(), - Inet("127.0.0.1"), - Inet("0:0:0:0:0:0:0:1"), - Inet("2001:db8:85a3:0:0:8a2e:370:7334") -}; -template<> const std::vector CassandraTypesTest::values_( - INET_VALUES, - INET_VALUES + ARRAY_LEN(INET_VALUES)); +const Inet INET_VALUES[] = { Inet::max(), Inet::min(), Inet("127.0.0.1"), Inet("0:0:0:0:0:0:0:1"), + Inet("2001:db8:85a3:0:0:8a2e:370:7334") }; +template <> +const std::vector CassandraTypesTest::values_(INET_VALUES, + INET_VALUES + ARRAY_LEN(INET_VALUES)); /** * Values for int tests */ -const Integer INT_VALUES[] = { - Integer::max(), - Integer::min(), - Integer(0), - Integer(148) -}; -template<> const std::vector CassandraTypesTest::values_( - INT_VALUES, - INT_VALUES + ARRAY_LEN(INT_VALUES)); +const Integer INT_VALUES[] = { Integer::max(), Integer::min(), Integer(0), Integer(148) }; +template <> +const std::vector CassandraTypesTest::values_(INT_VALUES, + INT_VALUES + ARRAY_LEN(INT_VALUES)); /** * Values for smallint tests */ -const SmallInteger SMALLINT_VALUES[] = { - SmallInteger::max(), - SmallInteger::min(), - SmallInteger(static_cast(0)), - SmallInteger(148) -}; -template<> const std::vector CassandraTypesTest::values_( - SMALLINT_VALUES, - SMALLINT_VALUES + ARRAY_LEN(SMALLINT_VALUES)); +const SmallInteger SMALLINT_VALUES[] = { SmallInteger::max(), SmallInteger::min(), + SmallInteger(static_cast(0)), SmallInteger(148) }; +template <> +const std::vector + CassandraTypesTest::values_(SMALLINT_VALUES, + SMALLINT_VALUES + ARRAY_LEN(SMALLINT_VALUES)); /** * Values for text tests */ -const Text TEXT_VALUES[] = { - Text("The quick brown fox jumps over the lazy dog"), - Text("Hello World"), - Text("DataStax C/C++ Driver") -}; -template<> const std::vector CassandraTypesTest::values_( - TEXT_VALUES, - TEXT_VALUES + ARRAY_LEN(TEXT_VALUES)); +const Text TEXT_VALUES[] = { Text("The quick brown fox jumps over the lazy dog"), + Text("Hello World"), Text("DataStax C/C++ Driver") }; +template <> +const std::vector CassandraTypesTest::values_(TEXT_VALUES, + TEXT_VALUES + ARRAY_LEN(TEXT_VALUES)); /** * Values for time tests */ -const Time TIME_VALUES[] = { - Time::max(), - Time::min(), - Time(static_cast(0)), - Time(9876543210) -}; -template<> const std::vector