You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-10-31 18:30:33 +03:00
Merge branch 'develop-1.1' into 1.1-mergeup-20180224
This commit is contained in:
153
procmgr/main.cpp
153
procmgr/main.cpp
@@ -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();
|
||||
@@ -280,6 +281,13 @@ int main(int argc, char** argv)
|
||||
pthread_t MessageThread;
|
||||
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);
|
||||
|
||||
@@ -377,6 +385,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);
|
||||
|
||||
@@ -406,6 +415,13 @@ int main(int argc, char** argv)
|
||||
pthread_t MessageThread;
|
||||
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);
|
||||
}
|
||||
@@ -513,8 +529,143 @@ static void messageThread(Configuration config)
|
||||
sleep(60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
/******************************************************************************************
|
||||
* @brief alarmMesssageThread
|
||||
*
|
||||
* purpose: Read incoming alarm messages
|
||||
*
|
||||
******************************************************************************************/
|
||||
static void alarmMessageThread(Configuration config)
|
||||
{
|
||||
ProcessLog log;
|
||||
ProcessManager processManager(config, log);
|
||||
Oam oam;
|
||||
|
||||
ByteStream msg;
|
||||
|
||||
//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();
|
||||
|
||||
try
|
||||
{
|
||||
msg = fIos.read();
|
||||
|
||||
if (msg.length() <= 0)
|
||||
continue;
|
||||
|
||||
//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);
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
string error = ex.what();
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on read for ProcMgr_Alarm:" + error, LOG_TYPE_ERROR);
|
||||
continue;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on read for ProcMgr_Alarm: Caught unknown exception!", LOG_TYPE_ERROR);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (exception& ex)
|
||||
{
|
||||
string error = ex.what();
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on accept for ProcMgr_Alarm:" + error, LOG_TYPE_ERROR);
|
||||
continue;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
log.writeLog(__LINE__, "EXCEPTION ERROR on accept for ProcMgr_Alarm: Caught unknown exception!", LOG_TYPE_ERROR);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user