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

📄 eventlogger.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* Copyright (C) 2003 MySQL AB   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <ndb_global.h>#include "EventLogger.hpp"#include <NdbConfig.h>#include <kernel/BlockNumbers.h>#include <signaldata/ArbitSignalData.hpp>#include <GrepEvent.hpp>#include <NodeState.hpp>#include <version.h>#include <ndbd_exit_codes.h>//// PUBLIC//EventLoggerBase::~EventLoggerBase(){  }#define QQQQ char *m_text, size_t m_text_len, const Uint32* theDatavoid getTextConnected(QQQQ) {  BaseString::snprintf(m_text, m_text_len, 		       "Node %u Connected",		       theData[1]);}void getTextConnectedApiVersion(QQQQ) {  BaseString::snprintf(m_text, m_text_len, 		       "Node %u: API version %d.%d.%d",		       theData[1],		       getMajor(theData[2]),		       getMinor(theData[2]),		       getBuild(theData[2]));}void getTextDisconnected(QQQQ) {  BaseString::snprintf(m_text, m_text_len, 		       "Node %u Disconnected", 		       theData[1]);}void getTextCommunicationClosed(QQQQ) {  //-----------------------------------------------------------------------  // REPORT communication to node closed.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "Communication to Node %u closed", 		       theData[1]);}void getTextCommunicationOpened(QQQQ) {  //-----------------------------------------------------------------------  // REPORT communication to node opened.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "Communication to Node %u opened", 		       theData[1]);}void getTextNDBStartStarted(QQQQ) {  //-----------------------------------------------------------------------  // Start of NDB has been initiated.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "Start initiated (version %d.%d.%d)", 		       getMajor(theData[1]),		       getMinor(theData[1]),		       getBuild(theData[1]));}void getTextNDBStopStarted(QQQQ) {  BaseString::snprintf(m_text, m_text_len,		       "%s shutdown initiated", 		       (theData[1] == 1 ? "Cluster" : "Node"));}void getRestartAction(Uint32 action, BaseString &str){  if (action == 0)    return;  str.appfmt(", restarting");  if (action & 2)    str.appfmt(", no start");  if (action & 4)    str.appfmt(", initial");}void getTextNDBStopCompleted(QQQQ) {  BaseString action_str("");  BaseString signum_str("");  getRestartAction(theData[1], action_str);  if (theData[2])    signum_str.appfmt(" Initiated by signal %d.", theData[2]);  BaseString::snprintf(m_text, m_text_len,		       "Node shutdown completed%s.%s",		       action_str.c_str(),		       signum_str.c_str());}void getTextNDBStopForced(QQQQ) {  BaseString action_str("");  BaseString reason_str("");  BaseString sphase_str("");  int signum        = theData[2];  int error         = theData[3];  int sphase        = theData[4];  int extra         = theData[5];  getRestartAction(theData[1],action_str);  if (signal)    reason_str.appfmt(" Initiated by signal %d.", signum);  if (error)  {    ndbd_exit_classification cl;    ndbd_exit_status st;    const char *msg = ndbd_exit_message(error, &cl);    const char *cl_msg = ndbd_exit_classification_message(cl, &st);    const char *st_msg = ndbd_exit_status_message(st);    reason_str.appfmt(" Caused by error %d: \'%s(%s). %s\'.",		      error, msg, cl_msg, st_msg);    if (extra != 0)      reason_str.appfmt(" (extra info %d)", extra);  }  if (sphase < 255)    sphase_str.appfmt(" Occured during startphase %u.", sphase);  BaseString::snprintf(m_text, m_text_len,		       "Forced node shutdown completed%s.%s%s",		       action_str.c_str(), sphase_str.c_str(),		       reason_str.c_str());}void getTextNDBStopAborted(QQQQ) {  BaseString::snprintf(m_text, m_text_len,		       "Node shutdown aborted");}void getTextNDBStartCompleted(QQQQ) {  //-----------------------------------------------------------------------  // Start of NDB has been completed.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "Started (version %d.%d.%d)", 		       getMajor(theData[1]),		       getMinor(theData[1]),		       getBuild(theData[1]));}void getTextSTTORRYRecieved(QQQQ) {  //-----------------------------------------------------------------------  // STTORRY recevied after restart finished.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "STTORRY received after restart finished");}void getTextStartPhaseCompleted(QQQQ) {  //-----------------------------------------------------------------------  // REPORT Start phase completed.  //-----------------------------------------------------------------------  const char *type = "<Unknown>";  switch((NodeState::StartType)theData[2]){  case NodeState::ST_INITIAL_START:    type = "(initial start)";    break;  case NodeState::ST_SYSTEM_RESTART:    type = "(system restart)";    break;  case NodeState::ST_NODE_RESTART:    type = "(node restart)";    break;  case NodeState::ST_INITIAL_NODE_RESTART:    type = "(initial node restart)";    break;  case NodeState::ST_ILLEGAL_TYPE:    type = "";    break;  default:    BaseString::snprintf(m_text, m_text_len, 			 "Start phase %u completed (unknown = %d)", 			 theData[1],			 theData[2]);    return;  }  BaseString::snprintf(m_text, m_text_len, 		       "Start phase %u completed %s", 		       theData[1],		       type);}void getTextCM_REGCONF(QQQQ) {  BaseString::snprintf(m_text, m_text_len, 		       "CM_REGCONF president = %u, own Node = %u, our dynamic id = %u",		       theData[2], 		       theData[1],		       theData[3]);}void getTextCM_REGREF(QQQQ) {  const char* line = "";  switch (theData[3]) {  case 0:    line = "Busy";    break;  case 1:    line = "Election with wait = false";    break;  case 2:    line = "Election with wait = false";    break;  case 3:    line = "Not president";    break;  case 4:    line = "Election without selecting new candidate";    break;  default:    line = "No such cause";    break;  }//switch  BaseString::snprintf(m_text, m_text_len, 		       "CM_REGREF from Node %u to our Node %u. Cause = %s", 		       theData[2], 		       theData[1], 		       line);}void getTextFIND_NEIGHBOURS(QQQQ) {  //-----------------------------------------------------------------------  // REPORT Node Restart copied a fragment.  //-----------------------------------------------------------------------  BaseString::snprintf(m_text, m_text_len, 		       "We are Node %u with dynamic ID %u, our left neighbour "		       "is Node %u, our right is Node %u", 		       theData[1], 		       theData[4], 		       theData[2], 		       theData[3]);}void getTextNodeFailCompleted(QQQQ) {  //-----------------------------------------------------------------------  // REPORT Node failure phase completed.  //-----------------------------------------------------------------------  if (theData[1] == 0)  {    if (theData[3] != 0) {      BaseString::snprintf(m_text, m_text_len, 			   "Node %u completed failure of Node %u", 			   theData[3], 			   theData[2]);    } else {      BaseString::snprintf(m_text, m_text_len, 			   "All nodes completed failure of Node %u", 			   theData[2]);    }//if        } else {    const char* line = "";    if (theData[1] == DBTC){      line = "DBTC";    }else if (theData[1] == DBDICT){      line = "DBDICT";    }else if (theData[1] == DBDIH){      line = "DBDIH";    }else if (theData[1] == DBLQH){      line = "DBLQH";    }    BaseString::snprintf(m_text, m_text_len, 			 "Node failure of %u %s completed", 			 theData[2], 			 line);  }}void getTextNODE_FAILREP(QQQQ) {  BaseString::snprintf(m_text, m_text_len, 		       "Node %u has failed. The Node state at failure "		       "was %u", 		       theData[1], 		       theData[2]); }void getTextArbitState(QQQQ) {  //-----------------------------------------------------------------------  // REPORT arbitrator found or lost.  //-----------------------------------------------------------------------  {    const ArbitSignalData* sd = (ArbitSignalData*)theData;    char ticketText[ArbitTicket::TextLength + 1];    char errText[ArbitCode::ErrTextLength + 1];    const unsigned code = sd->code & 0xFFFF;    const unsigned state = sd->code >> 16;    switch (code) {    case ArbitCode::ThreadStart:      BaseString::snprintf(m_text, m_text_len,			   "President restarts arbitration thread [state=%u]",			   state);      break;    case ArbitCode::PrepPart2:      sd->ticket.getText(ticketText, sizeof(ticketText));      BaseString::snprintf(m_text, m_text_len,			   "Prepare arbitrator node %u [ticket=%s]",			   sd->node, ticketText);      break;    case ArbitCode::PrepAtrun:      sd->ticket.getText(ticketText, sizeof(ticketText));      BaseString::snprintf(m_text, m_text_len,			   "Receive arbitrator node %u [ticket=%s]",			   sd->node, ticketText);      break;    case ArbitCode::ApiStart:      sd->ticket.getText(ticketText, sizeof(ticketText));      BaseString::snprintf(m_text, m_text_len,			   "Started arbitrator node %u [ticket=%s]",			   sd->node, ticketText);      break;    case ArbitCode::ApiFail:      BaseString::snprintf(m_text, m_text_len,			   "Lost arbitrator node %u - process failure [state=%u]",			   sd->node, state);      break;    case ArbitCode::ApiExit:      BaseString::snprintf(m_text, m_text_len,			   "Lost arbitrator node %u - process exit [state=%u]",			   sd->node, state);      break;    default:      ArbitCode::getErrText(code, errText, sizeof(errText));      BaseString::snprintf(m_text, m_text_len,			   "Lost arbitrator node %u - %s [state=%u]",			   sd->node, errText, state);      break;    }  }}void getTextArbitResult(QQQQ) {  //-----------------------------------------------------------------------  // REPORT arbitration result (the failures may not reach us).  //-----------------------------------------------------------------------  {    const ArbitSignalData* sd = (ArbitSignalData*)theData;    char errText[ArbitCode::ErrTextLength + 1];    const unsigned code = sd->code & 0xFFFF;

⌨️ 快捷键说明

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