Merge branch 'feature/flexible_duration' into 'master'

Replace duration with flexible_duration

See merge request icingadb/icingadb-main!22
This commit is contained in:
Eric Lippmann 2019-10-23 13:21:42 +02:00
commit 1340abc449
6 changed files with 12 additions and 12 deletions

View file

@ -168,7 +168,7 @@ func stateHistoryWorker(super *supervisor.Supervisor, objectType string) {
func downtimeHistoryWorker(super *supervisor.Supervisor, objectType string) {
statements := []string{
`REPLACE INTO ` + objectType + `_downtime_history (downtime_id, environment_id, ` + objectType + `_id, triggered_by_id, entry_time,` +
`author, comment, is_flexible, duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time)` +
`author, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time)` +
`VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
`REPLACE INTO `+objectType+`_history (id, environment_id, `+objectType+`_id, notification_history_id,` +
`state_history_id, downtime_history_id, comment_history_id, flapping_history_id, event_type, event_time)` +
@ -191,7 +191,7 @@ func downtimeHistoryWorker(super *supervisor.Supervisor, objectType string) {
values["author"],
values["comment"],
utils.RedisIntToDBBoolean(values["is_flexible"]),
values["duration"],
values["flexible_duration"],
values["scheduled_start_time"],
values["scheduled_end_time"],
utils.RedisIntToDBBoolean(values["was_started"]),

View file

@ -52,7 +52,7 @@ func InsertNullRows(super *supervisor.Supervisor) {
// *_downtime_history
execFunc(
objectType + "_downtime_history",
fmt.Sprintf("REPLACE INTO %s_downtime_history(downtime_id, environment_id, %s_id, triggered_by_id, entry_time, author, comment, is_flexible, duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", objectType, objectType),
fmt.Sprintf("REPLACE INTO %s_downtime_history(downtime_id, environment_id, %s_id, triggered_by_id, entry_time, author, comment, is_flexible, flexible_duration, scheduled_start_time, scheduled_end_time, was_started, actual_start_time, actual_end_time, was_cancelled, is_in_effect, trigger_time, deletion_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", objectType, objectType),
emptyID, super.EnvId, emptyID, emptyID, 0, "", "", "y", 0, 0, 0, "y", 0, 0, "y", "y", 0, 0,
)

View file

@ -22,7 +22,7 @@ var (
"entry_time",
"scheduled_start_time",
"scheduled_end_time",
"duration",
"flexible_duration",
"is_flexible",
"is_in_effect",
"actual_start_time",
@ -45,7 +45,7 @@ type Downtime struct {
EntryTime float64 `json:"entry_time"`
ScheduledStartTime float64 `json:"scheduled_start_time"`
ScheduledEndTime float64 `json:"scheduled_end_time"`
Duration float64 `json:"duration"`
FlexibleDuration float64 `json:"flexible_duration"`
IsFlexible bool `json:"is_flexible"`
IsInEffect bool `json:"is_in_effect"`
ActualStartTime float64 `json:"actual_start_time"`
@ -82,7 +82,7 @@ func (d *Downtime) UpdateValues() []interface{} {
d.EntryTime,
d.ScheduledStartTime,
d.ScheduledEndTime,
d.Duration,
d.FlexibleDuration,
utils.Bool[d.IsFlexible],
utils.Bool[d.IsInEffect],
d.ActualStartTime,

View file

@ -18,12 +18,12 @@ CREATE TABLE downtime (
entry_time bigint(20) unsigned NOT NULL,
scheduled_start_time bigint(20) unsigned NOT NULL,
scheduled_end_time bigint(20) unsigned NOT NULL,
duration bigint(20) unsigned NOT NULL,
flexible_duration bigint(20) unsigned NOT NULL,
is_flexible enum('y', 'n') NOT NULL,
is_in_effect enum('y', 'n') NOT NULL,
actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the host went into a problem state during the downtimes timeframe',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise',
zone_id binary(20) DEFAULT NULL COMMENT 'zone.id',

View file

@ -191,12 +191,12 @@ CREATE TABLE host_downtime_history (
author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
comment text NOT NULL,
is_flexible enum('y', 'n') NOT NULL,
duration bigint(20) unsigned NOT NULL,
flexible_duration bigint(20) unsigned NOT NULL,
scheduled_start_time bigint(20) unsigned NOT NULL,
scheduled_end_time bigint(20) unsigned NOT NULL,
was_started enum('y', 'n') NOT NULL,
actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the host went into a problem state during the downtimes timeframe',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise',
was_cancelled enum('y', 'n') NOT NULL,
is_in_effect enum('y', 'n') NOT NULL,
trigger_time bigint(20) unsigned NOT NULL,

View file

@ -184,12 +184,12 @@ CREATE TABLE service_downtime_history (
author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
comment text NOT NULL,
is_flexible enum('y', 'n') NOT NULL,
duration bigint(20) unsigned NOT NULL,
flexible_duration bigint(20) unsigned NOT NULL,
scheduled_start_time bigint(20) unsigned NOT NULL,
scheduled_end_time bigint(20) unsigned NOT NULL,
was_started enum('y', 'n') NOT NULL,
actual_start_time bigint(20) unsigned DEFAULT NULL COMMENT 'Time when the service went into a problem state during the downtimes timeframe',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + duration otherwise',
actual_end_time bigint(20) unsigned DEFAULT NULL COMMENT 'Problem state assumed: scheduled_end_time if fixed, start_time + flexible_duration otherwise',
was_cancelled enum('y', 'n') NOT NULL,
is_in_effect enum('y', 'n') NOT NULL,
trigger_time bigint(20) unsigned NOT NULL,