本文整理汇总了C++中TestConnections::open_rwsplit_connection方法的典型用法代码示例。如果您正苦于以下问题:C++ TestConnections::open_rwsplit_connection方法的具体用法?C++ TestConnections::open_rwsplit_connection怎么用?C++ TestConnections::open_rwsplit_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestConnections
的用法示例。
在下文中一共展示了TestConnections::open_rwsplit_connection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->read_env();
Test->print_env();
Test->repl->connect();
const int TestConnNum = 100;
MYSQL *conn[TestConnNum];
int i;
int conn_num;
int res = 0;
MYSQL * backend_conn;
for (i = 0; i < Test->repl->N; i++) {
backend_conn = open_conn(Test->repl->port[i], Test->repl->IP[i], Test->repl->user_name, Test->repl->password, Test->repl->ssl);
execute_query(backend_conn, "SET GLOBAL max_connections = 200;");
mysql_close(backend_conn);
}
printf("Creating %d connections to RWSplit router\n", TestConnNum);
for (i=0; i<TestConnNum; i++){
conn[i] = Test->open_rwsplit_connection();
}
printf("Waiting 5 seconds\n");
sleep(5);
int ConnFloor = floor((float)TestConnNum / (Test->repl->N - 1));
int ConnCell = ceil((float)TestConnNum / (Test->repl->N - 1));
int TotalConn = 0;
printf("Checking connections to Master: should be %d\n", TestConnNum);
conn_num = get_conn_num(Test->repl->nodes[0], Test->maxscale_IP, (char *) "test");
if (conn_num != TestConnNum) {
res++;
printf("FAILED: number of connections to Master is %d\n", conn_num);
}
printf("Number of connections to each slave should be between %d and %d\n", ConnFloor, ConnCell);
printf("Checking connections to each node\n");
for (int i = 1; i < Test->repl->N; i++) {
conn_num = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, (char *) "test");
TotalConn += conn_num;
printf("Connections to node %d (%s):\t%d\n", i, Test->repl->IP[i], conn_num);
if ((conn_num > ConnCell) || (conn_num < ConnFloor)) {
res++;
printf("FAILED: wrong number of connections to node %d\n", i);
}
}
printf("Total number of connections %d\n", TotalConn);
if (TotalConn != TestConnNum) {
res++;
printf("FAILED: total number of connections is wrong\n");
}
for (i=0; i<TestConnNum; i++) { mysql_close(conn[i]); }
Test->copy_all_logs(); return(res);
}