MXS-1703 Rearrange functions and methods
Lots of cleanup, but mostly distributing functions/methods to correct files.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user