summaryrefslogtreecommitdiffstats
path: root/jobs/schedulers.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-08-17 15:05:17 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2017-08-17 10:05:17 -0400
commit22459ee17a3ba0b4487f975b6ebe630cab2d9feb (patch)
tree275d8b68561d1c5046416d04264efc35806b8342 /jobs/schedulers.go
parent4e92d1801733410c47bdde29c4bda4d52210d4e7 (diff)
downloadchat-22459ee17a3ba0b4487f975b6ebe630cab2d9feb.tar.gz
chat-22459ee17a3ba0b4487f975b6ebe630cab2d9feb.tar.bz2
chat-22459ee17a3ba0b4487f975b6ebe630cab2d9feb.zip
PLT-7302: Aggregate Elasticsearch indexes over a certain age. (#7224)
* PLT-7302: Aggregate Elasticsearch indexes over a certain age. This is done by a scheduled daily job, in order to keep the shard count to a sensible level in Elasticsearch. * Use map[string]string instead of StringMap
Diffstat (limited to 'jobs/schedulers.go')
-rw-r--r--jobs/schedulers.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/jobs/schedulers.go b/jobs/schedulers.go
index 73ec6661a..2f4e18001 100644
--- a/jobs/schedulers.go
+++ b/jobs/schedulers.go
@@ -16,7 +16,8 @@ import (
type Schedulers struct {
startOnce sync.Once
- DataRetention model.Scheduler
+ DataRetention model.Scheduler
+ ElasticsearchAggregation model.Scheduler
listenerId string
}
@@ -28,6 +29,10 @@ func InitSchedulers() *Schedulers {
schedulers.DataRetention = dataRetentionInterface.MakeScheduler()
}
+ if elasticsearchAggregatorInterface := ejobs.GetElasticsearchAggregatorInterface(); elasticsearchAggregatorInterface != nil {
+ schedulers.ElasticsearchAggregation = elasticsearchAggregatorInterface.MakeScheduler()
+ }
+
return schedulers
}
@@ -38,6 +43,10 @@ func (schedulers *Schedulers) Start() *Schedulers {
if schedulers.DataRetention != nil && *utils.Cfg.DataRetentionSettings.Enable {
go schedulers.DataRetention.Run()
}
+
+ if schedulers.ElasticsearchAggregation != nil && *utils.Cfg.ElasticsearchSettings.EnableIndexing {
+ go schedulers.ElasticsearchAggregation.Run()
+ }
})
schedulers.listenerId = utils.AddConfigListener(schedulers.handleConfigChange)
@@ -53,6 +62,14 @@ func (schedulers *Schedulers) handleConfigChange(oldConfig *model.Config, newCon
schedulers.DataRetention.Stop()
}
}
+
+ if schedulers.ElasticsearchAggregation != nil {
+ if !*oldConfig.ElasticsearchSettings.EnableIndexing && *newConfig.ElasticsearchSettings.EnableIndexing {
+ go schedulers.ElasticsearchAggregation.Run()
+ } else if *oldConfig.ElasticsearchSettings.EnableIndexing && !*newConfig.ElasticsearchSettings.EnableIndexing {
+ schedulers.ElasticsearchAggregation.Stop()
+ }
+ }
}
func (schedulers *Schedulers) Stop() *Schedulers {
@@ -62,6 +79,10 @@ func (schedulers *Schedulers) Stop() *Schedulers {
schedulers.DataRetention.Stop()
}
+ if schedulers.ElasticsearchAggregation != nil && *utils.Cfg.ElasticsearchSettings.EnableIndexing {
+ schedulers.ElasticsearchAggregation.Stop()
+ }
+
l4g.Info("Stopped schedulers")
return schedulers