|
@@ -7,7 +7,6 @@
|
|
|
package org.elasticsearch.xpack.autoscaling;
|
|
|
|
|
|
import org.apache.lucene.util.SetOnce;
|
|
|
-import org.elasticsearch.Build;
|
|
|
import org.elasticsearch.action.ActionRequest;
|
|
|
import org.elasticsearch.action.ActionResponse;
|
|
|
import org.elasticsearch.client.Client;
|
|
@@ -21,7 +20,6 @@ import org.elasticsearch.common.ParseField;
|
|
|
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
|
|
import org.elasticsearch.common.settings.ClusterSettings;
|
|
|
import org.elasticsearch.common.settings.IndexScopedSettings;
|
|
|
-import org.elasticsearch.common.settings.Setting;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.settings.SettingsFilter;
|
|
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
|
@@ -68,61 +66,21 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugin, AutoscalingExtension {
|
|
|
|
|
|
- private static final Boolean AUTOSCALING_FEATURE_FLAG_REGISTERED;
|
|
|
-
|
|
|
static {
|
|
|
final String property = System.getProperty("es.autoscaling_feature_flag_registered");
|
|
|
- if (Build.CURRENT.isSnapshot() && property != null) {
|
|
|
- throw new IllegalArgumentException("es.autoscaling_feature_flag_registered is only supported in non-snapshot builds");
|
|
|
- }
|
|
|
- if ("true".equals(property)) {
|
|
|
- AUTOSCALING_FEATURE_FLAG_REGISTERED = true;
|
|
|
- } else if ("false".equals(property)) {
|
|
|
- AUTOSCALING_FEATURE_FLAG_REGISTERED = false;
|
|
|
- } else if (property == null) {
|
|
|
- AUTOSCALING_FEATURE_FLAG_REGISTERED = null;
|
|
|
- } else {
|
|
|
- throw new IllegalArgumentException(
|
|
|
- "expected es.autoscaling_feature_flag_registered to be unset or [true|false] but was [" + property + "]"
|
|
|
- );
|
|
|
+ if (property != null) {
|
|
|
+ throw new IllegalArgumentException("es.autoscaling_feature_flag_registered is no longer supported");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static final Setting<Boolean> AUTOSCALING_ENABLED_SETTING = Setting.boolSetting(
|
|
|
- "xpack.autoscaling.enabled",
|
|
|
- true,
|
|
|
- Setting.Property.NodeScope
|
|
|
- );
|
|
|
-
|
|
|
- private final boolean enabled;
|
|
|
-
|
|
|
private final List<AutoscalingExtension> autoscalingExtensions;
|
|
|
private final SetOnce<ClusterService> clusterService = new SetOnce<>();
|
|
|
private final SetOnce<AllocationDeciders> allocationDeciders = new SetOnce<>();
|
|
|
|
|
|
- public Autoscaling(final Settings settings) {
|
|
|
- this.enabled = AUTOSCALING_ENABLED_SETTING.get(settings);
|
|
|
+ public Autoscaling() {
|
|
|
this.autoscalingExtensions = new ArrayList<>(List.of(this));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * The settings defined by autoscaling.
|
|
|
- *
|
|
|
- * @return the settings
|
|
|
- */
|
|
|
- @Override
|
|
|
- public List<Setting<?>> getSettings() {
|
|
|
- if (isSnapshot() || (AUTOSCALING_FEATURE_FLAG_REGISTERED != null && AUTOSCALING_FEATURE_FLAG_REGISTERED)) {
|
|
|
- return List.of(AUTOSCALING_ENABLED_SETTING);
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- boolean isSnapshot() {
|
|
|
- return Build.CURRENT.isSnapshot();
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Collection<Object> createComponents(
|
|
|
Client client,
|
|
@@ -143,16 +101,12 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi
|
|
|
|
|
|
@Override
|
|
|
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
|
|
- if (enabled) {
|
|
|
- return List.of(
|
|
|
- new ActionHandler<>(GetAutoscalingCapacityAction.INSTANCE, TransportGetAutoscalingCapacityAction.class),
|
|
|
- new ActionHandler<>(DeleteAutoscalingPolicyAction.INSTANCE, TransportDeleteAutoscalingPolicyAction.class),
|
|
|
- new ActionHandler<>(GetAutoscalingPolicyAction.INSTANCE, TransportGetAutoscalingPolicyAction.class),
|
|
|
- new ActionHandler<>(PutAutoscalingPolicyAction.INSTANCE, TransportPutAutoscalingPolicyAction.class)
|
|
|
- );
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ new ActionHandler<>(GetAutoscalingCapacityAction.INSTANCE, TransportGetAutoscalingCapacityAction.class),
|
|
|
+ new ActionHandler<>(DeleteAutoscalingPolicyAction.INSTANCE, TransportDeleteAutoscalingPolicyAction.class),
|
|
|
+ new ActionHandler<>(GetAutoscalingPolicyAction.INSTANCE, TransportGetAutoscalingPolicyAction.class),
|
|
|
+ new ActionHandler<>(PutAutoscalingPolicyAction.INSTANCE, TransportPutAutoscalingPolicyAction.class)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -165,16 +119,12 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi
|
|
|
final IndexNameExpressionResolver indexNameExpressionResolver,
|
|
|
final Supplier<DiscoveryNodes> nodesInCluster
|
|
|
) {
|
|
|
- if (enabled) {
|
|
|
- return List.of(
|
|
|
- new RestGetAutoscalingCapacityHandler(),
|
|
|
- new RestDeleteAutoscalingPolicyHandler(),
|
|
|
- new RestGetAutoscalingPolicyHandler(),
|
|
|
- new RestPutAutoscalingPolicyHandler()
|
|
|
- );
|
|
|
- } else {
|
|
|
- return List.of();
|
|
|
- }
|
|
|
+ return List.of(
|
|
|
+ new RestGetAutoscalingCapacityHandler(),
|
|
|
+ new RestDeleteAutoscalingPolicyHandler(),
|
|
|
+ new RestGetAutoscalingPolicyHandler(),
|
|
|
+ new RestPutAutoscalingPolicyHandler()
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
@Override
|