⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsystemrestart.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  return result;}int runSystemRestart3(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int count;  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR3 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));    Uint32 currentRestartNodeIndex = 0;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());    while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart 1 node -nostart     * 3. Update records     * 4. Restart cluster and verify records     * 5. Restart 1 node -nostart     * 6. Delete half of the records     * 7. Restart cluster and verify records     * 8. Restart 1 node -nostart     * 9. Delete all records     * 10. Restart cluster and verify records     */    g_info << "Loading records..." << endl;    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    /*** 1 ***/    g_info << "1 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Updating records..." << endl;    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    g_info << "2 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting 50% of records..." << endl;    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == (records/2));    g_info << "3 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting all records..." << endl;    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);    g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);        ndbout << "Verifying records..." << endl;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == 0);        i++;  }  g_info << "runSystemRestart3 finished" << endl;    return result;}int runSystemRestart4(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int count;  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR4 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));    Uint32 currentRestartNodeIndex = 0;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  {    int val = DumpStateOrd::DihMinTimeBetweenLCP;    if(restarter.dumpStateAllNodes(&val, 1) != 0){      g_err << "ERR: "<< step->getName() 	    << " failed on line " << __LINE__ << endl;       return NDBT_FAILED;    }  }    while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart 1 node -nostart     * 3. Update records     * 4. Restart cluster and verify records     * 5. Restart 1 node -nostart     * 6. Delete half of the records     * 7. Restart cluster and verify records     * 8. Restart 1 node -nostart     * 9. Delete all records     * 10. Restart cluster and verify records     */    g_info << "Loading records..." << endl;    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    /*** 1 ***/    g_info << "1 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Updating records..." << endl;    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    g_info << "2 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting 50% of records..." << endl;    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == (records/2));    g_info << "3 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting all records..." << endl;    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);    g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);        ndbout << "Verifying records..." << endl;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == 0);        i++;  }  g_info << "runSystemRestart4 finished" << endl;    return result;}int runSystemRestart5(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int count;  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR5 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));    Uint32 currentRestartNodeIndex = 0;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  {    int val = DumpStateOrd::DihMinTimeBetweenLCP;    if(restarter.dumpStateAllNodes(&val, 1) != 0){      g_err << "ERR: "<< step->getName() 	    << " failed on line " << __LINE__ << endl;       return NDBT_FAILED;    }  }    while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart 1 node -nostart     * 3. Update records     * 4. Restart cluster and verify records     * 5. Restart 1 node -nostart     * 6. Delete half of the records     * 7. Restart cluster and verify records     * 8. Restart 1 node -nostart     * 9. Delete all records     * 10. Restart cluster and verify records     */    g_info << "Loading records..." << endl;    hugoTrans.loadTable(pNdb, records);    /*** 1 ***/    g_info << "1 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Updating records..." << endl;    hugoTrans.pkUpdateRecords(pNdb, records);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll(false, false, true) == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    hugoTrans.pkReadRecords(pNdb, records);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    //CHECK(count == records);    g_info << "2 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting 50% of records..." << endl;    hugoTrans.pkDelRecords(pNdb, records/2);        g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll(false, false, true) == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);    g_info << "Verifying records..." << endl;    hugoTrans.scanReadRecords(pNdb, records/2, 0, 64);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    //CHECK(count == (records/2));    g_info << "3 - Stopping one node" << endl;    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],				     false, 				     true,				     false) == 0);    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    g_info << "Deleting all records..." << endl;    utilTrans.clearTable(pNdb, records/2);    g_info << "Restarting cluster..." << endl;    CHECK(restarter.restartAll(false, false, true) == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    {      int val = DumpStateOrd::DihMinTimeBetweenLCP;      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);    }    CHECK(pNdb->waitUntilReady(timeout) == 0);        ndbout << "Verifying records..." << endl;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    //CHECK(count == 0);        CHECK(utilTrans.clearTable(pNdb) == 0);        i++;  }  g_info << "runSystemRestart5 finished" << endl;    return result;}int runSystemRestart6(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR6 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));    Uint32 currentRestartNodeIndex = 0;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart all node -nostart     * 3. Restart some nodes -i -nostart     * 4. Start all nodes verify records     */    g_info << "Loading records..." << endl;    hugoTrans.loadTable(pNdb, records);    CHECK(restarter.restartAll(false, true, false) == 0);    Uint32 nodeId = nodeIds[currentRestartNodeIndex];    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;        CHECK(restarter.restartOneDbNode(nodeId, true, true,false) == 0);    CHECK(restarter.waitClusterNoStart(timeout) == 0);    CHECK(restarter.startAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    int count = records - 1;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    CHECK(utilTrans.clearTable(pNdb) == 0);        i++;  }  g_info << "runSystemRestart6 finished" << endl;    return result;}int runSystemRestart7(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -