You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1185 MCOL-436 -send alarms to procmgr to be processed
This commit is contained in:
@ -19,6 +19,10 @@
|
||||
<IPAddr>0.0.0.0</IPAddr>
|
||||
<Port>8603</Port>
|
||||
</ProcMgr>
|
||||
<ProcMgr_Alarm>
|
||||
<IPAddr>127.0.0.1</IPAddr>
|
||||
<Port>8606</Port>
|
||||
</ProcMgr_Alarm>
|
||||
<ProcStatusControl>
|
||||
<IPAddr>0.0.0.0</IPAddr>
|
||||
<Port>8604</Port>
|
||||
|
@ -14,6 +14,10 @@
|
||||
<IPAddr>127.0.0.1</IPAddr>
|
||||
<Port>8603</Port>
|
||||
</ProcMgr>
|
||||
<ProcMgr_Alarm>
|
||||
<IPAddr>127.0.0.1</IPAddr>
|
||||
<Port>8606</Port>
|
||||
</ProcMgr_Alarm>
|
||||
<ProcStatusControl>
|
||||
<IPAddr>127.0.0.1</IPAddr>
|
||||
<Port>8604</Port>
|
||||
|
@ -38,7 +38,7 @@ const std::string ACTIVE_ALARM_FILE = "/var/log/mariadb/columnstore/activeAlarms
|
||||
const std::string ALARM_FILE = "/var/log/mariadb/columnstore/alarm.log";
|
||||
const std::string ALARM_ARCHIVE_FILE = "/var/log/mariadb/columnstore/archive";
|
||||
|
||||
const bool ALARM_DEBUG = false;
|
||||
const bool ALARM_DEBUG = true;
|
||||
const uint16_t INVALID_ALARM_ID = 0;
|
||||
}
|
||||
|
||||
|
@ -28,10 +28,10 @@
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
#include "messagequeue.h"
|
||||
#include "alarmglobal.h"
|
||||
#include "liboamcpp.h"
|
||||
#include "installdir.h"
|
||||
#include "messagequeue.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace oam;
|
||||
@ -373,7 +373,7 @@ void configAlarm (Alarm& calAlarm)
|
||||
/*****************************************************************************************
|
||||
* @brief sendAlarmReport API
|
||||
*
|
||||
* purpose: Process Alarm Report
|
||||
* purpose: Send Alarm Report
|
||||
*
|
||||
*****************************************************************************************/
|
||||
void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int state,
|
||||
@ -438,16 +438,73 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st
|
||||
else
|
||||
processName = repProcessName;
|
||||
|
||||
Alarm calAlarm;
|
||||
int returnStatus = API_SUCCESS; //default
|
||||
ByteStream msg1;
|
||||
|
||||
calAlarm.setAlarmID (alarmID);
|
||||
calAlarm.setComponentID (componentID);
|
||||
calAlarm.setState (state);
|
||||
calAlarm.setSname (ModuleName);
|
||||
calAlarm.setPname (processName);
|
||||
calAlarm.setPid (pid);
|
||||
calAlarm.setTid (tid);
|
||||
// setup message
|
||||
msg1 << (ByteStream::byte) alarmID;
|
||||
msg1 << (std::string) componentID;
|
||||
msg1 << (ByteStream::byte) state;
|
||||
msg1 << (std::string) ModuleName;
|
||||
msg1 << (std::string) processName;
|
||||
msg1 << (ByteStream::byte) pid;
|
||||
msg1 << (ByteStream::byte) tid;
|
||||
|
||||
try
|
||||
{
|
||||
//send the msg to Process Manager
|
||||
MessageQueueClient procmgr("ProcMgr_Alarm");
|
||||
procmgr.write(msg1);
|
||||
|
||||
// shutdown connection
|
||||
procmgr.shutdown();
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
LoggingID lid(11);
|
||||
MessageLog ml(lid);
|
||||
Message msg;
|
||||
Message::Args args;
|
||||
args.add("sendAlarmReport error:");
|
||||
args.add(e.what());
|
||||
msg.format(args);
|
||||
ml.logErrorMessage(msg);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LoggingID lid(11);
|
||||
MessageLog ml(lid);
|
||||
Message msg;
|
||||
Message::Args args;
|
||||
args.add("sendAlarmReport error:");
|
||||
args.add(e.what());
|
||||
msg.format(args);
|
||||
ml.logErrorMessage(msg);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LoggingID lid(11);
|
||||
MessageLog ml(lid);
|
||||
Message msg;
|
||||
Message::Args args;
|
||||
args.add("sendAlarmReport error:");
|
||||
args.add("general failure");
|
||||
msg.format(args);
|
||||
ml.logErrorMessage(msg);
|
||||
}
|
||||
|
||||
return;
|
||||
#endif //SKIP_ALARM
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* @brief processAlarmReport API
|
||||
*
|
||||
* purpose: Process Alarm Report
|
||||
*
|
||||
*****************************************************************************************/
|
||||
void ALARMManager::processAlarmReport (Alarm& calAlarm)
|
||||
{
|
||||
// Get alarm configuration
|
||||
try {
|
||||
configAlarm (calAlarm);
|
||||
@ -464,7 +521,7 @@ void ALARMManager::sendAlarmReport (const char* componentID, int alarmID, int st
|
||||
}
|
||||
|
||||
return;
|
||||
#endif //SKIP_ALARM
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
std::string repProcessName = "");
|
||||
|
||||
|
||||
EXPORT void processAlarmReport (Alarm& calAlarm);
|
||||
|
||||
/** @brief return active alarm list
|
||||
*
|
||||
* @param AlarmList the alarm map reference to store alarms
|
||||
|
@ -2028,8 +2028,8 @@ int main(int argc, char *argv[])
|
||||
sysConfig->setConfig(parentProcessMonitor, "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfig->setConfig(parentProcessMonitor, "Port", "8800");
|
||||
sysConfig->setConfig("ProcMgr", "IPAddr", parentOAMModuleIPAddr);
|
||||
//sysConfig->setConfig("ProcHeartbeatControl", "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfig->setConfig("ProcStatusControl", "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfig->setConfig("ProcHeartbeatControl", "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", parentOAMModuleIPAddr);
|
||||
string parentServerMonitor = parentOAMModuleName + "_ServerMonitor";
|
||||
sysConfig->setConfig(parentServerMonitor, "IPAddr", parentOAMModuleIPAddr);
|
||||
string portName = parentOAMModuleName + "_WriteEngineServer";
|
||||
|
@ -78,6 +78,7 @@ extern bool startFailOver;
|
||||
extern bool gOAMParentModuleFlag;
|
||||
|
||||
static void messageThread(Configuration config);
|
||||
static void alarmMessageThread(Configuration config);
|
||||
static void sigUser1Handler(int sig);
|
||||
static void startMgrProcessThread();
|
||||
static void hdfsActiveAlarmsPushingThread();
|
||||
@ -265,6 +266,12 @@ int main(int argc, char **argv)
|
||||
if ( ret != 0 )
|
||||
log.writeLog(__LINE__, "pthread_create failed, return code = " + oam.itoa(ret), LOG_TYPE_ERROR);
|
||||
|
||||
// create alarm message thread
|
||||
pthread_t AlarmMessageThread;
|
||||
ret = pthread_create (&AlarmMessageThread, NULL, (void*(*)(void*)) &alarmMessageThread, &config);
|
||||
if ( ret != 0 )
|
||||
log.writeLog(__LINE__, "pthread_create failed, return code = " + oam.itoa(ret), LOG_TYPE_ERROR);
|
||||
|
||||
//monitor OAM Parent Module for failover
|
||||
while(true)
|
||||
{
|
||||
@ -351,6 +358,7 @@ int main(int argc, char **argv)
|
||||
string IPaddr = (*pt1).IPAddr;
|
||||
|
||||
sysConfig->setConfig("ProcMgr", "IPAddr", IPaddr);
|
||||
sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", IPaddr);
|
||||
|
||||
log.writeLog(__LINE__, "set ProcMgr IPaddr to " + IPaddr, LOG_TYPE_DEBUG);
|
||||
//update Calpont Config table
|
||||
@ -378,6 +386,12 @@ int main(int argc, char **argv)
|
||||
int ret = pthread_create (&MessageThread, NULL, (void*(*)(void*)) &messageThread, &config);
|
||||
if ( ret != 0 )
|
||||
log.writeLog(__LINE__, "pthread_create failed, return code = " + oam.itoa(ret), LOG_TYPE_ERROR);
|
||||
|
||||
// create alarm message thread
|
||||
pthread_t AlarmMessageThread;
|
||||
ret = pthread_create (&AlarmMessageThread, NULL, (void*(*)(void*)) &alarmMessageThread, &config);
|
||||
if ( ret != 0 )
|
||||
log.writeLog(__LINE__, "pthread_create failed, return code = " + oam.itoa(ret), LOG_TYPE_ERROR);
|
||||
}
|
||||
|
||||
//
|
||||
@ -482,6 +496,87 @@ static void messageThread(Configuration config)
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
* @brief alarmMesssageThread
|
||||
*
|
||||
* purpose: Read incoming alarm messages
|
||||
*
|
||||
******************************************************************************************/
|
||||
static void alarmMessageThread(Configuration config)
|
||||
{
|
||||
ProcessLog log;
|
||||
ProcessManager processManager(config, log);
|
||||
Oam oam;
|
||||
|
||||
//check for running active, then launch
|
||||
while(true)
|
||||
{
|
||||
if ( !runStandby)
|
||||
break;
|
||||
sleep (1);
|
||||
}
|
||||
|
||||
log.writeLog(__LINE__, "Alarm Message Thread started ..", LOG_TYPE_DEBUG);
|
||||
|
||||
//read and cleanup port before trying to use
|
||||
try {
|
||||
Config* sysConfig = Config::makeConfig();
|
||||
string port = sysConfig->getConfig("ProcMgr_Alarm", "Port");
|
||||
string cmd = "fuser -k " + port + "/tcp >/dev/null 2>&1";
|
||||
if ( !rootUser)
|
||||
cmd = "sudo fuser -k " + port + "/tcp >/dev/null 2>&1";
|
||||
|
||||
|
||||
system(cmd.c_str());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//waiting for request
|
||||
//
|
||||
IOSocket fIos;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageQueueServer procmgr("ProcMgr_Alarm");
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
fIos = procmgr.accept();
|
||||
|
||||
pthread_t alarmMessagethread;
|
||||
int status = pthread_create (&alarmMessagethread, NULL, (void*(*)(void*)) &processAlarmMSG, &fIos);
|
||||
|
||||
if ( status != 0 )
|
||||
log.writeLog(__LINE__, "alarmmessagethread: pthread_create failed, return status = " + oam.itoa(status), LOG_TYPE_ERROR);
|
||||
}
|
||||
catch(...)
|
||||
{}
|
||||
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
string error = ex.what();
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on MessageQueueServer for ProcMgr_Alarm:" + error, LOG_TYPE_ERROR);
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on MessageQueueServer for ProcMgr_Alarm: Caught unknown exception!", LOG_TYPE_ERROR);
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
* @brief sigUser1Handler
|
||||
*
|
||||
|
@ -301,6 +301,79 @@ ProcessManager::~ProcessManager()
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
* @brief processAlarmMSG
|
||||
*
|
||||
* purpose: Process the Alarm message
|
||||
*
|
||||
******************************************************************************************/
|
||||
//void ProcessManager::processAlarmMSG( messageqcpp::IOSocket fIos, messageqcpp::ByteStream msg)
|
||||
void processAlarmMSG(messageqcpp::IOSocket* cfIos)
|
||||
{
|
||||
messageqcpp::IOSocket afIos = *cfIos;
|
||||
|
||||
pthread_t ThreadId;
|
||||
ThreadId = pthread_self();
|
||||
|
||||
ByteStream msg;
|
||||
|
||||
try{
|
||||
msg = afIos.read();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
pthread_detach (ThreadId);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
if (msg.length() <= 0) {
|
||||
afIos.close();
|
||||
pthread_detach (ThreadId);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
Oam oam;
|
||||
ProcessLog log;
|
||||
|
||||
Configuration config;
|
||||
ProcessManager processManager(config, log);
|
||||
|
||||
log.writeLog(__LINE__, "MSG RECEIVED: Process Alarm Message");
|
||||
|
||||
ByteStream::byte alarmID;
|
||||
std::string componentID;
|
||||
ByteStream::byte state;
|
||||
std::string ModuleName;
|
||||
std::string processName;
|
||||
ByteStream::byte pid;
|
||||
ByteStream::byte tid;
|
||||
|
||||
msg >> alarmID;
|
||||
msg >> componentID;
|
||||
msg >> state;
|
||||
msg >> ModuleName;
|
||||
msg >> processName;
|
||||
msg >> pid;
|
||||
msg >> tid;
|
||||
|
||||
Alarm calAlarm;
|
||||
|
||||
calAlarm.setAlarmID (alarmID);
|
||||
calAlarm.setComponentID (componentID);
|
||||
calAlarm.setState (state);
|
||||
calAlarm.setSname (ModuleName);
|
||||
calAlarm.setPname (processName);
|
||||
calAlarm.setPid (pid);
|
||||
calAlarm.setTid (tid);
|
||||
|
||||
ALARMManager aManager;
|
||||
aManager.processAlarmReport(calAlarm);
|
||||
|
||||
afIos.close();
|
||||
pthread_detach (ThreadId);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
* @brief processMSG
|
||||
*
|
||||
@ -2629,8 +2702,8 @@ void processMSG(messageqcpp::IOSocket* cfIos)
|
||||
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case PROCESSALARM:
|
||||
|
||||
/* case PROCESSALARM:
|
||||
{
|
||||
log.writeLog(__LINE__, "MSG RECEIVED: Process Alarm Message");
|
||||
|
||||
@ -2665,8 +2738,8 @@ void processMSG(messageqcpp::IOSocket* cfIos)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
default:
|
||||
log.writeLog(__LINE__, "MSG RECEIVED: Invalid type" );
|
||||
break;
|
||||
@ -8720,6 +8793,7 @@ int ProcessManager::switchParentOAMModule(std::string newActiveModuleName)
|
||||
newActiveIPaddr = (*pt2).IPAddr;
|
||||
|
||||
sysConfig4->setConfig("ProcMgr", "IPAddr", newActiveIPaddr);
|
||||
sysConfig4->setConfig("ProcMgr_Alarm", "IPAddr", newActiveIPaddr);
|
||||
sysConfig4->setConfig("ProcStatusControl", "IPAddr", newActiveIPaddr);
|
||||
sysConfig4->setConfig("DBRM_Controller", "IPAddr", newActiveIPaddr);
|
||||
|
||||
@ -9296,6 +9370,7 @@ int ProcessManager::OAMParentModuleChange()
|
||||
localIPaddr = (*pt1).IPAddr;
|
||||
|
||||
sysConfig4->setConfig("ProcMgr", "IPAddr", localIPaddr);
|
||||
sysConfig4->setConfig("ProcMgr_Alarm", "IPAddr", localIPaddr);
|
||||
sysConfig4->setConfig("ProcStatusControl", "IPAddr", localIPaddr);
|
||||
sysConfig4->setConfig("DBRM_Controller", "IPAddr", localIPaddr);
|
||||
|
||||
|
@ -79,6 +79,8 @@ namespace processmanager{
|
||||
void startModuleThread(std::string moduleName);
|
||||
void stopModuleThread(std::string moduleName);
|
||||
void processMSG(messageqcpp::IOSocket* fIos);
|
||||
void processAlarmMSG(messageqcpp::IOSocket* fIos);
|
||||
|
||||
void sendUpgradeRequest();
|
||||
|
||||
/** @brief Timeset for Milleseconds
|
||||
|
@ -339,6 +339,7 @@ int main(int argc, char **argv)
|
||||
string IPaddr = (*pt1).IPAddr;
|
||||
|
||||
sysConfig->setConfig("ProcMgr", "IPAddr", IPaddr);
|
||||
sysConfig->setConfig("ProcMgr_Alarm", "IPAddr", IPaddr);
|
||||
|
||||
log.writeLog(__LINE__, "set ProcMgr IPaddr to Old Standby Module: " + IPaddr, LOG_TYPE_DEBUG);
|
||||
//update Calpont Config table
|
||||
|
@ -938,6 +938,7 @@ int main(int argc, char *argv[])
|
||||
sysConfigNew->setConfig(parentProcessMonitor, "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfigNew->setConfig(parentProcessMonitor, "Port", "8800");
|
||||
sysConfigNew->setConfig("ProcMgr", "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfigNew->setConfig("ProcMgr_Alarm", "IPAddr", parentOAMModuleIPAddr);
|
||||
sysConfigNew->setConfig("ProcStatusControl", "IPAddr", parentOAMModuleIPAddr);
|
||||
string parentServerMonitor = systemParentOAMModuleName + "_ServerMonitor";
|
||||
sysConfigNew->setConfig(parentServerMonitor, "IPAddr", parentOAMModuleIPAddr);
|
||||
|
Reference in New Issue
Block a user