Skip to content

Commit d96038e

Browse files
authored
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.
1 parent 03218ed commit d96038e

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ subprojects {
107107
// switched to an exclude list, and eventualy removed completely.
108108
def projectPathsToFormat = [
109109
':build-tools',
110+
':x-pack:plugin:autoscaling',
110111
':x-pack:plugin:enrich'
111112
]
112113

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[role="xpack"]
2+
[testenv="platinum"]
3+
[[xpack-autoscaling]]
4+
[chapter]
5+
= Autoscaling
6+
7+
experimental[]
8+
9+
The autoscaling feature enables an operator to configure tiers of nodes that
10+
self-monitor whether or not they need to scale based on an operator-defined
11+
policy. Then, via the autoscaling API, an Elasticsearch cluster can report
12+
whether or not it needs additional resources to meet the policy. For example, an
13+
operator could define a policy that a warm tier should scale on available disk
14+
space. Elasticsearch would monitor and forecast the available disk space in the
15+
warm tier, and if the forecast is such that the cluster will soon not be able to
16+
allocate existing and future shard copies due to disk space, then the
17+
autoscaling API would report that the cluster needs to scale due to disk space.
18+
It remains the responsibility of the operator to add the additional resources
19+
that the cluster signals it requires.

docs/reference/index.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ include::ingest.asciidoc[]
4040

4141
include::ilm/index.asciidoc[]
4242

43+
include::autoscaling/index.asciidoc[]
44+
4345
include::sql/index.asciidoc[]
4446

4547
include::monitoring/index.asciidoc[]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
evaluationDependsOn(xpackModule('core'))
2+
3+
apply plugin: 'elasticsearch.esplugin'
4+
5+
esplugin {
6+
name 'x-pack-autoscaling'
7+
description 'Elasticsearch Expanded Pack Plugin - Autoscaling'
8+
classname 'org.elasticsearch.xpack.autoscaling.Autoscaling'
9+
extendedPlugins = ['x-pack-core']
10+
hasNativeController false
11+
requiresKeystore true
12+
}
13+
archivesBaseName = 'x-pack-autoscaling'
14+
15+
integTest.enabled = false
16+
17+
dependencies {
18+
compileOnly project(path: xpackModule('core'), configuration: 'default')
19+
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
20+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.autoscaling;
8+
9+
import org.elasticsearch.Build;
10+
import org.elasticsearch.common.settings.Setting;
11+
import org.elasticsearch.plugins.Plugin;
12+
13+
import java.util.List;
14+
15+
/**
16+
* Container class for autoscaling functionality.
17+
*/
18+
public class Autoscaling extends Plugin {
19+
20+
public static final Setting<Boolean> AUTOSCALING_ENABLED_SETTING = Setting.boolSetting(
21+
"xpack.autoscaling.enabled",
22+
false,
23+
Setting.Property.NodeScope
24+
);
25+
26+
/**
27+
* The settings defined by autoscaling.
28+
*
29+
* @return the settings
30+
*/
31+
@Override
32+
public List<Setting<?>> getSettings() {
33+
if (isSnapshot()) {
34+
return List.of(AUTOSCALING_ENABLED_SETTING);
35+
} else {
36+
return List.of();
37+
}
38+
}
39+
40+
boolean isSnapshot() {
41+
return Build.CURRENT.isSnapshot();
42+
}
43+
44+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.autoscaling;
8+
9+
import org.elasticsearch.test.ESTestCase;
10+
11+
import static org.hamcrest.Matchers.hasItem;
12+
import static org.hamcrest.Matchers.not;
13+
14+
public class AutoscalingTests extends ESTestCase {
15+
16+
public void testEnabledSettingRegisteredInSnapshotBuilds() {
17+
final Autoscaling plugin = new Autoscaling() {
18+
19+
@Override
20+
protected boolean isSnapshot() {
21+
return true;
22+
}
23+
24+
};
25+
assertThat(plugin.getSettings(), hasItem(Autoscaling.AUTOSCALING_ENABLED_SETTING));
26+
}
27+
28+
public void testEnabledSettingNotRegisteredInNonSnapshotBuilds() {
29+
final Autoscaling plugin = new Autoscaling() {
30+
31+
@Override
32+
protected boolean isSnapshot() {
33+
return false;
34+
}
35+
36+
};
37+
assertThat(plugin.getSettings(), not(hasItem(Autoscaling.AUTOSCALING_ENABLED_SETTING)));
38+
}
39+
40+
}

0 commit comments

Comments
 (0)