Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ libcassandra.so*
*.a

# cmake output
src/third_party/sparsehash/src/sparsehash/internal/sparseconfig.h
*.cmake
!Find*.cmake
*.build
Expand Down
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ option(CASS_USE_BOOST_ATOMIC "Use Boost atomics library" OFF)
option(CASS_USE_STD_ATOMIC "Use C++11 atomics library" OFF)
option(CASS_USE_OPENSSL "Use OpenSSL" ON)
option(CASS_USE_TCMALLOC "Use tcmalloc" OFF)
option(CASS_USE_SPARSEHASH "Use sparsehash" OFF)
option(CASS_USE_ZLIB "Use zlib" OFF)
option(CASS_USE_LIBSSH2 "Use libssh2 for integration tests" ON)

Expand Down Expand Up @@ -108,12 +107,6 @@ if(CASS_USE_BOOST_ATOMIC OR CASS_BUILD_INTEGRATION_TESTS OR CASS_BUILD_UNIT_TEST
CassUseBoost()
endif()

# Sparsehash
if(CASS_USE_SPARSEHASH)
CassUseSparshHash()
endif()


# OpenSSL
if(CASS_USE_OPENSSL)
CassUseOpenSSL()
Expand Down
37 changes: 3 additions & 34 deletions cmake/modules/CppDriver.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,40 +158,6 @@ macro(CassUseBoost)
endif()
endmacro()

#------------------------
# CassUseSparseHash
#
# Add includes required for using SparseHash.
#
# Input: CASS_INCLUDES
# Output: CASS_INCLUDES
#------------------------
macro(CassUseSparseHash)
# Setup the paths and hints for sparsehash
set(_SPARSEHASH_ROOT_PATHS "${PROJECT_SOURCE_DIR}/lib/sparsehash/")
set(_SPARSEHASH_ROOT_HINTS ${SPARSEHASH_ROOT_DIR} $ENV{SPARSEHASH_ROOT_DIR})
if(NOT WIN32)
set(_SPARSEHASH_ROOT_PATHS ${_SPARSEHASH_ROOT_PATHS} "/usr/" "/usr/local/")
endif()
set(_SPARSEHASH_ROOT_HINTS_AND_PATHS
HINTS ${_SPARSEHASH_ROOT_HINTS}
PATHS ${_SPARSEHASH_ROOT_PATHS})

# Ensure sparsehash headers were found
find_path(SPARSEHASH_INCLUDE_DIR
NAMES google/dense_hash_map
HINTS ${_SPARSEHASH_INCLUDE_DIR} ${_SPARSEHASH_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES include)
find_package_handle_standard_args(SparseJash "Could NOT find sparsehash, try to set the path to the sparsehash root folder in the system variable SPARSEHASH_ROOT_DIR"
SPARSEHASH_INCLUDE_DIR)

set(CASS_INCLUDES ${CASS_INCLUDES} ${SPARSEHASH_INCLUDE_DIR})

if (SPARSEHASH_INCLUDE_DIR)
add_definitions("-DCASS_USE_SPARSEHASH")
endif()
endmacro()

#------------------------
# CassUseOpenSSL
#
Expand Down Expand Up @@ -458,8 +424,11 @@ macro(CassAddIncludes)
${CASS_SOURCE_DIR}/src
${CASS_SOURCE_DIR}/src/ssl
${CASS_SOURCE_DIR}/src/third_party/rapidjson
${CASS_SOURCE_DIR}/src/third_party/rapidjson
${CASS_SOURCE_DIR}/src/third_party/sparsehash/src
${CASS_INCLUDES}
)
add_subdirectory(src/third_party/sparsehash)
endmacro()

#------------------------
Expand Down
14 changes: 5 additions & 9 deletions include/cassandra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,9 @@ cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster,
/**
* Configures the cluster to use token-aware request routing or not.
*
* <b>Important:</b> Token-aware routing depends on keyspace information.
* For this reason enabling token-aware routing will also enable the usage
* of schema metadata.
* <b>Important:</b> Token-aware routing depends on keyspace metadata.
* For this reason enabling token-aware routing will also enable retrieving
* and updating keyspace schema metadata.
*
* <b>Default:</b> cass_true (enabled).
*
Expand All @@ -1343,8 +1343,6 @@ cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster,
*
* @param[in] cluster
* @param[in] enabled
*
* @see cass_cluster_set_use_schema();
*/
CASS_EXPORT void
cass_cluster_set_token_aware_routing(CassCluster* cluster,
Expand Down Expand Up @@ -1665,9 +1663,8 @@ cass_cluster_set_retry_policy(CassCluster* cluster,
/**
* Enable/Disable retrieving and updating schema metadata. If disabled
* this is allows the driver to skip over retrieving and updating schema
* metadata, but it also disables the usage of token-aware routing and
* cass_session_get_schema_meta() will always return an empty object. This can
* be useful for reducing the startup overhead of short-lived sessions.
* metadata and cass_session_get_schema_meta() will always return an empty object.
* This can be useful for reducing the startup overhead of short-lived sessions.
*
* <b>Default:</b> cass_true (enabled).
*
Expand All @@ -1677,7 +1674,6 @@ cass_cluster_set_retry_policy(CassCluster* cluster,
* @param[in] enabled
*
* @see cass_session_get_schema_meta()
* @see cass_cluster_set_token_aware_routing()
*/
CASS_EXPORT void
cass_cluster_set_use_schema(CassCluster* cluster,
Expand Down
6 changes: 6 additions & 0 deletions src/address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

namespace cass {

const Address Address::EMPTY_KEY("0.0.0.0", 0);
const Address Address::DELETED_KEY("0.0.0.0", 1);

Address::Address() {
init();
}
Expand Down Expand Up @@ -153,6 +156,9 @@ int Address::compare(const Address& a) const {
if (family() != a.family()) {
return family() < a.family() ? -1 : 1;
}
if (port() != a.port()) {
return port() < a.port() ? -1 : 1;
}
if (family() == AF_INET) {
if (addr_in()->sin_addr.s_addr != a.addr_in()->sin_addr.s_addr) {
return addr_in()->sin_addr.s_addr < a.addr_in()->sin_addr.s_addr ? -1 : 1;
Expand Down
21 changes: 20 additions & 1 deletion src/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
#ifndef __CASS_ADDRESS_HPP_INCLUDED__
#define __CASS_ADDRESS_HPP_INCLUDED__

#include "hash.hpp"
#include "utils.hpp"

#include <sparsehash/dense_hash_set>

#include <uv.h>
#include <set>
#include <string.h>
Expand All @@ -29,6 +32,9 @@ namespace cass {

class Address {
public:
static const Address EMPTY_KEY;
static const Address DELETED_KEY;

Address();

Address(const std::string& ip, int port);
Expand Down Expand Up @@ -77,8 +83,21 @@ class Address {
struct sockaddr_storage addr_;
};

struct AddressHash {
std::size_t operator()(const cass::Address& a) const {
if (a.family() == AF_INET) {
return cass::hash::fnv1a(reinterpret_cast<const char*>(a.addr_in()),
sizeof(struct sockaddr_in));
} else if (a.family() == AF_INET6) {
return cass::hash::fnv1a(reinterpret_cast<const char*>(a.addr_in6()),
sizeof(struct sockaddr_in6));
}
return 0;
}
};

typedef std::vector<Address> AddressVec;
typedef std::set<Address> AddressSet;
typedef sparsehash::dense_hash_set<Address, AddressHash> AddressSet;

inline bool operator<(const Address& a, const Address& b) {
return a.compare(b) < 0;
Expand Down
8 changes: 0 additions & 8 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ CassError cass_cluster_set_load_balance_dc_aware_n(CassCluster* cluster,
void cass_cluster_set_token_aware_routing(CassCluster* cluster,
cass_bool_t enabled) {
cluster->config().set_token_aware_routing(enabled == cass_true);
// Token-aware routing relies on up-to-date schema information
if (enabled == cass_true) {
cluster->config().set_use_schema(true);
}
}

void cass_cluster_set_latency_aware_routing(CassCluster* cluster,
Expand Down Expand Up @@ -407,10 +403,6 @@ void cass_cluster_set_timestamp_gen(CassCluster* cluster,
void cass_cluster_set_use_schema(CassCluster* cluster,
cass_bool_t enabled) {
cluster->config().set_use_schema(enabled == cass_true);
// Token-aware routing relies on up-to-date schema information
if (enabled == cass_false) {
cluster->config().set_token_aware_routing(false);
}
}

CassError cass_cluster_set_use_hostname_resolution(CassCluster* cluster,
Expand Down
1 change: 1 addition & 0 deletions src/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "buffer.hpp"
#include "cassandra.h"
#include "handler.hpp"
#include "hash.hpp"
#include "host.hpp"
#include "list.hpp"
#include "macros.hpp"
Expand Down
2 changes: 2 additions & 0 deletions src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef __CASS_CONSTANTS_HPP_INCLUDED__
#define __CASS_CONSTANTS_HPP_INCLUDED__

#define CASS_UINT32_MAX 4294967295UL

#define CASS_INT64_MAX 9223372036854775807LL
#define CASS_INT64_MIN (-CASS_INT64_MAX - 1)

Expand Down
Loading