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

📄 ndbcntrmain.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 5 页
字号:
void Ndbcntr::crSystab9Lab(Signal* signal) {  signal->theData[1] = reference();  sendSignalWithDelay(DBDIH_REF, GSN_GETGCIREQ, signal, 100, 2);  return;}//Ndbcntr::crSystab9Lab()/*******************************//*  GETGCICONF                 *//*******************************/void Ndbcntr::execGETGCICONF(Signal* signal) {  jamEntry();#ifndef NO_GCP  if (signal->theData[1] < cgciSystab) {    jam();/*--------------------------------------*//* MAKE SURE THAT THE SYSTABLE IS       *//* NOW SAFE ON DISK                     *//*--------------------------------------*/    crSystab9Lab(signal);    return;  }//if#endif  waitpoint52Lab(signal);  return;}//Ndbcntr::execGETGCICONF()void Ndbcntr::execTCKEYREF(Signal* signal) {  jamEntry();  systemErrorLab(signal, __LINE__);  return;}//Ndbcntr::execTCKEYREF()void Ndbcntr::execTCROLLBACKREP(Signal* signal) {  jamEntry();  systemErrorLab(signal, __LINE__);  return;}//Ndbcntr::execTCROLLBACKREP()void Ndbcntr::execTCRELEASEREF(Signal* signal) {  jamEntry();  systemErrorLab(signal, __LINE__);  return;}//Ndbcntr::execTCRELEASEREF()void Ndbcntr::execTCSEIZEREF(Signal* signal) {  jamEntry();  systemErrorLab(signal, __LINE__);  return;}//Ndbcntr::execTCSEIZEREF()/*---------------------------------------------------------------------------*//*INITIALIZE VARIABLES AND RECORDS                                           *//*---------------------------------------------------------------------------*/void Ndbcntr::initData(Signal* signal) {  c_start.reset();  cmasterNodeId = 0;  cnoStartNodes = 0;  cnoWaitrep = 0;}//Ndbcntr::initData()/*---------------------------------------------------------------------------*//*RESET VARIABLES USED DURING THE START                                      *//*---------------------------------------------------------------------------*/void Ndbcntr::resetStartVariables(Signal* signal) {  cnoStartNodes = 0;  cnoWaitrep6 = cnoWaitrep7 = 0;}//Ndbcntr::resetStartVariables()/*---------------------------------------------------------------------------*/// SEND THE SIGNAL// INPUT                  CNDB_BLOCKS_COUNT/*---------------------------------------------------------------------------*/void Ndbcntr::sendNdbSttor(Signal* signal) {  NdbBlocksRecPtr ndbBlocksPtr;  ndbBlocksPtr.i = cndbBlocksCount;  ptrCheckGuard(ndbBlocksPtr, ZSIZE_NDB_BLOCKS_REC, ndbBlocksRec);  NdbSttor * const req = (NdbSttor*)signal->getDataPtrSend();  req->senderRef = reference();  req->nodeId = getOwnNodeId();  req->internalStartPhase = cinternalStartphase;  req->typeOfStart = ctypeOfStart;  req->masterNodeId = cmasterNodeId;    for (int i = 0; i < 16; i++) {    // Garbage    req->config[i] = 0x88776655;    //cfgBlockPtr.p->cfgData[i];  }    //#define MAX_STARTPHASE 2#ifdef TRACE_STTOR  ndbout_c("sending NDB_STTOR(%d) to %s",	   cinternalStartphase, 	   getBlockName( refToBlock(ndbBlocksPtr.p->blockref)));#endif  sendSignal(ndbBlocksPtr.p->blockref, GSN_NDB_STTOR, signal, 22, JBB);  cndbBlocksCount++;}//Ndbcntr::sendNdbSttor()/*---------------------------------------------------------------------------*/// JUST SEND THE SIGNAL/*---------------------------------------------------------------------------*/void Ndbcntr::sendSttorry(Signal* signal) {  signal->theData[3] = ZSTART_PHASE_1;  signal->theData[4] = ZSTART_PHASE_2;  signal->theData[5] = ZSTART_PHASE_3;  signal->theData[6] = ZSTART_PHASE_4;  signal->theData[7] = ZSTART_PHASE_5;  signal->theData[8] = ZSTART_PHASE_6;  // skip simulated phase 7  signal->theData[9] = ZSTART_PHASE_8;  signal->theData[10] = ZSTART_PHASE_9;  signal->theData[11] = ZSTART_PHASE_END;  sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 12, JBB);}//Ndbcntr::sendSttorry()voidNdbcntr::execDUMP_STATE_ORD(Signal* signal){  DumpStateOrd * const & dumpState = (DumpStateOrd *)&signal->theData[0];  Uint32 arg = dumpState->args[0];  if(arg == 13){    infoEvent("Cntr: cstartPhase = %d, cinternalStartphase = %d, block = %d", 	      cstartPhase, cinternalStartphase, cndbBlocksCount);    infoEvent("Cntr: cmasterNodeId = %d", cmasterNodeId);  }  if (arg == DumpStateOrd::NdbcntrTestStopOnError){    if (theConfiguration.stopOnError() == true)      ((Configuration&)theConfiguration).stopOnError(false);        const BlockReference tblockref = calcNdbCntrBlockRef(getOwnNodeId());          SystemError * const sysErr = (SystemError*)&signal->theData[0];    sysErr->errorCode = SystemError::TestStopOnError;    sysErr->errorRef = reference();    sendSignal(tblockref, GSN_SYSTEM_ERROR, signal, 	       SystemError::SignalLength, JBA);  }  if (arg == DumpStateOrd::NdbcntrStopNodes)  {    NdbNodeBitmask mask;    for(Uint32 i = 1; i<signal->getLength(); i++)      mask.set(signal->theData[i]);    StopReq* req = (StopReq*)signal->getDataPtrSend();    req->senderRef = RNIL;    req->senderData = 123;    req->requestInfo = 0;    req->singleuser = 0;    req->singleUserApi = 0;    mask.copyto(NdbNodeBitmask::Size, req->nodes);    StopReq::setPerformRestart(req->requestInfo, 1);    StopReq::setNoStart(req->requestInfo, 1);    StopReq::setStopNodes(req->requestInfo, 1);    StopReq::setStopAbort(req->requestInfo, 1);        sendSignal(reference(), GSN_STOP_REQ, signal,	       StopReq::SignalLength, JBB);    return;  }}//Ndbcntr::execDUMP_STATE_ORD()void Ndbcntr::execSET_VAR_REQ(Signal* signal) {#if 0  SetVarReq* const setVarReq = (SetVarReq*)&signal->theData[0];  ConfigParamId var = setVarReq->variable();  switch (var) {  case TimeToWaitAlive:    // Valid only during start so value not set.    sendSignal(CMVMI_REF, GSN_SET_VAR_CONF, signal, 1, JBB);    break;  default:    sendSignal(CMVMI_REF, GSN_SET_VAR_REF, signal, 1, JBB);  }// switch#endif}//Ndbcntr::execSET_VAR_REQ()void Ndbcntr::updateNodeState(Signal* signal, const NodeState& newState) const{  NodeStateRep * const stateRep = (NodeStateRep *)&signal->theData[0];  stateRep->nodeState = newState;  stateRep->nodeState.masterNodeId = cmasterNodeId;  stateRep->nodeState.setNodeGroup(c_nodeGroup);    for(Uint32 i = 0; i<ALL_BLOCKS_SZ; i++){    sendSignal(ALL_BLOCKS[i].Ref, GSN_NODE_STATE_REP, signal,	       NodeStateRep::SignalLength, JBB);  }}voidNdbcntr::execRESUME_REQ(Signal* signal){  //ResumeReq * const req = (ResumeReq *)&signal->theData[0];  //ResumeRef * const ref = (ResumeRef *)&signal->theData[0];    jamEntry();  signal->theData[0] = NDB_LE_SingleUser;  signal->theData[1] = 2;  sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);  //Uint32 senderData = req->senderData;  //BlockReference senderRef = req->senderRef;  NodeState newState(NodeState::SL_STARTED);		    updateNodeState(signal, newState);  c_stopRec.stopReq.senderRef=0;}voidNdbcntr::execSTOP_REQ(Signal* signal){  StopReq * const req = (StopReq *)&signal->theData[0];  StopRef * const ref = (StopRef *)&signal->theData[0];  Uint32 singleuser  = req->singleuser;  jamEntry();  Uint32 senderData = req->senderData;  BlockReference senderRef = req->senderRef;  bool abort = StopReq::getStopAbort(req->requestInfo);  bool stopnodes = StopReq::getStopNodes(req->requestInfo);  if(!singleuser &&      (getNodeState().startLevel < NodeState::SL_STARTED ||       (abort && !stopnodes)))  {    /**     * Node is not started yet     *     * So stop it quickly     */    jam();    const Uint32 reqInfo = req->requestInfo;    if(StopReq::getPerformRestart(reqInfo)){      jam();      StartOrd * startOrd = (StartOrd *)&signal->theData[0];      startOrd->restartInfo = reqInfo;      sendSignal(CMVMI_REF, GSN_START_ORD, signal, 1, JBA);    } else {      jam();      sendSignal(CMVMI_REF, GSN_STOP_ORD, signal, 1, JBA);    }    return;  }  if(c_stopRec.stopReq.senderRef != 0 ||     (cmasterNodeId == getOwnNodeId() && !c_start.m_starting.isclear()))  {    /**     * Requested a system shutdown     */    if(!singleuser && StopReq::getSystemStop(req->requestInfo)){      jam();      sendSignalWithDelay(reference(), GSN_STOP_REQ, signal, 100,			  StopReq::SignalLength);      return;    }    /**     * Requested a node shutdown     */    if(c_stopRec.stopReq.senderRef &&       StopReq::getSystemStop(c_stopRec.stopReq.requestInfo))      ref->errorCode = StopRef::SystemShutdownInProgress;    else      ref->errorCode = StopRef::NodeShutdownInProgress;    ref->senderData = senderData;    ref->masterNodeId = cmasterNodeId;        if (senderRef != RNIL)      sendSignal(senderRef, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);    return;  }  if (stopnodes && !abort)  {    jam();    ref->errorCode = StopRef::UnsupportedNodeShutdown;    ref->senderData = senderData;    ref->masterNodeId = cmasterNodeId;    if (senderRef != RNIL)      sendSignal(senderRef, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);    return;  }  if (stopnodes && cmasterNodeId != getOwnNodeId())  {    jam();    ref->errorCode = StopRef::MultiNodeShutdownNotMaster;    ref->senderData = senderData;    ref->masterNodeId = cmasterNodeId;    if (senderRef != RNIL)      sendSignal(senderRef, GSN_STOP_REF, signal, StopRef::SignalLength, JBB);    return;  }    c_stopRec.stopReq = * req;  c_stopRec.stopInitiatedTime = NdbTick_CurrentMillisecond();    if (stopnodes)  {    jam();    if(!c_stopRec.checkNodeFail(signal))    {      jam();      return;    }    char buf[100];    NdbNodeBitmask mask;    mask.assign(NdbNodeBitmask::Size, c_stopRec.stopReq.nodes);    infoEvent("Initiating shutdown abort of %s", mask.getText(buf));    ndbout_c("Initiating shutdown abort of %s", mask.getText(buf));        WaitGCPReq * req = (WaitGCPReq*)&signal->theData[0];    req->senderRef = reference();    req->senderData = StopRecord::SR_BLOCK_GCP_START_GCP;    req->requestType = WaitGCPReq::BlockStartGcp;    sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal, 	       WaitGCPReq::SignalLength, JBB);    return;  }  else if(!singleuser)   {    if(StopReq::getSystemStop(c_stopRec.stopReq.requestInfo))     {      jam();      if(StopReq::getPerformRestart(c_stopRec.stopReq.requestInfo))      {	((Configuration&)theConfiguration).stopOnError(false);      }    }    if(!c_stopRec.checkNodeFail(signal))    {      jam();      return;    }    signal->theData[0] = NDB_LE_NDBStopStarted;    signal->theData[1] = StopReq::getSystemStop(c_stopRec.stopReq.requestInfo) ? 1 : 0;    sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);  }  else  {    signal->theData[0] = NDB_LE_SingleUser;    signal->theData[1] = 0;    sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);  }  NodeState newState(NodeState::SL_STOPPING_1, 		     StopReq::getSystemStop(c_stopRec.stopReq.requestInfo));     if(singleuser) {     newState.setSingleUser(true);     newState.setSingleUserApi(c_stopRec.stopReq.singleUserApi);   }  updateNodeState(signal, newState);  signal->theData[0] = ZSHUTDOWN;  sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100, 1);}voidNdbcntr::StopRecord::checkTimeout(Signal* signal){  jamEntry();  if(!cntr.getNodeState().getSingleUserMode())    if(!checkNodeFail(signal)){      jam();      return;    }  switch(cntr.getNodeState().startLevel){  case NodeState::SL_STOPPING_1:    checkApiTimeout(signal);    break;  case NodeState::SL_STOPPING_2:    checkTcTimeout(signal);    break;  case NodeState::SL_STOPPING_3:    checkLqhTimeout_1(signal);    break;  case NodeState::SL_STOPPING_4:    checkLqhTimeout_2(signal);    break;  case NodeState::SL_SINGLEUSER:    break;  default:    ndbrequire(false);  }}boolNdbcntr::StopRecord::checkNodeFail(Signal* signal){  jam();  if(StopReq::getSystemStop(stopReq.requestInfo)){    jam();    return true;  }  /**   * Check if I can survive me stopping   */  NodeBitmask ndbMask;   ndbMask.assign(cntr.c_startedNodes);  if (StopReq::getStopNodes(stopReq.requestInfo))  {    NdbNodeBitmask tmp;    tmp.assign(NdbNodeBitmask::Size, stopReq.nodes);    ndbMask.bitANDC(tmp);  }  else  {    ndbMask.clear(cntr.getOwnNodeId());  }    CheckNodeGroups* sd = (CheckNodeGroups*)&signal->theData[0];  sd->blockRef = cntr.reference();  sd->requestType = CheckNodeGroups::Direct | CheckNodeGroups::ArbitCheck;  sd->mask = ndbMask;  cntr.EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal, 		      CheckNodeGroups::SignalLength);  jamEntry();  switch (sd->output) {  case CheckNodeGroups::Win:  case CheckNodeGroups::Partitioning:    return true;    break;  }    StopRef * const ref = (StopRef *)&signal->theData[0];        ref->senderData = stopReq.senderData;  ref->errorCode = StopRef::NodeShutdownWouldCauseSystemCrash;  ref->masterNodeId = cntr.cmasterNodeId;    const BlockReference bref = stopReq.senderRef;  if (bref != RNIL)    cntr.sendSignal(bref, GSN_STOP_REF, signal, StopRef::SignalLength, JBB)

⌨️ 快捷键说明

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