MXS-1703 Rearrange functions and methods

Lots of cleanup, but mostly distributing functions/methods to correct files.
This commit is contained in:
Esa Korhonen
2018-03-15 15:54:59 +02:00
parent 3331eb9eb6
commit 4a6fc6b1c8
6 changed files with 895 additions and 913 deletions

View File

@ -15,6 +15,19 @@
#include <maxscale/cppdefs.hh>
#include <string>
#include <vector>
#include <maxscale/monitor.h>
/** Utility macro for printing both MXS_ERROR and json error */
#define PRINT_MXS_JSON_ERROR(err_out, format, ...)\
do {\
MXS_ERROR(format, ##__VA_ARGS__);\
if (err_out)\
{\
*err_out = mxs_json_error_append(*err_out, format, ##__VA_ARGS__);\
}\
} while (false)
using std::string;
@ -25,6 +38,11 @@ enum mysql_server_version
MYSQL_SERVER_VERSION_51
};
extern const int64_t SERVER_ID_UNKNOWN;
typedef std::vector<string> StringVector;
typedef std::vector<MXS_MONITORED_SERVER*> ServerVector;
class Gtid
{
public:
@ -125,3 +143,47 @@ public:
*/
int64_t relay_log_events();
};
/**
* Scan a server id from a string.
*
* @param id_string
* @return Server id, or -1 if scanning fails
*/
int64_t scan_server_id(const char* id_string);
/**
* Generates a MASTER_GTID_WAIT()- query.
* @param gtid What gtid to wait for
* @param timeout Maximum wait time in seconds
* @return The query
*/
string generate_master_gtid_wait_cmd(const Gtid& gtid, double timeout);
/**
* Query one row of results, save strings to array. Any additional rows are ignored.
*
* @param database The database to query.
* @param query The query to execute.
* @param expected_cols How many columns the result should have.
* @param output The output array to populate.
* @return True on success.
*/
bool query_one_row(MXS_MONITORED_SERVER *database, const char* query, unsigned int expected_cols,
StringVector* output);
/**
* Get MariaDB connection error strings from all the given servers, form one string.
*
* @param slaves Servers with errors
* @return Concatenated string.
*/
string get_connection_errors(const ServerVector& servers);
/**
* Generates a list of server names separated by ', '
*
* @param array The servers
* @return Server names
*/
string monitored_servers_to_string(const ServerVector& array);