diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2004-12-08 14:25:36 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2004-12-08 14:25:36 +0000 |
commit | 75b5e9d39f4ed782b5a4d96f7801597a803235bc (patch) | |
tree | 60035fbe48b3f279086a5ca0b8454be0f0453b6b /ndb | |
parent | 875cdfe3c965c1d38e30c04a9d42112936be76fb (diff) | |
parent | b89ef30962f3f5cc30c5a9cf6ea7ae4a034b48f0 (diff) | |
download | mariadb-git-75b5e9d39f4ed782b5a4d96f7801597a803235bc.tar.gz |
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-clean
ndb/src/mgmsrv/MgmtSrvr.cpp:
Auto merged
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/include/debugger/EventLogger.hpp | 5 | ||||
-rw-r--r-- | ndb/include/kernel/LogLevel.hpp | 12 | ||||
-rw-r--r-- | ndb/src/common/debugger/EventLogger.cpp | 35 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbTCP.cpp | 12 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 23 | ||||
-rw-r--r-- | ndb/src/mgmapi/mgmapi.cpp | 7 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.cpp | 34 | ||||
-rw-r--r-- | ndb/src/mgmsrv/MgmtSrvr.hpp | 19 | ||||
-rw-r--r-- | ndb/src/mgmsrv/Services.cpp | 63 | ||||
-rw-r--r-- | ndb/src/ndbapi/TransporterFacade.cpp | 4 |
10 files changed, 128 insertions, 86 deletions
diff --git a/ndb/include/debugger/EventLogger.hpp b/ndb/include/debugger/EventLogger.hpp index 686989089ae..b82c823ee0b 100644 --- a/ndb/include/debugger/EventLogger.hpp +++ b/ndb/include/debugger/EventLogger.hpp @@ -48,6 +48,11 @@ public: static const EventRepLogLevelMatrix matrix[]; static const Uint32 matrixSize; + static int + EventLoggerBase::event_lookup(int eventType, + LogLevel::EventCategory &cat, + Uint32 &threshold, + Logger::LoggerLevel &severity); }; /** diff --git a/ndb/include/kernel/LogLevel.hpp b/ndb/include/kernel/LogLevel.hpp index 467f0604edd..0ff4386da8e 100644 --- a/ndb/include/kernel/LogLevel.hpp +++ b/ndb/include/kernel/LogLevel.hpp @@ -73,7 +73,7 @@ public: /** * Note level is valid as 0-15 */ - void setLogLevel(EventCategory ec, Uint32 level = 7); + int setLogLevel(EventCategory ec, Uint32 level = 7); /** * Get the loglevel (0-15) for a category @@ -119,10 +119,14 @@ LogLevel::clear(){ } inline -void +int LogLevel::setLogLevel(EventCategory ec, Uint32 level){ - assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES); - logLevelData[ec] = (Uint8)level; + if (ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES) + { + logLevelData[ec] = (Uint8)level; + return 0; + } + return 1; } inline diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 59be0affcb4..8bb797b7855 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -1342,27 +1342,41 @@ operator<<(NdbOut& out, const LogLevel & ll) return out; } -void -EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, - const LogLevel* ll) +int +EventLoggerBase::event_lookup(int eventType, + LogLevel::EventCategory &cat, + Uint32 &threshold, + Logger::LoggerLevel &severity) { - Uint32 threshold = 0; - Logger::LoggerLevel severity = Logger::LL_WARNING; - LogLevel::EventCategory cat= LogLevel::llInvalid; - for(unsigned i = 0; i<EventLoggerBase::matrixSize; i++){ if(EventLoggerBase::matrix[i].eventType == eventType){ cat = EventLoggerBase::matrix[i].eventCategory; threshold = EventLoggerBase::matrix[i].threshold; severity = EventLoggerBase::matrix[i].severity; - break; + return 0; } } + return 1; +} + +void +EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, + const LogLevel* ll) +{ + Uint32 threshold = 0; + Logger::LoggerLevel severity = Logger::LL_WARNING; + LogLevel::EventCategory cat= LogLevel::llInvalid; + + DBUG_ENTER("EventLogger::log"); + DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId)); - if (cat == LogLevel::llInvalid) - return; + if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity)) + DBUG_VOID_RETURN; Uint32 set = ll?ll->getLogLevel(cat) : m_logLevel.getLogLevel(cat); + DBUG_PRINT("info",("threshold=%d, set=%d", threshold, set)); + if (ll) + DBUG_PRINT("info",("m_logLevel.getLogLevel=%d", m_logLevel.getLogLevel(cat))); if (threshold <= set){ switch (severity){ case Logger::LL_ALERT: @@ -1401,6 +1415,7 @@ EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, break; } } // if (.. + DBUG_VOID_RETURN; } int diff --git a/ndb/src/common/portlib/NdbTCP.cpp b/ndb/src/common/portlib/NdbTCP.cpp index 35b0c8c21e4..a63f5a7ba27 100644 --- a/ndb/src/common/portlib/NdbTCP.cpp +++ b/ndb/src/common/portlib/NdbTCP.cpp @@ -22,7 +22,7 @@ extern "C" int Ndb_getInAddr(struct in_addr * dst, const char *address) { - DBUG_ENTER("Ndb_getInAddr"); + // DBUG_ENTER("Ndb_getInAddr"); { int tmp_errno; struct hostent tmp_hostent, *hp; @@ -33,7 +33,7 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) { { memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length)); my_gethostbyname_r_free(); - DBUG_RETURN(0); + return 0; //DBUG_RETURN(0); } my_gethostbyname_r_free(); } @@ -47,11 +47,11 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) { #endif ) { - DBUG_RETURN(0); + return 0; //DBUG_RETURN(0); } - DBUG_PRINT("error",("inet_addr(%s) - %d - %s", - address, errno, strerror(errno))); - DBUG_RETURN(-1); + // DBUG_PRINT("error",("inet_addr(%s) - %d - %s", + // address, errno, strerror(errno))); + return -1; //DBUG_RETURN(-1); } #if 0 diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 234d832655c..af8668180f9 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -193,21 +193,11 @@ void Cmvmi::execEVENT_REP(Signal* signal) /** * If entry is not found */ - Uint32 threshold = 16; - LogLevel::EventCategory eventCategory = (LogLevel::EventCategory)0; - - for(unsigned int i = 0; i< EventLoggerBase::matrixSize; i++){ - if(EventLoggerBase::matrix[i].eventType == eventType){ - eventCategory = EventLoggerBase::matrix[i].eventCategory; - threshold = EventLoggerBase::matrix[i].threshold; - break; - } - } - - if(threshold > 15){ - // No entry found in matrix (or event that should never be printed) + Uint32 threshold; + LogLevel::EventCategory eventCategory; + Logger::LoggerLevel severity; + if (EventLoggerBase::event_lookup(eventType,eventCategory,threshold,severity)) return; - } SubscriberPtr ptr; for(subscribers.first(ptr); ptr.i != RNIL; subscribers.next(ptr)){ @@ -225,14 +215,15 @@ void Cmvmi::execEVENT_REP(Signal* signal) // Print the event info g_eventLogger.log(eventReport->getEventType(), signal->theData); + return; }//execEVENT_REP() void Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){ EventSubscribeReq * subReq = (EventSubscribeReq *)&signal->theData[0]; SubscriberPtr ptr; - jamEntry(); + DBUG_ENTER("Cmvmi::execEVENT_SUBSCRIBE_REQ"); /** * Search for subcription @@ -269,11 +260,13 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){ category = (LogLevel::EventCategory)(subReq->theData[i] >> 16); level = subReq->theData[i] & 0xFFFF; ptr.p->logLevel.setLogLevel(category, level); + DBUG_PRINT("info",("entry %d: level=%d, category= %d", i, level, category)); } } signal->theData[0] = ptr.i; sendSignal(ptr.p->blockRef, GSN_EVENT_SUBSCRIBE_CONF, signal, 1, JBB); + DBUG_VOID_RETURN; } void diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 59ab6c00258..1a4a10f9421 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1102,15 +1102,18 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId, "set cluster loglevel", &args); CHECK_REPLY(reply, -1); + DBUG_ENTER("ndb_mgm_set_loglevel_clusterlog"); + DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level)); + BaseString result; reply->get("result", result); if(strcmp(result.c_str(), "Ok") != 0) { SET_ERROR(handle, EINVAL, result.c_str()); delete reply; - return -1; + DBUG_RETURN(-1); } delete reply; - return 0; + DBUG_RETURN(0); } extern "C" diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index e1ab3633679..c5f08df8a6c 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -153,7 +153,7 @@ MgmtSrvr::logLevelThreadRun() * Handle started nodes */ EventSubscribeReq req; - req = m_statisticsListner.m_clients[0].m_logLevel; + req = m_event_listner[0].m_logLevel; req.blockRef = _ownReference; SetLogLevelOrd ord; @@ -409,7 +409,7 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server, _ownReference(0), theSignalIdleList(NULL), theWaitState(WAIT_SUBSCRIBE_CONF), - m_statisticsListner(this) + m_event_listner(this) { DBUG_ENTER("MgmtSrvr::MgmtSrvr"); @@ -547,16 +547,18 @@ MgmtSrvr::MgmtSrvr(SocketServer *socket_server, } } + // Setup clusterlog as client[0] in m_event_listner { - MgmStatService::StatListener se; + Ndb_mgmd_event_service::Event_listener se; se.m_socket = -1; for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++){ se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7); } se.m_logLevel.setLogLevel(LogLevel::llError, 15); + se.m_logLevel.setLogLevel(LogLevel::llConnection, 8); se.m_logLevel.setLogLevel(LogLevel::llBackup, 15); - m_statisticsListner.m_clients.push_back(se); - m_statisticsListner.m_logLevel = se.m_logLevel; + m_event_listner.m_clients.push_back(se); + m_event_listner.m_logLevel = se.m_logLevel; } DBUG_VOID_RETURN; @@ -2071,21 +2073,18 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode) void MgmtSrvr::handleStatus(NodeId nodeId, bool alive) { + DBUG_ENTER("MgmtSrvr::handleStatus"); + Uint32 theData[25]; + theData[1] = nodeId; if (alive) { m_started_nodes.push_back(nodeId); - Uint32 theData[25]; theData[0] = EventReport::Connected; - theData[1] = nodeId; - eventReport(_ownNodeId, theData); } else { handleStopReply(nodeId, 0); - - Uint32 theData[25]; theData[0] = EventReport::Disconnected; - theData[1] = nodeId; - - eventReport(_ownNodeId, theData); } + eventReport(_ownNodeId, theData); + DBUG_VOID_RETURN; } //**************************************************************************** @@ -2106,8 +2105,11 @@ void MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId, bool alive, bool nfComplete) { + DBUG_ENTER("MgmtSrvr::nodeStatusNotification"); + DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive, nfComplete)); if(!(!alive && nfComplete)) ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive); + DBUG_VOID_RETURN; } enum ndb_mgm_node_type @@ -2387,8 +2389,8 @@ MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData) EventReport::EventType type = eventReport->getEventType(); // Log event g_EventLogger.log(type, theData, nodeId, - &m_statisticsListner.m_clients[0].m_logLevel); - m_statisticsListner.log(type, theData, nodeId); + &m_event_listner[0].m_logLevel); + m_event_listner.log(type, theData, nodeId); } /*************************************************************************** @@ -2741,5 +2743,5 @@ template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbA #endif template class MutexVector<unsigned short>; -template class MutexVector<MgmStatService::StatListener>; +template class MutexVector<Ndb_mgmd_event_service::Event_listener>; template class MutexVector<EventSubscribeReq>; diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 4d5631d3eb6..0cad99e9d86 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -43,27 +43,30 @@ class Config; class SetLogLevelOrd; class SocketServer; -class MgmStatService : public EventLoggerBase +class Ndb_mgmd_event_service : public EventLoggerBase { friend class MgmtSrvr; public: - struct StatListener : public EventLoggerBase { + struct Event_listener : public EventLoggerBase { NDB_SOCKET_TYPE m_socket; }; private: class MgmtSrvr * m_mgmsrv; - MutexVector<StatListener> m_clients; + MutexVector<Event_listener> m_clients; public: - MgmStatService(class MgmtSrvr * m) : m_clients(5) { + Ndb_mgmd_event_service(class MgmtSrvr * m) : m_clients(5) { m_mgmsrv = m; } - void add_listener(const StatListener&); + void add_listener(const Event_listener&); void log(int eventType, const Uint32* theData, NodeId nodeId); - void stopSessions(); + void stop_sessions(); + + Event_listener& operator[](unsigned i) { return m_clients[i]; } + const Event_listener& operator[](unsigned i) const { return m_clients[i]; } }; /** @@ -732,8 +735,8 @@ private: LogLevel m_nodeLogLevel[MAX_NODES]; enum ndb_mgm_node_type nodeTypes[MAX_NODES]; friend class MgmApiSession; - friend class MgmStatService; - MgmStatService m_statisticsListner; + friend class Ndb_mgmd_event_service; + Ndb_mgmd_event_service m_event_listner; /** * Handles the thread wich upon a 'Node is started' event will diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 6ba2663c335..5b8d12e44d5 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -208,12 +208,12 @@ ParserRow<MgmApiSession> commands[] = { MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""), MGM_ARG("node", Int, Mandatory, "Node"), - MGM_ARG("category", String, Mandatory, "Event category"), + MGM_ARG("category", Int, Mandatory, "Event category"), MGM_ARG("level", Int, Mandatory, "Log level (0-15)"), MGM_CMD("set cluster loglevel", &MgmApiSession::setClusterLogLevel, ""), MGM_ARG("node", Int, Mandatory, "Node"), - MGM_ARG("category", String, Mandatory, "Event category"), + MGM_ARG("category", Int, Mandatory, "Event category"), MGM_ARG("level", Int, Mandatory, "Log level (0-15)"), MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""), @@ -781,20 +781,35 @@ MgmApiSession::bye(Parser<MgmApiSession>::Context &, void MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, Properties const &args) { - Uint32 node, level, category; + const char *reply= "set cluster loglevel reply"; + Uint32 node, level, cat; BaseString errorString; SetLogLevelOrd logLevel; int result; + DBUG_ENTER("MgmApiSession::setClusterLogLevel"); args.get("node", &node); - args.get("category", &category); + args.get("category", &cat); args.get("level", &level); + DBUG_PRINT("enter",("node=%d, category=%d, level=%d", node, cat, level)); + /* XXX should use constants for this value */ if(level > 15) { - m_output->println("set cluster loglevel reply"); - m_output->println("result: Invalid loglevel"); + m_output->println(reply); + m_output->println("result: Invalid loglevel %d", level); m_output->println(""); - return; + DBUG_VOID_RETURN; + } + + LogLevel::EventCategory category= + (LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL); + + if (m_mgmsrv.m_event_listner[0].m_logLevel.setLogLevel(category,level)) + { + m_output->println(reply); + m_output->println("result: Invalid category %d", category); + m_output->println(""); + DBUG_VOID_RETURN; } EventSubscribeReq req; @@ -802,10 +817,11 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, req.noOfEntries = 1; req.theData[0] = (category << 16) | level; m_mgmsrv.m_log_level_requests.push_back(req); - - m_output->println("set cluster loglevel reply"); + + m_output->println(reply); m_output->println("result: Ok"); m_output->println(""); + DBUG_VOID_RETURN; } void @@ -1263,21 +1279,17 @@ operator<<(NdbOut& out, const LogLevel & ll) } void -MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){ +Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId){ - Uint32 threshold = 0; - LogLevel::EventCategory cat= LogLevel::llInvalid; + Uint32 threshold; + LogLevel::EventCategory cat; + Logger::LoggerLevel severity; int i; + DBUG_ENTER("Ndb_mgmd_event_service::log"); + DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId)); - for(i = 0; (unsigned)i<EventLogger::matrixSize; i++){ - if(EventLogger::matrix[i].eventType == eventType){ - cat = EventLogger::matrix[i].eventCategory; - threshold = EventLogger::matrix[i].threshold; - break; - } - } - if (cat == LogLevel::llInvalid) - return; + if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity)) + DBUG_VOID_RETURN; char m_text[256]; EventLogger::getText(m_text, sizeof(m_text), eventType, theData, nodeId); @@ -1316,10 +1328,11 @@ MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){ m_mgmsrv->m_log_level_requests.push_back(req); } } + DBUG_VOID_RETURN; } void -MgmStatService::add_listener(const StatListener& client){ +Ndb_mgmd_event_service::add_listener(const Event_listener& client){ m_clients.push_back(client); LogLevel tmp = m_logLevel; tmp.set_max(client.m_logLevel); @@ -1334,7 +1347,7 @@ MgmStatService::add_listener(const StatListener& client){ } void -MgmStatService::stopSessions(){ +Ndb_mgmd_event_service::stop_sessions(){ for(int i = m_clients.size() - 1; i >= 0; i--){ if(m_clients[i].m_socket >= 0){ NDB_CLOSE_SOCKET(m_clients[i].m_socket); @@ -1374,7 +1387,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx, int result = 0; BaseString msg; - MgmStatService::StatListener le; + Ndb_mgmd_event_service::Event_listener le; le.m_socket = m_socket; Vector<BaseString> list; @@ -1419,7 +1432,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx, goto done; } - m_mgmsrv.m_statisticsListner.add_listener(le); + m_mgmsrv.m_event_listner.add_listener(le); m_stop = true; m_socket = -1; diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index dfb090c8416..031ee6315e8 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -626,6 +626,9 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId) * After the restart the node is up again and the Ndb object * might not have noticed the failure. */ + + DBUG_ENTER("TransporterFacade::ReportNodeFailureComplete"); + DBUG_PRINT("enter",("nodeid= %d", tNodeId)); Uint32 sz = m_threads.m_statusNext.size(); for (Uint32 i = 0; i < sz ; i ++) { if (m_threads.getInUse(i)){ @@ -634,6 +637,7 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId) (*RegPC) (obj, tNodeId, false, true); } } + DBUG_VOID_RETURN; } void |