Explorar o código

HPCC-12240 Update Cassandra driver to latest

The cassandra C++ driver has now reached rc1 status - we should update again
when it reaches gold...

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman %!s(int64=10) %!d(string=hai) anos
pai
achega
186c5ac4d0

+ 0 - 1
cmake_modules/commonSetup.cmake

@@ -315,7 +315,6 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   endmacro(HPCC_ADD_SUBDIRECTORY)
 
   set ( SCM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated )
-  include_directories (${SCM_GENERATED_DIR})
 
   ###############################################################
   # Macro for Logging Plugin build in CMake

+ 1 - 0
esp/CMakeLists.txt

@@ -13,6 +13,7 @@
 #    See the License for the specific language governing permissions and
 #    limitations under the License.
 ################################################################################
+include_directories (${SCM_GENERATED_DIR})
 HPCC_ADD_SUBDIRECTORY (bindings)
 HPCC_ADD_SUBDIRECTORY (clients "PLATFORM")
 HPCC_ADD_SUBDIRECTORY (eclwatch "PLATFORM")

+ 5 - 0
plugins/cassandra/CMakeLists.txt

@@ -56,9 +56,14 @@ if (USE_CASSANDRA)
     option(CASS_INSTALL_HEADER "Install header file" OFF)
     option(CASS_BUILD_STATIC "Build static library" OFF)
     option(CASS_BUILD_EXAMPLES "Build examples" OFF)
+
+    SET (_SAVE_Boost_FOUND "${Boost_FOUND}")  # Working around a bug in the cassandra cmake file
+    UNSET(Boost_FOUND)
     add_subdirectory (cpp-driver ${PROJECT_BINARY_DIR}/cassandra)
     add_dependencies( cassandra libuv )
 
+    SET (Boost_FOUND "${_SAVE_Boost_FOUND}")
+
     set(SRCS cassandraembed.cpp)
 
     include_directories (

+ 20 - 26
plugins/cassandra/cassandraembed.cpp

@@ -155,6 +155,7 @@ public:
         {
             CassandraFuture close_future(cass_session_close(session));
             cass_future_wait(close_future);
+            cass_session_free(session);
         }
     }
     inline operator CassSession *() const
@@ -1106,12 +1107,6 @@ protected:
 
 // Each call to a Cassandra function will use a new CassandraEmbedFunctionContext object
 
