diff options
author | George Goldberg <george@gberg.me> | 2017-08-17 15:05:17 +0100 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-08-17 10:05:17 -0400 |
commit | 22459ee17a3ba0b4487f975b6ebe630cab2d9feb (patch) | |
tree | 275d8b68561d1c5046416d04264efc35806b8342 /jobs/jobs_watcher.go | |
parent | 4e92d1801733410c47bdde29c4bda4d52210d4e7 (diff) | |
download | chat-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/jobs_watcher.go')
-rw-r--r-- | jobs/jobs_watcher.go | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/jobs/jobs_watcher.go b/jobs/jobs_watcher.go index 9ba68e85e..83d4249eb 100644 --- a/jobs/jobs_watcher.go +++ b/jobs/jobs_watcher.go @@ -64,25 +64,27 @@ func (watcher *Watcher) PollAndNotify() { if result := <-Srv.Store.Job().GetAllByStatus(model.JOB_STATUS_PENDING); result.Err != nil { l4g.Error("Error occured getting all pending statuses: %v", result.Err.Error()) } else { - jobStatuses := result.Data.([]*model.Job) + jobs := result.Data.([]*model.Job) - for _, js := range jobStatuses { - j := model.Job{ - Type: js.Type, - Id: js.Id, - } - - if js.Type == model.JOB_TYPE_DATA_RETENTION { + for _, job := range jobs { + if job.Type == model.JOB_TYPE_DATA_RETENTION { if watcher.workers.DataRetention != nil { select { - case watcher.workers.DataRetention.JobChannel() <- j: + case watcher.workers.DataRetention.JobChannel() <- *job: default: } } - } else if js.Type == model.JOB_TYPE_ELASTICSEARCH_POST_INDEXING { + } else if job.Type == model.JOB_TYPE_ELASTICSEARCH_POST_INDEXING { if watcher.workers.ElasticsearchIndexing != nil { select { - case watcher.workers.ElasticsearchIndexing.JobChannel() <- j: + case watcher.workers.ElasticsearchIndexing.JobChannel() <- *job: + default: + } + } + } else if job.Type == model.JOB_TYPE_ELASTICSEARCH_POST_AGGREGATION { + if watcher.workers.ElasticsearchAggregation != nil { + select { + case watcher.workers.ElasticsearchAggregation.JobChannel() <- *job: default: } } |