Commit 2468e5ba authored by unknown's avatar unknown

wl1668 -

Add support for getting events via mgmapi
removed all traces of stat port


BitKeeper/deleted/.del-NodeLogLevel.cpp~324045b93af7123b:
  Delete: ndb/src/mgmsrv/NodeLogLevel.cpp
BitKeeper/deleted/.del-NodeLogLevel.hpp~4f4ab0fe52fb497c:
  Delete: ndb/src/mgmsrv/NodeLogLevel.hpp
BitKeeper/deleted/.del-NodeLogLevelList.cpp~97dc9c909e3e92bf:
  Delete: ndb/src/mgmsrv/NodeLogLevelList.cpp
BitKeeper/deleted/.del-NodeLogLevelList.hpp~ef567dd850abddc7:
  Delete: ndb/src/mgmsrv/NodeLogLevelList.hpp
ndb/include/debugger/EventLogger.hpp:
  Split EventLogger into two classes
ndb/include/kernel/LogLevel.hpp:
  Add some nice to have methods + use uint8 for storage
ndb/include/kernel/signaldata/EventSubscribeReq.hpp:
  operator=
ndb/include/kernel/signaldata/SetLogLevelOrd.hpp:
  operator=
ndb/include/mgmapi/mgmapi.h:
  remove deprecated vars
ndb/src/common/debugger/EventLogger.cpp:
  Split into 2
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  Remove hardcoded mgm stuff
ndb/src/mgmsrv/CommandInterpreter.cpp:
  #if 0
  some deprecated code
ndb/src/mgmsrv/Makefile.am:
  remove NodeLogLevel*
ndb/src/mgmsrv/MgmtSrvr.cpp:
  Remove dead code
  Handle multiple event listeners in mgmapi
ndb/src/mgmsrv/MgmtSrvr.hpp:
  Remove dead code
  Handle multiple event listeners in mgmapi
ndb/src/mgmsrv/Services.cpp:
  listen event method in mgmapi
ndb/src/mgmsrv/Services.hpp:
  listen event method in mgmapi
ndb/src/mgmsrv/main.cpp:
  remove stat port
parent 3e78c89e
...@@ -24,6 +24,65 @@ ...@@ -24,6 +24,65 @@
#include <kernel/LogLevel.hpp> #include <kernel/LogLevel.hpp>
#include <signaldata/EventReport.hpp> #include <signaldata/EventReport.hpp>
class EventLoggerBase {
public:
virtual ~EventLoggerBase();
/**
* LogLevel settings
*/
LogLevel m_logLevel;
/**
* Find a category matching the string
*
* @param str string to match.
* @param cat the event category.
* @param exactMatch only do exact matching.
*
* @return TRUE if match is found, then cat is modified
* FALSE if match is not found
*/
static bool matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch = false);
/**
* Returns category name or NULL if not found.
*
* @param cat the event category.
* @return category name.
*/
static const char * getEventCategoryName(LogLevel::EventCategory cat);
/**
* Specifies allowed event categories/log levels.
*/
struct EventCategoryName {
LogLevel::EventCategory category;
const char * name;
};
static const EventCategoryName eventCategoryNames[];
static const Uint32 noOfEventCategoryNames;
/**
* This matrix defines which event should be printed when
*
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
struct EventRepLogLevelMatrix {
EventReport::EventType eventType;
LogLevel::EventCategory eventCategory;
Uint32 threshold;
Logger::LoggerLevel severity;
};
static const EventRepLogLevelMatrix matrix[];
static const Uint32 matrixSize;
};
/** /**
* The EventLogger is primarily used for logging NDB events * The EventLogger is primarily used for logging NDB events
* in the Management Server. It inherits all logging functionality of Logger. * in the Management Server. It inherits all logging functionality of Logger.
...@@ -58,7 +117,7 @@ ...@@ -58,7 +117,7 @@
* @see Logger * @see Logger
* @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $ * @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $
*/ */
class EventLogger : public Logger class EventLogger : public EventLoggerBase, public Logger
{ {
public: public:
/** /**
...@@ -70,7 +129,7 @@ public: ...@@ -70,7 +129,7 @@ public:
/** /**
* Destructor. * Destructor.
*/ */
~EventLogger(); virtual ~EventLogger();
/** /**
* Opens/creates the eventlog with the specified filename. * Opens/creates the eventlog with the specified filename.
...@@ -92,16 +151,6 @@ public: ...@@ -92,16 +151,6 @@ public:
*/ */
void close(); void close();
/**
* Logs the NDB event.
*
* @param nodeId the node id of event origin.
* @param eventType the type of event.
* @param theData the event data.
* @deprecated use log(int eventType, const Uint32* theData, NodeId nodeId)
*/
void log(NodeId nodeId, int eventType, const Uint32* theData);
/** /**
* Logs the NDB event. * Logs the NDB event.
* *
...@@ -109,16 +158,19 @@ public: ...@@ -109,16 +158,19 @@ public:
* @param theData the event data. * @param theData the event data.
* @param nodeId the node id of event origin. * @param nodeId the node id of event origin.
*/ */
void log(int eventType, const Uint32* theData, NodeId nodeId = 0); virtual void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
/** /**
* Returns the current log levels. * Returns the event text for the specified event report type.
* Enable, disable log levels to filter the events that are sent to the
* eventlog.
* *
* @return the log level. * @param type the event type.
* @param theData the event data.
* @param nodeId a node id.
* @return the event report text.
*/ */
LogLevel& getLoglevel(); static const char* getText(char * dst, size_t dst_len,
int type,
const Uint32* theData, NodeId nodeId = 0);
/** /**
* Returns the log level that is used to filter an event. The event will not * Returns the log level that is used to filter an event. The event will not
...@@ -127,6 +179,7 @@ public: ...@@ -127,6 +179,7 @@ public:
* @return the log level filter that is used for all event categories. * @return the log level filter that is used for all event categories.
*/ */
int getFilterLevel() const; int getFilterLevel() const;
/** /**
* Sets log level filter. The event will be logged if * Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'. * the event category's log level is <= 'filterLevel'.
...@@ -135,92 +188,16 @@ public: ...@@ -135,92 +188,16 @@ public:
*/ */
void setFilterLevel(int filterLevel); void setFilterLevel(int filterLevel);
/**
* Returns the event text for the specified event report type.
*
* @param type the event type.
* @param theData the event data.
* @param nodeId a node id.
* @return the event report text.
*/
static const char* getText(int type,
const Uint32* theData, NodeId nodeId = 0);
/**
* Find a category matching the string
*
* @param str string to match.
* @param cat the event category.
* @param exactMatch only do exact matching.
*
* @return TRUE if match is found, then cat is modified
* FALSE if match is not found
*/
static bool matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch = false);
/**
* Returns category name or NULL if not found.
*
* @param cat the event category.
* @return category name.
*/
static const char * getEventCategoryName(LogLevel::EventCategory cat);
/**
* Specifies allowed event categories/log levels.
*/
struct EventCategoryName {
LogLevel::EventCategory category;
const char * name;
};
static const EventCategoryName eventCategoryNames[];
static const Uint32 noOfEventCategoryNames;
/**
* This matrix defines which event should be printed when
*
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
struct EventRepLogLevelMatrix {
EventReport::EventType eventType;
LogLevel::EventCategory eventCategory;
Uint32 threshold;
Logger::LoggerLevel severity;
};
static const EventRepLogLevelMatrix matrix[];
/**
* Default log levels for management nodes.
*
* threshold - is in range [0-15]
*/
struct EventLogMatrix {
LogLevel::EventCategory eventCategory;
Uint32 threshold;
};
static const EventLogMatrix defEventLogMatrix[];
static const Uint32 matrixSize;
static const Uint32 defEventLogMatrixSize;
private: private:
/** Prohibit */ /** Prohibit */
EventLogger(const EventLogger&); EventLogger(const EventLogger&);
EventLogger operator = (const EventLogger&); EventLogger operator = (const EventLogger&);
bool operator == (const EventLogger&); bool operator == (const EventLogger&);
LogLevel m_logLevel;
Uint32 m_filterLevel; Uint32 m_filterLevel;
STATIC_CONST(MAX_TEXT_LENGTH = 256); STATIC_CONST(MAX_TEXT_LENGTH = 256);
static char m_text[MAX_TEXT_LENGTH]; char m_text[MAX_TEXT_LENGTH];
}; };
......
...@@ -130,18 +130,25 @@ public: ...@@ -130,18 +130,25 @@ public:
*/ */
Uint32 getLogLevel(EventCategory ec) const; Uint32 getLogLevel(EventCategory ec) const;
/**
* Set this= max(this, ll) per category
*/
LogLevel& set_max(const LogLevel& ll);
bool operator==(const LogLevel& l) const {
return memcmp(this, &l, sizeof(* this)) == 0;
}
private: private:
/** /**
* The actual data * The actual data
*/ */
Uint32 logLevelData[LOGLEVEL_CATEGORIES]; Uint8 logLevelData[LOGLEVEL_CATEGORIES];
LogLevel(const LogLevel &);
}; };
inline inline
LogLevel::LogLevel(){ LogLevel::LogLevel(){
clear(); clear();
} }
inline inline
...@@ -176,5 +183,14 @@ LogLevel::getLogLevel(EventCategory ec) const{ ...@@ -176,5 +183,14 @@ LogLevel::getLogLevel(EventCategory ec) const{
return logLevelData[ec]; return logLevelData[ec];
} }
inline
LogLevel &
LogLevel::set_max(const LogLevel & org){
for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
if(logLevelData[i] < org.logLevelData[i])
logLevelData[i] = org.logLevelData[i];
}
return * this;
}
#endif #endif
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* RECIVER: SimBlockCMCtrBlck * RECIVER: SimBlockCMCtrBlck
*/ */
class EventSubscribeReq { struct EventSubscribeReq {
/** /**
* Receiver(s) * Receiver(s)
*/ */
...@@ -38,9 +38,8 @@ class EventSubscribeReq { ...@@ -38,9 +38,8 @@ class EventSubscribeReq {
*/ */
friend class MgmtSrvr; friend class MgmtSrvr;
public:
STATIC_CONST( SignalLength = 22 ); STATIC_CONST( SignalLength = 22 );
private:
/** /**
* Note: If you use the same blockRef as you have used earlier, * Note: If you use the same blockRef as you have used earlier,
* you update your ongoing subscription * you update your ongoing subscription
...@@ -55,6 +54,15 @@ private: ...@@ -55,6 +54,15 @@ private:
Uint32 theCategories[10]; Uint32 theCategories[10];
Uint32 theLevels[10]; Uint32 theLevels[10];
EventSubscribeReq& operator= (const LogLevel& ll){
noOfEntries = _LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theCategories[i] = i;
theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
}; };
#endif #endif
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define SET_LOGLEVEL_ORD_HPP #define SET_LOGLEVEL_ORD_HPP
#include <LogLevel.hpp> #include <LogLevel.hpp>
#include "EventSubscribeReq.hpp"
#include "SignalData.hpp" #include "SignalData.hpp"
/** /**
...@@ -51,6 +52,24 @@ private: ...@@ -51,6 +52,24 @@ private:
* Note level is valid as 0-15 * Note level is valid as 0-15
*/ */
void setLogLevel(LogLevel::EventCategory ec, int level = 7); void setLogLevel(LogLevel::EventCategory ec, int level = 7);
SetLogLevelOrd& operator= (const LogLevel& ll){
noOfEntries = _LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theCategories[i] = i;
theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
noOfEntries = ll.noOfEntries;
for(size_t i = 0; i<noOfEntries; i++){
theCategories[i] = ll.theCategories[i];
theLevels[i] = ll.theLevels[i];
}
return * this;
}
}; };
inline inline
......
...@@ -55,24 +55,6 @@ ...@@ -55,24 +55,6 @@
extern "C" { extern "C" {
#endif #endif
/**
* Format of statistical information from the NDB Cluster.
* STATISTIC_LINE is sent on the statistical port from the Management server,
* each line is timestamped with STATISTIC_DATE.
*/
#define STATISTIC_LINE "date=%s epochsecs=%d nodeid=%u trans=%u commit=%u " \
"read=%u insert=%u attrinfo=%u cops=%u abort=%u"
/**
* Format of statistical information from the NDB Cluster.
* STATISTIC_LINE is sent on the statistical port from the Management server,
* each line is timestamped with STATISTIC_DATE.
*/
#define STATISTIC_DATE "%d-%.2d-%.2d/%.2d:%.2d:%.2d"
/**
* Format of statistical information from the NDB Cluster.
*/
#define OP_STATISTIC_LINE "date=%s epochsecs=%d nodeid=%d operations=%u"
/** /**
* The NdbMgmHandle. * The NdbMgmHandle.
*/ */
......
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
// //
// PUBLIC // PUBLIC
// //
EventLoggerBase::~EventLoggerBase()
{
}
/** /**
* This matrix defines which event should be printed when * This matrix defines which event should be printed when
...@@ -35,105 +39,86 @@ ...@@ -35,105 +39,86 @@
* threshold - is in range [0-15] * threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message) * severity - DEBUG to ALERT (Type of log message)
*/ */
const EventLogger::EventRepLogLevelMatrix EventLogger::matrix[] = { const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
// CONNECTION // CONNECTION
{ EventReport::Connected, LogLevel::llConnection, 8, LL_INFO }, { EventReport::Connected, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::Disconnected, LogLevel::llConnection, 8, LL_ALERT }, { EventReport::Disconnected, LogLevel::llConnection, 8, Logger::LL_ALERT },
{ EventReport::CommunicationClosed, LogLevel::llConnection, 8, LL_INFO }, { EventReport::CommunicationClosed, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::CommunicationOpened, LogLevel::llConnection, 8, LL_INFO }, { EventReport::CommunicationOpened, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, LL_INFO }, { EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, Logger::LL_INFO },
// CHECKPOINT // CHECKPOINT
{ EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, LL_INFO }, { EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, Logger::LL_INFO },
{ EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, LL_INFO }, { EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, Logger::LL_INFO },
{ EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, LL_INFO }, { EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
{ EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, LL_INFO }, { EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, Logger::LL_INFO },
{ EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, LL_ALERT }, { EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, Logger::LL_ALERT },
{ EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, LL_INFO }, { EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, Logger::LL_INFO },
{ EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, LL_INFO }, { EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
// STARTUP // STARTUP
{ EventReport::NDBStartStarted, LogLevel::llStartUp, 1, LL_INFO }, { EventReport::NDBStartStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, LL_INFO }, { EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::STTORRYRecieved, LogLevel::llStartUp,15, LL_INFO }, { EventReport::STTORRYRecieved, LogLevel::llStartUp,15, Logger::LL_INFO },
{ EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, LL_INFO }, { EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, Logger::LL_INFO },
{ EventReport::CM_REGCONF, LogLevel::llStartUp, 3, LL_INFO }, { EventReport::CM_REGCONF, LogLevel::llStartUp, 3, Logger::LL_INFO },
{ EventReport::CM_REGREF, LogLevel::llStartUp, 8, LL_INFO }, { EventReport::CM_REGREF, LogLevel::llStartUp, 8, Logger::LL_INFO },
{ EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, LL_INFO }, { EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, Logger::LL_INFO },
{ EventReport::NDBStopStarted, LogLevel::llStartUp, 1, LL_INFO }, { EventReport::NDBStopStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::NDBStopAborted, LogLevel::llStartUp, 1, LL_INFO }, { EventReport::NDBStopAborted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::StartREDOLog, LogLevel::llStartUp, 10, LL_INFO }, { EventReport::StartREDOLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
{ EventReport::StartLog, LogLevel::llStartUp, 10, LL_INFO }, { EventReport::StartLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
{ EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, LL_INFO }, { EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, Logger::LL_INFO },
// NODERESTART // NODERESTART
{ EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, LL_INFO }, { EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, LL_INFO }, { EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, LL_INFO }, { EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, LL_INFO }, { EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, Logger::LL_INFO },
{ EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, LL_INFO }, { EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, LL_ALERT}, { EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
{ EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, LL_ALERT}, { EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
{ EventReport::ArbitState, LogLevel::llNodeRestart, 6, LL_INFO }, { EventReport::ArbitState, LogLevel::llNodeRestart, 6, Logger::LL_INFO },
{ EventReport::ArbitResult, LogLevel::llNodeRestart, 2, LL_ALERT}, { EventReport::ArbitResult, LogLevel::llNodeRestart, 2, Logger::LL_ALERT},
{ EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO }, { EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO }, { EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO }, { EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO }, { EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
// STATISTIC // STATISTIC
{ EventReport::TransReportCounters, LogLevel::llStatistic, 8, LL_INFO }, { EventReport::TransReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
{ EventReport::OperationReportCounters, LogLevel::llStatistic, 8, LL_INFO }, { EventReport::OperationReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
{ EventReport::TableCreated, LogLevel::llStatistic, 7, LL_INFO }, { EventReport::TableCreated, LogLevel::llStatistic, 7, Logger::LL_INFO },
{ EventReport::JobStatistic, LogLevel::llStatistic, 9, LL_INFO }, { EventReport::JobStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, LL_INFO }, { EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, LL_INFO }, { EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::MemoryUsage, LogLevel::llStatistic, 5, LL_INFO }, { EventReport::MemoryUsage, LogLevel::llStatistic, 5, Logger::LL_INFO },
// ERROR // ERROR
{ EventReport::TransporterError, LogLevel::llError, 2, LL_ERROR }, { EventReport::TransporterError, LogLevel::llError, 2, Logger::LL_ERROR },
{ EventReport::TransporterWarning, LogLevel::llError, 8, LL_WARNING }, { EventReport::TransporterWarning, LogLevel::llError, 8, Logger::LL_WARNING },
{ EventReport::MissedHeartbeat, LogLevel::llError, 8, LL_WARNING }, { EventReport::MissedHeartbeat, LogLevel::llError, 8, Logger::LL_WARNING },
{ EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, LL_ALERT }, { EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, Logger::LL_ALERT },
{ EventReport::WarningEvent, LogLevel::llError, 2, LL_WARNING }, { EventReport::WarningEvent, LogLevel::llError, 2, Logger::LL_WARNING },
// INFO // INFO
{ EventReport::SentHeartbeat, LogLevel::llInfo, 12, LL_INFO }, { EventReport::SentHeartbeat, LogLevel::llInfo, 12, Logger::LL_INFO },
{ EventReport::CreateLogBytes, LogLevel::llInfo, 11, LL_INFO }, { EventReport::CreateLogBytes, LogLevel::llInfo, 11, Logger::LL_INFO },
{ EventReport::InfoEvent, LogLevel::llInfo, 2, LL_INFO }, { EventReport::InfoEvent, LogLevel::llInfo, 2, Logger::LL_INFO },
//Global replication //Global replication
{ EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, LL_INFO}, { EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, Logger::LL_INFO},
{ EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, LL_ALERT} { EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, Logger::LL_ALERT}
}; };
const Uint32 EventLogger::matrixSize = sizeof(EventLogger::matrix)/ const Uint32 EventLoggerBase::matrixSize = sizeof(EventLoggerBase::matrix)/
sizeof(EventRepLogLevelMatrix); sizeof(EventRepLogLevelMatrix);
/**
* Default log levels for management nodes.
*
* threshold - is in range [0-15]
*/
const EventLogger::EventLogMatrix EventLogger::defEventLogMatrix[] = {
{ LogLevel::llStartUp, 7 },
{ LogLevel::llShutdown, 7 },
{ LogLevel::llStatistic, 7 },
{ LogLevel::llCheckpoint, 7 },
{ LogLevel::llNodeRestart, 7 },
{ LogLevel::llConnection, 7 },
{ LogLevel::llError, 15 },
{ LogLevel::llInfo, 7 },
{ LogLevel::llGrep, 7 }
};
const Uint32
EventLogger::defEventLogMatrixSize = sizeof(EventLogger::defEventLogMatrix)/
sizeof(EventLogMatrix);
/** /**
* Specifies allowed event categories/log levels that can be set from * Specifies allowed event categories/log levels that can be set from
* the Management API/interactive shell. * the Management API/interactive shell.
*/ */
const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = { const EventLoggerBase::EventCategoryName
EventLoggerBase::eventCategoryNames[] = {
{ LogLevel::llStartUp, "STARTUP" }, { LogLevel::llStartUp, "STARTUP" },
{ LogLevel::llStatistic, "STATISTICS" }, { LogLevel::llStatistic, "STATISTICS" },
{ LogLevel::llCheckpoint, "CHECKPOINT" }, { LogLevel::llCheckpoint, "CHECKPOINT" },
...@@ -144,13 +129,13 @@ const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = { ...@@ -144,13 +129,13 @@ const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = {
}; };
const Uint32 const Uint32
EventLogger::noOfEventCategoryNames = sizeof(EventLogger::eventCategoryNames)/ EventLoggerBase::noOfEventCategoryNames =
sizeof(EventLogger::EventCategoryName); sizeof(EventLoggerBase::eventCategoryNames)/
sizeof(EventLoggerBase::EventCategoryName);
char EventLogger::m_text[MAX_TEXT_LENGTH];
const char* const char*
EventLogger::getText(int type, EventLogger::getText(char * m_text, size_t m_text_len,
int type,
const Uint32* theData, NodeId nodeId) const Uint32* theData, NodeId nodeId)
{ {
// TODO: Change the switch implementation... // TODO: Change the switch implementation...
...@@ -164,13 +149,13 @@ EventLogger::getText(int type, ...@@ -164,13 +149,13 @@ EventLogger::getText(int type,
EventReport::EventType eventType = (EventReport::EventType)type; EventReport::EventType eventType = (EventReport::EventType)type;
switch (eventType){ switch (eventType){
case EventReport::Connected: case EventReport::Connected:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode %u Connected", "%sNode %u Connected",
theNodeId, theNodeId,
theData[1]); theData[1]);
break; break;
case EventReport::ConnectedApiVersion: case EventReport::ConnectedApiVersion:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode %u: API version %d.%d.%d", "%sNode %u: API version %d.%d.%d",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -179,7 +164,7 @@ EventLogger::getText(int type, ...@@ -179,7 +164,7 @@ EventLogger::getText(int type,
getBuild(theData[2])); getBuild(theData[2]));
break; break;
case EventReport::Disconnected: case EventReport::Disconnected:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode %u Disconnected", "%sNode %u Disconnected",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -188,7 +173,7 @@ EventLogger::getText(int type, ...@@ -188,7 +173,7 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// REPORT communication to node closed. // REPORT communication to node closed.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sCommunication to Node %u closed", "%sCommunication to Node %u closed",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -197,7 +182,7 @@ EventLogger::getText(int type, ...@@ -197,7 +182,7 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// REPORT communication to node opened. // REPORT communication to node opened.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sCommunication to Node %u opened", "%sCommunication to Node %u opened",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -206,7 +191,7 @@ EventLogger::getText(int type, ...@@ -206,7 +191,7 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Start of NDB has been initiated. // Start of NDB has been initiated.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sStart initiated (version %d.%d.%d)", "%sStart initiated (version %d.%d.%d)",
theNodeId , theNodeId ,
getMajor(theData[1]), getMajor(theData[1]),
...@@ -214,13 +199,13 @@ EventLogger::getText(int type, ...@@ -214,13 +199,13 @@ EventLogger::getText(int type,
getBuild(theData[1])); getBuild(theData[1]));
break; break;
case EventReport::NDBStopStarted: case EventReport::NDBStopStarted:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%s%s shutdown initiated", "%s%s shutdown initiated",
theNodeId, theNodeId,
(theData[1] == 1 ? "Cluster" : "Node")); (theData[1] == 1 ? "Cluster" : "Node"));
break; break;
case EventReport::NDBStopAborted: case EventReport::NDBStopAborted:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode shutdown aborted", "%sNode shutdown aborted",
theNodeId); theNodeId);
break; break;
...@@ -228,7 +213,7 @@ EventLogger::getText(int type, ...@@ -228,7 +213,7 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Start of NDB has been completed. // Start of NDB has been completed.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sStarted (version %d.%d.%d)", "%sStarted (version %d.%d.%d)",
theNodeId , theNodeId ,
getMajor(theData[1]), getMajor(theData[1]),
...@@ -240,7 +225,7 @@ EventLogger::getText(int type, ...@@ -240,7 +225,7 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// STTORRY recevied after restart finished. // STTORRY recevied after restart finished.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sSTTORRY received after restart finished", "%sSTTORRY received after restart finished",
theNodeId); theNodeId);
break; break;
...@@ -266,7 +251,7 @@ EventLogger::getText(int type, ...@@ -266,7 +251,7 @@ EventLogger::getText(int type,
type = ""; type = "";
break; break;
default:{ default:{
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sStart phase %u completed (unknown = %d)", "%sStart phase %u completed (unknown = %d)",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -274,7 +259,7 @@ EventLogger::getText(int type, ...@@ -274,7 +259,7 @@ EventLogger::getText(int type,
return m_text; return m_text;
} }
} }
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sStart phase %u completed %s", "%sStart phase %u completed %s",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -283,7 +268,7 @@ EventLogger::getText(int type, ...@@ -283,7 +268,7 @@ EventLogger::getText(int type,
break; break;
} }
case EventReport::CM_REGCONF: case EventReport::CM_REGCONF:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sCM_REGCONF president = %u, own Node = %u, our dynamic id = %u" "%sCM_REGCONF president = %u, own Node = %u, our dynamic id = %u"
, ,
theNodeId, theNodeId,
...@@ -315,7 +300,7 @@ EventLogger::getText(int type, ...@@ -315,7 +300,7 @@ EventLogger::getText(int type,
break; break;
}//switch }//switch
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sCM_REGREF from Node %u to our Node %u. Cause = %s", "%sCM_REGREF from Node %u to our Node %u. Cause = %s",
theNodeId, theNodeId,
theData[2], theData[2],
...@@ -328,7 +313,7 @@ EventLogger::getText(int type, ...@@ -328,7 +313,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment. // REPORT Node Restart copied a fragment.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sWe are Node %u with dynamic ID %u, our left neighbour " "%sWe are Node %u with dynamic ID %u, our left neighbour "
"is Node %u, our right is Node %u", "is Node %u, our right is Node %u",
theNodeId, theNodeId,
...@@ -344,13 +329,13 @@ EventLogger::getText(int type, ...@@ -344,13 +329,13 @@ EventLogger::getText(int type,
if (theData[1] == 0) if (theData[1] == 0)
{ {
if (theData[3] != 0) { if (theData[3] != 0) {
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode %u completed failure of Node %u", "%sNode %u completed failure of Node %u",
theNodeId, theNodeId,
theData[3], theData[3],
theData[2]); theData[2]);
} else { } else {
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sAll nodes completed failure of Node %u", "%sAll nodes completed failure of Node %u",
theNodeId, theNodeId,
theData[2]); theData[2]);
...@@ -367,7 +352,7 @@ EventLogger::getText(int type, ...@@ -367,7 +352,7 @@ EventLogger::getText(int type,
line = "DBLQH"; line = "DBLQH";
} }
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNode failure of %u %s completed", "%sNode failure of %u %s completed",
theNodeId, theNodeId,
theData[2], theData[2],
...@@ -376,7 +361,7 @@ EventLogger::getText(int type, ...@@ -376,7 +361,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::NODE_FAILREP: case EventReport::NODE_FAILREP:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode %u has failed. The Node state at failure " "%sNode %u has failed. The Node state at failure "
"was %u", "was %u",
theNodeId, theNodeId,
...@@ -395,41 +380,41 @@ EventLogger::getText(int type, ...@@ -395,41 +380,41 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16; const unsigned state = sd->code >> 16;
switch (code) { switch (code) {
case ArbitCode::ThreadStart: case ArbitCode::ThreadStart:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sPresident restarts arbitration thread [state=%u]", "%sPresident restarts arbitration thread [state=%u]",
theNodeId, state); theNodeId, state);
break; break;
case ArbitCode::PrepPart2: case ArbitCode::PrepPart2:
sd->ticket.getText(ticketText, sizeof(ticketText)); sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sPrepare arbitrator node %u [ticket=%s]", "%sPrepare arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText); theNodeId, sd->node, ticketText);
break; break;
case ArbitCode::PrepAtrun: case ArbitCode::PrepAtrun:
sd->ticket.getText(ticketText, sizeof(ticketText)); sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sReceive arbitrator node %u [ticket=%s]", "%sReceive arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText); theNodeId, sd->node, ticketText);
break; break;
case ArbitCode::ApiStart: case ArbitCode::ApiStart:
sd->ticket.getText(ticketText, sizeof(ticketText)); sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sStarted arbitrator node %u [ticket=%s]", "%sStarted arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText); theNodeId, sd->node, ticketText);
break; break;
case ArbitCode::ApiFail: case ArbitCode::ApiFail:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process failure [state=%u]", "%sLost arbitrator node %u - process failure [state=%u]",
theNodeId, sd->node, state); theNodeId, sd->node, state);
break; break;
case ArbitCode::ApiExit: case ArbitCode::ApiExit:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process exit [state=%u]", "%sLost arbitrator node %u - process exit [state=%u]",
theNodeId, sd->node, state); theNodeId, sd->node, state);
break; break;
default: default:
ArbitCode::getErrText(code, errText, sizeof(errText)); ArbitCode::getErrText(code, errText, sizeof(errText));
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - %s [state=%u]", "%sLost arbitrator node %u - %s [state=%u]",
theNodeId, sd->node, errText, state); theNodeId, sd->node, errText, state);
break; break;
...@@ -446,48 +431,48 @@ EventLogger::getText(int type, ...@@ -446,48 +431,48 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16; const unsigned state = sd->code >> 16;
switch (code) { switch (code) {
case ArbitCode::LoseNodes: case ArbitCode::LoseNodes:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration check lost - less than 1/2 nodes left", "%sArbitration check lost - less than 1/2 nodes left",
theNodeId); theNodeId);
break; break;
case ArbitCode::WinGroups: case ArbitCode::WinGroups:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration check won - node group majority", "%sArbitration check won - node group majority",
theNodeId); theNodeId);
break; break;
case ArbitCode::LoseGroups: case ArbitCode::LoseGroups:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration check lost - missing node group", "%sArbitration check lost - missing node group",
theNodeId); theNodeId);
break; break;
case ArbitCode::Partitioning: case ArbitCode::Partitioning:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - arbitration required", "%sNetwork partitioning - arbitration required",
theNodeId); theNodeId);
break; break;
case ArbitCode::WinChoose: case ArbitCode::WinChoose:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration won - positive reply from node %u", "%sArbitration won - positive reply from node %u",
theNodeId, sd->node); theNodeId, sd->node);
break; break;
case ArbitCode::LoseChoose: case ArbitCode::LoseChoose:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration lost - negative reply from node %u", "%sArbitration lost - negative reply from node %u",
theNodeId, sd->node); theNodeId, sd->node);
break; break;
case ArbitCode::LoseNorun: case ArbitCode::LoseNorun:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator available", "%sNetwork partitioning - no arbitrator available",
theNodeId); theNodeId);
break; break;
case ArbitCode::LoseNocfg: case ArbitCode::LoseNocfg:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator configured", "%sNetwork partitioning - no arbitrator configured",
theNodeId); theNodeId);
break; break;
default: default:
ArbitCode::getErrText(code, errText, sizeof(errText)); ArbitCode::getErrText(code, errText, sizeof(errText));
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sArbitration failure - %s [state=%u]", "%sArbitration failure - %s [state=%u]",
theNodeId, errText, state); theNodeId, errText, state);
break; break;
...@@ -500,7 +485,7 @@ EventLogger::getText(int type, ...@@ -500,7 +485,7 @@ EventLogger::getText(int type,
// node is the master of this global checkpoint. // node is the master of this global checkpoint.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sGlobal checkpoint %u started", "%sGlobal checkpoint %u started",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -510,7 +495,7 @@ EventLogger::getText(int type, ...@@ -510,7 +495,7 @@ EventLogger::getText(int type,
// This event reports that a global checkpoint has been completed on this // This event reports that a global checkpoint has been completed on this
// node and the node is the master of this global checkpoint. // node and the node is the master of this global checkpoint.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sGlobal checkpoint %u completed", "%sGlobal checkpoint %u completed",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -521,7 +506,7 @@ EventLogger::getText(int type, ...@@ -521,7 +506,7 @@ EventLogger::getText(int type,
// node is the master of this local checkpoint. // node is the master of this local checkpoint.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLocal checkpoint %u started. " "%sLocal checkpoint %u started. "
"Keep GCI = %u oldest restorable GCI = %u", "Keep GCI = %u oldest restorable GCI = %u",
theNodeId, theNodeId,
...@@ -535,7 +520,7 @@ EventLogger::getText(int type, ...@@ -535,7 +520,7 @@ EventLogger::getText(int type,
// node and the node is the master of this local checkpoint. // node and the node is the master of this local checkpoint.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLocal checkpoint %u completed", "%sLocal checkpoint %u completed",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -544,14 +529,14 @@ EventLogger::getText(int type, ...@@ -544,14 +529,14 @@ EventLogger::getText(int type,
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// This event reports that a table has been created. // This event reports that a table has been created.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sTable with ID = %u created", "%sTable with ID = %u created",
theNodeId, theNodeId,
theData[1]); theData[1]);
break; break;
case EventReport::LCPStoppedInCalcKeepGci: case EventReport::LCPStoppedInCalcKeepGci:
if (theData[1] == 0) if (theData[1] == 0)
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sLocal Checkpoint stopped in CALCULATED_KEEP_GCI", "%sLocal Checkpoint stopped in CALCULATED_KEEP_GCI",
theNodeId); theNodeId);
break; break;
...@@ -560,7 +545,7 @@ EventLogger::getText(int type, ...@@ -560,7 +545,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of dictionary information. // REPORT Node Restart completed copy of dictionary information.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode restart completed copy of dictionary information", "%sNode restart completed copy of dictionary information",
theNodeId); theNodeId);
break; break;
...@@ -569,7 +554,7 @@ EventLogger::getText(int type, ...@@ -569,7 +554,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of distribution information. // REPORT Node Restart completed copy of distribution information.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode restart completed copy of distribution information", "%sNode restart completed copy of distribution information",
theNodeId); theNodeId);
break; break;
...@@ -578,7 +563,7 @@ EventLogger::getText(int type, ...@@ -578,7 +563,7 @@ EventLogger::getText(int type,
// REPORT Node Restart is starting to copy the fragments. // REPORT Node Restart is starting to copy the fragments.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode restart starting to copy the fragments " "%sNode restart starting to copy the fragments "
"to Node %u", "to Node %u",
theNodeId, theNodeId,
...@@ -589,7 +574,7 @@ EventLogger::getText(int type, ...@@ -589,7 +574,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment. // REPORT Node Restart copied a fragment.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sTable ID = %u, fragment ID = %u have been copied " "%sTable ID = %u, fragment ID = %u have been copied "
"to Node %u", "to Node %u",
theNodeId, theNodeId,
...@@ -599,7 +584,7 @@ EventLogger::getText(int type, ...@@ -599,7 +584,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::NR_CopyFragsCompleted: case EventReport::NR_CopyFragsCompleted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode restart completed copying the fragments " "%sNode restart completed copying the fragments "
"to Node %u", "to Node %u",
theNodeId, theNodeId,
...@@ -607,7 +592,7 @@ EventLogger::getText(int type, ...@@ -607,7 +592,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::LCPFragmentCompleted: case EventReport::LCPFragmentCompleted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sTable ID = %u, fragment ID = %u has completed LCP " "%sTable ID = %u, fragment ID = %u has completed LCP "
"on Node %u", "on Node %u",
theNodeId, theNodeId,
...@@ -620,7 +605,7 @@ EventLogger::getText(int type, ...@@ -620,7 +605,7 @@ EventLogger::getText(int type,
// Report information about transaction activity once per 10 seconds. // Report information about transaction activity once per 10 seconds.
// ------------------------------------------------------------------- // -------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sTrans. Count = %u, Commit Count = %u, " "%sTrans. Count = %u, Commit Count = %u, "
"Read Count = %u, Simple Read Count = %u,\n" "Read Count = %u, Simple Read Count = %u,\n"
"Write Count = %u, AttrInfo Count = %u, " "Write Count = %u, AttrInfo Count = %u, "
...@@ -639,7 +624,7 @@ EventLogger::getText(int type, ...@@ -639,7 +624,7 @@ EventLogger::getText(int type,
theData[10]); theData[10]);
break; break;
case EventReport::OperationReportCounters: case EventReport::OperationReportCounters:
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%sOperations=%u", "%sOperations=%u",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -649,7 +634,7 @@ EventLogger::getText(int type, ...@@ -649,7 +634,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow. // REPORT Undo Logging blocked due to buffer near to overflow.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sACC Blocked %u and TUP Blocked %u times last second", "%sACC Blocked %u and TUP Blocked %u times last second",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -658,7 +643,7 @@ EventLogger::getText(int type, ...@@ -658,7 +643,7 @@ EventLogger::getText(int type,
case EventReport::TransporterError: case EventReport::TransporterError:
case EventReport::TransporterWarning: case EventReport::TransporterWarning:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sTransporter to node %d reported error 0x%x", "%sTransporter to node %d reported error 0x%x",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -669,7 +654,7 @@ EventLogger::getText(int type, ...@@ -669,7 +654,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow. // REPORT Undo Logging blocked due to buffer near to overflow.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode %d missed heartbeat %d", "%sNode %d missed heartbeat %d",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -680,21 +665,21 @@ EventLogger::getText(int type, ...@@ -680,21 +665,21 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow. // REPORT Undo Logging blocked due to buffer near to overflow.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode %d declared dead due to missed heartbeat", "%sNode %d declared dead due to missed heartbeat",
theNodeId, theNodeId,
theData[1]); theData[1]);
break; break;
case EventReport::JobStatistic: case EventReport::JobStatistic:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sMean loop Counter in doJob last 8192 times = %u", "%sMean loop Counter in doJob last 8192 times = %u",
theNodeId, theNodeId,
theData[1]); theData[1]);
break; break;
case EventReport::SendBytesStatistic: case EventReport::SendBytesStatistic:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sMean send size to Node = %d last 4096 sends = %u bytes", "%sMean send size to Node = %d last 4096 sends = %u bytes",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -702,7 +687,7 @@ EventLogger::getText(int type, ...@@ -702,7 +687,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::ReceiveBytesStatistic: case EventReport::ReceiveBytesStatistic:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sMean receive size to Node = %d last 4096 sends = %u bytes", "%sMean receive size to Node = %d last 4096 sends = %u bytes",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -710,14 +695,14 @@ EventLogger::getText(int type, ...@@ -710,14 +695,14 @@ EventLogger::getText(int type,
break; break;
case EventReport::SentHeartbeat: case EventReport::SentHeartbeat:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode Sent Heartbeat to node = %d", "%sNode Sent Heartbeat to node = %d",
theNodeId, theNodeId,
theData[1]); theData[1]);
break; break;
case EventReport::CreateLogBytes: case EventReport::CreateLogBytes:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLog part %u, log file %u, MB %u", "%sLog part %u, log file %u, MB %u",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -726,7 +711,7 @@ EventLogger::getText(int type, ...@@ -726,7 +711,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::StartLog: case EventReport::StartLog:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLog part %u, start MB %u, stop MB %u, last GCI, log exec %u", "%sLog part %u, start MB %u, stop MB %u, last GCI, log exec %u",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -736,7 +721,7 @@ EventLogger::getText(int type, ...@@ -736,7 +721,7 @@ EventLogger::getText(int type,
break; break;
case EventReport::StartREDOLog: case EventReport::StartREDOLog:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sNode: %d StartLog: [GCI Keep: %d LastCompleted: %d NewestRestorable: %d]", "%sNode: %d StartLog: [GCI Keep: %d LastCompleted: %d NewestRestorable: %d]",
theNodeId, theNodeId,
theData[1], theData[1],
...@@ -753,7 +738,7 @@ EventLogger::getText(int type, ...@@ -753,7 +738,7 @@ EventLogger::getText(int type,
} }
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%s UNDO %s %d [%d %d %d %d %d %d %d %d %d]", "%s UNDO %s %d [%d %d %d %d %d %d %d %d %d]",
theNodeId, theNodeId,
line, line,
...@@ -771,36 +756,36 @@ EventLogger::getText(int type, ...@@ -771,36 +756,36 @@ EventLogger::getText(int type,
break; break;
case EventReport::InfoEvent: case EventReport::InfoEvent:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%s%s", "%s%s",
theNodeId, theNodeId,
(char *)&theData[1]); (char *)&theData[1]);
break; break;
case EventReport::WarningEvent: case EventReport::WarningEvent:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%s%s", "%s%s",
theNodeId, theNodeId,
(char *)&theData[1]); (char *)&theData[1]);
break; break;
case EventReport::GCP_TakeoverStarted: case EventReport::GCP_TakeoverStarted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sGCP Take over started", theNodeId); "%sGCP Take over started", theNodeId);
break; break;
case EventReport::GCP_TakeoverCompleted: case EventReport::GCP_TakeoverCompleted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sGCP Take over completed", theNodeId); "%sGCP Take over completed", theNodeId);
break; break;
case EventReport::LCP_TakeoverStarted: case EventReport::LCP_TakeoverStarted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLCP Take over started", theNodeId); "%sLCP Take over started", theNodeId);
break; break;
case EventReport::LCP_TakeoverCompleted: case EventReport::LCP_TakeoverCompleted:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sLCP Take over completed (state = %d)", "%sLCP Take over completed (state = %d)",
theNodeId, theData[1]); theNodeId, theData[1]);
break; break;
...@@ -812,7 +797,7 @@ EventLogger::getText(int type, ...@@ -812,7 +797,7 @@ EventLogger::getText(int type,
const int block = theData[5]; const int block = theData[5];
const int percent = (used*100)/total; const int percent = (used*100)/total;
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"%s%s usage %s %d%s(%d %dK pages of total %d)", "%s%s usage %s %d%s(%d %dK pages of total %d)",
theNodeId, theNodeId,
(block==DBACC ? "Index" : (block == DBTUP ?"Data":"<unknown>")), (block==DBACC ? "Index" : (block == DBTUP ?"Data":"<unknown>")),
...@@ -833,7 +818,7 @@ EventLogger::getText(int type, ...@@ -833,7 +818,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription id" "Grep::SSCoord: Created subscription id"
" (subId=%d,SubKey=%d)" " (subId=%d,SubKey=%d)"
" Return code: %d.", " Return code: %d.",
...@@ -847,7 +832,7 @@ EventLogger::getText(int type, ...@@ -847,7 +832,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Created subscription id" "Grep::PSCoord: Created subscription id"
" (subId=%d,SubKey=%d)" " (subId=%d,SubKey=%d)"
" Return code: %d.", " Return code: %d.",
...@@ -862,7 +847,7 @@ EventLogger::getText(int type, ...@@ -862,7 +847,7 @@ EventLogger::getText(int type,
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
const int nodegrp = theData[5]; const int nodegrp = theData[5];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription using" "Grep::SSCoord: Created subscription using"
" (subId=%d,SubKey=%d)" " (subId=%d,SubKey=%d)"
" in primary system. Primary system has %d nodegroup(s)." " in primary system. Primary system has %d nodegroup(s)."
...@@ -878,7 +863,7 @@ EventLogger::getText(int type, ...@@ -878,7 +863,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have created " "Grep::PSCoord: All participants have created "
"subscriptions" "subscriptions"
" using (subId=%d,SubKey=%d)." " using (subId=%d,SubKey=%d)."
...@@ -893,7 +878,7 @@ EventLogger::getText(int type, ...@@ -893,7 +878,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging started on meta data changes." "Grep::SSCoord: Logging started on meta data changes."
" using (subId=%d,SubKey=%d)" " using (subId=%d,SubKey=%d)"
" Return code: %d", " Return code: %d",
...@@ -907,7 +892,7 @@ EventLogger::getText(int type, ...@@ -907,7 +892,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started " "Grep::PSCoord: All participants have started "
"logging meta data" "logging meta data"
" changes on the subscription subId=%d,SubKey=%d) " " changes on the subscription subId=%d,SubKey=%d) "
...@@ -922,7 +907,7 @@ EventLogger::getText(int type, ...@@ -922,7 +907,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging started on table data changes " "Grep::SSCoord: Logging started on table data changes "
" using (subId=%d,SubKey=%d)" " using (subId=%d,SubKey=%d)"
" Return code: %d", " Return code: %d",
...@@ -936,7 +921,7 @@ EventLogger::getText(int type, ...@@ -936,7 +921,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started logging " "Grep::PSCoord: All participants have started logging "
"table data changes on the subscription " "table data changes on the subscription "
"subId=%d,SubKey=%d)." "subId=%d,SubKey=%d)."
...@@ -951,7 +936,7 @@ EventLogger::getText(int type, ...@@ -951,7 +936,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started " "Grep::PSCoord: All participants have started "
" synchronization on meta data (META SCAN) using " " synchronization on meta data (META SCAN) using "
"(subId=%d,SubKey=%d)." "(subId=%d,SubKey=%d)."
...@@ -966,7 +951,7 @@ EventLogger::getText(int type, ...@@ -966,7 +951,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (META SCAN) on " "Grep::SSCoord: Synchronization started (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)" " meta data using (subId=%d,SubKey=%d)"
" Return code: %d", " Return code: %d",
...@@ -980,7 +965,7 @@ EventLogger::getText(int type, ...@@ -980,7 +965,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started " "Grep::PSCoord: All participants have started "
"synchronization " "synchronization "
" on table data (DATA SCAN) using (subId=%d,SubKey=%d)." " on table data (DATA SCAN) using (subId=%d,SubKey=%d)."
...@@ -996,7 +981,7 @@ EventLogger::getText(int type, ...@@ -996,7 +981,7 @@ EventLogger::getText(int type,
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
const int gci = theData[5]; const int gci = theData[5];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (DATA SCAN) on " "Grep::SSCoord: Synchronization started (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d" "table data using (subId=%d,SubKey=%d). GCI = %d"
" Return code: %d", " Return code: %d",
...@@ -1011,7 +996,7 @@ EventLogger::getText(int type, ...@@ -1011,7 +996,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have removed " "Grep::PSCoord: All participants have removed "
"subscription (subId=%d,SubKey=%d). I have cleaned " "subscription (subId=%d,SubKey=%d). I have cleaned "
"up resources I've used." "up resources I've used."
...@@ -1026,7 +1011,7 @@ EventLogger::getText(int type, ...@@ -1026,7 +1011,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Removed subscription " "Grep::SSCoord: Removed subscription "
"(subId=%d,SubKey=%d)" "(subId=%d,SubKey=%d)"
" Return code: %d", " Return code: %d",
...@@ -1037,7 +1022,7 @@ EventLogger::getText(int type, ...@@ -1037,7 +1022,7 @@ EventLogger::getText(int type,
} }
default: default:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sUnknown GrepSubscriptonInfo event: %d", "%sUnknown GrepSubscriptonInfo event: %d",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -1055,7 +1040,7 @@ EventLogger::getText(int type, ...@@ -1055,7 +1040,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord:Error code: %d Error message: %s" "Grep::SSCoord:Error code: %d Error message: %s"
" (subId=%d,SubKey=%d)", " (subId=%d,SubKey=%d)",
err, err,
...@@ -1069,7 +1054,7 @@ EventLogger::getText(int type, ...@@ -1069,7 +1054,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: FAILED to Created subscription using" "Grep::SSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system." " (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1084,7 +1069,7 @@ EventLogger::getText(int type, ...@@ -1084,7 +1069,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging failed to start on meta " "Grep::SSCoord: Logging failed to start on meta "
"data changes." "data changes."
" using (subId=%d,SubKey=%d)" " using (subId=%d,SubKey=%d)"
...@@ -1100,7 +1085,7 @@ EventLogger::getText(int type, ...@@ -1100,7 +1085,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Logging FAILED to start on table data " "Grep::SSCoord: Logging FAILED to start on table data "
" changes using (subId=%d,SubKey=%d)" " changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1115,7 +1100,7 @@ EventLogger::getText(int type, ...@@ -1115,7 +1100,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (META SCAN) on " "Grep::SSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)" " meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1131,7 +1116,7 @@ EventLogger::getText(int type, ...@@ -1131,7 +1116,7 @@ EventLogger::getText(int type,
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
const int gci = theData[5]; const int gci = theData[5];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (DATA SCAN) on " "Grep::SSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d" "table data using (subId=%d,SubKey=%d). GCI = %d"
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1147,7 +1132,7 @@ EventLogger::getText(int type, ...@@ -1147,7 +1132,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::SSCoord: Failed to remove subscription " "Grep::SSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d). " "(subId=%d,SubKey=%d). "
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1164,7 +1149,7 @@ EventLogger::getText(int type, ...@@ -1164,7 +1149,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Error code: %d Error Message: %s" "Grep::PSCoord: Error code: %d Error Message: %s"
" (subId=%d,SubKey=%d)", " (subId=%d,SubKey=%d)",
err, err,
...@@ -1178,7 +1163,7 @@ EventLogger::getText(int type, ...@@ -1178,7 +1163,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: FAILED to Created subscription using" "Grep::PSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system." " (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1193,7 +1178,7 @@ EventLogger::getText(int type, ...@@ -1193,7 +1178,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Logging failed to start on meta " "Grep::PSCoord: Logging failed to start on meta "
"data changes." "data changes."
" using (subId=%d,SubKey=%d)" " using (subId=%d,SubKey=%d)"
...@@ -1209,7 +1194,7 @@ EventLogger::getText(int type, ...@@ -1209,7 +1194,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Logging FAILED to start on table data " "Grep::PSCoord: Logging FAILED to start on table data "
" changes using (subId=%d,SubKey=%d)" " changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1224,7 +1209,7 @@ EventLogger::getText(int type, ...@@ -1224,7 +1209,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (META SCAN) on " "Grep::PSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)" " meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1240,7 +1225,7 @@ EventLogger::getText(int type, ...@@ -1240,7 +1225,7 @@ EventLogger::getText(int type,
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
const int gci = theData[5]; const int gci = theData[5];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (DATA SCAN) on " "Grep::PSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d. " "table data using (subId=%d,SubKey=%d). GCI = %d. "
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1256,7 +1241,7 @@ EventLogger::getText(int type, ...@@ -1256,7 +1241,7 @@ EventLogger::getText(int type,
const int subId = theData[2]; const int subId = theData[2];
const int subKey = theData[3]; const int subKey = theData[3];
const int err = theData[4]; const int err = theData[4];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Grep::PSCoord: Failed to remove subscription " "Grep::PSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d)." "(subId=%d,SubKey=%d)."
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
...@@ -1270,7 +1255,7 @@ EventLogger::getText(int type, ...@@ -1270,7 +1255,7 @@ EventLogger::getText(int type,
{ {
const int err = theData[4]; const int err = theData[4];
const int nodeId = theData[5]; const int nodeId = theData[5];
::snprintf(m_text, sizeof(m_text), ::snprintf(m_text, m_text_len,
"Rep: Node %d." "Rep: Node %d."
" Error code: %d Error Message: %s", " Error code: %d Error Message: %s",
nodeId, nodeId,
...@@ -1282,7 +1267,7 @@ EventLogger::getText(int type, ...@@ -1282,7 +1267,7 @@ EventLogger::getText(int type,
default: default:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sUnknown GrepSubscriptionAlert event: %d", "%sUnknown GrepSubscriptionAlert event: %d",
theNodeId, theNodeId,
theData[1]); theData[1]);
...@@ -1293,7 +1278,7 @@ EventLogger::getText(int type, ...@@ -1293,7 +1278,7 @@ EventLogger::getText(int type,
default: default:
::snprintf(m_text, ::snprintf(m_text,
sizeof(m_text), m_text_len,
"%sUnknown event: %d", "%sUnknown event: %d",
theNodeId, theNodeId,
theData[0]); theData[0]);
...@@ -1303,9 +1288,9 @@ EventLogger::getText(int type, ...@@ -1303,9 +1288,9 @@ EventLogger::getText(int type,
} }
bool bool
EventLogger::matchEventCategory(const char * str, EventLoggerBase::matchEventCategory(const char * str,
LogLevel::EventCategory * cat, LogLevel::EventCategory * cat,
bool exactMatch){ bool exactMatch){
unsigned i; unsigned i;
if(cat == 0 || str == 0) if(cat == 0 || str == 0)
return false; return false;
...@@ -1326,7 +1311,7 @@ EventLogger::matchEventCategory(const char * str, ...@@ -1326,7 +1311,7 @@ EventLogger::matchEventCategory(const char * str,
} }
const char * const char *
EventLogger::getEventCategoryName(LogLevel::EventCategory cat){ EventLoggerBase::getEventCategoryName(LogLevel::EventCategory cat){
for(unsigned i = 0; i<noOfEventCategoryNames; i++){ for(unsigned i = 0; i<noOfEventCategoryNames; i++){
if(cat == eventCategoryNames[i].category){ if(cat == eventCategoryNames[i].category){
...@@ -1337,19 +1322,19 @@ EventLogger::getEventCategoryName(LogLevel::EventCategory cat){ ...@@ -1337,19 +1322,19 @@ EventLogger::getEventCategoryName(LogLevel::EventCategory cat){
} }
EventLogger::EventLogger() : Logger(), m_logLevel(), m_filterLevel(15) EventLogger::EventLogger() : m_filterLevel(15)
{ {
setCategory("EventLogger"); setCategory("EventLogger");
m_logLevel.setLogLevel(LogLevel::llStartUp, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llStartUp, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llShutdown, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llShutdown, m_filterLevel);
// m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel);
// m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llNodeRestart, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llNodeRestart, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llConnection, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llConnection, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llError, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llError, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llInfo, m_filterLevel); m_logLevel.setLogLevel(LogLevel::llInfo, m_filterLevel);
enable(Logger::LL_INFO, Logger::LL_ALERT); // Log INFO to ALERT enable(Logger::Logger::LL_INFO, Logger::Logger::LL_ALERT); // Log INFO to ALERT
} }
EventLogger::~EventLogger() EventLogger::~EventLogger()
...@@ -1370,66 +1355,62 @@ EventLogger::close() ...@@ -1370,66 +1355,62 @@ EventLogger::close()
removeAllHandlers(); removeAllHandlers();
} }
void
EventLogger::log(NodeId nodeId, int eventType, const Uint32* theData)
{
log(eventType, theData, nodeId);
}
void void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId) EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId)
{ {
Uint32 threshold = 0; Uint32 threshold = 0;
Logger::LoggerLevel severity = LL_WARNING; Logger::LoggerLevel severity = Logger::LL_WARNING;
LogLevel::EventCategory cat;
for(unsigned i = 0; i<EventLogger::matrixSize; i++){ for(unsigned i = 0; i<EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){ if(EventLogger::matrix[i].eventType == eventType){
const LogLevel::EventCategory cat = EventLogger::matrix[i].eventCategory; cat = EventLogger::matrix[i].eventCategory;
threshold = m_logLevel.getLogLevel(cat); threshold = EventLogger::matrix[i].threshold;
severity = EventLogger::matrix[i].severity; severity = EventLogger::matrix[i].severity;
break; break;
} }
} }
if (threshold <= m_filterLevel){ if (threshold <= m_logLevel.getLogLevel(cat)){
switch (severity){ switch (severity){
case LL_ALERT: case Logger::LL_ALERT:
alert(EventLogger::getText(eventType, theData, nodeId)); alert(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
case LL_CRITICAL: case Logger::LL_CRITICAL:
critical(EventLogger::getText(eventType, theData, nodeId)); critical(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
case LL_WARNING: case Logger::LL_WARNING:
warning(EventLogger::getText(eventType, theData, nodeId)); warning(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
case LL_ERROR: case Logger::LL_ERROR:
error(EventLogger::getText(eventType, theData, nodeId)); error(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
case LL_INFO: case Logger::LL_INFO:
info(EventLogger::getText(eventType, theData, nodeId)); info(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
case LL_DEBUG: case Logger::LL_DEBUG:
debug(EventLogger::getText(eventType, theData, nodeId)); debug(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
default: default:
info(EventLogger::getText(eventType, theData, nodeId)); info(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break; break;
} }
} // if (.. } // if (..
} }
LogLevel&
EventLogger::getLoglevel()
{
return m_logLevel;
}
int int
EventLogger::getFilterLevel() const EventLogger::getFilterLevel() const
{ {
......
...@@ -250,17 +250,7 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){ ...@@ -250,17 +250,7 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
sendSignal(subReq->blockRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB); sendSignal(subReq->blockRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB);
return; return;
} }
/** ptr.p->logLevel.clear();
* If it's a new subscription, clear the loglevel
*
* Clear only if noOfEntries is 0, this is needed beacuse we set
* the default loglevels for the MGMT nodes during the inital connect phase.
* See reportConnected().
*/
if (subReq->noOfEntries == 0){
ptr.p->logLevel.clear();
}
ptr.p->blockRef = subReq->blockRef; ptr.p->blockRef = subReq->blockRef;
} }
...@@ -384,11 +374,6 @@ void Cmvmi::execCLOSE_COMREQ(Signal* signal) ...@@ -384,11 +374,6 @@ void Cmvmi::execCLOSE_COMREQ(Signal* signal)
globalTransporterRegistry.setIOState(i, HaltIO); globalTransporterRegistry.setIOState(i, HaltIO);
globalTransporterRegistry.do_disconnect(i); globalTransporterRegistry.do_disconnect(i);
/**
* Cancel possible event subscription
*/
cancelSubscription(i);
} }
} }
if (failNo != 0) { if (failNo != 0) {
...@@ -494,6 +479,8 @@ void Cmvmi::execDISCONNECT_REP(Signal *signal) ...@@ -494,6 +479,8 @@ void Cmvmi::execDISCONNECT_REP(Signal *signal)
globalTransporterRegistry.do_connect(hostId); globalTransporterRegistry.do_connect(hostId);
} }
cancelSubscription(hostId);
signal->theData[0] = EventReport::Disconnected; signal->theData[0] = EventReport::Disconnected;
signal->theData[1] = hostId; signal->theData[1] = hostId;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB); sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
...@@ -539,20 +526,6 @@ void Cmvmi::execCONNECT_REP(Signal *signal){ ...@@ -539,20 +526,6 @@ void Cmvmi::execCONNECT_REP(Signal *signal){
if(type == NodeInfo::MGM){ if(type == NodeInfo::MGM){
jam(); jam();
globalTransporterRegistry.setIOState(hostId, NoHalt); globalTransporterRegistry.setIOState(hostId, NoHalt);
EventSubscribeReq* dst = (EventSubscribeReq *)&signal->theData[0];
for (Uint32 i = 0; i < EventLogger::defEventLogMatrixSize; i++) {
dst->theCategories[i] = EventLogger::defEventLogMatrix[i].eventCategory;
dst->theLevels[i] = EventLogger::defEventLogMatrix[i].threshold;
}
dst->noOfEntries = EventLogger::defEventLogMatrixSize;
/* The BlockNumber is hardcoded as 1 in MgmtSrvr */
dst->blockRef = numberToRef(MIN_API_BLOCK_NO, hostId);
execEVENT_SUBSCRIBE_REQ(signal);
} }
//------------------------------------------ //------------------------------------------
......
...@@ -389,9 +389,9 @@ void CommandInterpreter::executeHelp(char* parameters) { ...@@ -389,9 +389,9 @@ void CommandInterpreter::executeHelp(char* parameters) {
<< endl; << endl;
ndbout << "<category> = "; ndbout << "<category> = ";
for(i = 0; i<EventLogger::noOfEventCategoryNames; i++){ for(i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++){
ndbout << EventLogger::eventCategoryNames[i].name; ndbout << EventLoggerBase::eventCategoryNames[i].name;
if (i < EventLogger::noOfEventCategoryNames - 1) { if (i < EventLoggerBase::noOfEventCategoryNames - 1) {
ndbout << " | "; ndbout << " | ";
} }
} }
...@@ -831,12 +831,13 @@ void CommandInterpreter::executeStatus(int processId, ...@@ -831,12 +831,13 @@ void CommandInterpreter::executeStatus(int processId,
//***************************************************************************** //*****************************************************************************
void CommandInterpreter::executeLogLevel(int processId, void CommandInterpreter::executeLogLevel(int processId,
const char* parameters, bool all) { const char* parameters, bool all) {
#if 0
(void)all; // Don't want compiler warning (void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear(); SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) { if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++) for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7); logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else { } else {
char * tmpString = strdup(parameters); char * tmpString = strdup(parameters);
...@@ -852,7 +853,7 @@ void CommandInterpreter::executeLogLevel(int processId, ...@@ -852,7 +853,7 @@ void CommandInterpreter::executeLogLevel(int processId,
return; return;
} }
LogLevel::EventCategory cat; LogLevel::EventCategory cat;
if(!EventLogger::matchEventCategory(categoryTxt, if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){ &cat)){
ndbout << "Invalid loglevel specification, unknown category: " ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl; << categoryTxt << endl;
...@@ -875,6 +876,7 @@ void CommandInterpreter::executeLogLevel(int processId, ...@@ -875,6 +876,7 @@ void CommandInterpreter::executeLogLevel(int processId,
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << _mgmtSrvr.getErrorText(result) << endl;
} }
#endif
} }
...@@ -1080,12 +1082,13 @@ void CommandInterpreter::executeTestOff(int processId, ...@@ -1080,12 +1082,13 @@ void CommandInterpreter::executeTestOff(int processId,
void CommandInterpreter::executeEventReporting(int processId, void CommandInterpreter::executeEventReporting(int processId,
const char* parameters, const char* parameters,
bool all) { bool all) {
#if 0
(void)all; // Don't want compiler warning (void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear(); SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) { if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++) for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7); logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else { } else {
char * tmpString = strdup(parameters); char * tmpString = strdup(parameters);
...@@ -1101,7 +1104,7 @@ void CommandInterpreter::executeEventReporting(int processId, ...@@ -1101,7 +1104,7 @@ void CommandInterpreter::executeEventReporting(int processId,
return; return;
} }
LogLevel::EventCategory cat; LogLevel::EventCategory cat;
if(!EventLogger::matchEventCategory(categoryTxt, if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){ &cat)){
ndbout << "Invalid loglevel specification, unknown category: " ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl; << categoryTxt << endl;
...@@ -1124,6 +1127,7 @@ void CommandInterpreter::executeEventReporting(int processId, ...@@ -1124,6 +1127,7 @@ void CommandInterpreter::executeEventReporting(int processId,
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << _mgmtSrvr.getErrorText(result) << endl;
} }
#endif
} }
void void
......
...@@ -12,8 +12,6 @@ ndb_mgmd_SOURCES = \ ...@@ -12,8 +12,6 @@ ndb_mgmd_SOURCES = \
main.cpp \ main.cpp \
Services.cpp \ Services.cpp \
convertStrToInt.cpp \ convertStrToInt.cpp \
NodeLogLevel.cpp \
NodeLogLevelList.cpp \
SignalQueue.cpp \ SignalQueue.cpp \
MgmtSrvrConfig.cpp \ MgmtSrvrConfig.cpp \
ConfigInfo.cpp \ ConfigInfo.cpp \
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <ndb_version.h> #include <ndb_version.h>
#include <SocketServer.hpp> #include <SocketServer.hpp>
#include "NodeLogLevel.hpp"
#include <NdbConfig.h> #include <NdbConfig.h>
#include <NdbAutoPtr.hpp> #include <NdbAutoPtr.hpp>
...@@ -191,41 +190,49 @@ EventLogger g_EventLogger; ...@@ -191,41 +190,49 @@ EventLogger g_EventLogger;
void void
MgmtSrvr::logLevelThreadRun() MgmtSrvr::logLevelThreadRun()
{ {
NdbMutex* threadMutex = NdbMutex_Create();
while (!_isStopThread) { while (!_isStopThread) {
if (_startedNodeId != 0) { /**
NdbMutex_Lock(threadMutex); * Handle started nodes
*/
// Local node EventSubscribeReq req;
NodeLogLevel* n = NULL; req = m_statisticsListner.m_clients[0].m_logLevel;
while ((n = _nodeLogLevelList->next()) != NULL) { req.blockRef = _ownReference;
if (n->getNodeId() == _startedNodeId) {
setNodeLogLevel(_startedNodeId, n->getLogLevelOrd(), true);
}
}
// Cluster log
while ((n = _clusterLogLevelList->next()) != NULL) {
if (n->getNodeId() == _startedNodeId) {
setEventReportingLevel(_startedNodeId, n->getLogLevelOrd(), true);
}
}
_startedNodeId = 0;
NdbMutex_Unlock(threadMutex);
} // if (_startedNodeId != 0) { SetLogLevelOrd ord;
m_started_nodes.lock();
while(m_started_nodes.size() > 0){
Uint32 node = m_started_nodes[0];
m_started_nodes.erase(0, false);
m_started_nodes.unlock();
setEventReportingLevelImpl(node, req);
ord = m_nodeLogLevel[node];
setNodeLogLevelImpl(node, ord);
m_started_nodes.lock();
}
m_started_nodes.unlock();
m_log_level_requests.lock();
while(m_log_level_requests.size() > 0){
req = m_log_level_requests[0];
m_log_level_requests.erase(0, false);
m_log_level_requests.unlock();
if(req.blockRef == 0){
req.blockRef = _ownReference;
setEventReportingLevelImpl(0, req);
} else {
ord = req;
setNodeLogLevelImpl(req.blockRef, ord);
}
m_log_level_requests.lock();
}
m_log_level_requests.unlock();
NdbSleep_MilliSleep(_logLevelThreadSleep); NdbSleep_MilliSleep(_logLevelThreadSleep);
} // while (!_isStopThread) }
NdbMutex_Destroy(threadMutex);
}
void
MgmtSrvr::setStatisticsListner(StatisticsListner* listner)
{
m_statisticsListner = listner;
} }
void void
...@@ -272,7 +279,7 @@ class ErrorItem ...@@ -272,7 +279,7 @@ class ErrorItem
{ {
public: public:
int _errorCode; int _errorCode;
const BaseString _errorText; const char * _errorText;
}; };
bool bool
...@@ -485,23 +492,6 @@ MgmtSrvr::getPort() const { ...@@ -485,23 +492,6 @@ MgmtSrvr::getPort() const {
return port; return port;
} }
int
MgmtSrvr::getStatPort() const {
#if 0
const Properties *mgmProps;
if(!getConfig()->get("Node", _ownNodeId, &mgmProps))
return -1;
int tmp = -1;
if(!mgmProps->get("PortNumberStats", (Uint32 *)&tmp))
return -1;
return tmp;
#else
return -1;
#endif
}
/* Constructor */ /* Constructor */
MgmtSrvr::MgmtSrvr(NodeId nodeId, MgmtSrvr::MgmtSrvr(NodeId nodeId,
const BaseString &configFilename, const BaseString &configFilename,
...@@ -510,22 +500,19 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -510,22 +500,19 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
_blockNumber(1), // Hard coded block number since it makes it easy to send _blockNumber(1), // Hard coded block number since it makes it easy to send
// signals to other management servers. // signals to other management servers.
_ownReference(0), _ownReference(0),
m_allocated_resources(*this),
theSignalIdleList(NULL), theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF), theWaitState(WAIT_SUBSCRIBE_CONF),
theConfCount(0), m_statisticsListner(this){
m_allocated_resources(*this) {
DBUG_ENTER("MgmtSrvr::MgmtSrvr"); DBUG_ENTER("MgmtSrvr::MgmtSrvr");
_config = NULL; _config = NULL;
_isStatPortActive = false;
_isClusterLogStatActive = false;
_isStopThread = false; _isStopThread = false;
_logLevelThread = NULL; _logLevelThread = NULL;
_logLevelThreadSleep = 500; _logLevelThreadSleep = 500;
m_signalRecvThread = NULL; m_signalRecvThread = NULL;
_startedNodeId = 0;
theFacade = 0; theFacade = 0;
...@@ -583,13 +570,7 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -583,13 +570,7 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
ndb_mgm_destroy_iterator(iter); ndb_mgm_destroy_iterator(iter);
} }
m_statisticsListner = NULL;
_nodeLogLevelList = new NodeLogLevelList();
_clusterLogLevelList = new NodeLogLevelList();
_props = NULL; _props = NULL;
_ownNodeId= 0; _ownNodeId= 0;
NodeId tmp= nodeId; NodeId tmp= nodeId;
BaseString error_string; BaseString error_string;
...@@ -610,6 +591,16 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, ...@@ -610,6 +591,16 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
} }
} }
{
MgmStatService::StatListener se;
se.m_socket = -1;
for(size_t t = 0; t<_LOGLEVEL_CATEGORIES; t++)
se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7);
se.m_logLevel.setLogLevel(LogLevel::llError, 15);
m_statisticsListner.m_clients.push_back(se);
m_statisticsListner.m_logLevel = se.m_logLevel;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -671,8 +662,6 @@ MgmtSrvr::start(BaseString &error_string) ...@@ -671,8 +662,6 @@ MgmtSrvr::start(BaseString &error_string)
// Set the initial confirmation count for subscribe requests confirm // Set the initial confirmation count for subscribe requests confirm
// from NDB nodes in the cluster. // from NDB nodes in the cluster.
// //
theConfCount = getNodeCount(NDB_MGM_NODE_TYPE_NDB);
// Loglevel thread // Loglevel thread
_logLevelThread = NdbThread_Create(logLevelThread_C, _logLevelThread = NdbThread_Create(logLevelThread_C,
(void**)this, (void**)this,
...@@ -713,9 +702,6 @@ MgmtSrvr::~MgmtSrvr() ...@@ -713,9 +702,6 @@ MgmtSrvr::~MgmtSrvr()
if(_config != NULL) if(_config != NULL)
delete _config; delete _config;
delete _nodeLogLevelList;
delete _clusterLogLevelList;
// End set log level thread // End set log level thread
void* res = 0; void* res = 0;
_isStopThread = true; _isStopThread = true;
...@@ -736,6 +722,9 @@ MgmtSrvr::~MgmtSrvr() ...@@ -736,6 +722,9 @@ MgmtSrvr::~MgmtSrvr()
int MgmtSrvr::okToSendTo(NodeId processId, bool unCond) int MgmtSrvr::okToSendTo(NodeId processId, bool unCond)
{ {
if(processId == 0)
return 0;
if (getNodeType(processId) != NDB_MGM_NODE_TYPE_NDB) if (getNodeType(processId) != NDB_MGM_NODE_TYPE_NDB)
return WRONG_PROCESS_TYPE; return WRONG_PROCESS_TYPE;
...@@ -1540,175 +1529,72 @@ MgmtSrvr::status(int processId, ...@@ -1540,175 +1529,72 @@ MgmtSrvr::status(int processId,
return -1; return -1;
} }
//****************************************************************************
//****************************************************************************
int
MgmtSrvr::startStatisticEventReporting(int level)
{
SetLogLevelOrd ll;
NodeId nodeId = 0;
ll.clear();
ll.setLogLevel(LogLevel::llStatistic, level);
if (level > 0) {
_isStatPortActive = true;
} else {
_isStatPortActive = false;
if (_isClusterLogStatActive) {
return 0;
}
}
while (getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) {
setEventReportingLevelImpl(nodeId, ll);
}
return 0;
}
int
MgmtSrvr::setEventReportingLevel(int processId, const SetLogLevelOrd & ll,
bool isResend)
{
for (Uint32 i = 0; i < ll.noOfEntries; i++) {
if (ll.theCategories[i] == LogLevel::llStatistic) {
if (ll.theLevels[i] > 0) {
_isClusterLogStatActive = true;
break;
} else {
_isClusterLogStatActive = false;
if (_isStatPortActive) {
return 0;
}
break;
}
} // if (ll.theCategories
} // for (int i = 0
return setEventReportingLevelImpl(processId, ll, isResend);
}
int int
MgmtSrvr::setEventReportingLevelImpl(int processId, MgmtSrvr::setEventReportingLevelImpl(int processId,
const SetLogLevelOrd & ll, const EventSubscribeReq& ll)
bool isResend)
{ {
Uint32 i;
for(i = 0; i<ll.noOfEntries; i++){
// Save log level for the cluster log
if (!isResend) {
NodeLogLevel* n = NULL;
bool found = false;
while ((n = _clusterLogLevelList->next()) != NULL) {
if (n->getNodeId() == processId &&
n->getCategory() == ll.theCategories[i]) {
n->setLevel(ll.theLevels[i]);
found = true;
}
}
if (!found) {
_clusterLogLevelList->add(new NodeLogLevel(processId, ll));
}
}
}
int result = okToSendTo(processId, true); int result = okToSendTo(processId, true);
if (result != 0) { if (result != 0) {
return result; return result;
} }
NdbApiSignal* signal = getSignal(); NdbApiSignal signal(_ownReference);
if (signal == NULL) {
return COULD_NOT_ALLOCATE_MEMORY;
}
EventSubscribeReq * dst = EventSubscribeReq * dst =
CAST_PTR(EventSubscribeReq, signal->getDataPtrSend()); CAST_PTR(EventSubscribeReq, signal.getDataPtrSend());
for(i = 0; i<ll.noOfEntries; i++){
dst->theCategories[i] = ll.theCategories[i];
dst->theLevels[i] = ll.theLevels[i];
}
dst->noOfEntries = ll.noOfEntries;
dst->blockRef = _ownReference;
signal->set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ, * dst = ll;
EventSubscribeReq::SignalLength);
signal.set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ,
EventSubscribeReq::SignalLength);
theFacade->lock_mutex();
send(&signal, processId, NODE_TYPE_DB);
theFacade->unlock_mutex();
result = sendSignal(processId, WAIT_SUBSCRIBE_CONF, signal, true);
if (result == -1) {
return SEND_OR_RECEIVE_FAILED;
}
else {
// Increment the conf counter
theConfCount++;
}
return 0; return 0;
} }
//**************************************************************************** //****************************************************************************
//**************************************************************************** //****************************************************************************
int int
MgmtSrvr::setNodeLogLevel(int processId, const SetLogLevelOrd & ll, MgmtSrvr::setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll)
bool isResend)
{ {
Uint32 i;
for(i = 0; i<ll.noOfEntries; i++){
// Save log level for the cluster log
if (!isResend) {
NodeLogLevel* n = NULL;
bool found = false;
while ((n = _clusterLogLevelList->next()) != NULL) {
if (n->getNodeId() == processId &&
n->getCategory() == ll.theCategories[i]) {
n->setLevel(ll.theLevels[i]);
found = true;
}
}
if (!found) {
_clusterLogLevelList->add(new NodeLogLevel(processId, ll));
}
}
}
int result = okToSendTo(processId, true); int result = okToSendTo(processId, true);
if (result != 0) { if (result != 0) {
return result; return result;
} }
NdbApiSignal* signal = getSignal(); NdbApiSignal signal(_ownReference);
if (signal == NULL) {
return COULD_NOT_ALLOCATE_MEMORY;
}
SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal->getDataPtrSend());
for(i = 0; i<ll.noOfEntries; i++){
dst->theCategories[i] = ll.theCategories[i];
dst->theLevels[i] = ll.theLevels[i];
}
dst->noOfEntries = ll.noOfEntries; SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal.getDataPtrSend());
signal->set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD, * dst = ll;
SetLogLevelOrd::SignalLength);
signal.set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD,
result = sendSignal(processId, NO_WAIT, signal, true); SetLogLevelOrd::SignalLength);
if (result == -1) {
return SEND_OR_RECEIVE_FAILED; theFacade->lock_mutex();
} theFacade->sendSignalUnCond(&signal, processId);
theFacade->unlock_mutex();
return 0; return 0;
} }
int
MgmtSrvr::send(NdbApiSignal* signal, Uint32 node, Uint32 node_type){
Uint32 max = (node == 0) ? MAX_NODES : node + 1;
for(; node < max; node++){
while(nodeTypes[node] != node_type && node < max) node++;
if(nodeTypes[node] != node_type)
break;
theFacade->sendSignalUnCond(signal, node);
}
return 0;
}
//**************************************************************************** //****************************************************************************
//**************************************************************************** //****************************************************************************
...@@ -2003,7 +1889,7 @@ const char* MgmtSrvr::getErrorText(int errorCode) ...@@ -2003,7 +1889,7 @@ const char* MgmtSrvr::getErrorText(int errorCode)
for (int i = 0; i < noOfErrorCodes; ++i) { for (int i = 0; i < noOfErrorCodes; ++i) {
if (errorCode == errorTable[i]._errorCode) { if (errorCode == errorTable[i]._errorCode) {
return errorTable[i]._errorText.c_str(); return errorTable[i]._errorText;
} }
} }
...@@ -2011,21 +1897,6 @@ const char* MgmtSrvr::getErrorText(int errorCode) ...@@ -2011,21 +1897,6 @@ const char* MgmtSrvr::getErrorText(int errorCode)
return text; return text;
} }
/*****************************************************************************
* Handle reception of various signals
*****************************************************************************/
int
MgmtSrvr::handleSTATISTICS_CONF(NdbApiSignal* signal)
{
//ndbout << "MgmtSrvr::handleSTATISTICS_CONF" << endl;
int x = signal->readData(1);
//ndbout << "MgmtSrvr::handleSTATISTICS_CONF, x: " << x << endl;
_statistics._test1 = x;
return 0;
}
void void
MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
{ {
...@@ -2049,51 +1920,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) ...@@ -2049,51 +1920,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
} }
break; break;
case GSN_STATISTICS_CONF:
if (theWaitState != WAIT_STATISTICS) {
g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
"signal received, gsn %d, theWaitState = %d",
gsn, theWaitState);
return;
}
returnCode = handleSTATISTICS_CONF(signal);
if (returnCode != -1) {
theWaitState = NO_WAIT;
}
break;
case GSN_SET_VAR_CONF:
if (theWaitState != WAIT_SET_VAR) {
g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
"signal received, gsn %d, theWaitState = %d",
gsn, theWaitState);
return;
}
theWaitState = NO_WAIT;
_setVarReqResult = 0;
break;
case GSN_SET_VAR_REF:
if (theWaitState != WAIT_SET_VAR) {
g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
"signal received, gsn %d, theWaitState = %d",
gsn, theWaitState);
return;
}
theWaitState = NO_WAIT;
_setVarReqResult = -1;
break;
case GSN_EVENT_SUBSCRIBE_CONF: case GSN_EVENT_SUBSCRIBE_CONF:
theConfCount--; // OK, we've received a conf message
if (theConfCount < 0) {
g_EventLogger.warning("MgmtSrvr::handleReceivedSignal, unexpected "
"signal received, gsn %d, theWaitState = %d",
gsn, theWaitState);
theConfCount = 0;
}
break; break;
case GSN_EVENT_REP: case GSN_EVENT_REP:
...@@ -2276,20 +2103,19 @@ void ...@@ -2276,20 +2103,19 @@ void
MgmtSrvr::handleStatus(NodeId nodeId, bool alive) MgmtSrvr::handleStatus(NodeId nodeId, bool alive)
{ {
if (alive) { if (alive) {
_startedNodeId = nodeId; // Used by logLevelThreadRun() m_started_nodes.push_back(nodeId);
Uint32 theData[25]; Uint32 theData[25];
theData[0] = EventReport::Connected; theData[0] = EventReport::Connected;
theData[1] = nodeId; theData[1] = nodeId;
eventReport(_ownNodeId, theData);
} else { } else {
handleStopReply(nodeId, 0); handleStopReply(nodeId, 0);
theConfCount++; // Increment the event subscr conf count because
Uint32 theData[25]; Uint32 theData[25];
theData[0] = EventReport::Disconnected; theData[0] = EventReport::Disconnected;
theData[1] = nodeId; theData[1] = nodeId;
eventReport(_ownNodeId, theData); eventReport(_ownNodeId, theData);
g_EventLogger.info("Lost connection to node %d", nodeId);
} }
} }
...@@ -2370,7 +2196,7 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, ...@@ -2370,7 +2196,7 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
continue; continue;
found_matching_id= true; found_matching_id= true;
if(iter.get(CFG_TYPE_OF_SECTION, &type_c)) abort(); if(iter.get(CFG_TYPE_OF_SECTION, &type_c)) abort();
if(type_c != type) if(type_c != (unsigned)type)
continue; continue;
found_matching_type= true; found_matching_type= true;
if (connected_nodes.get(tmp)) if (connected_nodes.get(tmp))
...@@ -2483,77 +2309,18 @@ MgmtSrvr::getNextNodeId(NodeId * nodeId, enum ndb_mgm_node_type type) const ...@@ -2483,77 +2309,18 @@ MgmtSrvr::getNextNodeId(NodeId * nodeId, enum ndb_mgm_node_type type) const
return true; return true;
} }
#include "Services.hpp"
void void
MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData) MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
{ {
const EventReport * const eventReport = (EventReport *)&theData[0]; const EventReport * const eventReport = (EventReport *)&theData[0];
EventReport::EventType type = eventReport->getEventType(); EventReport::EventType type = eventReport->getEventType();
if (type == EventReport::TransReportCounters ||
type == EventReport::OperationReportCounters) {
if (_isClusterLogStatActive) {
g_EventLogger.log(type, theData, nodeId);
}
if (_isStatPortActive) {
char theTime[128];
struct tm* tm_now;
time_t now;
now = time((time_t*)NULL);
#ifdef NDB_WIN32
tm_now = localtime(&now);
#else
tm_now = gmtime(&now);
#endif
snprintf(theTime, sizeof(theTime),
STATISTIC_DATE,
tm_now->tm_year + 1900,
tm_now->tm_mon,
tm_now->tm_mday,
tm_now->tm_hour,
tm_now->tm_min,
tm_now->tm_sec);
char str[255];
if (type == EventReport::TransReportCounters) {
snprintf(str, sizeof(str),
STATISTIC_LINE,
theTime,
(int)now,
nodeId,
theData[1],
theData[2],
theData[3],
// theData[4], simple reads
theData[5],
theData[6],
theData[7],
theData[8]);
} else if (type == EventReport::OperationReportCounters) {
snprintf(str, sizeof(str),
OP_STATISTIC_LINE,
theTime,
(int)now,
nodeId,
theData[1]);
}
if(m_statisticsListner != 0){
m_statisticsListner->println_statistics(str);
}
}
return;
} // if (type ==
// Log event // Log event
g_EventLogger.log(type, theData, nodeId); g_EventLogger.log(type, theData, nodeId);
m_statisticsListner.log(type, theData, nodeId);
} }
/*************************************************************************** /***************************************************************************
...@@ -2981,3 +2748,7 @@ template class Vector<SigMatch>; ...@@ -2981,3 +2748,7 @@ template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560 #if __SUNPRO_CC != 0x560
template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned); template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned);
#endif #endif
template class MutexVector<unsigned short>;
template class MutexVector<MgmStatService::StatListener>;
template class MutexVector<EventSubscribeReq>;
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#include <signaldata/ManagementServer.hpp> #include <signaldata/ManagementServer.hpp>
#include "SignalQueue.hpp" #include "SignalQueue.hpp"
#include <ndb_version.h> #include <ndb_version.h>
#include <EventLogger.hpp>
#include "NodeLogLevelList.hpp" #include <signaldata/EventSubscribeReq.hpp>
/** /**
* @desc Block number for Management server. * @desc Block number for Management server.
...@@ -43,6 +43,29 @@ class Config; ...@@ -43,6 +43,29 @@ class Config;
class SetLogLevelOrd; class SetLogLevelOrd;
class SocketServer; class SocketServer;
class MgmStatService : public EventLoggerBase
{
friend class MgmtSrvr;
public:
struct StatListener : public EventLoggerBase {
NDB_SOCKET_TYPE m_socket;
};
private:
class MgmtSrvr * m_mgmsrv;
MutexVector<StatListener> m_clients;
public:
MgmStatService(class MgmtSrvr * m) : m_clients(5) {
m_mgmsrv = m;
}
void add_listener(const StatListener&);
void log(int eventType, const Uint32* theData, NodeId nodeId);
void stopSessions();
};
/** /**
* @class MgmtSrvr * @class MgmtSrvr
* @brief Main class for the management server. * @brief Main class for the management server.
...@@ -63,11 +86,6 @@ class SocketServer; ...@@ -63,11 +86,6 @@ class SocketServer;
class MgmtSrvr { class MgmtSrvr {
public: public:
class StatisticsListner {
public:
virtual void println_statistics(const BaseString &s) = 0;
};
// some compilers need all of this // some compilers need all of this
class Allocated_resources; class Allocated_resources;
friend class Allocated_resources; friend class Allocated_resources;
...@@ -84,11 +102,6 @@ public: ...@@ -84,11 +102,6 @@ public:
NodeBitmask m_reserved_nodes; NodeBitmask m_reserved_nodes;
}; };
/**
* Set a reference to the socket server.
*/
void setStatisticsListner(StatisticsListner* listner);
/** /**
* Start/initate the event log. * Start/initate the event log.
*/ */
...@@ -150,15 +163,6 @@ public: ...@@ -150,15 +163,6 @@ public:
STATIC_CONST( OPERATION_IN_PROGRESS = 6667 ); STATIC_CONST( OPERATION_IN_PROGRESS = 6667 );
STATIC_CONST( NO_CONTACT_WITH_DB_NODES = 5030 ); STATIC_CONST( NO_CONTACT_WITH_DB_NODES = 5030 );
/**
* This class holds all statistical variables fetched with
* the getStatistics methods.
*/
class Statistics { // TODO, Real statistic data to be added
public:
int _test1;
};
/** /**
* This enum specifies the different signal loggig modes possible to set * This enum specifies the different signal loggig modes possible to set
* with the setSignalLoggingMode method. * with the setSignalLoggingMode method.
...@@ -206,7 +210,7 @@ public: ...@@ -206,7 +210,7 @@ public:
typedef void (* EnterSingleCallback)(int nodeId, void * anyData, typedef void (* EnterSingleCallback)(int nodeId, void * anyData,
int errorCode); int errorCode);
typedef void (* ExitSingleCallback)(int nodeId, void * anyData, typedef void (* ExitSingleCallback)(int nodeId, void * anyData,
int errorCode); int errorCode);
/** /**
* Lock configuration * Lock configuration
...@@ -313,13 +317,6 @@ public: ...@@ -313,13 +317,6 @@ public:
bool abort = false, bool abort = false,
int * stopCount = 0, StopCallback = 0, void * anyData = 0); int * stopCount = 0, StopCallback = 0, void * anyData = 0);
int setEventReportingLevel(int processId,
const class SetLogLevelOrd & logLevel,
bool isResend = false);
int startStatisticEventReporting(int level = 5);
struct BackupEvent { struct BackupEvent {
enum Event { enum Event {
BackupStarted = 1, BackupStarted = 1,
...@@ -377,22 +374,8 @@ public: ...@@ -377,22 +374,8 @@ public:
// INVALID_LEVEL // INVALID_LEVEL
//************************************************************************** //**************************************************************************
/** int setEventReportingLevelImpl(int processId, const EventSubscribeReq& ll);
* Sets the Node's log level, i.e., its local event reporting. int setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll);
*
* @param processId the DB node id.
* @param logLevel the log level.
* @param isResend Flag to indicate for resending log levels
* during node restart
* @return 0 if successful or NO_CONTACT_WITH_PROCESS,
* SEND_OR_RECEIVE_FAILED,
* COULD_NOT_ALLOCATE_MEMORY
*/
int setNodeLogLevel(int processId,
const class SetLogLevelOrd & logLevel,
bool isResend = false);
/** /**
* Insert an error in a DB process. * Insert an error in a DB process.
...@@ -508,11 +491,6 @@ public: ...@@ -508,11 +491,6 @@ public:
*/ */
NodeId getPrimaryNode() const; NodeId getPrimaryNode() const;
/**
* Returns the statistics port number.
* @return statistic port number.
*/
int getStatPort() const;
/** /**
* Returns the port number. * Returns the port number.
* @return port number. * @return port number.
...@@ -526,10 +504,7 @@ public: ...@@ -526,10 +504,7 @@ public:
private: private:
//************************************************************************** //**************************************************************************
int setEventReportingLevelImpl(int processId, int setEventReportingLevel(int processId, LogLevel::EventCategory, Uint32);
const class SetLogLevelOrd & logLevel,
bool isResend = false);
/** /**
* Check if it is possible to send a signal to a (DB) process * Check if it is possible to send a signal to a (DB) process
...@@ -563,10 +538,6 @@ private: ...@@ -563,10 +538,6 @@ private:
Allocated_resources m_allocated_resources; Allocated_resources m_allocated_resources;
struct in_addr m_connect_address[MAX_NODES]; struct in_addr m_connect_address[MAX_NODES];
int _setVarReqResult; // The result of the SET_VAR_REQ response
Statistics _statistics; // handleSTATISTICS_CONF store the result here,
// and getStatistics reads it.
//************************************************************************** //**************************************************************************
// Specific signal handling methods // Specific signal handling methods
//************************************************************************** //**************************************************************************
...@@ -598,14 +569,6 @@ private: ...@@ -598,14 +569,6 @@ private:
// Returns: - // Returns: -
//************************************************************************** //**************************************************************************
int handleSTATISTICS_CONF(NdbApiSignal* signal);
//**************************************************************************
// Description: Handle reception of signal STATISTICS_CONF
// Parameters:
// signal: The recieved signal
// Returns: TODO, to be defined
//**************************************************************************
void handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal); void handle_MGM_LOCK_CONFIG_REQ(NdbApiSignal *signal);
void handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal); void handle_MGM_UNLOCK_CONFIG_REQ(NdbApiSignal *signal);
...@@ -631,7 +594,6 @@ private: ...@@ -631,7 +594,6 @@ private:
*/ */
enum WaitSignalType { enum WaitSignalType {
NO_WAIT, // We don't expect to receive any signal NO_WAIT, // We don't expect to receive any signal
WAIT_STATISTICS, // Accept STATISTICS_CONF
WAIT_SET_VAR, // Accept SET_VAR_CONF and SET_VAR_REF WAIT_SET_VAR, // Accept SET_VAR_CONF and SET_VAR_REF
WAIT_SUBSCRIBE_CONF, // Accept event subscription confirmation WAIT_SUBSCRIBE_CONF, // Accept event subscription confirmation
WAIT_STOP, WAIT_STOP,
...@@ -733,14 +695,6 @@ private: ...@@ -733,14 +695,6 @@ private:
class SignalQueue m_signalRecvQueue; class SignalQueue m_signalRecvQueue;
enum ndb_mgm_node_type nodeTypes[MAX_NODES];
int theConfCount; // The number of expected conf signals
StatisticsListner * m_statisticsListner; // Used for sending statistics info
bool _isStatPortActive;
bool _isClusterLogStatActive;
struct StopRecord { struct StopRecord {
StopRecord(){ inUse = false; callback = 0; singleUserMode = false;} StopRecord(){ inUse = false; callback = 0; singleUserMode = false;}
bool inUse; bool inUse;
...@@ -765,10 +719,16 @@ private: ...@@ -765,10 +719,16 @@ private:
void handleStopReply(NodeId nodeId, Uint32 errCode); void handleStopReply(NodeId nodeId, Uint32 errCode);
int translateStopRef(Uint32 errCode); int translateStopRef(Uint32 errCode);
bool _isStopThread; bool _isStopThread;
int _logLevelThreadSleep; int _logLevelThreadSleep;
int _startedNodeId; MutexVector<NodeId> m_started_nodes;
MutexVector<EventSubscribeReq> m_log_level_requests;
LogLevel m_nodeLogLevel[MAX_NODES];
enum ndb_mgm_node_type nodeTypes[MAX_NODES];
friend class MgmApiSession;
friend class MgmStatService;
MgmStatService m_statisticsListner;
/** /**
* Handles the thread wich upon a 'Node is started' event will * Handles the thread wich upon a 'Node is started' event will
...@@ -782,15 +742,13 @@ private: ...@@ -782,15 +742,13 @@ private:
static void *signalRecvThread_C(void *); static void *signalRecvThread_C(void *);
void signalRecvThreadRun(); void signalRecvThreadRun();
NodeLogLevelList* _nodeLogLevelList;
NodeLogLevelList* _clusterLogLevelList;
void backupCallback(BackupEvent &); void backupCallback(BackupEvent &);
BackupCallback m_backupCallback; BackupCallback m_backupCallback;
BackupEvent m_lastBackupEvent; BackupEvent m_lastBackupEvent;
Config *_props; Config *_props;
int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type);
public: public:
/** /**
* This method does not exist * This method does not exist
......
/* 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 "NodeLogLevel.hpp"
// TODO_RONM: Clearly getCategory and getLevel is not correctly coded. Must be taken care of.
NodeLogLevel::NodeLogLevel(int nodeId, const SetLogLevelOrd& ll)
{
m_nodeId = nodeId;
m_logLevel = ll;
}
NodeLogLevel::~NodeLogLevel()
{
}
int
NodeLogLevel::getNodeId() const
{
return m_nodeId;
}
Uint32
NodeLogLevel::getCategory() const
{
for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
{
return m_logLevel.theCategories[i];
}
return 0;
}
int
NodeLogLevel::getLevel() const
{
for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
{
return m_logLevel.theLevels[i];
}
return 0;
}
void
NodeLogLevel::setLevel(int level)
{
for (Uint32 i = 0; i < m_logLevel.noOfEntries; i++)
{
m_logLevel.theLevels[i] = level;
}
}
SetLogLevelOrd
NodeLogLevel::getLogLevelOrd() const
{
return m_logLevel;
}
/* 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 */
#ifndef NODELOGLEVEL_H
#define NODELOGLEVEL_H
#include <ndb_global.h>
#include <signaldata/SetLogLevelOrd.hpp>
/**
* Holds a DB node's log level settings for both local and event log levels.
* It only holds one log level setting even though SetLogLevelOrd can handle
* multiple log levels at once, it is not used in that way in the managment
* server.
*
* @version #@ $Id: NodeLogLevel.hpp,v 1.2 2003/07/05 17:40:22 elathal Exp $
*/
class NodeLogLevel
{
public:
NodeLogLevel(int nodeId, const SetLogLevelOrd& ll);
~NodeLogLevel();
int getNodeId() const;
Uint32 getCategory() const;
int getLevel() const;
void setLevel(int level);
SetLogLevelOrd getLogLevelOrd() const;
private:
NodeLogLevel();
NodeLogLevel(const NodeLogLevel&);
bool operator == (const NodeLogLevel&);
NodeLogLevel operator = (const NodeLogLevel&);
int m_nodeId;
SetLogLevelOrd m_logLevel;
};
#endif
/* 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 "NodeLogLevelList.hpp"
#include "NodeLogLevel.hpp"
//
// PUBLIC
//
NodeLogLevelList::NodeLogLevelList() :
m_size(0),
m_pHeadNode(NULL),
m_pTailNode(NULL),
m_pCurrNode(NULL)
{
}
NodeLogLevelList::~NodeLogLevelList()
{
removeAll();
}
void
NodeLogLevelList::add(NodeLogLevel* pNewNode)
{
NodeLogLevelNode* pNode = new NodeLogLevelNode();
if (m_pHeadNode == NULL)
{
m_pHeadNode = pNode;
pNode->pPrev = NULL;
}
else
{
m_pTailNode->pNext = pNode;
pNode->pPrev = m_pTailNode;
}
m_pTailNode = pNode;
pNode->pNext = NULL;
pNode->pHandler = pNewNode;
m_size++;
}
bool
NodeLogLevelList::remove(NodeLogLevel* pRemoveNode)
{
NodeLogLevelNode* pNode = m_pHeadNode;
bool removed = false;
do
{
if (pNode->pHandler == pRemoveNode)
{
removeNode(pNode);
removed = true;
break;
}
} while ( (pNode = next(pNode)) != NULL);
return removed;
}
void
NodeLogLevelList::removeAll()
{
while (m_pHeadNode != NULL)
{
removeNode(m_pHeadNode);
}
}
NodeLogLevel*
NodeLogLevelList::next()
{
NodeLogLevel* pHandler = NULL;
if (m_pCurrNode == NULL)
{
m_pCurrNode = m_pHeadNode;
if (m_pCurrNode != NULL)
{
pHandler = m_pCurrNode->pHandler;
}
}
else
{
m_pCurrNode = next(m_pCurrNode); // Next node
if (m_pCurrNode != NULL)
{
pHandler = m_pCurrNode->pHandler;
}
}
return pHandler;
}
int
NodeLogLevelList::size() const
{
return m_size;
}
//
// PRIVATE
//
NodeLogLevelList::NodeLogLevelNode*
NodeLogLevelList::next(NodeLogLevelNode* pNode)
{
NodeLogLevelNode* pCurr = pNode;
if (pNode->pNext != NULL)
{
pCurr = pNode->pNext;
}
else
{
// Tail
pCurr = NULL;
}
return pCurr;
}
NodeLogLevelList::NodeLogLevelNode*
NodeLogLevelList::prev(NodeLogLevelNode* pNode)
{
NodeLogLevelNode* pCurr = pNode;
if (pNode->pPrev != NULL) // head
{
pCurr = pNode->pPrev;
}
else
{
// Head
pCurr = NULL;
}
return pCurr;
}
void
NodeLogLevelList::removeNode(NodeLogLevelNode* pNode)
{
if (pNode->pPrev == NULL) // If head
{
m_pHeadNode = pNode->pNext;
}
else
{
pNode->pPrev->pNext = pNode->pNext;
}
if (pNode->pNext == NULL) // if tail
{
m_pTailNode = pNode->pPrev;
}
else
{
pNode->pNext->pPrev = pNode->pPrev;
}
pNode->pNext = NULL;
pNode->pPrev = NULL;
delete pNode->pHandler; // Delete log handler
delete pNode;
m_size--;
}
/* 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 */
#ifndef NODELOGLEVELLIST_H
#define NODELOGLEVELLIST_H
class NodeLogLevel;
/**
* Provides a simple linked list of NodeLogLevel.
*
* @see NodeLogLevel
* @version #@ $Id: NodeLogLevelList.hpp,v 1.1 2002/08/09 12:53:50 eyualex Exp $
*/
class NodeLogLevelList
{
public:
/**
* Default Constructor.
*/
NodeLogLevelList();
/**
* Destructor.
*/
~NodeLogLevelList();
/**
* Adds a new node.
*
* @param pNewHandler a new NodeLogLevel.
*/
void add(NodeLogLevel* pNewNode);
/**
* Removes a NodeLogLevel from the list and call its destructor.
*
* @param pRemoveHandler the NodeLogLevel to remove
*/
bool remove(NodeLogLevel* pRemoveNode);
/**
* Removes all items.
*/
void removeAll();
/**
* Returns the next node in the list.
* returns a node or NULL.
*/
NodeLogLevel* next();
/**
* Returns the size of the list.
*/
int size() const;
private:
/** List node */
struct NodeLogLevelNode
{
NodeLogLevelNode* pPrev;
NodeLogLevelNode* pNext;
NodeLogLevel* pHandler;
};
NodeLogLevelNode* next(NodeLogLevelNode* pNode);
NodeLogLevelNode* prev(NodeLogLevelNode* pNode);
void removeNode(NodeLogLevelNode* pNode);
int m_size;
NodeLogLevelNode* m_pHeadNode;
NodeLogLevelNode* m_pTailNode;
NodeLogLevelNode* m_pCurrNode;
};
#endif
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <mgmapi.h> #include <mgmapi.h>
#include <EventLogger.hpp> #include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp> #include <signaldata/SetLogLevelOrd.hpp>
#include <LogLevel.hpp>
#include <BaseString.hpp> #include <BaseString.hpp>
#include <Base64.hpp> #include <Base64.hpp>
...@@ -133,7 +134,7 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -133,7 +134,7 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("public key", String, Mandatory, "Public key"), MGM_ARG("public key", String, Mandatory, "Public key"),
MGM_CMD("get version", &MgmApiSession::getVersion, ""), MGM_CMD("get version", &MgmApiSession::getVersion, ""),
MGM_CMD("get status", &MgmApiSession::getStatus, ""), MGM_CMD("get status", &MgmApiSession::getStatus, ""),
MGM_CMD("get info clusterlog", &MgmApiSession::getInfoClusterLog, ""), MGM_CMD("get info clusterlog", &MgmApiSession::getInfoClusterLog, ""),
...@@ -236,7 +237,11 @@ ParserRow<MgmApiSession> commands[] = { ...@@ -236,7 +237,11 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("node", String, Mandatory, "Node"), MGM_ARG("node", String, Mandatory, "Node"),
MGM_ARG("parameter", String, Mandatory, "Parameter"), MGM_ARG("parameter", String, Mandatory, "Parameter"),
MGM_ARG("value", String, Mandatory, "Value"), MGM_ARG("value", String, Mandatory, "Value"),
MGM_CMD("listen event", &MgmApiSession::listen_event, ""),
MGM_ARG("node", Int, Optional, "Node"),
MGM_ARG("filter", String, Mandatory, "Event category"),
MGM_END() MGM_END()
}; };
...@@ -289,7 +294,8 @@ MgmApiSession::runSession() { ...@@ -289,7 +294,8 @@ MgmApiSession::runSession() {
break; break;
} }
} }
NDB_CLOSE_SOCKET(m_socket); if(m_socket >= 0)
NDB_CLOSE_SOCKET(m_socket);
} }
#ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT #ifdef MGM_GET_CONFIG_BACKWARDS_COMPAT
...@@ -554,7 +560,7 @@ MgmApiSession::getStatPort(Parser_t::Context &, ...@@ -554,7 +560,7 @@ MgmApiSession::getStatPort(Parser_t::Context &,
const class Properties &) { const class Properties &) {
m_output->println("get statport reply"); m_output->println("get statport reply");
m_output->println("tcpport: %d", m_mgmsrv.getStatPort()); m_output->println("tcpport: %d", 0);
m_output->println(""); m_output->println("");
} }
...@@ -760,7 +766,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, ...@@ -760,7 +766,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
BaseString categoryName, errorString; BaseString categoryName, errorString;
SetLogLevelOrd logLevel; SetLogLevelOrd logLevel;
int result; int result;
logLevel.clear();
args.get("node", &node); args.get("node", &node);
args.get("category", categoryName); args.get("category", categoryName);
args.get("level", &level); args.get("level", &level);
...@@ -779,14 +784,15 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, ...@@ -779,14 +784,15 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
goto error; goto error;
} }
logLevel.setLogLevel(category, level); EventSubscribeReq req;
result = m_mgmsrv.setEventReportingLevel(node, logLevel); req.blockRef = 0;
req.noOfEntries = 1;
req.theCategories[0] = category;
req.theLevels[0] = level;
m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set cluster loglevel reply"); m_output->println("set cluster loglevel reply");
if(result != 0) m_output->println("result: Ok");
m_output->println("result: %s", m_mgmsrv.getErrorText(result));
else
m_output->println("result: Ok");
m_output->println(""); m_output->println("");
return; return;
error: error:
...@@ -821,15 +827,15 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &, ...@@ -821,15 +827,15 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
goto error; goto error;
} }
logLevel.setLogLevel(category, level); EventSubscribeReq req;
req.blockRef = node;
result = m_mgmsrv.setNodeLogLevel(node, logLevel); req.noOfEntries = 1;
req.theCategories[0] = category;
req.theLevels[0] = level;
m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set loglevel reply"); m_output->println("set loglevel reply");
if(result != 0) m_output->println("result: Ok");
m_output->println("result: %s", m_mgmsrv.getErrorText(result));
else
m_output->println("result: Ok");
m_output->println(""); m_output->println("");
return; return;
error: error:
...@@ -1248,33 +1254,91 @@ MgmApiSession::configChange(Parser_t::Context &, ...@@ -1248,33 +1254,91 @@ MgmApiSession::configChange(Parser_t::Context &,
m_output->println(""); m_output->println("");
} }
void NdbOut&
MgmStatService::println_statistics(const BaseString &line){ operator<<(NdbOut& out, const LogLevel & ll)
MutexVector<NDB_SOCKET_TYPE> copy(m_sockets.size()); {
m_sockets.lock(); out << "[LogLevel: ";
for(size_t i = 0; i<_LOGLEVEL_CATEGORIES; i++)
out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
out << "]";
}
void
MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){
Uint32 threshold = 0;
LogLevel::EventCategory cat;
for(unsigned i = 0; i<EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){
cat = EventLogger::matrix[i].eventCategory;
threshold = EventLogger::matrix[i].threshold;
break;
}
}
char m_text[256];
EventLogger::getText(m_text, sizeof(m_text), eventType, theData, nodeId);
Vector<NDB_SOCKET_TYPE> copy;
m_clients.lock();
int i; int i;
for(i = m_sockets.size() - 1; i >= 0; i--){ for(i = m_clients.size() - 1; i >= 0; i--){
if(println_socket(m_sockets[i], MAX_WRITE_TIMEOUT, line.c_str()) == -1){ if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){
copy.push_back(m_sockets[i]); if(m_clients[i].m_socket >= 0 &&
m_sockets.erase(i, false); println_socket(m_clients[i].m_socket,
MAX_WRITE_TIMEOUT, m_text) == -1){
copy.push_back(m_clients[i].m_socket);
m_clients.erase(i, false);
}
} }
} }
m_sockets.unlock(); m_clients.unlock();
for(i = copy.size() - 1; i >= 0; i--){ for(i = 0; (unsigned)i<copy.size(); i++){
NDB_CLOSE_SOCKET(copy[i]); NDB_CLOSE_SOCKET(copy[i]);
copy.erase(i);
} }
if(m_sockets.size() == 0 || false){
m_mgmsrv->startStatisticEventReporting(0); if(copy.size()){
LogLevel tmp; tmp.clear();
m_clients.lock();
for(i = 0; i < m_clients.size(); i++){
tmp.set_max(m_clients[i].m_logLevel);
}
m_clients.unlock();
if(!(tmp == m_logLevel)){
m_logLevel = tmp;
EventSubscribeReq req;
req = tmp;
req.blockRef = 0;
m_mgmsrv->m_log_level_requests.push_back(req);
}
}
}
void
MgmStatService::add_listener(const StatListener& client){
m_clients.push_back(client);
LogLevel tmp = m_logLevel;
tmp.set_max(client.m_logLevel);
if(!(tmp == m_logLevel)){
m_logLevel = tmp;
EventSubscribeReq req;
req = tmp;
req.blockRef = 0;
m_mgmsrv->m_log_level_requests.push_back(req);
} }
} }
void void
MgmStatService::stopSessions(){ MgmStatService::stopSessions(){
for(int i = m_sockets.size() - 1; i >= 0; i--){ for(int i = m_clients.size() - 1; i >= 0; i--){
NDB_CLOSE_SOCKET(m_sockets[i]); if(m_clients[i].m_socket >= 0){
m_sockets.erase(i); NDB_CLOSE_SOCKET(m_clients[i].m_socket);
m_clients.erase(i);
}
} }
} }
...@@ -1298,6 +1362,71 @@ MgmApiSession::setParameter(Parser_t::Context &, ...@@ -1298,6 +1362,71 @@ MgmApiSession::setParameter(Parser_t::Context &,
m_output->println(""); m_output->println("");
} }
void
MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx,
Properties const & args) {
BaseString node, param, value;
args.get("node", node);
args.get("filter", param);
int result = 0;
BaseString msg;
MgmStatService::StatListener le;
le.m_socket = m_socket;
Vector<BaseString> list;
param.trim();
param.split(list, " ,");
for(size_t i = 0; i<list.size(); i++){
Vector<BaseString> spec;
list[i].trim();
list[i].split(spec, "=:");
if(spec.size() != 2){
msg.appfmt("Invalid filter specification: >%s< >%s< %d",
param.c_str(), list[i].c_str(), spec.size());
result = -1;
goto done;
}
spec[0].trim();
spec[0].ndb_toupper();
LogLevel::EventCategory category;
if(!EventLogger::matchEventCategory(spec[0].c_str(), &category)) {
msg.appfmt("Unknown category: >%s<", spec[0].c_str());
result = -1;
goto done;
}
int level = atoi(spec[1].c_str());
if(level < 0 || level > 15){
msg.appfmt("Invalid level: >%s<", spec[1].c_str());
result = -1;
goto done;
}
le.m_logLevel.setLogLevel(category, level);
}
if(list.size() == 0){
msg.appfmt("Empty filter specification");
result = -1;
goto done;
}
m_mgmsrv.m_statisticsListner.add_listener(le);
m_stop = true;
m_socket = -1;
done:
m_output->println("listen event");
m_output->println("result: %d", result);
if(result != 0)
m_output->println("msg: %s", msg.c_str());
}
template class MutexVector<int>; template class MutexVector<int>;
template class Vector<ParserRow<MgmApiSession> const*>; template class Vector<ParserRow<MgmApiSession> const*>;
template class Vector<unsigned short>; template class Vector<unsigned short>;
...@@ -83,7 +83,8 @@ public: ...@@ -83,7 +83,8 @@ public:
void configChange(Parser_t::Context &ctx, const class Properties &args); void configChange(Parser_t::Context &ctx, const class Properties &args);
void setParameter(Parser_t::Context &ctx, const class Properties &args); void setParameter(Parser_t::Context &ctx, const class Properties &args);
void listen_event(Parser_t::Context &ctx, const class Properties &args);
void repCommand(Parser_t::Context &ctx, const class Properties &args); void repCommand(Parser_t::Context &ctx, const class Properties &args);
}; };
...@@ -103,28 +104,4 @@ public: ...@@ -103,28 +104,4 @@ public:
} }
}; };
class MgmStatService : public SocketServer::Service,
public MgmtSrvr::StatisticsListner
{
class MgmtSrvr * m_mgmsrv;
MutexVector<NDB_SOCKET_TYPE> m_sockets;
public:
MgmStatService() : m_sockets(5) {
m_mgmsrv = 0;
}
void setMgm(class MgmtSrvr * mgmsrv){
m_mgmsrv = mgmsrv;
}
SocketServer::Session * newSession(NDB_SOCKET_TYPE socket){
m_sockets.push_back(socket);
m_mgmsrv->startStatisticEventReporting(5);
return 0;
}
void stopSessions();
void println_statistics(const BaseString &line);
};
#endif #endif
...@@ -70,7 +70,6 @@ struct MgmGlobals { ...@@ -70,7 +70,6 @@ struct MgmGlobals {
bool use_specific_ip; bool use_specific_ip;
char * interface_name; char * interface_name;
int port; int port;
int port_stats;
/** The configuration of the cluster */ /** The configuration of the cluster */
Config * cluster_config; Config * cluster_config;
...@@ -169,8 +168,6 @@ NDB_MAIN(mgmsrv){ ...@@ -169,8 +168,6 @@ NDB_MAIN(mgmsrv){
MgmApiService * mapi = new MgmApiService(); MgmApiService * mapi = new MgmApiService();
MgmStatService * mstat = new MgmStatService();
/**************************** /****************************
* Read configuration files * * Read configuration files *
****************************/ ****************************/
...@@ -230,13 +227,6 @@ NDB_MAIN(mgmsrv){ ...@@ -230,13 +227,6 @@ NDB_MAIN(mgmsrv){
goto error_end; goto error_end;
} }
if(!glob.socketServer->setup(mstat, glob.port_stats, glob.interface_name)){
ndbout_c("Unable to setup statistic port: %d!\nPlease check if the port"
" is already used.", glob.port_stats);
delete mstat;
goto error_end;
}
if(!glob.mgmObject->check_start()){ if(!glob.mgmObject->check_start()){
ndbout_c("Unable to check start management server."); ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file."); ndbout_c("Probably caused by illegal initial configuration file.");
...@@ -267,10 +257,7 @@ NDB_MAIN(mgmsrv){ ...@@ -267,10 +257,7 @@ NDB_MAIN(mgmsrv){
} }
//glob.mgmObject->saveConfig(); //glob.mgmObject->saveConfig();
mstat->setMgm(glob.mgmObject);
mapi->setMgm(glob.mgmObject); mapi->setMgm(glob.mgmObject);
glob.mgmObject->setStatisticsListner(mstat);
char msg[256]; char msg[256];
snprintf(msg, sizeof(msg), snprintf(msg, sizeof(msg),
...@@ -278,8 +265,8 @@ NDB_MAIN(mgmsrv){ ...@@ -278,8 +265,8 @@ NDB_MAIN(mgmsrv){
ndbout_c(msg); ndbout_c(msg);
g_EventLogger.info(msg); g_EventLogger.info(msg);
snprintf(msg, 256, "Id: %d, Command port: %d, Statistics port: %d", snprintf(msg, 256, "Id: %d, Command port: %d",
glob.localNodeId, glob.port, glob.port_stats); glob.localNodeId, glob.port);
ndbout_c(msg); ndbout_c(msg);
g_EventLogger.info(msg); g_EventLogger.info(msg);
...@@ -309,7 +296,6 @@ NDB_MAIN(mgmsrv){ ...@@ -309,7 +296,6 @@ NDB_MAIN(mgmsrv){
MgmGlobals::MgmGlobals(){ MgmGlobals::MgmGlobals(){
// Default values // Default values
port = 0; port = 0;
port_stats = 0;
config_filename = NULL; config_filename = NULL;
local_config_filename = NULL; local_config_filename = NULL;
interface_name = 0; interface_name = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment