Commit 32cd5acd authored by joreland@mysql.com's avatar joreland@mysql.com

wl1668 -

Add support for getting events via mgmapi
removed all traces of stat port
parent 27a4e6e2
......@@ -24,6 +24,65 @@
#include <kernel/LogLevel.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
* in the Management Server. It inherits all logging functionality of Logger.
......@@ -58,7 +117,7 @@
* @see Logger
* @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:
/**
......@@ -70,7 +129,7 @@ public:
/**
* Destructor.
*/
~EventLogger();
virtual ~EventLogger();
/**
* Opens/creates the eventlog with the specified filename.
......@@ -92,16 +151,6 @@ public:
*/
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.
*
......@@ -109,16 +158,19 @@ public:
* @param theData the event data.
* @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.
* Enable, disable log levels to filter the events that are sent to the
* eventlog.
* Returns the event text for the specified event report type.
*
* @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
......@@ -127,6 +179,7 @@ public:
* @return the log level filter that is used for all event categories.
*/
int getFilterLevel() const;
/**
* Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'.
......@@ -135,92 +188,16 @@ public:
*/
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:
/** Prohibit */
EventLogger(const EventLogger&);
EventLogger operator = (const EventLogger&);
bool operator == (const EventLogger&);
LogLevel m_logLevel;
Uint32 m_filterLevel;
STATIC_CONST(MAX_TEXT_LENGTH = 256);
static char m_text[MAX_TEXT_LENGTH];
char m_text[MAX_TEXT_LENGTH];
};
......
......@@ -130,13 +130,20 @@ public:
*/
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:
/**
* The actual data
*/
Uint32 logLevelData[LOGLEVEL_CATEGORIES];
LogLevel(const LogLevel &);
Uint8 logLevelData[LOGLEVEL_CATEGORIES];
};
inline
......@@ -176,5 +183,14 @@ LogLevel::getLogLevel(EventCategory ec) const{
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
......@@ -27,7 +27,7 @@
* RECIVER: SimBlockCMCtrBlck
*/
class EventSubscribeReq {
struct EventSubscribeReq {
/**
* Receiver(s)
*/
......@@ -38,9 +38,8 @@ class EventSubscribeReq {
*/
friend class MgmtSrvr;
public:
STATIC_CONST( SignalLength = 22 );
private:
/**
* Note: If you use the same blockRef as you have used earlier,
* you update your ongoing subscription
......@@ -55,6 +54,15 @@ private:
Uint32 theCategories[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
......@@ -18,6 +18,7 @@
#define SET_LOGLEVEL_ORD_HPP
#include <LogLevel.hpp>
#include "EventSubscribeReq.hpp"
#include "SignalData.hpp"
/**
......@@ -51,6 +52,24 @@ private:
* Note level is valid as 0-15
*/
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
......
......@@ -55,24 +55,6 @@
extern "C" {
#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.
*/
......
......@@ -28,6 +28,10 @@
//
// PUBLIC
//
EventLoggerBase::~EventLoggerBase()
{
}
/**
* This matrix defines which event should be printed when
......@@ -35,105 +39,86 @@
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
const EventLogger::EventRepLogLevelMatrix EventLogger::matrix[] = {
const EventLoggerBase::EventRepLogLevelMatrix EventLoggerBase::matrix[] = {
// CONNECTION
{ EventReport::Connected, LogLevel::llConnection, 8, LL_INFO },
{ EventReport::Disconnected, LogLevel::llConnection, 8, LL_ALERT },
{ EventReport::CommunicationClosed, LogLevel::llConnection, 8, LL_INFO },
{ EventReport::CommunicationOpened, LogLevel::llConnection, 8, LL_INFO },
{ EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, LL_INFO },
{ EventReport::Connected, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::Disconnected, LogLevel::llConnection, 8, Logger::LL_ALERT },
{ EventReport::CommunicationClosed, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::CommunicationOpened, LogLevel::llConnection, 8, Logger::LL_INFO },
{ EventReport::ConnectedApiVersion, LogLevel::llConnection, 8, Logger::LL_INFO },
// CHECKPOINT
{ EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, LL_INFO },
{ EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, LL_INFO },
{ EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, LL_INFO },
{ EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, LL_INFO },
{ EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, LL_ALERT },
{ EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, LL_INFO },
{ EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, LL_INFO },
{ EventReport::GlobalCheckpointStarted, LogLevel::llCheckpoint, 9, Logger::LL_INFO },
{ EventReport::GlobalCheckpointCompleted,LogLevel::llCheckpoint,10, Logger::LL_INFO },
{ EventReport::LocalCheckpointStarted, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
{ EventReport::LocalCheckpointCompleted,LogLevel::llCheckpoint, 8, Logger::LL_INFO },
{ EventReport::LCPStoppedInCalcKeepGci, LogLevel::llCheckpoint, 0, Logger::LL_ALERT },
{ EventReport::LCPFragmentCompleted, LogLevel::llCheckpoint, 11, Logger::LL_INFO },
{ EventReport::UndoLogBlocked, LogLevel::llCheckpoint, 7, Logger::LL_INFO },
// STARTUP
{ EventReport::NDBStartStarted, LogLevel::llStartUp, 1, LL_INFO },
{ EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, LL_INFO },
{ EventReport::STTORRYRecieved, LogLevel::llStartUp,15, LL_INFO },
{ EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, LL_INFO },
{ EventReport::CM_REGCONF, LogLevel::llStartUp, 3, LL_INFO },
{ EventReport::CM_REGREF, LogLevel::llStartUp, 8, LL_INFO },
{ EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, LL_INFO },
{ EventReport::NDBStopStarted, LogLevel::llStartUp, 1, LL_INFO },
{ EventReport::NDBStopAborted, LogLevel::llStartUp, 1, LL_INFO },
{ EventReport::StartREDOLog, LogLevel::llStartUp, 10, LL_INFO },
{ EventReport::StartLog, LogLevel::llStartUp, 10, LL_INFO },
{ EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, LL_INFO },
{ EventReport::NDBStartStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::NDBStartCompleted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::STTORRYRecieved, LogLevel::llStartUp,15, Logger::LL_INFO },
{ EventReport::StartPhaseCompleted, LogLevel::llStartUp, 4, Logger::LL_INFO },
{ EventReport::CM_REGCONF, LogLevel::llStartUp, 3, Logger::LL_INFO },
{ EventReport::CM_REGREF, LogLevel::llStartUp, 8, Logger::LL_INFO },
{ EventReport::FIND_NEIGHBOURS, LogLevel::llStartUp, 8, Logger::LL_INFO },
{ EventReport::NDBStopStarted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::NDBStopAborted, LogLevel::llStartUp, 1, Logger::LL_INFO },
{ EventReport::StartREDOLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
{ EventReport::StartLog, LogLevel::llStartUp, 10, Logger::LL_INFO },
{ EventReport::UNDORecordsExecuted, LogLevel::llStartUp, 15, Logger::LL_INFO },
// NODERESTART
{ EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, LL_INFO },
{ EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, LL_INFO },
{ EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, LL_INFO },
{ EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, LL_INFO },
{ EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, LL_INFO },
{ EventReport::NR_CopyDict, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyDistr, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyFragsStarted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NR_CopyFragDone, LogLevel::llNodeRestart, 10, Logger::LL_INFO },
{ EventReport::NR_CopyFragsCompleted, LogLevel::llNodeRestart, 8, Logger::LL_INFO },
{ EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, LL_ALERT},
{ EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, LL_ALERT},
{ EventReport::ArbitState, LogLevel::llNodeRestart, 6, LL_INFO },
{ EventReport::ArbitResult, LogLevel::llNodeRestart, 2, LL_ALERT},
{ EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO },
{ EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO },
{ EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, LL_INFO },
{ EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, LL_INFO },
{ EventReport::NodeFailCompleted, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
{ EventReport::NODE_FAILREP, LogLevel::llNodeRestart, 8, Logger::LL_ALERT},
{ EventReport::ArbitState, LogLevel::llNodeRestart, 6, Logger::LL_INFO },
{ EventReport::ArbitResult, LogLevel::llNodeRestart, 2, Logger::LL_ALERT},
{ EventReport::GCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::GCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::LCP_TakeoverStarted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
{ EventReport::LCP_TakeoverCompleted, LogLevel::llNodeRestart, 7, Logger::LL_INFO },
// STATISTIC
{ EventReport::TransReportCounters, LogLevel::llStatistic, 8, LL_INFO },
{ EventReport::OperationReportCounters, LogLevel::llStatistic, 8, LL_INFO },
{ EventReport::TableCreated, LogLevel::llStatistic, 7, LL_INFO },
{ EventReport::JobStatistic, LogLevel::llStatistic, 9, LL_INFO },
{ EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, LL_INFO },
{ EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, LL_INFO },
{ EventReport::MemoryUsage, LogLevel::llStatistic, 5, LL_INFO },
{ EventReport::TransReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
{ EventReport::OperationReportCounters, LogLevel::llStatistic, 8, Logger::LL_INFO },
{ EventReport::TableCreated, LogLevel::llStatistic, 7, Logger::LL_INFO },
{ EventReport::JobStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::SendBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::ReceiveBytesStatistic, LogLevel::llStatistic, 9, Logger::LL_INFO },
{ EventReport::MemoryUsage, LogLevel::llStatistic, 5, Logger::LL_INFO },
// ERROR
{ EventReport::TransporterError, LogLevel::llError, 2, LL_ERROR },
{ EventReport::TransporterWarning, LogLevel::llError, 8, LL_WARNING },
{ EventReport::MissedHeartbeat, LogLevel::llError, 8, LL_WARNING },
{ EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, LL_ALERT },
{ EventReport::WarningEvent, LogLevel::llError, 2, LL_WARNING },
{ EventReport::TransporterError, LogLevel::llError, 2, Logger::LL_ERROR },
{ EventReport::TransporterWarning, LogLevel::llError, 8, Logger::LL_WARNING },
{ EventReport::MissedHeartbeat, LogLevel::llError, 8, Logger::LL_WARNING },
{ EventReport::DeadDueToHeartbeat, LogLevel::llError, 8, Logger::LL_ALERT },
{ EventReport::WarningEvent, LogLevel::llError, 2, Logger::LL_WARNING },
// INFO
{ EventReport::SentHeartbeat, LogLevel::llInfo, 12, LL_INFO },
{ EventReport::CreateLogBytes, LogLevel::llInfo, 11, LL_INFO },
{ EventReport::InfoEvent, LogLevel::llInfo, 2, LL_INFO },
{ EventReport::SentHeartbeat, LogLevel::llInfo, 12, Logger::LL_INFO },
{ EventReport::CreateLogBytes, LogLevel::llInfo, 11, Logger::LL_INFO },
{ EventReport::InfoEvent, LogLevel::llInfo, 2, Logger::LL_INFO },
//Global replication
{ EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, LL_INFO},
{ EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, LL_ALERT}
{ EventReport::GrepSubscriptionInfo, LogLevel::llGrep, 7, Logger::LL_INFO},
{ EventReport::GrepSubscriptionAlert, LogLevel::llGrep, 7, Logger::LL_ALERT}
};
const Uint32 EventLogger::matrixSize = sizeof(EventLogger::matrix)/
const Uint32 EventLoggerBase::matrixSize = sizeof(EventLoggerBase::matrix)/
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
* the Management API/interactive shell.
*/
const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = {
const EventLoggerBase::EventCategoryName
EventLoggerBase::eventCategoryNames[] = {
{ LogLevel::llStartUp, "STARTUP" },
{ LogLevel::llStatistic, "STATISTICS" },
{ LogLevel::llCheckpoint, "CHECKPOINT" },
......@@ -144,13 +129,13 @@ const EventLogger::EventCategoryName EventLogger::eventCategoryNames[] = {
};
const Uint32
EventLogger::noOfEventCategoryNames = sizeof(EventLogger::eventCategoryNames)/
sizeof(EventLogger::EventCategoryName);
char EventLogger::m_text[MAX_TEXT_LENGTH];
EventLoggerBase::noOfEventCategoryNames =
sizeof(EventLoggerBase::eventCategoryNames)/
sizeof(EventLoggerBase::EventCategoryName);
const char*
EventLogger::getText(int type,
EventLogger::getText(char * m_text, size_t m_text_len,
int type,
const Uint32* theData, NodeId nodeId)
{
// TODO: Change the switch implementation...
......@@ -164,13 +149,13 @@ EventLogger::getText(int type,
EventReport::EventType eventType = (EventReport::EventType)type;
switch (eventType){
case EventReport::Connected:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode %u Connected",
theNodeId,
theData[1]);
break;
case EventReport::ConnectedApiVersion:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode %u: API version %d.%d.%d",
theNodeId,
theData[1],
......@@ -179,7 +164,7 @@ EventLogger::getText(int type,
getBuild(theData[2]));
break;
case EventReport::Disconnected:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode %u Disconnected",
theNodeId,
theData[1]);
......@@ -188,7 +173,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// REPORT communication to node closed.
//-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sCommunication to Node %u closed",
theNodeId,
theData[1]);
......@@ -197,7 +182,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// REPORT communication to node opened.
//-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sCommunication to Node %u opened",
theNodeId,
theData[1]);
......@@ -206,7 +191,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// Start of NDB has been initiated.
//-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sStart initiated (version %d.%d.%d)",
theNodeId ,
getMajor(theData[1]),
......@@ -214,13 +199,13 @@ EventLogger::getText(int type,
getBuild(theData[1]));
break;
case EventReport::NDBStopStarted:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%s%s shutdown initiated",
theNodeId,
(theData[1] == 1 ? "Cluster" : "Node"));
break;
case EventReport::NDBStopAborted:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode shutdown aborted",
theNodeId);
break;
......@@ -228,7 +213,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// Start of NDB has been completed.
//-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sStarted (version %d.%d.%d)",
theNodeId ,
getMajor(theData[1]),
......@@ -240,7 +225,7 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// STTORRY recevied after restart finished.
//-----------------------------------------------------------------------
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sSTTORRY received after restart finished",
theNodeId);
break;
......@@ -266,7 +251,7 @@ EventLogger::getText(int type,
type = "";
break;
default:{
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sStart phase %u completed (unknown = %d)",
theNodeId,
theData[1],
......@@ -274,7 +259,7 @@ EventLogger::getText(int type,
return m_text;
}
}
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sStart phase %u completed %s",
theNodeId,
theData[1],
......@@ -283,7 +268,7 @@ EventLogger::getText(int type,
break;
}
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"
,
theNodeId,
......@@ -315,7 +300,7 @@ EventLogger::getText(int type,
break;
}//switch
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sCM_REGREF from Node %u to our Node %u. Cause = %s",
theNodeId,
theData[2],
......@@ -328,7 +313,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sWe are Node %u with dynamic ID %u, our left neighbour "
"is Node %u, our right is Node %u",
theNodeId,
......@@ -344,13 +329,13 @@ EventLogger::getText(int type,
if (theData[1] == 0)
{
if (theData[3] != 0) {
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode %u completed failure of Node %u",
theNodeId,
theData[3],
theData[2]);
} else {
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sAll nodes completed failure of Node %u",
theNodeId,
theData[2]);
......@@ -367,7 +352,7 @@ EventLogger::getText(int type,
line = "DBLQH";
}
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNode failure of %u %s completed",
theNodeId,
theData[2],
......@@ -376,7 +361,7 @@ EventLogger::getText(int type,
break;
case EventReport::NODE_FAILREP:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode %u has failed. The Node state at failure "
"was %u",
theNodeId,
......@@ -395,41 +380,41 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16;
switch (code) {
case ArbitCode::ThreadStart:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sPresident restarts arbitration thread [state=%u]",
theNodeId, state);
break;
case ArbitCode::PrepPart2:
sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sPrepare arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::PrepAtrun:
sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sReceive arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::ApiStart:
sd->ticket.getText(ticketText, sizeof(ticketText));
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sStarted arbitrator node %u [ticket=%s]",
theNodeId, sd->node, ticketText);
break;
case ArbitCode::ApiFail:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process failure [state=%u]",
theNodeId, sd->node, state);
break;
case ArbitCode::ApiExit:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sLost arbitrator node %u - process exit [state=%u]",
theNodeId, sd->node, state);
break;
default:
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]",
theNodeId, sd->node, errText, state);
break;
......@@ -446,48 +431,48 @@ EventLogger::getText(int type,
const unsigned state = sd->code >> 16;
switch (code) {
case ArbitCode::LoseNodes:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration check lost - less than 1/2 nodes left",
theNodeId);
break;
case ArbitCode::WinGroups:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration check won - node group majority",
theNodeId);
break;
case ArbitCode::LoseGroups:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration check lost - missing node group",
theNodeId);
break;
case ArbitCode::Partitioning:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNetwork partitioning - arbitration required",
theNodeId);
break;
case ArbitCode::WinChoose:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration won - positive reply from node %u",
theNodeId, sd->node);
break;
case ArbitCode::LoseChoose:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration lost - negative reply from node %u",
theNodeId, sd->node);
break;
case ArbitCode::LoseNorun:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator available",
theNodeId);
break;
case ArbitCode::LoseNocfg:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sNetwork partitioning - no arbitrator configured",
theNodeId);
break;
default:
ArbitCode::getErrText(code, errText, sizeof(errText));
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sArbitration failure - %s [state=%u]",
theNodeId, errText, state);
break;
......@@ -500,7 +485,7 @@ EventLogger::getText(int type,
// node is the master of this global checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sGlobal checkpoint %u started",
theNodeId,
theData[1]);
......@@ -510,7 +495,7 @@ EventLogger::getText(int type,
// This event reports that a global checkpoint has been completed on this
// 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",
theNodeId,
theData[1]);
......@@ -521,7 +506,7 @@ EventLogger::getText(int type,
// node is the master of this local checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLocal checkpoint %u started. "
"Keep GCI = %u oldest restorable GCI = %u",
theNodeId,
......@@ -535,7 +520,7 @@ EventLogger::getText(int type,
// node and the node is the master of this local checkpoint.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLocal checkpoint %u completed",
theNodeId,
theData[1]);
......@@ -544,14 +529,14 @@ EventLogger::getText(int type,
//-----------------------------------------------------------------------
// 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",
theNodeId,
theData[1]);
break;
case EventReport::LCPStoppedInCalcKeepGci:
if (theData[1] == 0)
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sLocal Checkpoint stopped in CALCULATED_KEEP_GCI",
theNodeId);
break;
......@@ -560,7 +545,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of dictionary information.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode restart completed copy of dictionary information",
theNodeId);
break;
......@@ -569,7 +554,7 @@ EventLogger::getText(int type,
// REPORT Node Restart completed copy of distribution information.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode restart completed copy of distribution information",
theNodeId);
break;
......@@ -578,7 +563,7 @@ EventLogger::getText(int type,
// REPORT Node Restart is starting to copy the fragments.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode restart starting to copy the fragments "
"to Node %u",
theNodeId,
......@@ -589,7 +574,7 @@ EventLogger::getText(int type,
// REPORT Node Restart copied a fragment.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sTable ID = %u, fragment ID = %u have been copied "
"to Node %u",
theNodeId,
......@@ -599,7 +584,7 @@ EventLogger::getText(int type,
break;
case EventReport::NR_CopyFragsCompleted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode restart completed copying the fragments "
"to Node %u",
theNodeId,
......@@ -607,7 +592,7 @@ EventLogger::getText(int type,
break;
case EventReport::LCPFragmentCompleted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sTable ID = %u, fragment ID = %u has completed LCP "
"on Node %u",
theNodeId,
......@@ -620,7 +605,7 @@ EventLogger::getText(int type,
// Report information about transaction activity once per 10 seconds.
// -------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sTrans. Count = %u, Commit Count = %u, "
"Read Count = %u, Simple Read Count = %u,\n"
"Write Count = %u, AttrInfo Count = %u, "
......@@ -639,7 +624,7 @@ EventLogger::getText(int type,
theData[10]);
break;
case EventReport::OperationReportCounters:
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"%sOperations=%u",
theNodeId,
theData[1]);
......@@ -649,7 +634,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sACC Blocked %u and TUP Blocked %u times last second",
theNodeId,
theData[1],
......@@ -658,7 +643,7 @@ EventLogger::getText(int type,
case EventReport::TransporterError:
case EventReport::TransporterWarning:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sTransporter to node %d reported error 0x%x",
theNodeId,
theData[1],
......@@ -669,7 +654,7 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode %d missed heartbeat %d",
theNodeId,
theData[1],
......@@ -680,21 +665,21 @@ EventLogger::getText(int type,
// REPORT Undo Logging blocked due to buffer near to overflow.
//-----------------------------------------------------------------------
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode %d declared dead due to missed heartbeat",
theNodeId,
theData[1]);
break;
case EventReport::JobStatistic:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sMean loop Counter in doJob last 8192 times = %u",
theNodeId,
theData[1]);
break;
case EventReport::SendBytesStatistic:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sMean send size to Node = %d last 4096 sends = %u bytes",
theNodeId,
theData[1],
......@@ -702,7 +687,7 @@ EventLogger::getText(int type,
break;
case EventReport::ReceiveBytesStatistic:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sMean receive size to Node = %d last 4096 sends = %u bytes",
theNodeId,
theData[1],
......@@ -710,14 +695,14 @@ EventLogger::getText(int type,
break;
case EventReport::SentHeartbeat:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode Sent Heartbeat to node = %d",
theNodeId,
theData[1]);
break;
case EventReport::CreateLogBytes:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLog part %u, log file %u, MB %u",
theNodeId,
theData[1],
......@@ -726,7 +711,7 @@ EventLogger::getText(int type,
break;
case EventReport::StartLog:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLog part %u, start MB %u, stop MB %u, last GCI, log exec %u",
theNodeId,
theData[1],
......@@ -736,7 +721,7 @@ EventLogger::getText(int type,
break;
case EventReport::StartREDOLog:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sNode: %d StartLog: [GCI Keep: %d LastCompleted: %d NewestRestorable: %d]",
theNodeId,
theData[1],
......@@ -753,7 +738,7 @@ EventLogger::getText(int type,
}
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%s UNDO %s %d [%d %d %d %d %d %d %d %d %d]",
theNodeId,
line,
......@@ -771,36 +756,36 @@ EventLogger::getText(int type,
break;
case EventReport::InfoEvent:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%s%s",
theNodeId,
(char *)&theData[1]);
break;
case EventReport::WarningEvent:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%s%s",
theNodeId,
(char *)&theData[1]);
break;
case EventReport::GCP_TakeoverStarted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sGCP Take over started", theNodeId);
break;
case EventReport::GCP_TakeoverCompleted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sGCP Take over completed", theNodeId);
break;
case EventReport::LCP_TakeoverStarted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLCP Take over started", theNodeId);
break;
case EventReport::LCP_TakeoverCompleted:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sLCP Take over completed (state = %d)",
theNodeId, theData[1]);
break;
......@@ -812,7 +797,7 @@ EventLogger::getText(int type,
const int block = theData[5];
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)",
theNodeId,
(block==DBACC ? "Index" : (block == DBTUP ?"Data":"<unknown>")),
......@@ -833,7 +818,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription id"
" (subId=%d,SubKey=%d)"
" Return code: %d.",
......@@ -847,7 +832,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: Created subscription id"
" (subId=%d,SubKey=%d)"
" Return code: %d.",
......@@ -862,7 +847,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int nodegrp = theData[5];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Created subscription using"
" (subId=%d,SubKey=%d)"
" in primary system. Primary system has %d nodegroup(s)."
......@@ -878,7 +863,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have created "
"subscriptions"
" using (subId=%d,SubKey=%d)."
......@@ -893,7 +878,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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."
" using (subId=%d,SubKey=%d)"
" Return code: %d",
......@@ -907,7 +892,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
"logging meta data"
" changes on the subscription subId=%d,SubKey=%d) "
......@@ -922,7 +907,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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 "
" using (subId=%d,SubKey=%d)"
" Return code: %d",
......@@ -936,7 +921,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started logging "
"table data changes on the subscription "
"subId=%d,SubKey=%d)."
......@@ -951,7 +936,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
" synchronization on meta data (META SCAN) using "
"(subId=%d,SubKey=%d)."
......@@ -966,7 +951,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Return code: %d",
......@@ -980,7 +965,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have started "
"synchronization "
" on table data (DATA SCAN) using (subId=%d,SubKey=%d)."
......@@ -996,7 +981,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization started (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d"
" Return code: %d",
......@@ -1011,7 +996,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: All participants have removed "
"subscription (subId=%d,SubKey=%d). I have cleaned "
"up resources I've used."
......@@ -1026,7 +1011,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Removed subscription "
"(subId=%d,SubKey=%d)"
" Return code: %d",
......@@ -1037,7 +1022,7 @@ EventLogger::getText(int type,
}
default:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sUnknown GrepSubscriptonInfo event: %d",
theNodeId,
theData[1]);
......@@ -1055,7 +1040,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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"
" (subId=%d,SubKey=%d)",
err,
......@@ -1069,7 +1054,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s",
......@@ -1084,7 +1069,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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 "
"data changes."
" using (subId=%d,SubKey=%d)"
......@@ -1100,7 +1085,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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 "
" changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
......@@ -1115,7 +1100,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
......@@ -1131,7 +1116,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d"
" Error code: %d Error Message: %s",
......@@ -1147,7 +1132,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::SSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d). "
" Error code: %d Error Message: %s",
......@@ -1164,7 +1149,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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"
" (subId=%d,SubKey=%d)",
err,
......@@ -1178,7 +1163,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: FAILED to Created subscription using"
" (subId=%d,SubKey=%d)in primary system."
" Error code: %d Error Message: %s",
......@@ -1193,7 +1178,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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 "
"data changes."
" using (subId=%d,SubKey=%d)"
......@@ -1209,7 +1194,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
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 "
" changes using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
......@@ -1224,7 +1209,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (META SCAN) on "
" meta data using (subId=%d,SubKey=%d)"
" Error code: %d Error Message: %s",
......@@ -1240,7 +1225,7 @@ EventLogger::getText(int type,
const int subKey = theData[3];
const int err = theData[4];
const int gci = theData[5];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: Synchronization FAILED (DATA SCAN) on "
"table data using (subId=%d,SubKey=%d). GCI = %d. "
" Error code: %d Error Message: %s",
......@@ -1256,7 +1241,7 @@ EventLogger::getText(int type,
const int subId = theData[2];
const int subKey = theData[3];
const int err = theData[4];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Grep::PSCoord: Failed to remove subscription "
"(subId=%d,SubKey=%d)."
" Error code: %d Error Message: %s",
......@@ -1270,7 +1255,7 @@ EventLogger::getText(int type,
{
const int err = theData[4];
const int nodeId = theData[5];
::snprintf(m_text, sizeof(m_text),
::snprintf(m_text, m_text_len,
"Rep: Node %d."
" Error code: %d Error Message: %s",
nodeId,
......@@ -1282,7 +1267,7 @@ EventLogger::getText(int type,
default:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sUnknown GrepSubscriptionAlert event: %d",
theNodeId,
theData[1]);
......@@ -1293,7 +1278,7 @@ EventLogger::getText(int type,
default:
::snprintf(m_text,
sizeof(m_text),
m_text_len,
"%sUnknown event: %d",
theNodeId,
theData[0]);
......@@ -1303,7 +1288,7 @@ EventLogger::getText(int type,
}
bool
EventLogger::matchEventCategory(const char * str,
EventLoggerBase::matchEventCategory(const char * str,
LogLevel::EventCategory * cat,
bool exactMatch){
unsigned i;
......@@ -1326,7 +1311,7 @@ EventLogger::matchEventCategory(const char * str,
}
const char *
EventLogger::getEventCategoryName(LogLevel::EventCategory cat){
EventLoggerBase::getEventCategoryName(LogLevel::EventCategory cat){
for(unsigned i = 0; i<noOfEventCategoryNames; i++){
if(cat == eventCategoryNames[i].category){
......@@ -1337,18 +1322,18 @@ EventLogger::getEventCategoryName(LogLevel::EventCategory cat){
}
EventLogger::EventLogger() : Logger(), m_logLevel(), m_filterLevel(15)
EventLogger::EventLogger() : m_filterLevel(15)
{
setCategory("EventLogger");
m_logLevel.setLogLevel(LogLevel::llStartUp, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llShutdown, m_filterLevel);
// m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel);
// m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llStatistic, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llCheckpoint, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llNodeRestart, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llConnection, m_filterLevel);
m_logLevel.setLogLevel(LogLevel::llError, 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
}
......@@ -1370,66 +1355,62 @@ EventLogger::close()
removeAllHandlers();
}
void
EventLogger::log(NodeId nodeId, int eventType, const Uint32* theData)
{
log(eventType, theData, nodeId);
}
void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId)
{
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++){
if(EventLogger::matrix[i].eventType == eventType){
const LogLevel::EventCategory cat = EventLogger::matrix[i].eventCategory;
threshold = m_logLevel.getLogLevel(cat);
cat = EventLogger::matrix[i].eventCategory;
threshold = EventLogger::matrix[i].threshold;
severity = EventLogger::matrix[i].severity;
break;
}
}
if (threshold <= m_filterLevel){
if (threshold <= m_logLevel.getLogLevel(cat)){
switch (severity){
case LL_ALERT:
alert(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_ALERT:
alert(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
case LL_CRITICAL:
critical(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_CRITICAL:
critical(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
case LL_WARNING:
warning(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_WARNING:
warning(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
case LL_ERROR:
error(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_ERROR:
error(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
case LL_INFO:
info(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_INFO:
info(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
case LL_DEBUG:
debug(EventLogger::getText(eventType, theData, nodeId));
case Logger::LL_DEBUG:
debug(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
default:
info(EventLogger::getText(eventType, theData, nodeId));
info(EventLogger::getText(m_text, sizeof(m_text),
eventType, theData, nodeId));
break;
}
} // if (..
}
LogLevel&
EventLogger::getLoglevel()
{
return m_logLevel;
}
int
EventLogger::getFilterLevel() const
{
......
......@@ -250,17 +250,7 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
sendSignal(subReq->blockRef, GSN_EVENT_SUBSCRIBE_REF, signal, 1, JBB);
return;
}
/**
* 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;
}
......@@ -384,11 +374,6 @@ void Cmvmi::execCLOSE_COMREQ(Signal* signal)
globalTransporterRegistry.setIOState(i, HaltIO);
globalTransporterRegistry.do_disconnect(i);
/**
* Cancel possible event subscription
*/
cancelSubscription(i);
}
}
if (failNo != 0) {
......@@ -494,6 +479,8 @@ void Cmvmi::execDISCONNECT_REP(Signal *signal)
globalTransporterRegistry.do_connect(hostId);
}
cancelSubscription(hostId);
signal->theData[0] = EventReport::Disconnected;
signal->theData[1] = hostId;
sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 2, JBB);
......@@ -539,20 +526,6 @@ void Cmvmi::execCONNECT_REP(Signal *signal){
if(type == NodeInfo::MGM){
jam();
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) {
<< endl;
ndbout << "<category> = ";
for(i = 0; i<EventLogger::noOfEventCategoryNames; i++){
ndbout << EventLogger::eventCategoryNames[i].name;
if (i < EventLogger::noOfEventCategoryNames - 1) {
for(i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++){
ndbout << EventLoggerBase::eventCategoryNames[i].name;
if (i < EventLoggerBase::noOfEventCategoryNames - 1) {
ndbout << " | ";
}
}
......@@ -831,12 +831,13 @@ void CommandInterpreter::executeStatus(int processId,
//*****************************************************************************
void CommandInterpreter::executeLogLevel(int processId,
const char* parameters, bool all) {
#if 0
(void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
......@@ -852,7 +853,7 @@ void CommandInterpreter::executeLogLevel(int processId,
return;
}
LogLevel::EventCategory cat;
if(!EventLogger::matchEventCategory(categoryTxt,
if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
......@@ -875,6 +876,7 @@ void CommandInterpreter::executeLogLevel(int processId,
if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl;
}
#endif
}
......@@ -1080,12 +1082,13 @@ void CommandInterpreter::executeTestOff(int processId,
void CommandInterpreter::executeEventReporting(int processId,
const char* parameters,
bool all) {
#if 0
(void)all; // Don't want compiler warning
SetLogLevelOrd logLevel; logLevel.clear();
if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) {
for(Uint32 i = 0; i<EventLogger::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLogger::eventCategoryNames[i].category, 7);
for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++)
logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7);
} else {
char * tmpString = strdup(parameters);
......@@ -1101,7 +1104,7 @@ void CommandInterpreter::executeEventReporting(int processId,
return;
}
LogLevel::EventCategory cat;
if(!EventLogger::matchEventCategory(categoryTxt,
if(!EventLoggerBase::matchEventCategory(categoryTxt,
&cat)){
ndbout << "Invalid loglevel specification, unknown category: "
<< categoryTxt << endl;
......@@ -1124,6 +1127,7 @@ void CommandInterpreter::executeEventReporting(int processId,
if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl;
}
#endif
}
void
......
......@@ -12,8 +12,6 @@ ndb_mgmd_SOURCES = \
main.cpp \
Services.cpp \
convertStrToInt.cpp \
NodeLogLevel.cpp \
NodeLogLevelList.cpp \
SignalQueue.cpp \
MgmtSrvrConfig.cpp \
ConfigInfo.cpp \
......
......@@ -45,7 +45,6 @@
#include <ndb_version.h>
#include <SocketServer.hpp>
#include "NodeLogLevel.hpp"
#include <NdbConfig.h>
#include <NdbAutoPtr.hpp>
......@@ -191,41 +190,49 @@ EventLogger g_EventLogger;
void
MgmtSrvr::logLevelThreadRun()
{
NdbMutex* threadMutex = NdbMutex_Create();
while (!_isStopThread) {
if (_startedNodeId != 0) {
NdbMutex_Lock(threadMutex);
/**
* Handle started nodes
*/
EventSubscribeReq req;
req = m_statisticsListner.m_clients[0].m_logLevel;
req.blockRef = _ownReference;
// Local node
NodeLogLevel* n = NULL;
while ((n = _nodeLogLevelList->next()) != NULL) {
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;
SetLogLevelOrd ord;
NdbMutex_Unlock(threadMutex);
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();
} // if (_startedNodeId != 0) {
setEventReportingLevelImpl(node, req);
NdbSleep_MilliSleep(_logLevelThreadSleep);
} // while (!_isStopThread)
ord = m_nodeLogLevel[node];
setNodeLogLevelImpl(node, ord);
NdbMutex_Destroy(threadMutex);
}
m_started_nodes.lock();
}
m_started_nodes.unlock();
void
MgmtSrvr::setStatisticsListner(StatisticsListner* listner)
{
m_statisticsListner = listner;
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);
}
}
void
......@@ -272,7 +279,7 @@ class ErrorItem
{
public:
int _errorCode;
const BaseString _errorText;
const char * _errorText;
};
bool
......@@ -485,23 +492,6 @@ MgmtSrvr::getPort() const {
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 */
MgmtSrvr::MgmtSrvr(NodeId nodeId,
const BaseString &configFilename,
......@@ -510,22 +500,19 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
_blockNumber(1), // Hard coded block number since it makes it easy to send
// signals to other management servers.
_ownReference(0),
m_allocated_resources(*this),
theSignalIdleList(NULL),
theWaitState(WAIT_SUBSCRIBE_CONF),
theConfCount(0),
m_allocated_resources(*this) {
m_statisticsListner(this){
DBUG_ENTER("MgmtSrvr::MgmtSrvr");
_config = NULL;
_isStatPortActive = false;
_isClusterLogStatActive = false;
_isStopThread = false;
_logLevelThread = NULL;
_logLevelThreadSleep = 500;
m_signalRecvThread = NULL;
_startedNodeId = 0;
theFacade = 0;
......@@ -583,13 +570,7 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
ndb_mgm_destroy_iterator(iter);
}
m_statisticsListner = NULL;
_nodeLogLevelList = new NodeLogLevelList();
_clusterLogLevelList = new NodeLogLevelList();
_props = NULL;
_ownNodeId= 0;
NodeId tmp= nodeId;
BaseString error_string;
......@@ -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;
}
......@@ -671,8 +662,6 @@ MgmtSrvr::start(BaseString &error_string)
// Set the initial confirmation count for subscribe requests confirm
// from NDB nodes in the cluster.
//
theConfCount = getNodeCount(NDB_MGM_NODE_TYPE_NDB);
// Loglevel thread
_logLevelThread = NdbThread_Create(logLevelThread_C,
(void**)this,
......@@ -713,9 +702,6 @@ MgmtSrvr::~MgmtSrvr()
if(_config != NULL)
delete _config;
delete _nodeLogLevelList;
delete _clusterLogLevelList;
// End set log level thread
void* res = 0;
_isStopThread = true;
......@@ -736,6 +722,9 @@ MgmtSrvr::~MgmtSrvr()
int MgmtSrvr::okToSendTo(NodeId processId, bool unCond)
{
if(processId == 0)
return 0;
if (getNodeType(processId) != NDB_MGM_NODE_TYPE_NDB)
return WRONG_PROCESS_TYPE;
......@@ -1541,114 +1530,29 @@ MgmtSrvr::status(int processId,
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
MgmtSrvr::setEventReportingLevelImpl(int processId,
const SetLogLevelOrd & ll,
bool isResend)
const EventSubscribeReq& ll)
{
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);
if (result != 0) {
return result;
}
NdbApiSignal* signal = getSignal();
if (signal == NULL) {
return COULD_NOT_ALLOCATE_MEMORY;
}
NdbApiSignal signal(_ownReference);
EventSubscribeReq * dst =
CAST_PTR(EventSubscribeReq, signal->getDataPtrSend());
for(i = 0; i<ll.noOfEntries; i++){
dst->theCategories[i] = ll.theCategories[i];
dst->theLevels[i] = ll.theLevels[i];
}
CAST_PTR(EventSubscribeReq, signal.getDataPtrSend());
dst->noOfEntries = ll.noOfEntries;
dst->blockRef = _ownReference;
* dst = ll;
signal->set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ,
signal.set(TestOrd::TraceAPI, CMVMI, GSN_EVENT_SUBSCRIBE_REQ,
EventSubscribeReq::SignalLength);
result = sendSignal(processId, WAIT_SUBSCRIBE_CONF, signal, true);
if (result == -1) {
return SEND_OR_RECEIVE_FAILED;
}
else {
// Increment the conf counter
theConfCount++;
}
theFacade->lock_mutex();
send(&signal, processId, NODE_TYPE_DB);
theFacade->unlock_mutex();
return 0;
}
......@@ -1656,59 +1560,41 @@ MgmtSrvr::setEventReportingLevelImpl(int processId,
//****************************************************************************
//****************************************************************************
int
MgmtSrvr::setNodeLogLevel(int processId, const SetLogLevelOrd & ll,
bool isResend)
MgmtSrvr::setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll)
{
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);
if (result != 0) {
return result;
}
NdbApiSignal* signal = getSignal();
if (signal == NULL) {
return COULD_NOT_ALLOCATE_MEMORY;
}
SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal->getDataPtrSend());
NdbApiSignal signal(_ownReference);
for(i = 0; i<ll.noOfEntries; i++){
dst->theCategories[i] = ll.theCategories[i];
dst->theLevels[i] = ll.theLevels[i];
}
SetLogLevelOrd * dst = CAST_PTR(SetLogLevelOrd, signal.getDataPtrSend());
dst->noOfEntries = ll.noOfEntries;
* dst = ll;
signal->set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD,
signal.set(TestOrd::TraceAPI, CMVMI, GSN_SET_LOGLEVELORD,
SetLogLevelOrd::SignalLength);
result = sendSignal(processId, NO_WAIT, signal, true);
if (result == -1) {
return SEND_OR_RECEIVE_FAILED;
}
theFacade->lock_mutex();
theFacade->sendSignalUnCond(&signal, processId);
theFacade->unlock_mutex();
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)
for (int i = 0; i < noOfErrorCodes; ++i) {
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)
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
MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
{
......@@ -2049,51 +1920,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
}
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:
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;
case GSN_EVENT_REP:
......@@ -2276,20 +2103,19 @@ void
MgmtSrvr::handleStatus(NodeId nodeId, bool alive)
{
if (alive) {
_startedNodeId = nodeId; // Used by logLevelThreadRun()
m_started_nodes.push_back(nodeId);
Uint32 theData[25];
theData[0] = EventReport::Connected;
theData[1] = nodeId;
eventReport(_ownNodeId, theData);
} else {
handleStopReply(nodeId, 0);
theConfCount++; // Increment the event subscr conf count because
Uint32 theData[25];
theData[0] = EventReport::Disconnected;
theData[1] = nodeId;
eventReport(_ownNodeId, theData);
g_EventLogger.info("Lost connection to node %d", nodeId);
}
}
......@@ -2370,7 +2196,7 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId,
continue;
found_matching_id= true;
if(iter.get(CFG_TYPE_OF_SECTION, &type_c)) abort();
if(type_c != type)
if(type_c != (unsigned)type)
continue;
found_matching_type= true;
if (connected_nodes.get(tmp))
......@@ -2483,6 +2309,8 @@ MgmtSrvr::getNextNodeId(NodeId * nodeId, enum ndb_mgm_node_type type) const
return true;
}
#include "Services.hpp"
void
MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
{
......@@ -2490,70 +2318,9 @@ MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
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
g_EventLogger.log(type, theData, nodeId);
m_statisticsListner.log(type, theData, nodeId);
}
/***************************************************************************
......@@ -2981,3 +2748,7 @@ template class Vector<SigMatch>;
#if __SUNPRO_CC != 0x560
template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned);
#endif
template class MutexVector<unsigned short>;
template class MutexVector<MgmStatService::StatListener>;
template class MutexVector<EventSubscribeReq>;
......@@ -28,8 +28,8 @@
#include <signaldata/ManagementServer.hpp>
#include "SignalQueue.hpp"
#include <ndb_version.h>
#include "NodeLogLevelList.hpp"
#include <EventLogger.hpp>
#include <signaldata/EventSubscribeReq.hpp>
/**
* @desc Block number for Management server.
......@@ -43,6 +43,29 @@ class Config;
class SetLogLevelOrd;
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
* @brief Main class for the management server.
......@@ -63,11 +86,6 @@ class SocketServer;
class MgmtSrvr {
public:
class StatisticsListner {
public:
virtual void println_statistics(const BaseString &s) = 0;
};
// some compilers need all of this
class Allocated_resources;
friend class Allocated_resources;
......@@ -84,11 +102,6 @@ public:
NodeBitmask m_reserved_nodes;
};
/**
* Set a reference to the socket server.
*/
void setStatisticsListner(StatisticsListner* listner);
/**
* Start/initate the event log.
*/
......@@ -150,15 +163,6 @@ public:
STATIC_CONST( OPERATION_IN_PROGRESS = 6667 );
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
* with the setSignalLoggingMode method.
......@@ -313,13 +317,6 @@ public:
bool abort = false,
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 {
enum Event {
BackupStarted = 1,
......@@ -377,22 +374,8 @@ public:
// INVALID_LEVEL
//**************************************************************************
/**
* Sets the Node's log level, i.e., its local event reporting.
*
* @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);
int setEventReportingLevelImpl(int processId, const EventSubscribeReq& ll);
int setNodeLogLevelImpl(int processId, const SetLogLevelOrd & ll);
/**
* Insert an error in a DB process.
......@@ -508,11 +491,6 @@ public:
*/
NodeId getPrimaryNode() const;
/**
* Returns the statistics port number.
* @return statistic port number.
*/
int getStatPort() const;
/**
* Returns the port number.
* @return port number.
......@@ -526,10 +504,7 @@ public:
private:
//**************************************************************************
int setEventReportingLevelImpl(int processId,
const class SetLogLevelOrd & logLevel,
bool isResend = false);
int setEventReportingLevel(int processId, LogLevel::EventCategory, Uint32);
/**
* Check if it is possible to send a signal to a (DB) process
......@@ -563,10 +538,6 @@ private:
Allocated_resources m_allocated_resources;
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
//**************************************************************************
......@@ -598,14 +569,6 @@ private:
// 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_UNLOCK_CONFIG_REQ(NdbApiSignal *signal);
......@@ -631,7 +594,6 @@ private:
*/
enum WaitSignalType {
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_SUBSCRIBE_CONF, // Accept event subscription confirmation
WAIT_STOP,
......@@ -733,14 +695,6 @@ private:
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 {
StopRecord(){ inUse = false; callback = 0; singleUserMode = false;}
bool inUse;
......@@ -768,7 +722,13 @@ private:
bool _isStopThread;
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
......@@ -782,15 +742,13 @@ private:
static void *signalRecvThread_C(void *);
void signalRecvThreadRun();
NodeLogLevelList* _nodeLogLevelList;
NodeLogLevelList* _clusterLogLevelList;
void backupCallback(BackupEvent &);
BackupCallback m_backupCallback;
BackupEvent m_lastBackupEvent;
Config *_props;
int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type);
public:
/**
* 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 @@
#include <mgmapi.h>
#include <EventLogger.hpp>
#include <signaldata/SetLogLevelOrd.hpp>
#include <LogLevel.hpp>
#include <BaseString.hpp>
#include <Base64.hpp>
......@@ -237,6 +238,10 @@ ParserRow<MgmApiSession> commands[] = {
MGM_ARG("parameter", String, Mandatory, "Parameter"),
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()
};
......@@ -289,6 +294,7 @@ MgmApiSession::runSession() {
break;
}
}
if(m_socket >= 0)
NDB_CLOSE_SOCKET(m_socket);
}
......@@ -554,7 +560,7 @@ MgmApiSession::getStatPort(Parser_t::Context &,
const class Properties &) {
m_output->println("get statport reply");
m_output->println("tcpport: %d", m_mgmsrv.getStatPort());
m_output->println("tcpport: %d", 0);
m_output->println("");
}
......@@ -760,7 +766,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
BaseString categoryName, errorString;
SetLogLevelOrd logLevel;
int result;
logLevel.clear();
args.get("node", &node);
args.get("category", categoryName);
args.get("level", &level);
......@@ -779,13 +784,14 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
logLevel.setLogLevel(category, level);
result = m_mgmsrv.setEventReportingLevel(node, logLevel);
EventSubscribeReq req;
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");
if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result));
else
m_output->println("result: Ok");
m_output->println("");
return;
......@@ -821,14 +827,14 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
goto error;
}
logLevel.setLogLevel(category, level);
result = m_mgmsrv.setNodeLogLevel(node, logLevel);
EventSubscribeReq req;
req.blockRef = node;
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");
if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result));
else
m_output->println("result: Ok");
m_output->println("");
return;
......@@ -1248,33 +1254,91 @@ MgmApiSession::configChange(Parser_t::Context &,
m_output->println("");
}
NdbOut&
operator<<(NdbOut& out, const LogLevel & ll)
{
out << "[LogLevel: ";
for(size_t i = 0; i<_LOGLEVEL_CATEGORIES; i++)
out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
out << "]";
}
void
MgmStatService::println_statistics(const BaseString &line){
MutexVector<NDB_SOCKET_TYPE> copy(m_sockets.size());
m_sockets.lock();
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;
for(i = m_sockets.size() - 1; i >= 0; i--){
if(println_socket(m_sockets[i], MAX_WRITE_TIMEOUT, line.c_str()) == -1){
copy.push_back(m_sockets[i]);
m_sockets.erase(i, false);
for(i = m_clients.size() - 1; i >= 0; i--){
if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){
if(m_clients[i].m_socket >= 0 &&
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]);
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
MgmStatService::stopSessions(){
for(int i = m_sockets.size() - 1; i >= 0; i--){
NDB_CLOSE_SOCKET(m_sockets[i]);
m_sockets.erase(i);
for(int i = m_clients.size() - 1; i >= 0; i--){
if(m_clients[i].m_socket >= 0){
NDB_CLOSE_SOCKET(m_clients[i].m_socket);
m_clients.erase(i);
}
}
}
......@@ -1298,6 +1362,71 @@ MgmApiSession::setParameter(Parser_t::Context &,
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 Vector<ParserRow<MgmApiSession> const*>;
template class Vector<unsigned short>;
......@@ -83,6 +83,7 @@ public:
void configChange(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);
};
......@@ -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
......@@ -70,7 +70,6 @@ struct MgmGlobals {
bool use_specific_ip;
char * interface_name;
int port;
int port_stats;
/** The configuration of the cluster */
Config * cluster_config;
......@@ -169,8 +168,6 @@ NDB_MAIN(mgmsrv){
MgmApiService * mapi = new MgmApiService();
MgmStatService * mstat = new MgmStatService();
/****************************
* Read configuration files *
****************************/
......@@ -230,13 +227,6 @@ NDB_MAIN(mgmsrv){
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()){
ndbout_c("Unable to check start management server.");
ndbout_c("Probably caused by illegal initial configuration file.");
......@@ -267,10 +257,7 @@ NDB_MAIN(mgmsrv){
}
//glob.mgmObject->saveConfig();
mstat->setMgm(glob.mgmObject);
mapi->setMgm(glob.mgmObject);
glob.mgmObject->setStatisticsListner(mstat);
char msg[256];
snprintf(msg, sizeof(msg),
......@@ -278,8 +265,8 @@ NDB_MAIN(mgmsrv){
ndbout_c(msg);
g_EventLogger.info(msg);
snprintf(msg, 256, "Id: %d, Command port: %d, Statistics port: %d",
glob.localNodeId, glob.port, glob.port_stats);
snprintf(msg, 256, "Id: %d, Command port: %d",
glob.localNodeId, glob.port);
ndbout_c(msg);
g_EventLogger.info(msg);
......@@ -309,7 +296,6 @@ NDB_MAIN(mgmsrv){
MgmGlobals::MgmGlobals(){
// Default values
port = 0;
port_stats = 0;
config_filename = NULL;
local_config_filename = NULL;
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