[ML] Use auto_expand_replicas (elastic/x-pack-elasticsearch#3375)

This creates all ML templates using the `index.auto_expand_replicas` set as `"0-1"` so that a single node cluster (e.g., dev) can startup as green.

Original commit: elastic/x-pack-elasticsearch@7a243c5b06
This commit is contained in:
Chris Earle 2017-12-20 17:23:36 -05:00 committed by GitHub
parent 15e738b184
commit 362ba75e6b
1 changed files with 4 additions and 0 deletions

View File

@ -576,6 +576,7 @@ public class MachineLearning implements ActionPlugin {
// Our indexes are small and one shard puts the // Our indexes are small and one shard puts the
// least possible burden on Elasticsearch // least possible burden on Elasticsearch
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting))
.build(); .build();
templates.put(Auditor.NOTIFICATIONS_INDEX, notificationMessageTemplate); templates.put(Auditor.NOTIFICATIONS_INDEX, notificationMessageTemplate);
@ -590,6 +591,7 @@ public class MachineLearning implements ActionPlugin {
// Our indexes are small and one shard puts the // Our indexes are small and one shard puts the
// least possible burden on Elasticsearch // least possible burden on Elasticsearch
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting))
.version(Version.CURRENT.id) .version(Version.CURRENT.id)
.putMapping(MlMetaIndex.TYPE, docMapping.string()) .putMapping(MlMetaIndex.TYPE, docMapping.string())
@ -604,6 +606,7 @@ public class MachineLearning implements ActionPlugin {
.patterns(Collections.singletonList(AnomalyDetectorsIndex.jobStateIndexName())) .patterns(Collections.singletonList(AnomalyDetectorsIndex.jobStateIndexName()))
// TODO review these settings // TODO review these settings
.settings(Settings.builder() .settings(Settings.builder()
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)
// Sacrifice durability for performance: in the event of power // Sacrifice durability for performance: in the event of power
// failure we can lose the last 5 seconds of changes, but it's // failure we can lose the last 5 seconds of changes, but it's
@ -621,6 +624,7 @@ public class MachineLearning implements ActionPlugin {
IndexTemplateMetaData jobResultsTemplate = IndexTemplateMetaData.builder(AnomalyDetectorsIndex.jobResultsIndexPrefix()) IndexTemplateMetaData jobResultsTemplate = IndexTemplateMetaData.builder(AnomalyDetectorsIndex.jobResultsIndexPrefix())
.patterns(Collections.singletonList(AnomalyDetectorsIndex.jobResultsIndexPrefix() + "*")) .patterns(Collections.singletonList(AnomalyDetectorsIndex.jobResultsIndexPrefix() + "*"))
.settings(Settings.builder() .settings(Settings.builder()
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting) .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)
// Sacrifice durability for performance: in the event of power // Sacrifice durability for performance: in the event of power
// failure we can lose the last 5 seconds of changes, but it's // failure we can lose the last 5 seconds of changes, but it's