1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-12 11:01:17 +03:00

Reformat all code to coding standard

This commit is contained in:
Andrew Hutchings
2017-10-26 17:18:17 +01:00
parent 4985f3456e
commit 01446d1e22
1296 changed files with 403852 additions and 353747 deletions

View File

@@ -40,144 +40,154 @@ using namespace messageqcpp;
void procmonMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
ServerMonitor serverMonitor;
Oam oam;
//wait before monitoring is started
sleep(60);
//wait before monitoring is started
sleep(60);
// get current server name
string moduleName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...) {
// Critical error, Log this event and exit
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to read local module Info");
msg.format(args);
ml.logCriticalMessage(msg);
exit(-1);
}
// get current server name
string moduleName;
oamModuleInfo_t st;
string msgPort = moduleName + "_ProcessMonitor";
try
{
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...)
{
// Critical error, Log this event and exit
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to read local module Info");
msg.format(args);
ml.logCriticalMessage(msg);
exit(-1);
}
int heartbeatCount = 0;
string msgPort = moduleName + "_ProcessMonitor";
// loop forever monitoring Local Process Monitor
while(true)
{
int heartbeatCount = 0;
ByteStream msg;
ByteStream::byte requestID = LOCALHEARTBEAT;
msg << requestID;
try
{
MessageQueueClient mqRequest(msgPort);
mqRequest.write(msg);
// wait 10 seconds for response
ByteStream::byte returnACK;
ByteStream::byte returnRequestID;
ByteStream::byte requestStatus;
ByteStream receivedMSG;
struct timespec ts = { 10, 0 };
try {
receivedMSG = mqRequest.read(&ts);
if (receivedMSG.length() > 0) {
receivedMSG >> returnACK;
receivedMSG >> returnRequestID;
receivedMSG >> requestStatus;
if ( returnACK == oam::ACK && returnRequestID == requestID) {
// ACK for this request
heartbeatCount = 0;
}
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: ProcMon Msg timeout!!!");
msg.format(args);
ml.logWarningMessage(msg);
// loop forever monitoring Local Process Monitor
while (true)
{
heartbeatCount++;
ByteStream msg;
ByteStream::byte requestID = LOCALHEARTBEAT;
if ( heartbeatCount > 2 ) {
//Process Monitor not responding, restart it
system("pkill ProcMon");
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: Restarting ProcMon");
msg.format(args);
ml.logWarningMessage(msg);
msg << requestID;
sleep(60);
heartbeatCount = 0;
}
}
mqRequest.shutdown();
}
catch (SocketClosed &ex) {
string error = ex.what();
try
{
MessageQueueClient mqRequest(msgPort);
mqRequest.write(msg);
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...) {
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
}
catch (exception& ex)
{
string error = ex.what();
// wait 10 seconds for response
ByteStream::byte returnACK;
ByteStream::byte returnRequestID;
ByteStream::byte requestStatus;
ByteStream receivedMSG;
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch(...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
struct timespec ts = { 10, 0 };
sleep(60);
} //while loop
try
{
receivedMSG = mqRequest.read(&ts);
if (receivedMSG.length() > 0)
{
receivedMSG >> returnACK;
receivedMSG >> returnRequestID;
receivedMSG >> requestStatus;
if ( returnACK == oam::ACK && returnRequestID == requestID)
{
// ACK for this request
heartbeatCount = 0;
}
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: ProcMon Msg timeout!!!");
msg.format(args);
ml.logWarningMessage(msg);
heartbeatCount++;
if ( heartbeatCount > 2 )
{
//Process Monitor not responding, restart it
system("pkill ProcMon");
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: Restarting ProcMon");
msg.format(args);
ml.logWarningMessage(msg);
sleep(60);
heartbeatCount = 0;
}
}
mqRequest.shutdown();
}
catch (SocketClosed& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on mqRequest.read: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
}
catch (exception& ex)
{
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient.read: " + error);
msg.format(args);
ml.logErrorMessage(msg);
}
catch (...)
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: EXCEPTION ERROR on MessageQueueClient: Caught unknown exception");
msg.format(args);
ml.logErrorMessage(msg);
}
sleep(60);
} //while loop
}