mirror of https://github.com/Icinga/icinga2.git
parent
e8a41d86c8
commit
1c98a3a9f7
|
@ -275,7 +275,7 @@ void IdoMysqlConnection::Reconnect(void)
|
|||
Log(LogNotice, "IdoMysqlConnection", "Last update by '" +
|
||||
endpoint_name + "' was " + Convert::ToString(status_update_age) + "s ago.");
|
||||
|
||||
if (status_update_age < 60) {
|
||||
if (status_update_age < GetFailoverTimeout()) {
|
||||
mysql_close(&m_Connection);
|
||||
m_Connected = false;
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ void IdoPgsqlConnection::Reconnect(void)
|
|||
Log(LogNotice, "IdoPgsqlConnection", "Last update by '" +
|
||||
endpoint_name + "' was " + Convert::ToString(status_update_age) + "s ago.");
|
||||
|
||||
if (status_update_age < 60) {
|
||||
if (status_update_age < GetFailoverTimeout()) {
|
||||
PQfinish(m_Connection);
|
||||
m_Connection = NULL;
|
||||
|
||||
|
|
|
@ -516,7 +516,8 @@ by running the following query:
|
|||
(1 Zeile)
|
||||
|
||||
This is useful when the cluster connection between endpoints breaks, and prevents
|
||||
data duplication in split-brain-scenarios.
|
||||
data duplication in split-brain-scenarios. The failover timeout can be set for the
|
||||
`failover_timeout` attribute, but not lower than 60 seconds.
|
||||
|
||||
|
||||
### <a id="cluster-scenarios"></a> Cluster Scenarios
|
||||
|
|
|
@ -1273,6 +1273,7 @@ Attributes:
|
|||
instance\_name |**Optional.** Unique identifier for the local Icinga 2 instance. Defaults to "default".
|
||||
instance\_description|**Optional.** Description for the Icinga 2 instance.
|
||||
enable_ha |**Optional.** Enable the high availability functionality. Only valid in a [cluster setup](#high-availability-db-ido). Defaults to "true".
|
||||
failover_timeout | **Optional.** Set the failover timeout in a [HA cluster](#high-availability-db-ido). Must not be lower than 60s". Defaults to "60s".
|
||||
cleanup |**Optional.** Dictionary with items for historical table cleanup.
|
||||
categories |**Optional.** The types of information that should be written to the database.
|
||||
|
||||
|
@ -1361,6 +1362,7 @@ Attributes:
|
|||
instance\_name |**Optional.** Unique identifier for the local Icinga 2 instance. Defaults to "default".
|
||||
instance\_description|**Optional.** Description for the Icinga 2 instance.
|
||||
enable_ha |**Optional.** Enable the high availability functionality. Only valid in a [cluster setup](#high-availability-db-ido). Defaults to "true".
|
||||
failover_timeout | **Optional.** Set the failover timeout in a [HA cluster](#high-availability-db-ido). Must not be lower than 60s". Defaults to "60s".
|
||||
cleanup |**Optional.** Dictionary with items for historical table cleanup.
|
||||
categories |**Optional.** The types of information that should be written to the database.
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
******************************************************************************/
|
||||
|
||||
%type DbConnection {
|
||||
%validator "ValidateFailoverTimeout"
|
||||
|
||||
%attribute %string "table_prefix",
|
||||
|
||||
%attribute %dictionary "cleanup" {
|
||||
|
@ -41,4 +43,6 @@
|
|||
%attribute %number "categories",
|
||||
|
||||
%attribute %number "enable_ha",
|
||||
|
||||
%attribute %number "failover_timeout",
|
||||
}
|
||||
|
|
|
@ -22,17 +22,20 @@
|
|||
#include "icinga/icingaapplication.hpp"
|
||||
#include "icinga/host.hpp"
|
||||
#include "icinga/service.hpp"
|
||||
#include "config/configcompilercontext.hpp"
|
||||
#include "base/dynamictype.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/initialize.hpp"
|
||||
#include "base/logger_fwd.hpp"
|
||||
#include "base/scriptfunction.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
REGISTER_TYPE(DbConnection);
|
||||
REGISTER_SCRIPTFUNCTION(ValidateFailoverTimeout, &DbConnection::ValidateFailoverTimeout);
|
||||
|
||||
Timer::Ptr DbConnection::m_ProgramStatusTimer;
|
||||
|
||||
|
@ -410,3 +413,12 @@ void DbConnection::PrepareDatabase(void)
|
|||
FillIDCache(type);
|
||||
}
|
||||
}
|
||||
|
||||
void DbConnection::ValidateFailoverTimeout(const String& location, const Dictionary::Ptr& attrs)
|
||||
{
|
||||
Value failover_timeout = attrs->Get("failover_timeout");
|
||||
if (failover_timeout < 60) {
|
||||
ConfigCompilerContext::GetInstance()->AddMessage(true, "Validation failed for " +
|
||||
location + ": Failover timeout minimum is 60s.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
void SetStatusUpdate(const DbObject::Ptr& dbobj, bool hasupdate);
|
||||
bool GetStatusUpdate(const DbObject::Ptr& dbobj) const;
|
||||
|
||||
static void ValidateFailoverTimeout(const String& location, const Dictionary::Ptr& attrs);
|
||||
|
||||
protected:
|
||||
virtual void OnConfigLoaded(void);
|
||||
virtual void Start(void);
|
||||
|
|
|
@ -25,6 +25,10 @@ abstract class DbConnection : DynamicObject
|
|||
[config] bool enable_ha {
|
||||
default {{{ return true; }}}
|
||||
};
|
||||
|
||||
[config] double failover_timeout {
|
||||
default {{{ return 60; }}}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue