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


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

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


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

示例1: main

int main(int argc, char *argv[])
{

    TestConnections * Test = new TestConnections(argc, argv);
    int master;
    long int q;
    int threads_num = 25;

    long int selects[256];
    long int inserts[256];
    long int new_selects[256];
    long int new_inserts[256];
    long int i1, i2;

    Test->set_timeout(20);
    master = Test->find_master_maxadmin(Test->galera);

    if (master >= 0)
    {
        Test->tprintf("Master node is %d (server%d)\n", master, master + 1);
        Test->set_timeout(20);

        if (Test->smoke)
        {
            threads_num = 15;
        }
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 300;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connect_errors = 100000;");
        }
        Test->galera->close_connections();

        Test->set_timeout(1200);
        load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], threads_num, Test, &i1, &i2, 1, true, true);

        long int avr = (i1 + i2 ) / (Test->galera->N);
        Test->tprintf("average number of quries per node %ld\n", avr);
        long int min_q = avr / 3;
        long int max_q = avr * 3;
        Test->tprintf("Acceplable value for every node from %ld until %ld\n", min_q, max_q);

        for (int i = 0; i < Test->galera->N; i++)
        {
            if ( i != master)
            {
                q = new_selects[i] - selects[i];
                if ((q > max_q) || (q < min_q))
                {
                    Test->add_result(1, "number of queries for node %d is %ld\n", i + 1, q);
                }
            }
        }

        if ((new_selects[master] - selects[master]) > avr / 3 )
        {
            Test->add_result(1,
                             "number of queries for master greater then 30%% of averange number of queries per node\n");
        }

        Test->tprintf("Restoring nodes\n");
        Test->galera->connect();
        for (int i = 0; i < Test->galera->N; i++)
        {
            execute_query(Test->galera->nodes[i], (char *) "flush hosts;");
            execute_query(Test->galera->nodes[i], (char *) "set global max_connections = 151;");
        }
        Test->galera->close_connections();

        Test->check_maxscale_alive();
    }
    else
    {
        Test->add_result(1, "Master is not found\n");
    }

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


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