This commit is contained in:
Mark Riddoch 2014-11-19 15:17:17 +00:00
commit c2655e048c
8 changed files with 134 additions and 73 deletions

View File

@ -10,11 +10,13 @@ set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to in
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/")
find_package(Valgrind)
project(MaxScale)
check_deps()
check_dirs()
find_package(Valgrind)
find_package(MySQLClient)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules)
@ -93,7 +95,10 @@ add_subdirectory(log_manager)
add_subdirectory(query_classifier)
add_subdirectory(server)
add_subdirectory(client)
if(BUILD_RABBITMQ)
find_package(RabbitMQ)
add_subdirectory(rabbitmq_consumer)
endif()
# Install startup scripts and ldconfig files
if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) )

33
FindMySQLClient.cmake Normal file
View File

@ -0,0 +1,33 @@
# This CMake file tries to find the the MySQL client library
# The following variables are set:
# MYSQLCLIENT_FOUND - System has MySQL client
# MYSQLCLIENT_STATIC_FOUND - System has statically linked MySQL client
# MYSQLCLIENT_LIBRARIES - The MySQL client library
# MYSQLCLIENT_STATIC_LIBRARIES - The static MySQL client library
# MYSQLCLIENT_HEADERS - The MySQL client headers
find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
message(STATUS "Dynamic MySQL client library not found.")
unset(MYSQLCLIENT_LIBRARIES)
else()
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found dynamic MySQL client library: ${MYSQLCLIENT_LIBRARIES}")
endif()
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
find_library(MYSQLCLIENT_STATIC_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
if(${MYSQLCLIENT_STATIC_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_STATIC_FOUND FALSE CACHE INTERNAL "")
message(STATUS "Static MySQL client library not found.")
unset(MYSQLCLIENT_STATIC_LIBRARIES)
else()
set(MYSQLCLIENT_STATIC_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found statc MySQL client library: ${MYSQLCLIENT_STATIC_LIBRARIES}")
endif()
find_path(MYSQLCLIENT_HEADERS mysql.h PATH_SUFFIXES mysql mariadb)

23
FindRabbitMQ.cmake Normal file
View File

@ -0,0 +1,23 @@
# This CMake file tries to find the the RabbitMQ library
# The following variables are set:
# RABBITMQ_FOUND - System has RabbitMQ client
# RABBITMQ_LIBRARIES - The RabbitMQ client library
# RABBITMQ_HEADERS - The RabbitMQ client headers
include(CheckCSourceCompiles)
find_library(RABBITMQ_LIBRARIES NAMES rabbitmq)
find_path(RABBITMQ_HEADERS amqp.h PATH_SUFFIXES mysql mariadb)
if(${RABBITMQ_LIBRARIES} MATCHES "NOTFOUND")
set(RABBITMQ_FOUND FALSE CACHE INTERNAL "")
message(STATUS "RabbitMQ library not found.")
unset(RABBITMQ_LIBRARIES)
else()
set(RABBITMQ_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found RabbitMQ library: ${RABBITMQ_LIBRARIES}")
endif()
set(CMAKE_REQUIRED_INCLUDES ${RABBITMQ_HEADERS})
check_c_source_compiles("#include <amqp.h>\n int main(){if(AMQP_DELIVERY_PERSISTENT){return 0;}return 1;}" HAVE_RABBITMQ50)
if(NOT HAVE_RABBITMQ50)
message(FATAL_ERROR "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
endif()

6
README
View File

@ -219,10 +219,10 @@ OLEVEL=<0-3> Level of optimization
BUILD_TESTS=[Y|N] Build tests
DEPS_OK=[Y|N] Check dependencies, use N when you want to force a recheck of values
DEBUG_OUTPUT=[Y|N] Produce debugging output when configuring CMake
RABBITMQ_LIB=<path> Path to RabbitMQ-C libraries
RABBITMQ_LIBRARIES=<path> Path to RabbitMQ-C libraries
RABBITMQ_HEADERS=<path> Path to RabbitMQ-C headers
MYSQL_CLIENT_LIB=<path> Path to MySQL client libraries
MYSQL_CLIENT_HEADERS=<path> Path to MySQL client headers
MYSQLCLIENT_LIBRARIES=<path> Path to MySQL client libraries
MYSQLCLIENT_HEADERS=<path> Path to MySQL client headers
\section Running Running MaxScale

View File

@ -206,50 +206,52 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
unset(RPM_FNC)
#Find the MySQL client library
find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
message(STATUS "Cannot find MySQL client library: Login tests disabled.")
else()
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
message(STATUS "Found MySQL client library: ${MYSQLCLIENT_LIBRARIES}")
endif()
# find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
# if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
# set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
# message(STATUS "Cannot find MySQL client library: Login tests disabled.")
# else()
# set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
# message(STATUS "Found MySQL client library: ${MYSQLCLIENT_LIBRARIES}")
# endif()
#Check RabbitMQ headers and libraries
if(BUILD_RABBITMQ)
include(CheckCSourceCompiles)
if(DEFINED RABBITMQ_LIB)
find_library(RMQ_LIB rabbitmq PATHS ${RABBITMQ_LIB} NO_DEFAULT_PATH)
else()
find_library(RMQ_LIB rabbitmq)
endif()
if(RMQ_LIB MATCHES "NOTFOUND")
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
message(FATAL_ERROR "Cannot find RabbitMQ libraries, please define the path to the libraries with -DRABBITMQ_LIB=<path>")
else()
set(RABBITMQ_LIB ${RMQ_LIB} CACHE PATH "Path to RabbitMQ libraries" FORCE)
message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
endif()
if(DEFINED RABBITMQ_HEADERS)
find_file(RMQ_HEADERS amqp.h PATHS ${RABBITMQ_HEADERS} NO_DEFAULT_PATH)
else()
find_file(RMQ_HEADERS amqp.h)
endif()
if(RMQ_HEADERS MATCHES "NOTFOUND")
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
message(FATAL_ERROR "Cannot find RabbitMQ headers, please define the path to the headers with -DRABBITMQ_HEADERS=<path>")
else()
set(RABBITMQ_HEADERS ${RMQ_HEADERS} CACHE PATH "Path to RabbitMQ headers" FORCE)
message(STATUS "Using RabbitMQ headers found at: ${RABBITMQ_HEADERS}")
endif()
set(CMAKE_REQUIRED_INCLUDES ${RABBITMQ_HEADERS})
check_c_source_compiles("#include <amqp.h>\n int main(){if(AMQP_DELIVERY_PERSISTENT){return 0;}return 1;}" HAVE_RMQ50)
if(NOT HAVE_RMQ50)
message(FATAL_ERROR "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
endif()
find_package(RabbitMQ)
# include(CheckCSourceCompiles)
#
# if(DEFINED RABBITMQ_LIB)
# find_library(RMQ_LIB rabbitmq PATHS ${RABBITMQ_LIB} NO_DEFAULT_PATH)
# else()
# find_library(RMQ_LIB rabbitmq)
# endif()
# if(RMQ_LIB MATCHES "NOTFOUND")
# set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
# message(FATAL_ERROR "Cannot find RabbitMQ libraries, please define the path to the libraries with -DRABBITMQ_LIB=<path>")
# else()
# set(RABBITMQ_LIB ${RMQ_LIB} CACHE PATH "Path to RabbitMQ libraries" FORCE)
# message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
# endif()
#
# if(DEFINED RABBITMQ_HEADERS)
# find_file(RMQ_HEADERS amqp.h PATHS ${RABBITMQ_HEADERS} NO_DEFAULT_PATH)
# else()
# find_file(RMQ_HEADERS amqp.h)
# endif()
# if(RMQ_HEADERS MATCHES "NOTFOUND")
# set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
# message(FATAL_ERROR "Cannot find RabbitMQ headers, please define the path to the headers with -DRABBITMQ_HEADERS=<path>")
# else()
# set(RABBITMQ_HEADERS ${RMQ_HEADERS} CACHE PATH "Path to RabbitMQ headers" FORCE)
# message(STATUS "Using RabbitMQ headers found at: ${RABBITMQ_HEADERS}")
# endif()
#
# set(CMAKE_REQUIRED_INCLUDES ${RABBITMQ_HEADERS})
# check_c_source_compiles("#include <amqp.h>\n int main(){if(AMQP_DELIVERY_PERSISTENT){return 0;}return 1;}" HAVE_RMQ50)
# if(NOT HAVE_RMQ50)
# message(FATAL_ERROR "Old version of RabbitMQ-C library found. Version 0.5 or newer is required.")
# endif()
#
endif()
endmacro()

View File

@ -1,19 +1,17 @@
if (NOT ( DEFINED MYSQL_CLIENT_LIB ) )
find_library(MYSQL_CLIENT_LIB NAMES mysqlclient PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb)
endif()
if(RABBITMQ_FOUND AND MYSQLCLIENT_FOUND)
if (NOT ( DEFINED MYSQL_CLIENT_HEADERS ) )
find_path(MYSQL_CLIENT_HEADERS NAMES mysql.h PATH_SUFFIXES mysql mariadb)
endif()
if( ( RABBITMQ_LIB AND RABBITMQ_HEADERS ) AND ( NOT ( ${MYSQL_CLIENT_LIB} STREQUAL "MYSQL_CLIENT_LIB-NOTFOUND" ) ) AND ( NOT ( ${MYSQL_CLIENT_HEADERS} STREQUAL "MYSQL_CLIENT_HEADERS-NOTFOUND" ) ) )
include_directories(${MYSQL_CLIENT_HEADERS})
include_directories(${MYSQLCLIENT_HEADERS})
add_executable (consumer consumer.c)
target_link_libraries(consumer ${MYSQL_CLIENT_LIB} rabbitmq inih)
if(MYSQLCLIENT_FOUND)
target_link_libraries(consumer ${MYSQLCLIENT_LIBRARIES} rabbitmq inih)
elseif(MYSQLCLIENT_STATIC_FOUND)
target_link_libraries(consumer ${MYSQLCLIENT_STATIC_LIBRARIES} rabbitmq inih)
endif()
install(TARGETS consumer DESTINATION bin)
install(FILES consumer.cnf DESTINATION etc)
else()
message(FATAL_ERROR "Error: Can not find requred libraries and headers: librabbitmq libmysqlclient")

View File

@ -143,7 +143,7 @@ int connectToServer(MYSQL* server)
}
memset(qstr,0,bsz);
sprintf(qstr,DB_TABLE);
sprintf(qstr,"%s",DB_TABLE);
if(mysql_query(server,qstr)){
fprintf(stderr,"Error: Could not send query MySQL server: %s\n",mysql_error(server));
}

View File

@ -383,6 +383,16 @@ struct subcommand enableoptions[] = {
"Enable Log options for MaxScale, options trace | error | "
"message E.g. enable log message.",
{ARG_TYPE_STRING, 0, 0}
},
{
"sessionlog",
2,
enable_sess_log_action,
"Enable Log options for a single session. Usage: enable sessionlog [trace | error | "
"message | debug] <session id>\t E.g. enable sessionlog message 123.",
"Enable Log options for a single session. Usage: enable sessionlog [trace | error | "
"message | debug] <session id>\t E.g. enable sessionlog message 123.",
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
},
{
"root",
@ -391,16 +401,6 @@ struct subcommand enableoptions[] = {
"Enable root access to a service, pass a service name to enable root access",
"Enable root access to a service, pass a service name to enable root access",
{ARG_TYPE_SERVICE, 0, 0}
},
{
"seslog",
2,
enable_sess_log_action,
"Enable Log options for a single session, options trace | error | "
"message <session id> E.g. enable log message 123.",
"Enable Log options for a single session, options trace | error | "
"message <session id> E.g. enable log message 123.",
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
},
{
NULL,
@ -437,13 +437,13 @@ struct subcommand disableoptions[] = {
{ARG_TYPE_STRING, 0, 0}
},
{
"seslog",
"sessionlog",
2,
disable_sess_log_action,
"Disable Log options for a single session, options trace | error | "
"message <session id> E.g. disable log message 123.",
"Disable Log options for a single session, options trace | error | "
"message <session id> E.g. disable log message 123.",
"Disable Log options for a single session. Usage: disable sessionlog [trace | error | "
"message | debug] <session id>\t E.g. disable sessionlog message 123.",
"Disable Log options for a single session. Usage: disable sessionlog [trace | error | "
"message | debug] <session id>\t E.g. disable sessionlog message 123.",
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
},
{