[ML] Use default number_of_shards for results and state indices (elastic/x-pack-elasticsearch#849)

Like other x-pack features, these indices are best created with
default number_of_shards. Users can adjust the setting by editing
the respective templates.

relates elastic/x-pack-elasticsearch#723

Original commit: elastic/x-pack-elasticsearch@1d688993be
This commit is contained in:
Dimitris Athanasiou 2017-03-27 13:08:19 +01:00 committed by GitHub
parent ecbfaace38
commit 9cd21cca4b
2 changed files with 6 additions and 12 deletions

View File

@ -274,9 +274,6 @@ public class MachineLearningTemplateRegistry extends AbstractComponent implemen
*/
Settings.Builder mlResultsIndexSettings() {
return Settings.builder()
// Our indexes are small and one shard puts the
// least possible burden on Elasticsearch
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-2")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)
// Sacrifice durability for performance: in the event of power
@ -315,9 +312,6 @@ public class MachineLearningTemplateRegistry extends AbstractComponent implemen
Settings.Builder mlStateIndexSettings() {
// TODO review these settings
return Settings.builder()
// Our indexes are small and one shard puts the
// least possible burden on Elasticsearch
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-2")
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), delayedNodeTimeOutSetting)
// Sacrifice durability for performance: in the event of power

View File

@ -39,14 +39,14 @@ import org.junit.Before;
import org.mockito.ArgumentCaptor;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import static org.elasticsearch.mock.orig.Mockito.doAnswer;
import static org.elasticsearch.mock.orig.Mockito.times;
import static org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex.ML_META_INDEX;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
@ -156,7 +156,7 @@ public class MachineLearningTemplateRegistryTests extends ESTestCase {
new MachineLearningTemplateRegistry(createSettings(), clusterService, client, threadPool);
Settings settings = templateRegistry.mlResultsIndexSettings().build();
assertEquals("1", settings.get("index.number_of_shards"));
assertThat(settings.get("index.number_of_shards"), is(nullValue()));
assertEquals("0-2", settings.get("index.auto_expand_replicas"));
assertEquals("async", settings.get("index.translog.durability"));
assertEquals("true", settings.get("index.mapper.dynamic"));
@ -167,11 +167,11 @@ public class MachineLearningTemplateRegistryTests extends ESTestCase {
public void testMlAuditIndexSettings() {
MachineLearningTemplateRegistry templateRegistry =
new MachineLearningTemplateRegistry(createSettings(), clusterService, client, threadPool);
Settings settings = templateRegistry.mlResultsIndexSettings().build();
Settings settings = templateRegistry.mlNotificationIndexSettings().build();
assertEquals(4, settings.size());
assertEquals("1", settings.get("index.number_of_shards"));
assertEquals("0-2", settings.get("index.auto_expand_replicas"));
assertEquals("async", settings.get("index.translog.durability"));
assertEquals("true", settings.get("index.mapper.dynamic"));
assertEquals("2s", settings.get("index.unassigned.node_left.delayed_timeout"));
}
@ -181,7 +181,7 @@ public class MachineLearningTemplateRegistryTests extends ESTestCase {
new MachineLearningTemplateRegistry(createSettings(), clusterService, client, threadPool);
Settings settings = templateRegistry.mlResultsIndexSettings().build();
assertEquals("1", settings.get("index.number_of_shards"));
assertThat(settings.get("index.number_of_shards"), is(nullValue()));
assertEquals("0-2", settings.get("index.auto_expand_replicas"));
assertEquals("async", settings.get("index.translog.durability"));
assertEquals("2s", settings.get("index.unassigned.node_left.delayed_timeout"));