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

📄 testscan.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 3 页
字号:
int runScanUpdate(NDBT_Context* ctx, NDBT_Step* step){  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int parallelism = ctx->getProperty("Parallelism", 1);  int abort = ctx->getProperty("AbortProb", 5);  int i = 0;  HugoTransactions hugoTrans(*ctx->getTab());  while (i<loops) {    g_info << i << ": ";    if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism) != 0){      return NDBT_FAILED;    }    i++;  }  return NDBT_OK;}int runScanUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){  int records = ctx->getNumRecords();  int i = 0;  int parallelism = ctx->getProperty("Parallelism", 240);  int para = parallelism;  HugoTransactions hugoTrans(*ctx->getTab());  while (ctx->isTestStopped() == false) {    if (parallelism == RANDOM_PARALLELISM)      para = myRandom48(239)+1;    g_info << i << ": ";    if (hugoTrans.scanUpdateRecords(GETNDB(step), records, 0, para) == NDBT_FAILED){      return NDBT_FAILED;    }    i++;  }  return NDBT_OK;}int runScanUpdate2(NDBT_Context* ctx, NDBT_Step* step){  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int parallelism = ctx->getProperty("Parallelism", 240);  int abort = ctx->getProperty("AbortProb", 5);  int i = 0;  HugoTransactions hugoTrans(*ctx->getTab());  while (i<loops) {    g_info << i << ": ";    if (hugoTrans.scanUpdateRecords2(GETNDB(step), records, abort, parallelism) != 0){      return NDBT_FAILED;    }    i++;  }  return NDBT_OK;}int runLocker(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  int records = ctx->getNumRecords();  HugoTransactions hugoTrans(*ctx->getTab());    if (hugoTrans.lockRecords(GETNDB(step), records, 5, 500) != 0){    result = NDBT_FAILED;  }  ctx->stopTest();    return result;}int runRestarter(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  int loops = ctx->getNumLoops();  NdbRestarter restarter;  int i = 0;  int lastId = 0;  int timeout = 240;  if (restarter.getNumDbNodes() < 2){      ctx->stopTest();      return NDBT_OK;  }  while(i<loops && result != NDBT_FAILED){    if(restarter.waitClusterStarted(timeout) != 0){      g_err << "Cluster failed to start 1" << endl;      result = NDBT_FAILED;      break;    }    NdbSleep_SecSleep(10);        int nodeId = restarter.getDbNodeId(lastId);    lastId = (lastId + 1) % restarter.getNumDbNodes();    if(restarter.restartOneDbNode(nodeId) != 0){      g_err << "Failed to restartNextDbNode" << endl;      result = NDBT_FAILED;      break;    }        i++;  }  if(restarter.waitClusterStarted(timeout) != 0){    g_err << "Cluster failed to start 2" << endl;    result = NDBT_FAILED;  }  ctx->stopTest();    return result;}int runStopAndStartNode(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  int loops = ctx->getNumLoops();  NdbRestarter restarter;  int i = 0;  int lastId = 0;  int timeout = 240;  if (restarter.getNumDbNodes() < 2){      ctx->stopTest();      return NDBT_OK;  }  while(i<loops && result != NDBT_FAILED){    if(restarter.waitClusterStarted(timeout) != 0){      g_err << "Cluster failed to start 1" << endl;      result = NDBT_FAILED;      break;    }    NdbSleep_SecSleep(1);    int nodeId = restarter.getDbNodeId(lastId);    lastId = (lastId + 1) % restarter.getNumDbNodes();    g_err << "Stopping node " << nodeId << endl;    if(restarter.restartOneDbNode(nodeId, false, true) != 0){      g_err << "Failed to restartOneDbNode" << endl;      result = NDBT_FAILED;      break;    }     if(restarter.waitNodesNoStart(&nodeId, 1, timeout) != 0){      g_err << "Node failed to reach NoStart" << endl;      result = NDBT_FAILED;      break;    }       g_info << "Sleeping for 10 secs" << endl;    NdbSleep_SecSleep(10);        g_err << "Starting node " << nodeId << endl;    if(restarter.startNodes(&nodeId, 1) != 0){      g_err << "Failed to start the node" << endl;      result = NDBT_FAILED;      break;    }        i++;  }  if(restarter.waitClusterStarted(timeout) != 0){    g_err << "Cluster failed to start 2" << endl;    result = NDBT_FAILED;  }  ctx->stopTest();    return result;}int runRestarter9999(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  int loops = ctx->getNumLoops();  NdbRestarter restarter;  int i = 0;  int lastId = 0;  if (restarter.getNumDbNodes() < 2){      ctx->stopTest();      return NDBT_OK;  }  while(i<loops && result != NDBT_FAILED){    if(restarter.waitClusterStarted(120) != 0){      g_err << "Cluster failed to start" << endl;      result = NDBT_FAILED;      break;    }    NdbSleep_SecSleep(10);        int nodeId = restarter.getDbNodeId(lastId);    lastId = (lastId + 1) % restarter.getNumDbNodes();    if(restarter.insertErrorInNode(nodeId, 9999) != 0){      g_err << "Failed to insertErrorInNode="<<nodeId << endl;      result = NDBT_FAILED;      break;    }        NdbSleep_SecSleep(10);    i++;  }  if(restarter.waitClusterStarted(120) != 0){    g_err << "Cluster failed to start" << endl;    result = NDBT_FAILED;  }  ctx->stopTest();    return result;}int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int parallelism = ctx->getProperty("Parallelism", 1);  int records = ctx->getNumRecords();  int numFailed = 0;  AttribList alist;   alist.buildAttribList(pTab);  UtilTransactions utilTrans(*pTab);    for(size_t i = 0; i < alist.attriblist.size(); i++){    g_info << (unsigned)i << endl;    if(utilTrans.scanReadRecords(GETNDB(step), 				 parallelism,				 NdbOperation::LM_Read,				 records,				 alist.attriblist[i]->numAttribs,				 alist.attriblist[i]->attribs) != 0){      numFailed++;    }    if(utilTrans.scanReadRecords(GETNDB(step), 				 parallelism,				 NdbOperation::LM_Read,				 records,				 alist.attriblist[i]->numAttribs,				 alist.attriblist[i]->attribs) != 0){      numFailed++;    }  }    if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runCloseWithoutStop(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  // Iterate over all possible parallelism valuse  for (int p = 1; p<240; p++){    g_info << p << " CloseWithoutStop openScan" << endl;    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				p,				ScanFunctions::CloseWithoutStop,				false) != 0){      numFailed++;    }    g_info << p << " CloseWithoutStop openScanExclusive" << endl;    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				p,				ScanFunctions::CloseWithoutStop,				true) != 0){      numFailed++;    }  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runNextScanWhenNoMore(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::NextScanWhenNoMore,			      false) != 0){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::NextScanWhenNoMore,			      true) != 0){    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runEqualAfterOpenScan(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::EqualAfterOpenScan,			      false) == NDBT_OK){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::EqualAfterOpenScan,			      true) == NDBT_OK){    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runOnlyOpenScanOnce(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  g_info << "OnlyOpenScanOnce openScanRead" << endl;  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::OnlyOpenScanOnce,			      false) == 0){    numFailed++;  }  g_info << "OnlyOpenScanOnce openScanExclusive" << endl;  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::OnlyOpenScanOnce,			      true) == 0){    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runOnlyOneOpInScanTrans(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runExecuteScanWithoutOpenScan(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runOnlyOneOpBeforeOpenScan(NDBT_Context* ctx, NDBT_Step* step){    return NDBT_OK;}int runOnlyOneScanPerTrans(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runNoCloseTransaction(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  int l = 0;  while(l < loops){    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				6,				ScanFunctions::NoCloseTransaction,				false) != 0){      numFailed++;    }    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				6,				ScanFunctions::NoCloseTransaction,				true) != 0){      numFailed++;    }    l++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runCheckInactivityTimeOut(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      1,			      ScanFunctions::CheckInactivityTimeOut,			      false) != NDBT_OK){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      240,			      ScanFunctions::CheckInactivityTimeOut,			      true) != NDBT_OK){    numFailed++;  }    if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runCheckInactivityBeforeClose(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      16,			      ScanFunctions::CheckInactivityBeforeClose,			      false) != 0){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      240,			      ScanFunctions::CheckInactivityBeforeClose,			      true) != 0){    numFailed++;  }    if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runScanRestart(NDBT_Context* ctx, NDBT_Step* step){  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  Ndb * pNdb = GETNDB(step);  const NdbDictionary::Table*  pTab = ctx->getTab();  HugoCalculator calc(* pTab);  NDBT_ResultRow tmpRow(* pTab);  int i = 0;  while (i<loops && !ctx->isTestStopped()) {    g_info << i++ << ": ";    const int record = (rand() % records);    g_info << " row=" << record;    NdbConnection* pCon = pNdb->startTransaction();    NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());	    if (pOp == NULL) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }        if( pOp->readTuples() ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }      int check = pOp->interpret_exit_ok();    if( check == -1 ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }        // Define attributes to read      for(int a = 0; a<pTab->getNoOfColumns(); a++){      if((tmpRow.attributeStore(a) = 	  pOp->getValue(pTab->getColumn(a)->getName())) == 0) {	ERR(pCon->getNdbError());	return NDBT_FAILED;      }    }         check = pCon->execute(NoCommit);    if( check == -1 ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }    int res;    int row = 0;    while(row < record && (res = pOp->nextResult()) == 0) {      if(calc.verifyRowValues(&tmpRow) != 0){	abort();	return NDBT_FAILED;      }      row++;    }    if(row != record){      ERR(pCon->getNdbError());      abort();      return NDBT_FAILED;    }    g_info << " restarting" << endl;    if((res = pOp->restart()) != 0){      ERR(pCon->getNdbError());      abort();      return NDBT_FAILED;    }          row = 0;    while((res = pOp->nextResult()) == 0) {      if(calc.verifyRowValues(&tmpRow) != 0){	abort();	return NDBT_FAILED;      }      row++;    }

⌨️ 快捷键说明

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