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

📄 ndbcntrmain.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  failedStarted.bitAND(allFailed);  failedStarting.bitAND(allFailed);  failedWaiting.bitAND(allFailed);    const bool tMasterFailed = allFailed.get(cmasterNodeId);  const bool tStarted = !failedStarted.isclear();  const bool tStarting = !failedStarting.isclear();  const bool tWaiting = !failedWaiting.isclear();  if(tMasterFailed){    jam();    /**     * If master has failed choose qmgr president as master     */    cmasterNodeId = nodeFail->masterNodeId;  }    /**   * Clear node bitmasks from failed nodes   */  c_start.m_starting.bitANDC(allFailed);  c_start.m_waiting.bitANDC(allFailed);  c_start.m_withLog.bitANDC(allFailed);  c_start.m_withoutLog.bitANDC(allFailed);  c_clusterNodes.bitANDC(allFailed);  c_startedNodes.bitANDC(allFailed);  const NodeState & st = getNodeState();  if(st.startLevel == st.SL_STARTING){    jam();    const Uint32 phase = st.starting.startPhase;        const bool tStartConf = (phase > 2) || (phase == 2 && cndbBlocksCount > 0);    if(tMasterFailed){      progError(__LINE__, NDBD_EXIT_SR_OTHERNODEFAILED,		"Unhandled node failure during restart");    }        if(tStartConf && tStarting){      // One of other starting nodes has crashed...      progError(__LINE__, NDBD_EXIT_SR_OTHERNODEFAILED,		"Unhandled node failure of starting node during restart");    }    if(tStartConf && tStarted){      // One of other started nodes has crashed...            progError(__LINE__, NDBD_EXIT_SR_OTHERNODEFAILED,		"Unhandled node failure of started node during restart");    }        Uint32 nodeId = 0;    while(!allFailed.isclear()){      nodeId = allFailed.find(nodeId + 1);      allFailed.clear(nodeId);      signal->theData[0] = nodeId;      sendSignal(QMGR_REF, GSN_NDB_FAILCONF, signal, 1, JBB);    }//for        return;  }    ndbrequire(!allFailed.get(getOwnNodeId()));  NodeFailRep * rep = (NodeFailRep *)&signal->theData[0];    rep->masterNodeId = cmasterNodeId;  sendSignal(DBTC_REF, GSN_NODE_FAILREP, signal, 	     NodeFailRep::SignalLength, JBB);    sendSignal(DBLQH_REF, GSN_NODE_FAILREP, signal, 	     NodeFailRep::SignalLength, JBB);    sendSignal(DBDIH_REF, GSN_NODE_FAILREP, signal, 	     NodeFailRep::SignalLength, JBB);    sendSignal(DBDICT_REF, GSN_NODE_FAILREP, signal, 	     NodeFailRep::SignalLength, JBB);    sendSignal(BACKUP_REF, GSN_NODE_FAILREP, signal,	     NodeFailRep::SignalLength, JBB);  sendSignal(SUMA_REF, GSN_NODE_FAILREP, signal,	     NodeFailRep::SignalLength, JBB);  if (c_stopRec.stopReq.senderRef)  {    jam();    switch(c_stopRec.m_state){    case StopRecord::SR_WAIT_NODE_FAILURES:    {      jam();      NdbNodeBitmask tmp;      tmp.assign(NdbNodeBitmask::Size, c_stopRec.stopReq.nodes);      tmp.bitANDC(allFailed);            tmp.copyto(NdbNodeBitmask::Size, c_stopRec.stopReq.nodes);            if (tmp.isclear())      {	jam();	if (c_stopRec.stopReq.senderRef != RNIL)	{	  jam();	  StopConf * const stopConf = (StopConf *)&signal->theData[0];	  stopConf->senderData = c_stopRec.stopReq.senderData;	  stopConf->nodeState  = (Uint32) NodeState::SL_SINGLEUSER;	  sendSignal(c_stopRec.stopReq.senderRef, GSN_STOP_CONF, signal, 		     StopConf::SignalLength, JBB);	}	c_stopRec.stopReq.senderRef = 0;	WaitGCPReq * req = (WaitGCPReq*)&signal->theData[0];	req->senderRef = reference();	req->senderData = StopRecord::SR_UNBLOCK_GCP_START_GCP;	req->requestType = WaitGCPReq::UnblockStartGcp;	sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal, 		   WaitGCPReq::SignalLength, JBA);      }      break;    }    case StopRecord::SR_QMGR_STOP_REQ:    {      NdbNodeBitmask tmp;      tmp.assign(NdbNodeBitmask::Size, c_stopRec.stopReq.nodes);      tmp.bitANDC(allFailed);            if (tmp.isclear())      {	Uint32 nodeId = allFailed.find(0);	tmp.set(nodeId);	StopConf* conf = (StopConf*)signal->getDataPtrSend();	conf->senderData = c_stopRec.stopReq.senderData;	conf->nodeId = nodeId;	sendSignal(reference(), 		   GSN_STOP_CONF, signal, StopConf::SignalLength, JBB);      }      tmp.copyto(NdbNodeBitmask::Size, c_stopRec.stopReq.nodes);            break;    }    }  }    signal->theData[0] = NDB_LE_NODE_FAILREP;  signal->theData[2] = 0;    Uint32 nodeId = 0;  while(!allFailed.isclear()){    nodeId = allFailed.find(nodeId + 1);    allFailed.clear(nodeId);    signal->theData[1] = nodeId;    sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 3, JBB);  }//for  return;}//Ndbcntr::execNODE_FAILREP()/*******************************//*  READ_NODESREQ              *//*******************************/void Ndbcntr::execREAD_NODESREQ(Signal* signal) {  jamEntry();  /*----------------------------------------------------------------------*/  // ANY BLOCK MAY SEND A REQUEST ABOUT NDB NODES AND VERSIONS IN THE  // SYSTEM. THIS REQUEST CAN ONLY BE HANDLED IN  // ABSOLUTE STARTPHASE 3 OR LATER  /*----------------------------------------------------------------------*/  BlockReference TuserBlockref = signal->theData[0];  ReadNodesConf * const readNodes = (ReadNodesConf *)&signal->theData[0];    /**   * Prepare inactiveNodes bitmask.   * The concept as such is by the way pretty useless.   * It makes parallell starts more or less impossible...   */  NdbNodeBitmask tmp1;   tmp1.bitOR(c_startedNodes);  if(!getNodeState().getNodeRestartInProgress()){    tmp1.bitOR(c_start.m_starting);  } else {    tmp1.set(getOwnNodeId());  }  NdbNodeBitmask tmp2;  tmp2.bitOR(c_allDefinedNodes);  tmp2.bitANDC(tmp1);  /**   * Fill in return signal   */  tmp2.copyto(NdbNodeBitmask::Size, readNodes->inactiveNodes);  c_allDefinedNodes.copyto(NdbNodeBitmask::Size, readNodes->allNodes);  c_clusterNodes.copyto(NdbNodeBitmask::Size, readNodes->clusterNodes);  c_startedNodes.copyto(NdbNodeBitmask::Size, readNodes->startedNodes);  c_start.m_starting.copyto(NdbNodeBitmask::Size, readNodes->startingNodes);  readNodes->noOfNodes = c_allDefinedNodes.count();  readNodes->masterNodeId = cmasterNodeId;  readNodes->ndynamicId = cdynamicNodeId;  if (cstartPhase > ZSTART_PHASE_2) {    jam();    sendSignal(TuserBlockref, GSN_READ_NODESCONF, signal, 	       ReadNodesConf::SignalLength, JBB);      } else {    jam();    signal->theData[0] = ZNOT_AVAILABLE;    sendSignal(TuserBlockref, GSN_READ_NODESREF, signal, 1, JBB);  }//if}//Ndbcntr::execREAD_NODESREQ()/*----------------------------------------------------------------------*/// SENDS APPL_ERROR TO QMGR AND THEN SET A POINTER OUT OF BOUNDS/*----------------------------------------------------------------------*/void Ndbcntr::systemErrorLab(Signal* signal, int line) {  progError(line, NDBD_EXIT_NDBREQUIRE); /* BUG INSERTION */  return;}//Ndbcntr::systemErrorLab()/*###########################################################################*//* CNTR MASTER CREATES AND INITIALIZES A SYSTEMTABLE AT INITIALSTART         *//*       |-2048| # 1 00000001    |                                           *//*       |  :  |   :             |                                           *//*       | -1  | # 1 00000001    |                                           *//*       |  0  |   0             |                                           *//*       |  1  |   0             |                                           *//*       |  :  |   :             |                                           *//*       | 2047|   0             |                                           *//*---------------------------------------------------------------------------*/void Ndbcntr::createSystableLab(Signal* signal, unsigned index){  if (index >= g_sysTableCount) {    ndbassert(index == g_sysTableCount);    startInsertTransactions(signal);    return;  }  const SysTable& table = *g_sysTableList[index];  Uint32 propPage[256];  LinearWriter w(propPage, 256);  // XXX remove commented-out lines later  w.first();  w.add(DictTabInfo::TableName, table.name);  w.add(DictTabInfo::TableLoggedFlag, table.tableLoggedFlag);  //w.add(DictTabInfo::TableKValue, 6);  //w.add(DictTabInfo::MinLoadFactor, 70);  //w.add(DictTabInfo::MaxLoadFactor, 80);  w.add(DictTabInfo::FragmentTypeVal, (Uint32)table.fragmentType);  //w.add(DictTabInfo::TableStorageVal, (Uint32)DictTabInfo::MainMemory);  //w.add(DictTabInfo::NoOfKeyAttr, 1);  w.add(DictTabInfo::NoOfAttributes, (Uint32)table.columnCount);  //w.add(DictTabInfo::NoOfNullable, (Uint32)0);  //w.add(DictTabInfo::NoOfVariable, (Uint32)0);  //w.add(DictTabInfo::KeyLength, 1);  w.add(DictTabInfo::TableTypeVal, (Uint32)table.tableType);  for (unsigned i = 0; i < table.columnCount; i++) {    const SysColumn& column = table.columnList[i];    ndbassert(column.pos == i);    w.add(DictTabInfo::AttributeName, column.name);    w.add(DictTabInfo::AttributeId, (Uint32)column.pos);    w.add(DictTabInfo::AttributeKeyFlag, (Uint32)column.keyFlag);    //w.add(DictTabInfo::AttributeStorage, (Uint32)DictTabInfo::MainMemory);    w.add(DictTabInfo::AttributeNullableFlag, (Uint32)column.nullable);    w.add(DictTabInfo::AttributeExtType, (Uint32)column.type);    w.add(DictTabInfo::AttributeExtLength, (Uint32)column.length);    w.add(DictTabInfo::AttributeEnd, (Uint32)true);  }  w.add(DictTabInfo::TableEnd, (Uint32)true);    Uint32 length = w.getWordsUsed();  LinearSectionPtr ptr[3];  ptr[0].p = &propPage[0];  ptr[0].sz = length;  CreateTableReq* const req = (CreateTableReq*)signal->getDataPtrSend();  req->senderData = index;  req->senderRef = reference();  sendSignal(DBDICT_REF, GSN_CREATE_TABLE_REQ, signal,	     CreateTableReq::SignalLength, JBB, ptr, 1);  return;}//Ndbcntr::createSystableLab()void Ndbcntr::execCREATE_TABLE_REF(Signal* signal) {  jamEntry();  progError(__LINE__,NDBD_EXIT_NDBREQUIRE, "CREATE_TABLE_REF");  return;}//Ndbcntr::execDICTTABREF()void Ndbcntr::execCREATE_TABLE_CONF(Signal* signal) {  jamEntry();  CreateTableConf * const conf = (CreateTableConf*)signal->getDataPtrSend();  //csystabId = conf->tableId;  ndbrequire(conf->senderData < g_sysTableCount);  const SysTable& table = *g_sysTableList[conf->senderData];  table.tableId = conf->tableId;  createSystableLab(signal, conf->senderData + 1);  //startInsertTransactions(signal);  return;}//Ndbcntr::execDICTTABCONF()/*******************************//*  DICTRELEASECONF            *//*******************************/void Ndbcntr::startInsertTransactions(Signal* signal) {  jamEntry();  ckey = 1;  ctransidPhase = ZTRUE;  signal->theData[0] = 0;  signal->theData[1] = reference();  sendSignal(DBTC_REF, GSN_TCSEIZEREQ, signal, 2, JBB);  return;}//Ndbcntr::startInsertTransactions()/*******************************//*  TCSEIZECONF                *//*******************************/void Ndbcntr::execTCSEIZECONF(Signal* signal) {  jamEntry();  ctcConnectionP = signal->theData[1];  crSystab7Lab(signal);  return;}//Ndbcntr::execTCSEIZECONF()const unsigned int RowsPerCommit = 16;void Ndbcntr::crSystab7Lab(Signal* signal) {  UintR tkey;  UintR Tmp;    TcKeyReq * const tcKeyReq = (TcKeyReq *)&signal->theData[0];    UintR reqInfo_Start = 0;  tcKeyReq->setOperationType(reqInfo_Start, ZINSERT); // Insert  tcKeyReq->setKeyLength    (reqInfo_Start, 1);  tcKeyReq->setAIInTcKeyReq (reqInfo_Start, 5);  tcKeyReq->setAbortOption  (reqInfo_Start, TcKeyReq::AbortOnError);/* KEY LENGTH = 1, ATTRINFO LENGTH IN TCKEYREQ = 5 */  cresponses = 0;  const UintR guard0 = ckey + (RowsPerCommit - 1);  for (Tmp = ckey; Tmp <= guard0; Tmp++) {    UintR reqInfo = reqInfo_Start;    if (Tmp == ckey) { // First iteration, Set start flag      jam();      tcKeyReq->setStartFlag(reqInfo, 1);    } //if    if (Tmp == guard0) { // Last iteration, Set commit flag      jam();      tcKeyReq->setCommitFlag(reqInfo, 1);            tcKeyReq->setExecuteFlag(reqInfo, 1);    } //if    if (ctransidPhase == ZTRUE) {      jam();      tkey = 0;      tkey = tkey - Tmp;    } else {      jam();      tkey = Tmp;    }//if    tcKeyReq->apiConnectPtr      = ctcConnectionP;    tcKeyReq->attrLen            = 5;    tcKeyReq->tableId            = g_sysTable_SYSTAB_0.tableId;    tcKeyReq->requestInfo        = reqInfo;    tcKeyReq->tableSchemaVersion = ZSYSTAB_VERSION;    tcKeyReq->transId1           = 0;    tcKeyReq->transId2           = ckey;//-------------------------------------------------------------// There is no optional part in this TCKEYREQ. There is one// key word and five ATTRINFO words.//-------------------------------------------------------------    Uint32* tKeyDataPtr          = &tcKeyReq->scanInfo;    Uint32* tAIDataPtr           = &tKeyDataPtr[1];    tKeyDataPtr[0]               = tkey;    AttributeHeader::init(&tAIDataPtr[0], 0, 1);    tAIDataPtr[1]                = tkey;    AttributeHeader::init(&tAIDataPtr[2], 1, 2);    tAIDataPtr[3]                = (tkey << 16);    tAIDataPtr[4]                = 1;        sendSignal(DBTC_REF, GSN_TCKEYREQ, signal, 	       TcKeyReq::StaticLength + 6, JBB);  }//for  ckey = ckey + RowsPerCommit;  return;}//Ndbcntr::crSystab7Lab()/*******************************//*  TCKEYCONF09                *//*******************************/void Ndbcntr::execTCKEYCONF(Signal* signal) {  const TcKeyConf * const keyConf = (TcKeyConf *)&signal->theData[0];    jamEntry();  cgciSystab = keyConf->gci;  UintR confInfo = keyConf->confInfo;    if (TcKeyConf::getMarkerFlag(confInfo)){    Uint32 transId1 = keyConf->transId1;    Uint32 transId2 = keyConf->transId2;    signal->theData[0] = transId1;    signal->theData[1] = transId2;    sendSignal(DBTC_REF, GSN_TC_COMMIT_ACK, signal, 2, JBB);      }//if    cresponses = cresponses + TcKeyConf::getNoOfOperations(confInfo);  if (TcKeyConf::getCommitFlag(confInfo)){    jam();    ndbrequire(cresponses == RowsPerCommit);    crSystab8Lab(signal);    return;  }  return;}//Ndbcntr::tckeyConfLab()void Ndbcntr::crSystab8Lab(Signal* signal) {  if (ckey < ZSIZE_SYSTAB) {    jam();    crSystab7Lab(signal);    return;  } else if (ctransidPhase == ZTRUE) {    jam();    ckey = 1;    ctransidPhase = ZFALSE;    crSystab7Lab(signal);    return;  }//if  signal->theData[0] = ctcConnectionP;  signal->theData[1] = reference();  signal->theData[2] = 0;  sendSignal(DBTC_REF, GSN_TCRELEASEREQ, signal, 2, JBB);  return;}//Ndbcntr::crSystab8Lab()/*******************************//*  TCRELEASECONF              *//*******************************/void Ndbcntr::execTCRELEASECONF(Signal* signal) {  jamEntry();  waitpoint52Lab(signal);  return;}//Ndbcntr::execTCRELEASECONF()

⌨️ 快捷键说明

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