mirror of https://github.com/Icinga/icinga2.git
DB IDO: Add 'enable_ha' configuration flag
This feature is true by default. If disabled all cluster nodes in a high availability zone will write to their own local database. TODO: documentation, tests. refs #6827 refs #6203
This commit is contained in:
parent
1f3c6b454f
commit
d326678e76
|
@ -62,6 +62,9 @@ Value IdoMysqlConnection::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& pe
|
|||
|
||||
void IdoMysqlConnection::Resume(void)
|
||||
{
|
||||
if (!IsPaused())
|
||||
return;
|
||||
|
||||
DbConnection::Resume();
|
||||
|
||||
m_Connected = false;
|
||||
|
@ -84,6 +87,11 @@ void IdoMysqlConnection::Resume(void)
|
|||
|
||||
void IdoMysqlConnection::Pause(void)
|
||||
{
|
||||
if (!GetEnableHa()) {
|
||||
Log(LogInformation, "IdoMysqlConnection", "HA functionality disabled. Won't pause IDO connection: " + GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ReconnectTimer.reset();
|
||||
|
||||
DbConnection::Pause();
|
||||
|
|
|
@ -64,6 +64,9 @@ Value IdoPgsqlConnection::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& pe
|
|||
|
||||
void IdoPgsqlConnection::Resume(void)
|
||||
{
|
||||
if (!IsPaused())
|
||||
return;
|
||||
|
||||
DbConnection::Resume();
|
||||
|
||||
m_Connection = NULL;
|
||||
|
@ -86,6 +89,11 @@ void IdoPgsqlConnection::Resume(void)
|
|||
|
||||
void IdoPgsqlConnection::Pause(void)
|
||||
{
|
||||
if (!GetEnableHa()) {
|
||||
Log(LogInformation, "IdoMysqlConnection", "HA functionality disabled. Won't pause IDO connection: " + GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
m_ReconnectTimer.reset();
|
||||
|
||||
DbConnection::Pause();
|
||||
|
|
|
@ -38,5 +38,7 @@
|
|||
%attribute %number "systemcommands_age",
|
||||
},
|
||||
|
||||
%attribute %number "categories"
|
||||
%attribute %number "categories",
|
||||
|
||||
%attribute %number "enable_ha",
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ void DbConnection::ProgramStatusHandler(void)
|
|||
query2.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
query2.Fields->Set("program_start_time", DbValue::FromTimestamp(Application::GetStartTime()));
|
||||
query2.Fields->Set("is_currently_running", 1);
|
||||
query2.Fields->Set("endpoint_name", IcingaApplication::GetInstance()->GetNodeName());
|
||||
query2.Fields->Set("process_id", Utility::GetPid());
|
||||
query2.Fields->Set("daemon_mode", 1);
|
||||
query2.Fields->Set("last_command_check", DbValue::FromTimestamp(Utility::GetTime()));
|
||||
|
@ -358,7 +359,7 @@ void DbConnection::UpdateAllObjects(void)
|
|||
|
||||
void DbConnection::PrepareDatabase(void)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* only clear tables on reconnect which
|
||||
* cannot be updated by their existing ids
|
||||
* for details check https://dev.icinga.org/issues/5565
|
||||
|
|
|
@ -21,6 +21,10 @@ abstract class DbConnection : DynamicObject
|
|||
DbCatLog | DbCatNotification | DbCatProgramStatus | DbCatRetention | DbCatStateHistory;
|
||||
}}}
|
||||
};
|
||||
|
||||
[config] bool enable_ha {
|
||||
default {{{ return true; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue