From 1f3665c8b003ff1eb7eee44989ff6d4902b94e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 8 Aug 2013 10:32:08 +0300 Subject: [PATCH] Fixed compiler issue on connecting to server binlog using binlog position or gtid. --- replication_listener/binary_log.cpp | 10 ++++++++++ replication_listener/binlog_api.h | 14 +++++++++----- replication_listener/binlog_driver.h | 4 +++- replication_listener/tcp_driver.cpp | 10 ++++++++-- replication_listener/tcp_driver.h | 5 +++-- table_replication_consistency/CMakeLists.txt | 9 +++++---- .../table_replication_consistency.cpp | 1 - .../table_replication_listener.cpp | 5 ++--- .../table_replication_metadata.cpp | 1 - .../table_replication_metadata.h | 3 +-- 10 files changed, 41 insertions(+), 21 deletions(-) diff --git a/replication_listener/binary_log.cpp b/replication_listener/binary_log.cpp index f3100cbbf..0e643269d 100644 --- a/replication_listener/binary_log.cpp +++ b/replication_listener/binary_log.cpp @@ -154,6 +154,16 @@ unsigned long Binary_log::get_position(std::string &filename) return m_binlog_position; } +int Binary_log::connect() +{ + return m_driver->connect(); +} + +int Binary_log::connect(const boost::uint64_t binlog_pos) +{ + return m_driver->connect(binlog_pos); +} + int Binary_log::connect(const Gtid gtid) { return m_driver->connect(gtid); diff --git a/replication_listener/binlog_api.h b/replication_listener/binlog_api.h index 03b2f934f..2a73423af 100644 --- a/replication_listener/binlog_api.h +++ b/replication_listener/binlog_api.h @@ -76,7 +76,9 @@ public: Dummy_driver() : Binary_log_driver("", 0) {} virtual ~Dummy_driver() {} - virtual int connect(Gtid gtid = Gtid()) { return 1; } + virtual int connect() { return 1; } + virtual int connect(const Gtid gtid) { return 1; } + virtual int connect(const boost::uint64_t binlog_pos) { return 1;} virtual int wait_for_next_event(mysql::Binary_log_event **event) { return ERR_EOF; @@ -94,11 +96,11 @@ public: return ERR_OK; } - virtual int fetch_server_version(const std::string& user, + virtual int fetch_server_version(const std::string& user, const std::string& passwd, - const std::string& host, + const std::string& host, long port) - { + { return ERR_OK; } @@ -124,7 +126,9 @@ public: Binary_log(system::Binary_log_driver *drv, std::string); ~Binary_log() {} - int connect(Gtid gtid = Gtid()); + int connect(); + int connect(const Gtid gtid); + int connect(const boost::uint64_t binlog_pos); /** * Blocking attempt to get the next binlog event from the stream diff --git a/replication_listener/binlog_driver.h b/replication_listener/binlog_driver.h index 788ce8342..cdec99e06 100644 --- a/replication_listener/binlog_driver.h +++ b/replication_listener/binlog_driver.h @@ -57,8 +57,10 @@ public: * @retval 0 Success * @retval >0 Error code (to be specified) */ - virtual int connect(Gtid gtid = Gtid())= 0; + virtual int connect(Gtid gtid)= 0; + virtual int connect() = 0; + virtual int connect(const boost::uint64_t binlog_pos) = 0; /** * Blocking attempt to get the next binlog event from the stream diff --git a/replication_listener/tcp_driver.cpp b/replication_listener/tcp_driver.cpp index 325775ee3..0f7001fa6 100644 --- a/replication_listener/tcp_driver.cpp +++ b/replication_listener/tcp_driver.cpp @@ -951,11 +951,17 @@ int Binlog_tcp_driver::connect(const Gtid gtid) return connect(m_user, m_passwd, m_host, m_port, gtid); } -int Binlog_tcp_driver::connect(size_t binlog_pos) +int Binlog_tcp_driver::connect() +{ + Gtid gtid = Gtid(); + return connect(m_user, m_passwd, m_host, m_port, gtid); +} + +int Binlog_tcp_driver::connect(boost::uint64_t binlog_pos) { Gtid gtid = Gtid(); std::string bf = std::string(""); - return connect(m_user, m_passwd, m_host, m_port, gtid, bf, binlog_pos); + return connect(m_user, m_passwd, m_host, m_port, gtid, bf, (size_t)binlog_pos); } /** diff --git a/replication_listener/tcp_driver.h b/replication_listener/tcp_driver.h index 2a5826bfd..268f3dcee 100644 --- a/replication_listener/tcp_driver.h +++ b/replication_listener/tcp_driver.h @@ -76,8 +76,9 @@ public: /** * Connect using previously declared connection parameters. */ - int connect(Gtid gtid = Gtid()); - int connect(size_t binlog_pos); + int connect(); + int connect(const Gtid gtid); + int connect(const boost::uint64_t binlog_pos); /** * Blocking wait for the next binary log event to reach the client diff --git a/table_replication_consistency/CMakeLists.txt b/table_replication_consistency/CMakeLists.txt index 3d74ec933..11bd90c03 100644 --- a/table_replication_consistency/CMakeLists.txt +++ b/table_replication_consistency/CMakeLists.txt @@ -1,4 +1,4 @@ -project (skysql_gateway_table_replication_concistency) +project (skysql_m_table_replication_concistency) cmake_minimum_required (VERSION 2.6) # This configuration file builds both the static and shared version of @@ -15,7 +15,7 @@ SET(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0") FIND_PACKAGE(Boost REQUIRED system thread) # --------- Find crypt -FIND_LIBRARY(LIB_CRYPTO crypto /opt/local/lib /opt/lib /usr/lib /usr/local/lib) +FIND_LIBRARY(LIB_CRYPTO crypto /opt/local/lib /opt/lib /usr/lib /usr/local/lib /usr/local/ssl/lib) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) @@ -23,16 +23,17 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) find_library(MySQL_LIBRARY NAMES libmysqld.a PATHS /usr/lib64/mysql /usr/lib/mysql /usr/local/mysql/lib) find_path(MySQL_INCLUDE_DIR mysql.h - /usr/local/include/mysql /usr/include/mysql) + /usr/local/include/mysql /usr/include/mysql /usr/local/mysql/include) include_directories(${MySQL_INCLUDE_DIR}) #SkySQL find_path(SkySQL_INCLUDE_DIR skygw_debug.h /usr/local/include /usr/include ../utils) include_directories(${SkySQL_INCLUDE_DIR}) +include_directories(../replication_listener) #log_manager -FIND_LIBRARY(LIB_LOGMANAGER log_manager /lib /opt/local/lib /opt/lib /usr/lib /usr/local/lib) +FIND_LIBRARY(LIB_LOGMANAGER log_manager /lib /opt/local/lib /opt/lib /usr/lib /usr/local/lib ../log_manager) find_path(LogManager_INCLUDE_DIR log_manager.h /usr/local/include /usr/include ../log_manager) include_directories(${LogManager_INCLUDE_DIR}) diff --git a/table_replication_consistency/table_replication_consistency.cpp b/table_replication_consistency/table_replication_consistency.cpp index 068c8896f..396829ef8 100644 --- a/table_replication_consistency/table_replication_consistency.cpp +++ b/table_replication_consistency/table_replication_consistency.cpp @@ -23,7 +23,6 @@ Updated: */ #include -#include "my_pthread.h" #include #include #include diff --git a/table_replication_consistency/table_replication_listener.cpp b/table_replication_consistency/table_replication_listener.cpp index 45e3406dc..9db67292f 100644 --- a/table_replication_consistency/table_replication_listener.cpp +++ b/table_replication_consistency/table_replication_listener.cpp @@ -22,7 +22,6 @@ Updated: */ #include "binlog_api.h" -#include "my_pthread.h" #include #include #include @@ -339,7 +338,7 @@ void* tb_replication_listener_reader( pthread_t id = pthread_self(); string database_dot_table; const char* server_type; - Gtid gtid(0,1,31); + Gtid gtid; bool gtid_known = false; boost::uint64_t binlog_pos = 0; bool use_binlog_pos = true; @@ -361,7 +360,7 @@ void* tb_replication_listener_reader( gtid = Gtid(domain, server, sno); use_binlog_pos = false; } else if (rlt->use_mysql_gtid) { - gtid(rlt->gtid); + gtid = Gtid(rlt->gtid); use_binlog_pos = false; } else { // At startup we need to iterate through servers and see if diff --git a/table_replication_consistency/table_replication_metadata.cpp b/table_replication_consistency/table_replication_metadata.cpp index 76b041546..fbcc425e7 100644 --- a/table_replication_consistency/table_replication_metadata.cpp +++ b/table_replication_consistency/table_replication_metadata.cpp @@ -21,7 +21,6 @@ Created: 15-07-2013 Updated: */ #include "binlog_api.h" -#include "my_pthread.h" #include #include #include diff --git a/table_replication_consistency/table_replication_metadata.h b/table_replication_consistency/table_replication_metadata.h index b7da7047e..78436714f 100644 --- a/table_replication_consistency/table_replication_metadata.h +++ b/table_replication_consistency/table_replication_metadata.h @@ -53,8 +53,7 @@ typedef struct { // Not really nice, but currently we support only these two // server types. -#define TRC_SERVER_TYPE_MARIADB = 1, -#define TRC_SERVER_TYPE_MYSQL = 2 +enum trc_server_type { TRC_SERVER_TYPE_MARIADB = 1, TRC_SERVER_TYPE_MYSQL = 2 }; /***********************************************************************//**