From 9ce4d2b9018ecdb5a269a4d3adff23abd04593aa Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Fri, 17 Jan 2020 14:54:53 -0500 Subject: [PATCH] Initial autoscaling commit (#51161) This commit merely adds the skeleton for the autoscaling project, adding the basics to include the autoscaling module in the default distribution, opt-in to code formatting, and a placeholder for the docs. --- build.gradle | 1 + docs/reference/autoscaling/index.asciidoc | 19 ++++++++ docs/reference/index.asciidoc | 2 + x-pack/plugin/autoscaling/build.gradle | 20 +++++++++ .../xpack/autoscaling/Autoscaling.java | 45 +++++++++++++++++++ .../xpack/autoscaling/AutoscalingTests.java | 40 +++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 docs/reference/autoscaling/index.asciidoc create mode 100644 x-pack/plugin/autoscaling/build.gradle create mode 100644 x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java create mode 100644 x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTests.java diff --git a/build.gradle b/build.gradle index 0f6ad0a6583..1d14d042a03 100644 --- a/build.gradle +++ b/build.gradle @@ -107,6 +107,7 @@ subprojects { // switched to an exclude list, and eventualy removed completely. def projectPathsToFormat = [ ':build-tools', + ':x-pack:plugin:autoscaling', ':x-pack:plugin:enrich' ] diff --git a/docs/reference/autoscaling/index.asciidoc b/docs/reference/autoscaling/index.asciidoc new file mode 100644 index 00000000000..f8f1f98c042 --- /dev/null +++ b/docs/reference/autoscaling/index.asciidoc @@ -0,0 +1,19 @@ +[role="xpack"] +[testenv="platinum"] +[[xpack-autoscaling]] +[chapter] += Autoscaling + +experimental[] + +The autoscaling feature enables an operator to configure tiers of nodes that +self-monitor whether or not they need to scale based on an operator-defined +policy. Then, via the autoscaling API, an Elasticsearch cluster can report +whether or not it needs additional resources to meet the policy. For example, an +operator could define a policy that a warm tier should scale on available disk +space. Elasticsearch would monitor and forecast the available disk space in the +warm tier, and if the forecast is such that the cluster will soon not be able to +allocate existing and future shard copies due to disk space, then the +autoscaling API would report that the cluster needs to scale due to disk space. +It remains the responsibility of the operator to add the additional resources +that the cluster signals it requires. diff --git a/docs/reference/index.asciidoc b/docs/reference/index.asciidoc index 72112b3325e..4bc73d9b6e8 100644 --- a/docs/reference/index.asciidoc +++ b/docs/reference/index.asciidoc @@ -44,6 +44,8 @@ include::ingest.asciidoc[] include::ilm/index.asciidoc[] +include::autoscaling/index.asciidoc[] + include::sql/index.asciidoc[] include::monitoring/index.asciidoc[] diff --git a/x-pack/plugin/autoscaling/build.gradle b/x-pack/plugin/autoscaling/build.gradle new file mode 100644 index 00000000000..4ffbdb78159 --- /dev/null +++ b/x-pack/plugin/autoscaling/build.gradle @@ -0,0 +1,20 @@ +evaluationDependsOn(xpackModule('core')) + +apply plugin: 'elasticsearch.esplugin' + +esplugin { + name 'x-pack-autoscaling' + description 'Elasticsearch Expanded Pack Plugin - Autoscaling' + classname 'org.elasticsearch.xpack.autoscaling.Autoscaling' + extendedPlugins = ['x-pack-core'] + hasNativeController false + requiresKeystore true +} +archivesBaseName = 'x-pack-autoscaling' + +integTest.enabled = false + +dependencies { + compileOnly project(path: xpackModule('core'), configuration: 'default') + testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') +} diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java new file mode 100644 index 00000000000..a231036c79b --- /dev/null +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.autoscaling; + +import org.elasticsearch.Build; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.plugins.Plugin; + +import java.util.Collections; +import java.util.List; + +/** + * Container class for autoscaling functionality. + */ +public class Autoscaling extends Plugin { + + public static final Setting AUTOSCALING_ENABLED_SETTING = Setting.boolSetting( + "xpack.autoscaling.enabled", + false, + Setting.Property.NodeScope + ); + + /** + * The settings defined by autoscaling. + * + * @return the settings + */ + @Override + public List> getSettings() { + if (isSnapshot()) { + return Collections.singletonList(AUTOSCALING_ENABLED_SETTING); + } else { + return Collections.emptyList(); + } + } + + boolean isSnapshot() { + return Build.CURRENT.isSnapshot(); + } + +} diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTests.java new file mode 100644 index 00000000000..32c2b94ab43 --- /dev/null +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTests.java @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +package org.elasticsearch.xpack.autoscaling; + +import org.elasticsearch.test.ESTestCase; + +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; + +public class AutoscalingTests extends ESTestCase { + + public void testEnabledSettingRegisteredInSnapshotBuilds() { + final Autoscaling plugin = new Autoscaling() { + + @Override + protected boolean isSnapshot() { + return true; + } + + }; + assertThat(plugin.getSettings(), hasItem(Autoscaling.AUTOSCALING_ENABLED_SETTING)); + } + + public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() { + final Autoscaling plugin = new Autoscaling() { + + @Override + protected boolean isSnapshot() { + return false; + } + + }; + assertThat(plugin.getSettings(), not(hasItem(Autoscaling.AUTOSCALING_ENABLED_SETTING))); + } + +}