Commit e8c9a137 authored by unknown's avatar unknown

Fix backup event

parent 3323469d
......@@ -125,8 +125,8 @@ public:
* @param theData the event data.
* @param nodeId the node id of event origin.
*/
virtual void log(int eventType, const Uint32* theData, NodeId nodeId = 0);
virtual void log(int, const Uint32*, NodeId = 0,const class LogLevel * = 0);
/**
* Returns the event text for the specified event report type.
*
......
......@@ -87,6 +87,8 @@ public:
bool operator==(const LogLevel& l) const {
return memcmp(this, &l, sizeof(* this)) == 0;
}
LogLevel& operator=(const class EventSubscribeReq & req);
private:
/**
......@@ -103,9 +105,7 @@ LogLevel::LogLevel(){
inline
LogLevel &
LogLevel::operator= (const LogLevel & org){
for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
logLevelData[i] = org.logLevelData[i];
}
memcpy(logLevelData, org.logLevelData, sizeof(logLevelData));
return * this;
}
......@@ -121,7 +121,7 @@ inline
void
LogLevel::setLogLevel(EventCategory ec, Uint32 level){
assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
logLevelData[ec] = level;
logLevelData[ec] = (Uint8)level;
}
inline
......@@ -129,7 +129,7 @@ Uint32
LogLevel::getLogLevel(EventCategory ec) const{
assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
return logLevelData[ec];
return (Uint32)logLevelData[ec];
}
inline
......@@ -142,4 +142,17 @@ LogLevel::set_max(const LogLevel & org){
return * this;
}
#include <signaldata/EventSubscribeReq.hpp>
inline
LogLevel&
LogLevel::operator=(const EventSubscribeReq& req)
{
clear();
for(size_t i = 0; i<req.noOfEntries; i++){
logLevelData[(req.theData[i] >> 16)] = req.theData[i] & 0xFFFF;
}
return * this;
}
#endif
......@@ -38,8 +38,8 @@ struct EventSubscribeReq {
*/
friend class MgmtSrvr;
STATIC_CONST( SignalLength = 22 );
STATIC_CONST( SignalLength = 2 + LogLevel::LOGLEVEL_CATEGORIES );
/**
* Note: If you use the same blockRef as you have used earlier,
* you update your ongoing subscription
......@@ -52,14 +52,12 @@ struct EventSubscribeReq {
*/
Uint32 noOfEntries;
Uint32 theCategories[10];
Uint32 theLevels[10];
Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
EventSubscribeReq& operator= (const LogLevel& ll){
noOfEntries = _LOGLEVEL_CATEGORIES;
noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theCategories[i] = i;
theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
......
......@@ -40,11 +40,10 @@ class SetLogLevelOrd {
friend class NodeLogLevel;
private:
STATIC_CONST( SignalLength = 25 );
STATIC_CONST( SignalLength = 1 + LogLevel::LOGLEVEL_CATEGORIES );
Uint32 noOfEntries;
Uint32 theCategories[12];
Uint32 theLevels[12];
Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
void clear();
......@@ -52,12 +51,11 @@ private:
* Note level is valid as 0-15
*/
void setLogLevel(LogLevel::EventCategory ec, int level = 7);
SetLogLevelOrd& operator= (const LogLevel& ll){
noOfEntries = _LOGLEVEL_CATEGORIES;
noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
for(size_t i = 0; i<noOfEntries; i++){
theCategories[i] = i;
theLevels[i] = ll.getLogLevel((LogLevel::EventCategory)i);
theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
}
return * this;
}
......@@ -65,8 +63,7 @@ private:
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];
theData[i] = ll.theData[i];
}
return * this;
}
......@@ -81,9 +78,7 @@ SetLogLevelOrd::clear(){
inline
void
SetLogLevelOrd::setLogLevel(LogLevel::EventCategory ec, int level){
assert(noOfEntries < 12);
theCategories[noOfEntries] = ec;
theLevels[noOfEntries] = level;
theData[noOfEntries] = (ec << 16) | level;
noOfEntries++;
}
......
......@@ -793,8 +793,6 @@ EventLogger::getText(char * m_text, size_t m_text_len,
);
break;
}
case EventReport::GrepSubscriptionInfo :
{
GrepEvent::Subscription event = (GrepEvent::Subscription)theData[1];
......@@ -1308,16 +1306,7 @@ EventLogger::getText(char * m_text, size_t m_text_len,
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::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::Logger::LL_INFO, Logger::Logger::LL_ALERT); // Log INFO to ALERT
enable(Logger::Logger::LL_INFO, Logger::Logger::LL_ALERT);
}
EventLogger::~EventLogger()
......@@ -1338,23 +1327,35 @@ EventLogger::close()
removeAllHandlers();
}
static NdbOut&
operator<<(NdbOut& out, const LogLevel & ll)
{
out << "[LogLevel: ";
for(size_t i = 0; i<LogLevel::LOGLEVEL_CATEGORIES; i++)
out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
out << "]";
return out;
}
void
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId)
EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId,
const LogLevel* ll)
{
Uint32 threshold = 0;
Logger::LoggerLevel severity = Logger::LL_WARNING;
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;
severity = EventLogger::matrix[i].severity;
for(unsigned i = 0; i<EventLoggerBase::matrixSize; i++){
if(EventLoggerBase::matrix[i].eventType == eventType){
cat = EventLoggerBase::matrix[i].eventCategory;
threshold = EventLoggerBase::matrix[i].threshold;
severity = EventLoggerBase::matrix[i].severity;
break;
}
}
if (threshold <= m_logLevel.getLogLevel(cat)){
Uint32 set = ll?ll->getLogLevel(cat) : m_logLevel.getLogLevel(cat);
if (threshold <= set){
switch (severity){
case Logger::LL_ALERT:
alert(EventLogger::getText(m_text, sizeof(m_text),
......
......@@ -169,9 +169,9 @@ void Cmvmi::execSET_LOGLEVELORD(Signal* signal)
jamEntry();
for(unsigned int i = 0; i<llOrd->noOfEntries; i++){
category = (LogLevel::EventCategory)llOrd->theCategories[i];
level = llOrd->theLevels[i];
category = (LogLevel::EventCategory)(llOrd->theData[i] >> 16);
level = llOrd->theData[i] & 0xFFFF;
clogLevel.setLogLevel(category, level);
}
}//execSET_LOGLEVELORD()
......@@ -196,10 +196,10 @@ void Cmvmi::execEVENT_REP(Signal* signal)
Uint32 threshold = 16;
LogLevel::EventCategory eventCategory = (LogLevel::EventCategory)0;
for(unsigned int i = 0; i< EventLogger::matrixSize; i++){
if(EventLogger::matrix[i].eventType == eventType){
eventCategory = EventLogger::matrix[i].eventCategory;
threshold = EventLogger::matrix[i].threshold;
for(unsigned int i = 0; i< EventLoggerBase::matrixSize; i++){
if(EventLoggerBase::matrix[i].eventType == eventType){
eventCategory = EventLoggerBase::matrix[i].eventCategory;
threshold = EventLoggerBase::matrix[i].threshold;
break;
}
}
......@@ -266,10 +266,9 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){
LogLevel::EventCategory category;
Uint32 level = 0;
for(Uint32 i = 0; i<subReq->noOfEntries; i++){
category = (LogLevel::EventCategory)subReq->theCategories[i];
level = subReq->theLevels[i];
ptr.p->logLevel.setLogLevel(category,
level);
category = (LogLevel::EventCategory)(subReq->theData[i] >> 16);
level = subReq->theData[i] & 0xFFFF;
ptr.p->logLevel.setLogLevel(category, level);
}
}
......
......@@ -133,6 +133,16 @@ MgmtSrvr::signalRecvThreadRun()
EventLogger g_EventLogger;
static NdbOut&
operator<<(NdbOut& out, const LogLevel & ll)
{
out << "[LogLevel: ";
for(size_t i = 0; i<LogLevel::LOGLEVEL_CATEGORIES; i++)
out << ll.getLogLevel((LogLevel::EventCategory)i) << " ";
out << "]";
return out;
}
void
MgmtSrvr::logLevelThreadRun()
{
......@@ -167,6 +177,10 @@ MgmtSrvr::logLevelThreadRun()
m_log_level_requests.erase(0, false);
m_log_level_requests.unlock();
LogLevel tmp;
tmp = req;
ndbout << "req3: " << tmp << endl;
if(req.blockRef == 0){
req.blockRef = _ownReference;
setEventReportingLevelImpl(0, req);
......@@ -564,13 +578,15 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId,
{
MgmStatService::StatListener se;
se.m_socket = -1;
for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++)
for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++){
se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7);
}
se.m_logLevel.setLogLevel(LogLevel::llError, 15);
se.m_logLevel.setLogLevel(LogLevel::llBackup, 15);
m_statisticsListner.m_clients.push_back(se);
m_statisticsListner.m_logLevel = se.m_logLevel;
}
DBUG_VOID_RETURN;
}
......@@ -1557,8 +1573,8 @@ 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)
while(nodeTypes[node] != (int)node_type && node < max) node++;
if(nodeTypes[node] != (int)node_type)
break;
theFacade->sendSignalUnCond(signal, node);
}
......@@ -1969,7 +1985,6 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal)
event.Completed.NoOfLogBytes = rep->noOfLogBytes;
event.Completed.NoOfRecords = rep->noOfRecords;
event.Completed.NoOfLogRecords = rep->noOfLogRecords;
event.Completed.stopGCP = rep->stopGCP;
event.Completed.startGCP = rep->startGCP;
event.Nodes = rep->nodes;
......@@ -2352,9 +2367,9 @@ MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData)
const EventReport * const eventReport = (EventReport *)&theData[0];
EventReport::EventType type = eventReport->getEventType();
// Log event
g_EventLogger.log(type, theData, nodeId);
g_EventLogger.log(type, theData, nodeId,
&m_statisticsListner.m_clients[0].m_logLevel);
m_statisticsListner.log(type, theData, nodeId);
}
......@@ -2467,98 +2482,6 @@ MgmtSrvr::abortBackup(Uint32 backupId)
void
MgmtSrvr::backupCallback(BackupEvent & event)
{
char str[255];
bool ok = false;
switch(event.Event){
case BackupEvent::BackupStarted:
ok = true;
snprintf(str, sizeof(str),
"Backup %d started", event.Started.BackupId);
break;
case BackupEvent::BackupFailedToStart:
ok = true;
snprintf(str, sizeof(str),
"Backup failed to start (Backup error %d)",
event.FailedToStart.ErrorCode);
break;
case BackupEvent::BackupCompleted:
ok = true;
snprintf(str, sizeof(str),
"Backup %d completed",
event.Completed.BackupId);
g_EventLogger.info(str);
snprintf(str, sizeof(str),
" StartGCP: %d StopGCP: %d",
event.Completed.startGCP, event.Completed.stopGCP);
g_EventLogger.info(str);
snprintf(str, sizeof(str),
" #Records: %d #LogRecords: %d",
event.Completed.NoOfRecords, event.Completed.NoOfLogRecords);
g_EventLogger.info(str);
snprintf(str, sizeof(str),
" Data: %d bytes Log: %d bytes",
event.Completed.NoOfBytes, event.Completed.NoOfLogBytes);
break;
case BackupEvent::BackupAborted:
ok = true;
snprintf(str, sizeof(str),
"Backup %d has been aborted reason %d",
event.Aborted.BackupId,
event.Aborted.Reason);
break;
}
if(!ok){
snprintf(str, sizeof(str),
"Unknown backup event: %d",
event.Event);
}
g_EventLogger.info(str);
switch (theWaitState){
case WAIT_BACKUP_STARTED:
switch(event.Event){
case BackupEvent::BackupStarted:
case BackupEvent::BackupFailedToStart:
m_lastBackupEvent = event;
theWaitState = NO_WAIT;
break;
default:
snprintf(str, sizeof(str),
"Received event %d in unexpected state WAIT_BACKUP_STARTED",
event.Event);
g_EventLogger.info(str);
return;
}
break;
case WAIT_BACKUP_COMPLETED:
switch(event.Event){
case BackupEvent::BackupCompleted:
case BackupEvent::BackupAborted:
case BackupEvent::BackupFailedToStart:
m_lastBackupEvent = event;
theWaitState = NO_WAIT;
break;
default:
snprintf(str, sizeof(str),
"Received event %d in unexpected state WAIT_BACKUP_COMPLETED",
event.Event);
g_EventLogger.info(str);
return;
}
break;
default:
snprintf(str, sizeof(str), "Received event %d in unexpected state = %d",
event.Event, theWaitState);
g_EventLogger.info(str);
return;
}
}
......
......@@ -780,8 +780,7 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &,
EventSubscribeReq req;
req.blockRef = 0;
req.noOfEntries = 1;
req.theCategories[0] = category;
req.theLevels[0] = level;
req.theData[0] = (category << 16) | level;
m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set cluster loglevel reply");
......@@ -815,8 +814,7 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &,
EventSubscribeReq req;
req.blockRef = node;
req.noOfEntries = 1;
req.theCategories[0] = category;
req.theLevels[0] = level;
req.theData[0] = (category << 16) | level;
m_mgmsrv.m_log_level_requests.push_back(req);
m_output->println("set loglevel reply");
......@@ -1239,7 +1237,7 @@ MgmApiSession::configChange(Parser_t::Context &,
m_output->println("");
}
NdbOut&
static NdbOut&
operator<<(NdbOut& out, const LogLevel & ll)
{
out << "[LogLevel: ";
......
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