Add default parameter values for methods in maxscales.h

As all current tests use only a single MaxScale, explicitly requiring the
number of the MaxScale to use is not convenient.
This commit is contained in:
Markus Mäkelä
2017-12-20 10:11:19 +02:00
parent f9e8af83ce
commit 5e2ac6a921
4 changed files with 43 additions and 25 deletions

View File

@ -33,7 +33,7 @@ int main(int argc, char *argv[])
long int i1, i2; long int i1, i2;
Test->set_timeout(20); Test->set_timeout(20);
master = Test->maxscales->find_master_maxadmin(0, Test->galera); master = Test->maxscales->find_master_maxadmin(Test->galera);
if (master >= 0) if (master >= 0)
{ {

View File

@ -326,7 +326,7 @@ long unsigned Maxscales::get_maxscale_memsize(int m)
} }
int Maxscales::find_master_maxadmin(int m, Mariadb_nodes * nodes) int Maxscales::find_master_maxadmin(Mariadb_nodes * nodes, int m)
{ {
bool found = false; bool found = false;
int master = -1; int master = -1;
@ -355,7 +355,7 @@ int Maxscales::find_master_maxadmin(int m, Mariadb_nodes * nodes)
return master; return master;
} }
int Maxscales::find_slave_maxadmin(int m, Mariadb_nodes * nodes) int Maxscales::find_slave_maxadmin(Mariadb_nodes * nodes, int m)
{ {
int slave = -1; int slave = -1;
@ -375,7 +375,7 @@ int Maxscales::find_slave_maxadmin(int m, Mariadb_nodes * nodes)
return slave; return slave;
} }
StringSet Maxscales::get_server_status(int m, const char* name) StringSet Maxscales::get_server_status(const char* name, int m)
{ {
std::set<std::string> rval; std::set<std::string> rval;
int exit_code; int exit_code;

View File

@ -95,38 +95,46 @@ public:
* Connections stored in maxscales->conn_rwsplit[0], maxscales->conn_master[0] and maxscales->conn_slave[0] MYSQL structs * Connections stored in maxscales->conn_rwsplit[0], maxscales->conn_master[0] and maxscales->conn_slave[0] MYSQL structs
* @return 0 in case of success * @return 0 in case of success
*/ */
int connect_maxscale(int m); int connect_maxscale(int m = 0);
int connect(int m = 0)
{
return connect_maxscale(m);
}
/** /**
* @brief CloseMaxscaleConn Closes connection that were opened by ConnectMaxscale() * @brief CloseMaxscaleConn Closes connection that were opened by ConnectMaxscale()
* @return 0 * @return 0
*/ */
int close_maxscale_connections(int m); int close_maxscale_connections(int m = 0);
int disconnect(int m = 0)
{
return close_maxscale_connections(m);
}
/** /**
* @brief ConnectRWSplit Opens connections to RWSplit and store MYSQL struct in maxscales->conn_rwsplit[0] * @brief ConnectRWSplit Opens connections to RWSplit and store MYSQL struct in maxscales->conn_rwsplit[0]
* @return 0 in case of success * @return 0 in case of success
*/ */
int connect_rwsplit(int m); int connect_rwsplit(int m = 0);
/** /**
* @brief ConnectReadMaster Opens connections to ReadConn master and store MYSQL struct in maxscales->conn_master[0] * @brief ConnectReadMaster Opens connections to ReadConn master and store MYSQL struct in maxscales->conn_master[0]
* @return 0 in case of success * @return 0 in case of success
*/ */
int connect_readconn_master(int m); int connect_readconn_master(int m = 0);
/** /**
* @brief ConnectReadSlave Opens connections to ReadConn slave and store MYSQL struct in maxscales->conn_slave[0] * @brief ConnectReadSlave Opens connections to ReadConn slave and store MYSQL struct in maxscales->conn_slave[0]
* @return 0 in case of success * @return 0 in case of success
*/ */
int connect_readconn_slave(int m); int connect_readconn_slave(int m = 0);
/** /**
* @brief OpenRWSplitConn Opens new connections to RWSplit and returns MYSQL struct * @brief OpenRWSplitConn Opens new connections to RWSplit and returns MYSQL struct
* To close connection mysql_close() have to be called * To close connection mysql_close() have to be called
* @return MYSQL struct * @return MYSQL struct
*/ */
MYSQL * open_rwsplit_connection(int m) MYSQL * open_rwsplit_connection(int m = 0)
{ {
return open_conn(rwsplit_port[m], IP[m], user_name, password, ssl); return open_conn(rwsplit_port[m], IP[m], user_name, password, ssl);
} }
@ -136,7 +144,7 @@ public:
* To close connection mysql_close() have to be called * To close connection mysql_close() have to be called
* @return MYSQL struct * @return MYSQL struct
*/ */
MYSQL * open_readconn_master_connection(int m) MYSQL * open_readconn_master_connection(int m = 0)
{ {
return open_conn(readconn_master_port[m], IP[m], user_name, return open_conn(readconn_master_port[m], IP[m], user_name,
password, ssl); password, ssl);
@ -147,7 +155,7 @@ public:
* To close connection mysql_close() have to be called * To close connection mysql_close() have to be called
* @return MYSQL struct * @return MYSQL struct
*/ */
MYSQL * open_readconn_slave_connection(int m) MYSQL * open_readconn_slave_connection(int m = 0)
{ {
return open_conn(readconn_slave_port[m], IP[m], user_name, return open_conn(readconn_slave_port[m], IP[m], user_name,
password, ssl); password, ssl);
@ -156,7 +164,7 @@ public:
/** /**
* @brief CloseRWSplit Closes RWplit connections stored in maxscales->conn_rwsplit[0] * @brief CloseRWSplit Closes RWplit connections stored in maxscales->conn_rwsplit[0]
*/ */
void close_rwsplit(int m) void close_rwsplit(int m = 0)
{ {
mysql_close(conn_rwsplit[m]); mysql_close(conn_rwsplit[m]);
conn_rwsplit[m] = NULL; conn_rwsplit[m] = NULL;
@ -165,7 +173,7 @@ public:
/** /**
* @brief CloseReadMaster Closes ReadConn master connections stored in maxscales->conn_master[0] * @brief CloseReadMaster Closes ReadConn master connections stored in maxscales->conn_master[0]
*/ */
void close_readconn_master(int m) void close_readconn_master(int m = 0)
{ {
mysql_close(conn_master[m]); mysql_close(conn_master[m]);
conn_master[m] = NULL; conn_master[m] = NULL;
@ -174,7 +182,7 @@ public:
/** /**
* @brief CloseReadSlave Closes ReadConn slave connections stored in maxscales->conn_slave[0] * @brief CloseReadSlave Closes ReadConn slave connections stored in maxscales->conn_slave[0]
*/ */
void close_readconn_slave(int m) void close_readconn_slave(int m = 0)
{ {
mysql_close(conn_slave[m]); mysql_close(conn_slave[m]);
conn_slave[m] = NULL; conn_slave[m] = NULL;
@ -183,17 +191,29 @@ public:
/** /**
* @brief restart_maxscale Issues 'service maxscale restart' command * @brief restart_maxscale Issues 'service maxscale restart' command
*/ */
int restart_maxscale(int m); int restart_maxscale(int m = 0);
int restart(int m = 0)
{
return restart_maxscale(m);
}
/** /**
* @brief start_maxscale Issues 'service maxscale start' command * @brief start_maxscale Issues 'service maxscale start' command
*/ */
int start_maxscale(int m); int start_maxscale(int m = 0);
int start(int m = 0)
{
return start_maxscale(m);
}
/** /**
* @brief stop_maxscale Issues 'service maxscale stop' command * @brief stop_maxscale Issues 'service maxscale stop' command
*/ */
int stop_maxscale(int m); int stop_maxscale(int m = 0);
int stop(int m = 0)
{
return stop_maxscale(m);
}
int execute_maxadmin_command(int m, char * cmd); int execute_maxadmin_command(int m, char * cmd);
int execute_maxadmin_command_print(int m, char * cmd); int execute_maxadmin_command_print(int m, char * cmd);
@ -204,17 +224,15 @@ public:
* @brief get_maxscale_memsize Gets size of the memory consumed by Maxscale process * @brief get_maxscale_memsize Gets size of the memory consumed by Maxscale process
* @return memory size in kilobytes * @return memory size in kilobytes
*/ */
long unsigned get_maxscale_memsize(int m); long unsigned get_maxscale_memsize(int m = 0);
int try_query_all(int m, const char *sql);
/** /**
* @brief find_master_maxadmin Tries to find node with 'Master' status using Maxadmin connand 'show server' * @brief find_master_maxadmin Tries to find node with 'Master' status using Maxadmin connand 'show server'
* @param nodes Mariadb_nodes object * @param nodes Mariadb_nodes object
* @return node index if one master found, -1 if no master found or several masters found * @return node index if one master found, -1 if no master found or several masters found
*/ */
int find_master_maxadmin(int m, Mariadb_nodes * nodes); int find_master_maxadmin(Mariadb_nodes * nodes, int m = 0);
int find_slave_maxadmin(int m, Mariadb_nodes * nodes); int find_slave_maxadmin(Mariadb_nodes * nodes, int m = 0);
/** /**
* @brief Get the set of labels that are assigned to server @c name * @brief Get the set of labels that are assigned to server @c name
@ -225,7 +243,7 @@ public:
* *
* @return A set of string labels assigned to this server * @return A set of string labels assigned to this server
*/ */
StringSet get_server_status(int m, const char* name); StringSet get_server_status(const char* name, int m = 0);
}; };

View File

@ -58,7 +58,7 @@ int main(int argc, char *argv[])
//Test->repl->flush_hosts(); //Test->repl->flush_hosts();
Test->set_timeout(20); Test->set_timeout(20);
int master = Test->maxscales->find_master_maxadmin(0, Test->galera); int master = Test->maxscales->find_master_maxadmin(Test->galera);
Test->stop_timeout(); Test->stop_timeout();
Test->tprintf(("Master is %d\n"), master); Test->tprintf(("Master is %d\n"), master);
int k = 0; int k = 0;