当前位置: 首页>>代码示例>>C++>>正文


C++ TestConnections::maxscale_ip方法代码示例

本文整理汇总了C++中TestConnections::maxscale_ip方法的典型用法代码示例。如果您正苦于以下问题:C++ TestConnections::maxscale_ip方法的具体用法?C++ TestConnections::maxscale_ip怎么用?C++ TestConnections::maxscale_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestConnections的用法示例。


在下文中一共展示了TestConnections::maxscale_ip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(100);
    Test->repl->connect();

    const int TestConnNum = 100;
    MYSQL *conn[TestConnNum];
    int i;
    int conn_num;

    Test->tprintf("Creating %d connections to ReadConnRouter in 'slave' mode\n", TestConnNum);
    for (i = 0; i < TestConnNum; i++)
    {
        conn[i] = Test->open_readconn_slave_connection();
    }
    Test->tprintf("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;

    Test->tprintf("Checking connections to Master: should be 0\n");
    conn_num = get_conn_num(Test->repl->nodes[0], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
    Test->add_result(conn_num, "number of connections to Master is %d\n", conn_num);

    Test->tprintf("Number of connections to each slave should be between %d and %d\n", ConnFloor, ConnCell);
    Test->tprintf("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(), Test->maxscale_hostname, (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))
        {
            Test->add_result(1, "wrong number of connectiosn to mode %d\n", i);
        }
    }

    Test->tprintf("Total number of connections %d\n", TotalConn);
    if (TotalConn != TestConnNum)
    {
        Test->add_result(1, "total number of connections is wrong\n");
    }

    for (i = 0; i < TestConnNum; i++)
    {
        mysql_close(conn[i]);
    }

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:55,代码来源:readconnrouter_slave.cpp

示例2: main

int main(int argc, char *argv[])
{
    TestConnections * Test = new TestConnections(argc, argv);
    Test->set_timeout(20);
    Test->repl->connect();

    Test->tprintf("Connecting to RWSplit %s\n", Test->maxscale_ip());
    Test->connect_rwsplit();

    unsigned int conn_num;
    unsigned int all_conn = 0;
    Test->tprintf("Sleeping 5 seconds\n");
    sleep(5);
    Test->tprintf("Checking number of connections ot backend servers\n");
    for (int i = 0; i < Test->repl->N; i++)
    {
        conn_num = get_conn_num(Test->repl->nodes[i], Test->maxscale_ip(), Test->maxscale_hostname, (char *) "test");
        Test->tprintf("connections: %u\n", conn_num);
        if ((i == 0) && (conn_num != 1))
        {
            Test->add_result(1, " Master should have only 1 connection, but it has %d connection(s)\n", conn_num);
        }
        all_conn += conn_num;
    }
    if (all_conn != 2)
    {
        Test->add_result(1,
                         "there should be two connections in total: one to master and one to one of slaves, but number of connections is %d\n",
                         all_conn);
    }

    Test->close_rwsplit();
    Test->repl->close_connections();

    int rval = Test->global_result;
    delete Test;
    return rval;
}
开发者ID:mariadb-corporation,项目名称:maxscale-system-test,代码行数:38,代码来源:rwsplit_connect.cpp


注:本文中的TestConnections::maxscale_ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。