-static void cassandraLogCallback(cass_uint64_t time, CassLogLevel severity, CassString message, void* data)
-{
-    const IContextLogger *logctx = (const IContextLogger *) data;
-    logctx->CTXLOG("cassandra: %s: %.*s", cass_log_level_string(severity), (int) message.length, message.data);
-}
-
 class CassandraEmbedFunctionContext : public CInterfaceOf<IEmbedFunctionContext>
 {
 public:
@@ -1119,7 +1114,6 @@ public:
       : logctx(_logctx), flags(_flags), nextParam(0), numParams(0), batchMode((CassBatchType) -1)
     {
         cluster.setown(new CassandraCluster(cass_cluster_new()));
-        cass_cluster_set_log_callback(*cluster, cassandraLogCallback, (void *) &logctx);
         const char *contact_points = "localhost";
         const char *user = "";
         const char *password = "";
@@ -1164,7 +1158,7 @@ public:
                 else if (stricmp(optName, "num_threads_io")==0)
                 {
                     unsigned num_threads_io = getUnsignedOption(val, "num_threads_io");
-                    checkSetOption(cass_cluster_set_num_threads_io(*cluster, num_threads_io), "num_threads_io");
+                    cass_cluster_set_num_threads_io(*cluster, num_threads_io);  // No status return
                 }
                 else if (stricmp(optName, "queue_size_io")==0)
                 {
@@ -1181,35 +1175,35 @@ public:
                     unsigned max_connections_per_host = getUnsignedOption(val, "max_connections_per_host");
                     checkSetOption(cass_cluster_set_max_connections_per_host(*cluster, max_connections_per_host), "max_connections_per_host");
                 }
-                else if (stricmp(optName, "max_simultaneous_creation")==0)
+                else if (stricmp(optName, "max_concurrent_creation")==0)
                 {
-                    unsigned max_simultaneous_creation = getUnsignedOption(val, "max_simultaneous_creation");
-                    checkSetOption(cass_cluster_set_max_simultaneous_creation(*cluster, max_simultaneous_creation), "max_simultaneous_creation");
+                    unsigned max_concurrent_creation = getUnsignedOption(val, "max_concurrent_creation");
+                    checkSetOption(cass_cluster_set_max_concurrent_creation(*cluster, max_concurrent_creation), "max_concurrent_creation");
                 }
-                else if (stricmp(optName, "max_pending_requests")==0)
+                else if (stricmp(optName, "pending_requests_high_water_mark")==0)
                 {
-                    unsigned max_pending_requests = getUnsignedOption(val, "max_pending_requests");
-                    checkSetOption(cass_cluster_set_max_pending_requests(*cluster, max_pending_requests), "max_pending_requests");
+                    unsigned pending_requests_high_water_mark = getUnsignedOption(val, "pending_requests_high_water_mark");
+                    checkSetOption(cass_cluster_set_pending_requests_high_water_mark(*cluster, pending_requests_high_water_mark), "pending_requests_high_water_mark");
                 }
-                else if (stricmp(optName, "max_simultaneous_requests_threshold")==0)
+                else if (stricmp(optName, "pending_requests_low_water_mark")==0)
                 {
-                    unsigned max_simultaneous_requests_threshold = getUnsignedOption(val, "max_simultaneous_requests_threshold");
-                    checkSetOption(cass_cluster_set_max_simultaneous_requests_threshold(*cluster, max_simultaneous_requests_threshold), "max_simultaneous_requests_threshold");
+                    unsigned pending_requests_low_water_mark = getUnsignedOption(val, "pending_requests_low_water_mark");
+                    checkSetOption(cass_cluster_set_pending_requests_low_water_mark(*cluster, pending_requests_low_water_mark), "pending_requests_low_water_mark");
+                }
+                else if (stricmp(optName, "max_concurrent_requests_threshold")==0)
+                {
+                    unsigned max_concurrent_requests_threshold = getUnsignedOption(val, "max_concurrent_requests_threshold");
+                    checkSetOption(cass_cluster_set_max_concurrent_requests_threshold(*cluster, max_concurrent_requests_threshold), "max_concurrent_requests_threshold");
                 }
                 else if (stricmp(optName, "connect_timeout")==0)
                 {
                     unsigned connect_timeout = getUnsignedOption(val, "connect_timeout");
-                    checkSetOption(cass_cluster_set_connect_timeout(*cluster, connect_timeout), "connect_timeout");
+                    cass_cluster_set_connect_timeout(*cluster, connect_timeout);
                 }
                 else if (stricmp(optName, "request_timeout")==0)
                 {
                     unsigned request_timeout = getUnsignedOption(val, "request_timeout");
-                    checkSetOption(cass_cluster_set_request_timeout(*cluster, request_timeout), "request_timeout");
-                }
-                else if (stricmp(optName, "log_level")==0)
-                {
-                    unsigned log_level = getUnsignedOption(val, "log_level");
-                    checkSetOption(cass_cluster_set_log_level(*cluster, (CassLogLevel) log_level), "log_level");
+                    cass_cluster_set_request_timeout(*cluster, request_timeout);
                 }
                 else
                     failx("Unrecognized option %s", optName.str());
@@ -1219,9 +1213,9 @@ public:
         if (*user || *password)
             cass_cluster_set_credentials(*cluster, user, password);
 
-        CassandraFuture future(keyspace ? cass_cluster_connect_keyspace(*cluster, keyspace) : cass_cluster_connect(*cluster));
+        session.setown(new CassandraSession(cass_session_new()));
+        CassandraFuture future(keyspace ? cass_session_connect_keyspace(*session, *cluster, keyspace) : cass_session_connect(*session, *cluster));
         future.wait("connect");
-        session.setown(new CassandraSession(cass_future_get_session(future)));
     }
     virtual bool getBooleanResult()
     {

+ 1 - 1
plugins/cassandra/cpp-driver

@@ -1 +1 @@
-Subproject commit 5822a469fdca3bdc0ca034dd61c01d1966acc6ef
+Subproject commit 019d3f62b39eb6ebf0a8605faa7130bd9863a9f9