Browse Source

Autoscaling capacity API and structure (#63905)

Renamed decision API to capacity. Responses now prefer objects/maps over
arrays. Removed mention of tier, using policies as the outer map and
total for the policy-wide total capacity.
Henning Andersen 5 years ago
parent
commit
d573fdefd3
34 changed files with 328 additions and 337 deletions
  1. 2 2
      docs/reference/autoscaling/apis/autoscaling-apis.asciidoc
  2. 15 15
      docs/reference/autoscaling/apis/get-autoscaling-capacity.asciidoc
  3. 1 1
      docs/reference/autoscaling/apis/put-autoscaling-policy.asciidoc
  4. 6 0
      docs/reference/redirects.asciidoc
  5. 39 0
      x-pack/plugin/autoscaling/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/autoscaling/get_autoscaling_capacity.yml
  6. 0 41
      x-pack/plugin/autoscaling/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/autoscaling/get_autoscaling_decision.yml
  7. 13 13
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java
  8. 2 2
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingExtension.java
  9. 18 17
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityAction.java
  10. 18 16
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityAction.java
  11. 23 20
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityService.java
  12. 23 23
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCapacity.java
  13. 1 1
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderConfiguration.java
  14. 2 2
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderContext.java
  15. 9 9
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResult.java
  16. 27 41
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResults.java
  17. 3 3
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderService.java
  18. 1 1
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderConfiguration.java
  19. 5 5
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderService.java
  20. 1 1
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java
  21. 6 6
      x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/rest/RestGetAutoscalingCapacityHandler.java
  22. 14 14
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java
  23. 6 6
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionRequestWireSerializingTests.java
  24. 9 9
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionResponseTests.java
  25. 10 10
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionResponseWireSerializingTests.java
  26. 3 3
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCapacityWireSerializationTests.java
  27. 23 24
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultServiceTests.java
  28. 6 6
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultWireSerializingTests.java
  29. 11 15
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultsTests.java
  30. 6 6
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultsWireSerializingTests.java
  31. 1 1
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderConfigurationSerializationTests.java
  32. 5 5
      x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderServiceTests.java
  33. 19 0
      x-pack/plugin/src/test/resources/rest-api-spec/api/autoscaling.get_autoscaling_capacity.json
  34. 0 19
      x-pack/plugin/src/test/resources/rest-api-spec/api/autoscaling.get_autoscaling_decision.json

+ 2 - 2
docs/reference/autoscaling/apis/autoscaling-apis.asciidoc

@@ -9,13 +9,13 @@ You can use the following APIs to perform autoscaling operations.
 [[autoscaling-api-top-level]]
 === Top-Level
 
-* <<autoscaling-get-autoscaling-decision,Get autoscaling decision>>
+* <<autoscaling-get-autoscaling-capacity,Get autoscaling capacity>>
 * <<autoscaling-delete-autoscaling-policy,Delete autoscaling policy>>
 * <<autoscaling-get-autoscaling-policy,Get autoscaling policy>>
 * <<autoscaling-put-autoscaling-policy,Put autoscaling policy>>
 
 // top-level
-include::get-autoscaling-decision.asciidoc[]
+include::get-autoscaling-capacity.asciidoc[]
 include::delete-autoscaling-policy.asciidoc[]
 include::get-autoscaling-policy.asciidoc[]
 include::put-autoscaling-policy.asciidoc[]

+ 15 - 15
docs/reference/autoscaling/apis/get-autoscaling-decision.asciidoc → docs/reference/autoscaling/apis/get-autoscaling-capacity.asciidoc

@@ -1,44 +1,44 @@
 [role="xpack"]
 [testenv="platinum"]
-[[autoscaling-get-autoscaling-decision]]
-=== Get autoscaling decision API
+[[autoscaling-get-autoscaling-capacity]]
+=== Get autoscaling capacity API
 ++++
-<titleabbrev>Get autoscaling decision</titleabbrev>
+<titleabbrev>Get autoscaling capacity</titleabbrev>
 ++++
 
-Get autoscaling decision.
+Get autoscaling capacity.
 
-[[autoscaling-get-autoscaling-decision-request]]
+[[autoscaling-get-autoscaling-capacity-request]]
 ==== {api-request-title}
 
 [source,console]
 --------------------------------------------------
-GET /_autoscaling/decision/
+GET /_autoscaling/capacity/
 --------------------------------------------------
 // TEST
 
-[[autoscaling-get-autoscaling-decision-prereqs]]
+[[autoscaling-get-autoscaling-capacity-prereqs]]
 ==== {api-prereq-title}
 
 * If the {es} {security-features} are enabled, you must have
 `manage_autoscaling` cluster privileges. For more information, see
 <<security-privileges>>.
 
-[[autoscaling-get-autoscaling-decision-desc]]
+[[autoscaling-get-autoscaling-capacity-desc]]
 ==== {api-description-title}
 
-This API gets the current autoscaling decision based on the configured
-autoscaling policy. This API will return whether or not autoscaling is
-needed.
+This API gets the current autoscaling capacity based on the configured
+autoscaling policy. This API will return information to size the cluster
+appropriately to the current workload.
 
-[[autoscaling-get-autoscaling-decision-examples]]
+[[autoscaling-get-autoscaling-capacity-examples]]
 ==== {api-examples-title}
 
-This example retrieves the current autoscaling decision.
+This example retrieves the current autoscaling capacity.
 
 [source,console]
 --------------------------------------------------
-GET /_autoscaling/decision
+GET /_autoscaling/capacity
 --------------------------------------------------
 // TEST
 
@@ -47,6 +47,6 @@ The API returns the following result:
 [source,console-result]
 --------------------------------------------------
 {
-  decisions: []
+  policies: {}
 }
 --------------------------------------------------

+ 1 - 1
docs/reference/autoscaling/apis/put-autoscaling-policy.asciidoc

@@ -51,7 +51,7 @@ This API puts an autoscaling policy with the provided name.
 ==== {api-examples-title}
 
 This example puts an autoscaling policy named `my_autoscaling_policy` using the
-always autoscaling decider.
+fixed autoscaling decider.
 
 [source,console]
 --------------------------------------------------

+ 6 - 0
docs/reference/redirects.asciidoc

@@ -1225,3 +1225,9 @@ See <<size-your-shards>>.
 === elasticsearch-croneval parameters
 
 See <<elasticsearch-croneval-parameters>>.
+
+[role="exclude",id="autoscaling-get-autoscaling-decision"]
+=== Autoscaling decision API
+
+The autoscaling decision API has been renamed to capacity,
+see <<autoscaling-get-autoscaling-capacity>>.

+ 39 - 0
x-pack/plugin/autoscaling/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/autoscaling/get_autoscaling_capacity.yml

@@ -0,0 +1,39 @@
+---
+"Test get empty autoscaling capacity":
+  - do:
+      autoscaling.get_autoscaling_capacity: {}
+
+  - match: { "policies": {} }
+
+---
+"Test get fixed autoscaling capacity":
+  - do:
+      autoscaling.put_autoscaling_policy:
+        name: my_autoscaling_policy
+        body:
+          policy:
+            deciders:
+              fixed:
+                storage: 1337b
+                memory: 7331b
+                nodes: 10
+
+  - match: { "acknowledged": true }
+
+  - do:
+      autoscaling.get_autoscaling_capacity: {}
+
+  - match: { policies.my_autoscaling_policy.required_capacity.total.storage: 13370b }
+  - match: { policies.my_autoscaling_policy.required_capacity.total.memory: 73310b }
+  - match: { policies.my_autoscaling_policy.required_capacity.node.storage: 1337b }
+  - match: { policies.my_autoscaling_policy.required_capacity.node.memory: 7331b }
+  - match: { policies.my_autoscaling_policy.deciders.fixed.required_capacity.total.storage: 13370b }
+  - match: { policies.my_autoscaling_policy.deciders.fixed.required_capacity.total.memory: 73310b }
+  - match: { policies.my_autoscaling_policy.deciders.fixed.required_capacity.node.storage: 1337b }
+  - match: { policies.my_autoscaling_policy.deciders.fixed.required_capacity.node.memory: 7331b }
+  - match: { policies.my_autoscaling_policy.deciders.fixed.reason_summary: "fixed storage [1.3kb] memory [7.1kb] nodes [10]" }
+
+  # test cleanup
+  - do:
+      autoscaling.delete_autoscaling_policy:
+        name: my_autoscaling_policy

+ 0 - 41
x-pack/plugin/autoscaling/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/autoscaling/get_autoscaling_decision.yml

@@ -1,41 +0,0 @@
----
-"Test get empty autoscaling decision":
-  - do:
-      autoscaling.get_autoscaling_decision: {}
-
-  - match: { "decisions": [] }
-
----
-"Test get fixed autoscaling decision":
-  - do:
-      autoscaling.put_autoscaling_policy:
-        name: my_autoscaling_policy
-        body:
-          policy:
-            deciders:
-              fixed:
-                storage: 1337b
-                memory: 7331b
-                nodes: 10
-
-  - match: { "acknowledged": true }
-
-  - do:
-      autoscaling.get_autoscaling_decision: {}
-
-  - match: { decisions.0.tier: my_autoscaling_policy }
-  - match: { decisions.0.required_capacity.tier.storage: 13370b }
-  - match: { decisions.0.required_capacity.tier.memory: 73310b }
-  - match: { decisions.0.required_capacity.node.storage: 1337b }
-  - match: { decisions.0.required_capacity.node.memory: 7331b }
-  - match: { decisions.0.decisions.0.name: fixed }
-  - match: { decisions.0.decisions.0.required_capacity.tier.storage: 13370b }
-  - match: { decisions.0.decisions.0.required_capacity.tier.memory: 73310b }
-  - match: { decisions.0.decisions.0.required_capacity.node.storage: 1337b }
-  - match: { decisions.0.decisions.0.required_capacity.node.memory: 7331b }
-  - match: { decisions.0.decisions.0.reason_summary: "fixed storage [1.3kb] memory [7.1kb] nodes [10]" }
-
-  # test cleanup
-  - do:
-      autoscaling.delete_autoscaling_policy:
-        name: my_autoscaling_policy

+ 13 - 13
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java

@@ -38,21 +38,21 @@ import org.elasticsearch.script.ScriptService;
 import org.elasticsearch.threadpool.ThreadPool;
 import org.elasticsearch.watcher.ResourceWatcherService;
 import org.elasticsearch.xpack.autoscaling.action.DeleteAutoscalingPolicyAction;
-import org.elasticsearch.xpack.autoscaling.action.GetAutoscalingDecisionAction;
+import org.elasticsearch.xpack.autoscaling.action.GetAutoscalingCapacityAction;
 import org.elasticsearch.xpack.autoscaling.action.GetAutoscalingPolicyAction;
 import org.elasticsearch.xpack.autoscaling.action.PutAutoscalingPolicyAction;
 import org.elasticsearch.xpack.autoscaling.action.TransportDeleteAutoscalingPolicyAction;
-import org.elasticsearch.xpack.autoscaling.action.TransportGetAutoscalingDecisionAction;
+import org.elasticsearch.xpack.autoscaling.action.TransportGetAutoscalingCapacityAction;
 import org.elasticsearch.xpack.autoscaling.action.TransportGetAutoscalingPolicyAction;
 import org.elasticsearch.xpack.autoscaling.action.TransportPutAutoscalingPolicyAction;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecision;
-import org.elasticsearch.xpack.autoscaling.decision.FixedAutoscalingDeciderConfiguration;
-import org.elasticsearch.xpack.autoscaling.decision.FixedAutoscalingDeciderService;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderConfiguration;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderService;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisionService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResult;
+import org.elasticsearch.xpack.autoscaling.capacity.FixedAutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.FixedAutoscalingDeciderService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingCalculateCapacityService;
 import org.elasticsearch.xpack.autoscaling.rest.RestDeleteAutoscalingPolicyHandler;
-import org.elasticsearch.xpack.autoscaling.rest.RestGetAutoscalingDecisionHandler;
+import org.elasticsearch.xpack.autoscaling.rest.RestGetAutoscalingCapacityHandler;
 import org.elasticsearch.xpack.autoscaling.rest.RestGetAutoscalingPolicyHandler;
 import org.elasticsearch.xpack.autoscaling.rest.RestPutAutoscalingPolicyHandler;
 import org.elasticsearch.xpack.core.XPackPlugin;
@@ -136,14 +136,14 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi
         IndexNameExpressionResolver indexNameExpressionResolver,
         Supplier<RepositoriesService> repositoriesServiceSupplier
     ) {
-        return List.of(new AutoscalingDecisionService.Holder(this));
+        return List.of(new AutoscalingCalculateCapacityService.Holder(this));
     }
 
     @Override
     public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
         if (enabled) {
             return List.of(
-                new ActionHandler<>(GetAutoscalingDecisionAction.INSTANCE, TransportGetAutoscalingDecisionAction.class),
+                new ActionHandler<>(GetAutoscalingCapacityAction.INSTANCE, TransportGetAutoscalingCapacityAction.class),
                 new ActionHandler<>(DeleteAutoscalingPolicyAction.INSTANCE, TransportDeleteAutoscalingPolicyAction.class),
                 new ActionHandler<>(GetAutoscalingPolicyAction.INSTANCE, TransportGetAutoscalingPolicyAction.class),
                 new ActionHandler<>(PutAutoscalingPolicyAction.INSTANCE, TransportPutAutoscalingPolicyAction.class)
@@ -165,7 +165,7 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi
     ) {
         if (enabled) {
             return List.of(
-                new RestGetAutoscalingDecisionHandler(),
+                new RestGetAutoscalingCapacityHandler(),
                 new RestDeleteAutoscalingPolicyHandler(),
                 new RestGetAutoscalingPolicyHandler(),
                 new RestPutAutoscalingPolicyHandler()
@@ -186,7 +186,7 @@ public class Autoscaling extends Plugin implements ActionPlugin, ExtensiblePlugi
                 FixedAutoscalingDeciderConfiguration::new
             ),
             new NamedWriteableRegistry.Entry(
-                AutoscalingDecision.Reason.class,
+                AutoscalingDeciderResult.Reason.class,
                 FixedAutoscalingDeciderConfiguration.NAME,
                 FixedAutoscalingDeciderService.FixedReason::new
             )

+ 2 - 2
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/AutoscalingExtension.java

@@ -6,8 +6,8 @@
 
 package org.elasticsearch.xpack.autoscaling;
 
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderConfiguration;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderService;
 
 import java.util.Collection;
 

+ 18 - 17
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionAction.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityAction.java

@@ -14,23 +14,24 @@ import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
 import org.elasticsearch.common.xcontent.ToXContentObject;
 import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisions;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResults;
 
 import java.io.IOException;
+import java.util.Map;
 import java.util.Objects;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-public class GetAutoscalingDecisionAction extends ActionType<GetAutoscalingDecisionAction.Response> {
+public class GetAutoscalingCapacityAction extends ActionType<GetAutoscalingCapacityAction.Response> {
 
-    public static final GetAutoscalingDecisionAction INSTANCE = new GetAutoscalingDecisionAction();
-    public static final String NAME = "cluster:admin/autoscaling/get_autoscaling_decision";
+    public static final GetAutoscalingCapacityAction INSTANCE = new GetAutoscalingCapacityAction();
+    public static final String NAME = "cluster:admin/autoscaling/get_autoscaling_capacity";
 
-    private GetAutoscalingDecisionAction() {
+    private GetAutoscalingCapacityAction() {
         super(NAME, Response::new);
     }
 
-    public static class Request extends AcknowledgedRequest<GetAutoscalingDecisionAction.Request> {
+    public static class Request extends AcknowledgedRequest<GetAutoscalingCapacityAction.Request> {
 
         public Request() {
 
@@ -66,33 +67,33 @@ public class GetAutoscalingDecisionAction extends ActionType<GetAutoscalingDecis
 
     public static class Response extends ActionResponse implements ToXContentObject {
 
-        private final SortedMap<String, AutoscalingDecisions> decisions;
+        private final SortedMap<String, AutoscalingDeciderResults> results;
 
-        public Response(final SortedMap<String, AutoscalingDecisions> decisions) {
-            this.decisions = Objects.requireNonNull(decisions);
+        public Response(final SortedMap<String, AutoscalingDeciderResults> results) {
+            this.results = Objects.requireNonNull(results);
         }
 
         public Response(final StreamInput in) throws IOException {
             super(in);
-            decisions = new TreeMap<>(in.readMap(StreamInput::readString, AutoscalingDecisions::new));
+            results = new TreeMap<>(in.readMap(StreamInput::readString, AutoscalingDeciderResults::new));
         }
 
         @Override
         public void writeTo(final StreamOutput out) throws IOException {
-            out.writeMap(decisions, StreamOutput::writeString, (o, decision) -> decision.writeTo(o));
+            out.writeMap(results, StreamOutput::writeString, (o, decision) -> decision.writeTo(o));
         }
 
         @Override
         public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
             builder.startObject();
             {
-                builder.startArray("decisions");
+                builder.startObject("policies");
                 {
-                    for (final AutoscalingDecisions decision : decisions.values()) {
-                        decision.toXContent(builder, params);
+                    for (Map.Entry<String, AutoscalingDeciderResults> entry : results.entrySet()) {
+                        builder.field(entry.getKey(), entry.getValue());
                     }
                 }
-                builder.endArray();
+                builder.endObject();
             }
             builder.endObject();
             return builder;
@@ -103,12 +104,12 @@ public class GetAutoscalingDecisionAction extends ActionType<GetAutoscalingDecis
             if (this == o) return true;
             if (o == null || getClass() != o.getClass()) return false;
             final Response response = (Response) o;
-            return decisions.equals(response.decisions);
+            return results.equals(response.results);
         }
 
         @Override
         public int hashCode() {
-            return Objects.hash(decisions);
+            return Objects.hash(results);
         }
 
     }

+ 18 - 16
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingDecisionAction.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/action/TransportGetAutoscalingCapacityAction.java

@@ -18,53 +18,55 @@ import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.tasks.Task;
 import org.elasticsearch.threadpool.ThreadPool;
 import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisionService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingCalculateCapacityService;
 
-public class TransportGetAutoscalingDecisionAction extends TransportMasterNodeAction<
-    GetAutoscalingDecisionAction.Request,
-    GetAutoscalingDecisionAction.Response> {
+public class TransportGetAutoscalingCapacityAction extends TransportMasterNodeAction<
+    GetAutoscalingCapacityAction.Request,
+    GetAutoscalingCapacityAction.Response> {
 
-    private final AutoscalingDecisionService decisionService;
+    private final AutoscalingCalculateCapacityService capacityService;
     private final ClusterInfoService clusterInfoService;
 
     @Inject
-    public TransportGetAutoscalingDecisionAction(
+    public TransportGetAutoscalingCapacityAction(
         final TransportService transportService,
         final ClusterService clusterService,
         final ThreadPool threadPool,
         final ActionFilters actionFilters,
         final IndexNameExpressionResolver indexNameExpressionResolver,
-        final AutoscalingDecisionService.Holder decisionServiceHolder,
+        final AutoscalingCalculateCapacityService.Holder capacityServiceHolder,
         final ClusterInfoService clusterInfoService
     ) {
         super(
-            GetAutoscalingDecisionAction.NAME,
+            GetAutoscalingCapacityAction.NAME,
             transportService,
             clusterService,
             threadPool,
             actionFilters,
-            GetAutoscalingDecisionAction.Request::new,
+            GetAutoscalingCapacityAction.Request::new,
             indexNameExpressionResolver,
-            GetAutoscalingDecisionAction.Response::new,
+            GetAutoscalingCapacityAction.Response::new,
             ThreadPool.Names.SAME
         );
-        this.decisionService = decisionServiceHolder.get();
+        this.capacityService = capacityServiceHolder.get();
         this.clusterInfoService = clusterInfoService;
-        assert this.decisionService != null;
+        assert this.capacityService != null;
     }
 
     @Override
     protected void masterOperation(
         final Task task,
-        final GetAutoscalingDecisionAction.Request request,
+        final GetAutoscalingCapacityAction.Request request,
         final ClusterState state,
-        final ActionListener<GetAutoscalingDecisionAction.Response> listener
+        final ActionListener<GetAutoscalingCapacityAction.Response> listener
     ) {
-        listener.onResponse(new GetAutoscalingDecisionAction.Response(decisionService.decide(state, clusterInfoService.getClusterInfo())));
+        listener.onResponse(
+            new GetAutoscalingCapacityAction.Response(capacityService.calculate(state, clusterInfoService.getClusterInfo()))
+        );
     }
 
     @Override
-    protected ClusterBlockException checkBlock(final GetAutoscalingDecisionAction.Request request, final ClusterState state) {
+    protected ClusterBlockException checkBlock(final GetAutoscalingCapacityAction.Request request, final ClusterState state) {
         return null;
     }
 

+ 23 - 20
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisionService.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityService.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.apache.lucene.util.SetOnce;
 import org.elasticsearch.cluster.ClusterInfo;
@@ -28,35 +28,35 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
 
-public class AutoscalingDecisionService {
+public class AutoscalingCalculateCapacityService {
     private Map<String, AutoscalingDeciderService<? extends AutoscalingDeciderConfiguration>> deciderByName;
 
-    public AutoscalingDecisionService(Set<AutoscalingDeciderService<? extends AutoscalingDeciderConfiguration>> deciders) {
+    public AutoscalingCalculateCapacityService(Set<AutoscalingDeciderService<? extends AutoscalingDeciderConfiguration>> deciders) {
         assert deciders.size() >= 1; // always have fixed
         this.deciderByName = deciders.stream().collect(Collectors.toMap(AutoscalingDeciderService::name, Function.identity()));
     }
 
     public static class Holder {
         private final Autoscaling autoscaling;
-        private final SetOnce<AutoscalingDecisionService> servicesSetOnce = new SetOnce<>();
+        private final SetOnce<AutoscalingCalculateCapacityService> servicesSetOnce = new SetOnce<>();
 
         public Holder(Autoscaling autoscaling) {
             this.autoscaling = autoscaling;
         }
 
-        public AutoscalingDecisionService get() {
+        public AutoscalingCalculateCapacityService get() {
             // defer constructing services until transport action creation time.
-            AutoscalingDecisionService autoscalingDecisionService = servicesSetOnce.get();
-            if (autoscalingDecisionService == null) {
-                autoscalingDecisionService = new AutoscalingDecisionService(autoscaling.createDeciderServices());
-                servicesSetOnce.set(autoscalingDecisionService);
+            AutoscalingCalculateCapacityService autoscalingCalculateCapacityService = servicesSetOnce.get();
+            if (autoscalingCalculateCapacityService == null) {
+                autoscalingCalculateCapacityService = new AutoscalingCalculateCapacityService(autoscaling.createDeciderServices());
+                servicesSetOnce.set(autoscalingCalculateCapacityService);
             }
 
-            return autoscalingDecisionService;
+            return autoscalingCalculateCapacityService;
         }
     }
 
-    public SortedMap<String, AutoscalingDecisions> decide(ClusterState state, ClusterInfo clusterInfo) {
+    public SortedMap<String, AutoscalingDeciderResults> calculate(ClusterState state, ClusterInfo clusterInfo) {
 
         AutoscalingMetadata autoscalingMetadata = state.metadata().custom(AutoscalingMetadata.NAME);
         if (autoscalingMetadata != null) {
@@ -64,7 +64,7 @@ public class AutoscalingDecisionService {
                 autoscalingMetadata.policies()
                     .entrySet()
                     .stream()
-                    .map(e -> Tuple.tuple(e.getKey(), getDecision(e.getValue().policy(), state, clusterInfo)))
+                    .map(e -> Tuple.tuple(e.getKey(), calculateForPolicy(e.getValue().policy(), state, clusterInfo)))
                     .collect(Collectors.toMap(Tuple::v1, Tuple::v2))
             );
         } else {
@@ -72,24 +72,27 @@ public class AutoscalingDecisionService {
         }
     }
 
-    private AutoscalingDecisions getDecision(AutoscalingPolicy policy, ClusterState state, ClusterInfo clusterInfo) {
-        DecisionAutoscalingDeciderContext context = new DecisionAutoscalingDeciderContext(policy.name(), state, clusterInfo);
-        SortedMap<String, AutoscalingDecision> decisions = policy.deciders()
+    private AutoscalingDeciderResults calculateForPolicy(AutoscalingPolicy policy, ClusterState state, ClusterInfo clusterInfo) {
+        DefaultAutoscalingDeciderContext context = new DefaultAutoscalingDeciderContext(policy.name(), state, clusterInfo);
+        SortedMap<String, AutoscalingDeciderResult> results = policy.deciders()
             .entrySet()
             .stream()
-            .map(entry -> Tuple.tuple(entry.getKey(), getDecision(entry.getValue(), context)))
+            .map(entry -> Tuple.tuple(entry.getKey(), calculateForDecider(entry.getValue(), context)))
             .collect(Collectors.toMap(Tuple::v1, Tuple::v2, (a, b) -> { throw new UnsupportedOperationException(); }, TreeMap::new));
-        return new AutoscalingDecisions(context.tier, context.currentCapacity, decisions);
+        return new AutoscalingDeciderResults(context.currentCapacity, results);
     }
 
-    private <T extends AutoscalingDeciderConfiguration> AutoscalingDecision getDecision(T decider, AutoscalingDeciderContext context) {
+    private <T extends AutoscalingDeciderConfiguration> AutoscalingDeciderResult calculateForDecider(
+        T decider,
+        AutoscalingDeciderContext context
+    ) {
         assert deciderByName.containsKey(decider.name());
         @SuppressWarnings("unchecked")
         AutoscalingDeciderService<T> service = (AutoscalingDeciderService<T>) deciderByName.get(decider.name());
         return service.scale(decider, context);
     }
 
-    static class DecisionAutoscalingDeciderContext implements AutoscalingDeciderContext {
+    static class DefaultAutoscalingDeciderContext implements AutoscalingDeciderContext {
 
         private final String tier;
         private final ClusterState state;
@@ -97,7 +100,7 @@ public class AutoscalingDecisionService {
         private final AutoscalingCapacity currentCapacity;
         private final boolean currentCapacityAccurate;
 
-        DecisionAutoscalingDeciderContext(String tier, ClusterState state, ClusterInfo clusterInfo) {
+        DefaultAutoscalingDeciderContext(String tier, ClusterState state, ClusterInfo clusterInfo) {
             this.tier = tier;
             Objects.requireNonNull(state);
             Objects.requireNonNull(clusterInfo);

+ 23 - 23
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingCapacity.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCapacity.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.io.stream.StreamInput;
@@ -22,7 +22,7 @@ import java.util.Objects;
  */
 public class AutoscalingCapacity implements ToXContent, Writeable {
 
-    private final AutoscalingResources tier;
+    private final AutoscalingResources total;
     private final AutoscalingResources node;
 
     public static class AutoscalingResources implements ToXContent, Writeable {
@@ -139,26 +139,26 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
 
     public static final AutoscalingCapacity ZERO = new AutoscalingCapacity(AutoscalingResources.ZERO, AutoscalingResources.ZERO);
 
-    public AutoscalingCapacity(AutoscalingResources tier, AutoscalingResources node) {
-        assert tier != null : "Cannot provide capacity without specifying tier level capacity";
+    public AutoscalingCapacity(AutoscalingResources total, AutoscalingResources node) {
+        assert total != null : "Cannot provide capacity without specifying tier level capacity";
         assert node == null || node.memory == null
         // implies
-            || tier.memory != null : "Cannot provide node memory without tier memory";
+            || total.memory != null : "Cannot provide node memory without tier memory";
         assert node == null || node.storage == null
         // implies
-            || tier.storage != null : "Cannot provide node storage without tier memory";
+            || total.storage != null : "Cannot provide node storage without tier memory";
 
-        this.tier = tier;
+        this.total = total;
         this.node = node;
     }
 
     public AutoscalingCapacity(StreamInput in) throws IOException {
-        this.tier = new AutoscalingResources(in);
+        this.total = new AutoscalingResources(in);
         this.node = in.readOptionalWriteable(AutoscalingResources::new);
     }
 
     public AutoscalingResources tier() {
-        return tier;
+        return total;
     }
 
     public AutoscalingResources node() {
@@ -167,7 +167,7 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
 
     @Override
     public void writeTo(StreamOutput out) throws IOException {
-        tier.writeTo(out);
+        total.writeTo(out);
         out.writeOptionalWriteable(node);
     }
 
@@ -177,7 +177,7 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
         if (node != null) {
             builder.field("node", node);
         }
-        builder.field("tier", tier);
+        builder.field("total", total);
         builder.endObject();
         return builder;
     }
@@ -188,7 +188,7 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
     }
 
     public static AutoscalingCapacity upperBound(AutoscalingCapacity c1, AutoscalingCapacity c2) {
-        return new AutoscalingCapacity(AutoscalingResources.max(c1.tier, c2.tier), AutoscalingResources.max(c1.node, c2.node));
+        return new AutoscalingCapacity(AutoscalingResources.max(c1.total, c2.total), AutoscalingResources.max(c1.node, c2.node));
     }
 
     @Override
@@ -196,12 +196,12 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
         AutoscalingCapacity capacity = (AutoscalingCapacity) o;
-        return tier.equals(capacity.tier) && Objects.equals(node, capacity.node);
+        return total.equals(capacity.total) && Objects.equals(node, capacity.node);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(tier, node);
+        return Objects.hash(total, node);
     }
 
     @Override
@@ -214,27 +214,27 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
     }
 
     public static class Builder {
-        private AutoscalingResources tier;
+        private AutoscalingResources total;
         private AutoscalingResources node;
 
         public Builder() {}
 
         public Builder capacity(AutoscalingCapacity capacity) {
-            this.tier = capacity.tier;
+            this.total = capacity.total;
             this.node = capacity.node;
             return this;
         }
 
-        public Builder tier(Long storage, Long memory) {
-            return tier(byteSizeValue(storage), byteSizeValue(memory));
+        public Builder total(Long storage, Long memory) {
+            return total(byteSizeValue(storage), byteSizeValue(memory));
         }
 
-        public Builder tier(ByteSizeValue storage, ByteSizeValue memory) {
-            return tier(new AutoscalingResources(storage, memory));
+        public Builder total(ByteSizeValue storage, ByteSizeValue memory) {
+            return total(new AutoscalingResources(storage, memory));
         }
 
-        public Builder tier(AutoscalingResources tier) {
-            this.tier = tier;
+        public Builder total(AutoscalingResources tier) {
+            this.total = tier;
             return this;
         }
 
@@ -252,7 +252,7 @@ public class AutoscalingCapacity implements ToXContent, Writeable {
         }
 
         public AutoscalingCapacity build() {
-            return new AutoscalingCapacity(tier, node);
+            return new AutoscalingCapacity(total, node);
         }
 
         private ByteSizeValue byteSizeValue(Long memory) {

+ 1 - 1
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDeciderConfiguration.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderConfiguration.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.NamedWriteable;
 import org.elasticsearch.common.xcontent.ToXContentObject;

+ 2 - 2
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDeciderContext.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderContext.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.cluster.ClusterState;
 
@@ -13,7 +13,7 @@ public interface AutoscalingDeciderContext {
 
     /**
      * Return current capacity of tier. Can be null if the capacity of some nodes is unavailable. If a decider relies on this value and
-     * gets a null current capacity, it should return a decision with a null requiredCapacity (undecided).
+     * gets a null current capacity, it should return a result with a null requiredCapacity (undecided).
      */
     AutoscalingCapacity currentCapacity();
 }

+ 9 - 9
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecision.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResult.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.NamedWriteable;
 import org.elasticsearch.common.io.stream.StreamInput;
@@ -17,9 +17,9 @@ import java.io.IOException;
 import java.util.Objects;
 
 /**
- * Represents an autoscaling decision from a single decider
+ * Represents an autoscaling result from a single decider
  */
-public class AutoscalingDecision implements ToXContent, Writeable {
+public class AutoscalingDeciderResult implements ToXContent, Writeable {
 
     private final AutoscalingCapacity requiredCapacity;
     private final Reason reason;
@@ -29,16 +29,16 @@ public class AutoscalingDecision implements ToXContent, Writeable {
     }
 
     /**
-     * Create a new decision with required capacity.
-     * @param requiredCapacity required capacity or null if no decision can be made due to insufficient information.
-     * @param reason details/data behind the decision
+     * Create a new result with required capacity.
+     * @param requiredCapacity required capacity or null if no capacity can be calculated due to insufficient information.
+     * @param reason details/data behind the calculation
      */
-    public AutoscalingDecision(AutoscalingCapacity requiredCapacity, Reason reason) {
+    public AutoscalingDeciderResult(AutoscalingCapacity requiredCapacity, Reason reason) {
         this.requiredCapacity = requiredCapacity;
         this.reason = reason;
     }
 
-    public AutoscalingDecision(StreamInput in) throws IOException {
+    public AutoscalingDeciderResult(StreamInput in) throws IOException {
         this.requiredCapacity = in.readOptionalWriteable(AutoscalingCapacity::new);
         this.reason = in.readOptionalNamedWriteable(Reason.class);
     }
@@ -75,7 +75,7 @@ public class AutoscalingDecision implements ToXContent, Writeable {
     public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
-        AutoscalingDecision that = (AutoscalingDecision) o;
+        AutoscalingDeciderResult that = (AutoscalingDeciderResult) o;
         return Objects.equals(requiredCapacity, that.requiredCapacity) && Objects.equals(reason, that.reason);
     }
 

+ 27 - 41
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisions.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResults.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
@@ -20,79 +20,69 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 /**
- * Represents a collection of individual autoscaling decisions that can be aggregated into a single autoscaling decision for a tier
+ * Represents a collection of individual autoscaling decider results that can be aggregated into a single autoscaling capacity for a
+ * policy
  */
-public class AutoscalingDecisions implements ToXContent, Writeable {
+public class AutoscalingDeciderResults implements ToXContent, Writeable {
 
-    private final String tier;
     private final AutoscalingCapacity currentCapacity;
-    private final SortedMap<String, AutoscalingDecision> decisions;
+    private final SortedMap<String, AutoscalingDeciderResult> results;
 
     /**
-     * Return map of decisions, keyed by decider name.
+     * Return map of results, keyed by decider name.
      */
-    public Map<String, AutoscalingDecision> decisions() {
-        return decisions;
+    public Map<String, AutoscalingDeciderResult> results() {
+        return results;
     }
 
-    public AutoscalingDecisions(
-        final String tier,
-        final AutoscalingCapacity currentCapacity,
-        final SortedMap<String, AutoscalingDecision> decisions
-    ) {
-        Objects.requireNonNull(tier);
+    public AutoscalingDeciderResults(final AutoscalingCapacity currentCapacity, final SortedMap<String, AutoscalingDeciderResult> results) {
         Objects.requireNonNull(currentCapacity);
-        this.tier = tier;
         this.currentCapacity = currentCapacity;
-        Objects.requireNonNull(decisions);
-        if (decisions.isEmpty()) {
-            throw new IllegalArgumentException("decisions can not be empty");
+        Objects.requireNonNull(results);
+        if (results.isEmpty()) {
+            throw new IllegalArgumentException("results can not be empty");
         }
-        this.decisions = decisions;
+        this.results = results;
     }
 
-    public AutoscalingDecisions(final StreamInput in) throws IOException {
-        this.tier = in.readString();
+    public AutoscalingDeciderResults(final StreamInput in) throws IOException {
         this.currentCapacity = new AutoscalingCapacity(in);
-        this.decisions = new TreeMap<>(in.readMap(StreamInput::readString, AutoscalingDecision::new));
+        this.results = new TreeMap<>(in.readMap(StreamInput::readString, AutoscalingDeciderResult::new));
     }
 
     @Override
     public void writeTo(final StreamOutput out) throws IOException {
-        out.writeString(tier);
         currentCapacity.writeTo(out);
-        out.writeMap(decisions, StreamOutput::writeString, (output, decision) -> decision.writeTo(output));
+        out.writeMap(results, StreamOutput::writeString, (output, result) -> result.writeTo(output));
     }
 
     @Override
     public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
         builder.startObject();
-        builder.field("tier", tier);
         AutoscalingCapacity requiredCapacity = requiredCapacity();
         if (requiredCapacity != null) {
             builder.field("required_capacity", requiredCapacity);
         }
         builder.field("current_capacity", currentCapacity);
-        builder.startArray("decisions");
-        for (Map.Entry<String, AutoscalingDecision> entry : decisions.entrySet()) {
-            builder.startObject();
-            builder.field("name", entry.getKey());
+        builder.startObject("deciders");
+        for (Map.Entry<String, AutoscalingDeciderResult> entry : results.entrySet()) {
+            builder.startObject(entry.getKey());
             entry.getValue().toXContent(builder, params);
             builder.endObject();
         }
-        builder.endArray();
+        builder.endObject();
         builder.endObject();
         return builder;
     }
 
     public AutoscalingCapacity requiredCapacity() {
-        if (decisions.values().stream().map(AutoscalingDecision::requiredCapacity).anyMatch(Objects::isNull)) {
-            // any undetermined decider cancels out any decision making.
+        if (results.values().stream().map(AutoscalingDeciderResult::requiredCapacity).anyMatch(Objects::isNull)) {
+            // any undetermined decider cancels out all required capacities
             return null;
         }
-        Optional<AutoscalingCapacity> result = decisions.values()
+        Optional<AutoscalingCapacity> result = results.values()
             .stream()
-            .map(AutoscalingDecision::requiredCapacity)
+            .map(AutoscalingDeciderResult::requiredCapacity)
             .reduce(AutoscalingCapacity::upperBound);
         assert result.isPresent();
         return result.get();
@@ -102,20 +92,16 @@ public class AutoscalingDecisions implements ToXContent, Writeable {
         return currentCapacity;
     }
 
-    public String tier() {
-        return tier;
-    }
-
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
-        AutoscalingDecisions that = (AutoscalingDecisions) o;
-        return tier.equals(that.tier) && currentCapacity.equals(that.currentCapacity) && decisions.equals(that.decisions);
+        AutoscalingDeciderResults that = (AutoscalingDeciderResults) o;
+        return currentCapacity.equals(that.currentCapacity) && results.equals(that.results);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(tier, currentCapacity, decisions);
+        return Objects.hash(currentCapacity, results);
     }
 }

+ 3 - 3
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDeciderService.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderService.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 /**
  * A service to decide for a specific decider.
@@ -22,8 +22,8 @@ public interface AutoscalingDeciderService<D extends AutoscalingDeciderConfigura
      * Whether or not to scale based on the current state.
      *
      * @param context provides access to information about current state
-     * @return the autoscaling decision
+     * @return result from this decider
      */
-    AutoscalingDecision scale(D decider, AutoscalingDeciderContext context);
+    AutoscalingDeciderResult scale(D decider, AutoscalingDeciderContext context);
 
 }

+ 1 - 1
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/FixedAutoscalingDeciderConfiguration.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderConfiguration.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.ParseField;
 import org.elasticsearch.common.io.stream.StreamInput;

+ 5 - 5
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/decision/FixedAutoscalingDeciderService.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderService.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.inject.Inject;
 import org.elasticsearch.common.io.stream.StreamInput;
@@ -26,19 +26,19 @@ public class FixedAutoscalingDeciderService implements AutoscalingDeciderService
     }
 
     @Override
-    public AutoscalingDecision scale(FixedAutoscalingDeciderConfiguration configuration, AutoscalingDeciderContext context) {
+    public AutoscalingDeciderResult scale(FixedAutoscalingDeciderConfiguration configuration, AutoscalingDeciderContext context) {
         int nodes = configuration.nodes() != null ? configuration.nodes() : 1;
         AutoscalingCapacity requiredCapacity;
         if (configuration.storage() != null || configuration.memory() != null) {
             requiredCapacity = AutoscalingCapacity.builder()
-                .tier(tierCapacity(configuration.storage(), nodes), tierCapacity(configuration.memory(), nodes))
+                .total(tierCapacity(configuration.storage(), nodes), tierCapacity(configuration.memory(), nodes))
                 .node(configuration.storage(), configuration.memory())
                 .build();
         } else {
             requiredCapacity = null;
         }
 
-        return new AutoscalingDecision(requiredCapacity, new FixedReason(configuration.storage(), configuration.memory(), nodes));
+        return new AutoscalingDeciderResult(requiredCapacity, new FixedReason(configuration.storage(), configuration.memory(), nodes));
     }
 
     private static ByteSizeValue tierCapacity(ByteSizeValue nodeCapacity, int nodes) {
@@ -49,7 +49,7 @@ public class FixedAutoscalingDeciderService implements AutoscalingDeciderService
         }
     }
 
-    public static class FixedReason implements AutoscalingDecision.Reason {
+    public static class FixedReason implements AutoscalingDeciderResult.Reason {
 
         private final ByteSizeValue storage;
         private final ByteSizeValue memory;

+ 1 - 1
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/policy/AutoscalingPolicy.java

@@ -15,7 +15,7 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
 import org.elasticsearch.common.xcontent.ToXContentObject;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderConfiguration;
 
 import java.io.IOException;
 import java.util.AbstractMap;

+ 6 - 6
x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/rest/RestGetAutoscalingDecisionHandler.java → x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/rest/RestGetAutoscalingCapacityHandler.java

@@ -10,28 +10,28 @@ import org.elasticsearch.client.node.NodeClient;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.autoscaling.action.GetAutoscalingDecisionAction;
+import org.elasticsearch.xpack.autoscaling.action.GetAutoscalingCapacityAction;
 
 import java.util.List;
 
 import static org.elasticsearch.rest.RestRequest.Method.GET;
 
-public class RestGetAutoscalingDecisionHandler extends BaseRestHandler {
+public class RestGetAutoscalingCapacityHandler extends BaseRestHandler {
 
     @Override
     public List<Route> routes() {
-        return List.of(new Route(GET, "/_autoscaling/decision"));
+        return List.of(new Route(GET, "/_autoscaling/capacity"));
     }
 
     @Override
     public String getName() {
-        return "get_autoscaling_decision";
+        return "get_autoscaling_capacity";
     }
 
     @Override
     protected RestChannelConsumer prepareRequest(final RestRequest restRequest, final NodeClient client) {
-        final GetAutoscalingDecisionAction.Request request = new GetAutoscalingDecisionAction.Request();
-        return channel -> client.execute(GetAutoscalingDecisionAction.INSTANCE, request, new RestToXContentListener<>(channel));
+        final GetAutoscalingCapacityAction.Request request = new GetAutoscalingCapacityAction.Request();
+        return channel -> client.execute(GetAutoscalingCapacityAction.INSTANCE, request, new RestToXContentListener<>(channel));
     }
 
 }

+ 14 - 14
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/AutoscalingTestCase.java

@@ -12,12 +12,12 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.ByteSizeValue;
 import org.elasticsearch.common.xcontent.NamedXContentRegistry;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingCapacity;
-import org.elasticsearch.xpack.autoscaling.decision.FixedAutoscalingDeciderConfiguration;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDeciderConfiguration;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecision;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisions;
-import org.elasticsearch.xpack.autoscaling.decision.FixedAutoscalingDeciderService;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingCapacity;
+import org.elasticsearch.xpack.autoscaling.capacity.FixedAutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderConfiguration;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResult;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResults;
+import org.elasticsearch.xpack.autoscaling.capacity.FixedAutoscalingDeciderService;
 import org.elasticsearch.xpack.autoscaling.policy.AutoscalingPolicy;
 import org.elasticsearch.xpack.autoscaling.policy.AutoscalingPolicyMetadata;
 
@@ -31,24 +31,24 @@ import java.util.stream.IntStream;
 
 public abstract class AutoscalingTestCase extends ESTestCase {
 
-    public static AutoscalingDecision randomAutoscalingDecision() {
+    public static AutoscalingDeciderResult randomAutoscalingDeciderResult() {
         AutoscalingCapacity capacity = randomNullableAutoscalingCapacity();
-        return randomAutoscalingDecisionWithCapacity(capacity);
+        return randomAutoscalingDeciderResultWithCapacity(capacity);
     }
 
-    protected static AutoscalingDecision randomAutoscalingDecisionWithCapacity(AutoscalingCapacity capacity) {
-        return new AutoscalingDecision(
+    protected static AutoscalingDeciderResult randomAutoscalingDeciderResultWithCapacity(AutoscalingCapacity capacity) {
+        return new AutoscalingDeciderResult(
             capacity,
             new FixedAutoscalingDeciderService.FixedReason(randomNullableByteSizeValue(), randomNullableByteSizeValue(), randomInt(1000))
         );
     }
 
-    public static AutoscalingDecisions randomAutoscalingDecisions() {
-        final SortedMap<String, AutoscalingDecision> decisions = IntStream.range(0, randomIntBetween(1, 10))
-            .mapToObj(i -> Tuple.tuple(Integer.toString(i), randomAutoscalingDecision()))
+    public static AutoscalingDeciderResults randomAutoscalingDeciderResults() {
+        final SortedMap<String, AutoscalingDeciderResult> results = IntStream.range(0, randomIntBetween(1, 10))
+            .mapToObj(i -> Tuple.tuple(Integer.toString(i), randomAutoscalingDeciderResult()))
             .collect(Collectors.toMap(Tuple::v1, Tuple::v2, (a, b) -> { throw new IllegalStateException(); }, TreeMap::new));
         AutoscalingCapacity capacity = new AutoscalingCapacity(randomAutoscalingResources(), randomAutoscalingResources());
-        return new AutoscalingDecisions(randomAlphaOfLength(10), capacity, decisions);
+        return new AutoscalingDeciderResults(capacity, results);
     }
 
     public static AutoscalingCapacity randomAutoscalingCapacity() {

+ 6 - 6
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionRequestWireSerializingTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionRequestWireSerializingTests.java

@@ -9,17 +9,17 @@ package org.elasticsearch.xpack.autoscaling.action;
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.test.AbstractWireSerializingTestCase;
 
-public class GetAutoscalingDecisionActionRequestWireSerializingTests extends AbstractWireSerializingTestCase<
-    GetAutoscalingDecisionAction.Request> {
+public class GetAutoscalingCapacityActionRequestWireSerializingTests extends AbstractWireSerializingTestCase<
+    GetAutoscalingCapacityAction.Request> {
 
     @Override
-    protected Writeable.Reader<GetAutoscalingDecisionAction.Request> instanceReader() {
-        return GetAutoscalingDecisionAction.Request::new;
+    protected Writeable.Reader<GetAutoscalingCapacityAction.Request> instanceReader() {
+        return GetAutoscalingCapacityAction.Request::new;
     }
 
     @Override
-    protected GetAutoscalingDecisionAction.Request createTestInstance() {
-        return new GetAutoscalingDecisionAction.Request();
+    protected GetAutoscalingCapacityAction.Request createTestInstance() {
+        return new GetAutoscalingCapacityAction.Request();
     }
 
 }

+ 9 - 9
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionResponseTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionResponseTests.java

@@ -11,7 +11,7 @@ import org.elasticsearch.common.collect.Tuple;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisions;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResults;
 import org.hamcrest.Matchers;
 
 import java.io.IOException;
@@ -22,18 +22,18 @@ import java.util.TreeMap;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
-public class GetAutoscalingDecisionActionResponseTests extends AutoscalingTestCase {
+public class GetAutoscalingCapacityActionResponseTests extends AutoscalingTestCase {
 
     public void testToXContent() throws IOException {
         Set<String> policyNames = IntStream.range(0, randomIntBetween(1, 10))
             .mapToObj(i -> randomAlphaOfLength(10))
             .collect(Collectors.toSet());
 
-        SortedMap<String, AutoscalingDecisions> decisions = new TreeMap<>(
-            policyNames.stream().map(s -> Tuple.tuple(s, randomAutoscalingDecisions())).collect(Collectors.toMap(Tuple::v1, Tuple::v2))
+        SortedMap<String, AutoscalingDeciderResults> results = new TreeMap<>(
+            policyNames.stream().map(s -> Tuple.tuple(s, randomAutoscalingDeciderResults())).collect(Collectors.toMap(Tuple::v1, Tuple::v2))
         );
 
-        GetAutoscalingDecisionAction.Response response = new GetAutoscalingDecisionAction.Response(decisions);
+        GetAutoscalingCapacityAction.Response response = new GetAutoscalingCapacityAction.Response(results);
         XContentType xContentType = randomFrom(XContentType.values());
 
         XContentBuilder builder = XContentBuilder.builder(xContentType.xContent());
@@ -42,11 +42,11 @@ public class GetAutoscalingDecisionActionResponseTests extends AutoscalingTestCa
 
         XContentBuilder expected = XContentBuilder.builder(xContentType.xContent());
         expected.startObject();
-        expected.startArray("decisions");
-        for (Map.Entry<String, AutoscalingDecisions> entry : decisions.entrySet()) {
-            entry.getValue().toXContent(expected, null);
+        expected.startObject("policies");
+        for (Map.Entry<String, AutoscalingDeciderResults> entry : results.entrySet()) {
+            expected.field(entry.getKey(), entry.getValue());
         }
-        expected.endArray();
+        expected.endObject();
         expected.endObject();
         BytesReference expectedBytes = BytesReference.bytes(expected);
         assertThat(responseBytes, Matchers.equalTo(expectedBytes));

+ 10 - 10
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingDecisionActionResponseWireSerializingTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/action/GetAutoscalingCapacityActionResponseWireSerializingTests.java

@@ -10,16 +10,16 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.test.AbstractWireSerializingTestCase;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
-import org.elasticsearch.xpack.autoscaling.decision.AutoscalingDecisions;
+import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderResults;
 
 import java.util.Collections;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingDecisions;
+import static org.elasticsearch.xpack.autoscaling.AutoscalingTestCase.randomAutoscalingDeciderResults;
 
-public class GetAutoscalingDecisionActionResponseWireSerializingTests extends AbstractWireSerializingTestCase<
-    GetAutoscalingDecisionAction.Response> {
+public class GetAutoscalingCapacityActionResponseWireSerializingTests extends AbstractWireSerializingTestCase<
+    GetAutoscalingCapacityAction.Response> {
 
     @Override
     protected NamedWriteableRegistry getNamedWriteableRegistry() {
@@ -27,18 +27,18 @@ public class GetAutoscalingDecisionActionResponseWireSerializingTests extends Ab
     }
 
     @Override
-    protected Writeable.Reader<GetAutoscalingDecisionAction.Response> instanceReader() {
-        return GetAutoscalingDecisionAction.Response::new;
+    protected Writeable.Reader<GetAutoscalingCapacityAction.Response> instanceReader() {
+        return GetAutoscalingCapacityAction.Response::new;
     }
 
     @Override
-    protected GetAutoscalingDecisionAction.Response createTestInstance() {
+    protected GetAutoscalingCapacityAction.Response createTestInstance() {
         final int numberOfPolicies = randomIntBetween(1, 8);
-        final SortedMap<String, AutoscalingDecisions> decisions = new TreeMap<>();
+        final SortedMap<String, AutoscalingDeciderResults> results = new TreeMap<>();
         for (int i = 0; i < numberOfPolicies; i++) {
-            decisions.put(randomAlphaOfLength(8), randomAutoscalingDecisions());
+            results.put(randomAlphaOfLength(8), randomAutoscalingDeciderResults());
         }
-        return new GetAutoscalingDecisionAction.Response(Collections.unmodifiableSortedMap(decisions));
+        return new GetAutoscalingCapacityAction.Response(Collections.unmodifiableSortedMap(results));
     }
 
 }

+ 3 - 3
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingCapacityWireSerializationTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCapacityWireSerializationTests.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.common.unit.ByteSizeValue;
@@ -32,7 +32,7 @@ public class AutoscalingCapacityWireSerializationTests extends AbstractWireSeria
             // mutate tier
             boolean hasBothStorageAndMemory = instance.tier().memory() != null && instance.tier().storage() != null;
             if (randomBoolean()) {
-                builder.tier(
+                builder.total(
                     randomByteSize(
                         hasBothStorageAndMemory && (instance.node() == null || instance.node().storage() == null),
                         instance.tier().storage()
@@ -40,7 +40,7 @@ public class AutoscalingCapacityWireSerializationTests extends AbstractWireSeria
                     instance.tier().memory()
                 );
             } else {
-                builder.tier(
+                builder.total(
                     instance.tier().storage(),
                     randomByteSize(
                         hasBothStorageAndMemory && (instance.node() == null || instance.node().memory() == null),

+ 23 - 24
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisionServiceTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultServiceTests.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.Version;
 import org.elasticsearch.cluster.ClusterInfo;
@@ -31,9 +31,9 @@ import java.util.stream.IntStream;
 
 import static org.hamcrest.Matchers.equalTo;
 
-public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
-    public void testMultiplePoliciesFixedDecision() {
-        AutoscalingDecisionService service = new AutoscalingDecisionService(Set.of(new FixedAutoscalingDeciderService()));
+public class AutoscalingDeciderResultServiceTests extends AutoscalingTestCase {
+    public void testMultiplePoliciesFixedCapacity() {
+        AutoscalingCalculateCapacityService service = new AutoscalingCalculateCapacityService(Set.of(new FixedAutoscalingDeciderService()));
         Set<String> policyNames = IntStream.range(0, randomIntBetween(1, 10))
             .mapToObj(i -> "test_ " + randomAlphaOfLength(10))
             .collect(Collectors.toSet());
@@ -46,32 +46,31 @@ public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
         ClusterState state = ClusterState.builder(ClusterName.DEFAULT)
             .metadata(Metadata.builder().putCustom(AutoscalingMetadata.NAME, new AutoscalingMetadata(policies)))
             .build();
-        SortedMap<String, AutoscalingDecisions> decisions = service.decide(state, new ClusterInfo() {
+        SortedMap<String, AutoscalingDeciderResults> resultsMap = service.calculate(state, new ClusterInfo() {
         });
-        assertThat(decisions.keySet(), equalTo(policyNames));
-        for (Map.Entry<String, AutoscalingDecisions> entry : decisions.entrySet()) {
-            AutoscalingDecisions decision = entry.getValue();
-            assertThat(decision.tier(), equalTo(entry.getKey()));
-            SortedMap<String, AutoscalingDeciderConfiguration> deciders = policies.get(decision.tier()).policy().deciders();
+        assertThat(resultsMap.keySet(), equalTo(policyNames));
+        for (Map.Entry<String, AutoscalingDeciderResults> entry : resultsMap.entrySet()) {
+            AutoscalingDeciderResults results = entry.getValue();
+            SortedMap<String, AutoscalingDeciderConfiguration> deciders = policies.get(entry.getKey()).policy().deciders();
             assertThat(deciders.size(), equalTo(1));
             FixedAutoscalingDeciderConfiguration configuration = (FixedAutoscalingDeciderConfiguration) deciders.values().iterator().next();
-            AutoscalingCapacity requiredCapacity = calculateFixedDecisionCapacity(configuration);
-            assertThat(decision.requiredCapacity(), equalTo(requiredCapacity));
-            assertThat(decision.decisions().size(), equalTo(1));
-            AutoscalingDecision deciderDecision = decision.decisions().get(deciders.firstKey());
-            assertNotNull(deciderDecision);
-            assertThat(deciderDecision.requiredCapacity(), equalTo(requiredCapacity));
+            AutoscalingCapacity requiredCapacity = calculateFixedDeciderCapacity(configuration);
+            assertThat(results.requiredCapacity(), equalTo(requiredCapacity));
+            assertThat(results.results().size(), equalTo(1));
+            AutoscalingDeciderResult deciderResult = results.results().get(deciders.firstKey());
+            assertNotNull(deciderResult);
+            assertThat(deciderResult.requiredCapacity(), equalTo(requiredCapacity));
             ByteSizeValue storage = configuration.storage();
             ByteSizeValue memory = configuration.memory();
             int nodes = configuration.nodes();
-            assertThat(deciderDecision.reason(), equalTo(new FixedAutoscalingDeciderService.FixedReason(storage, memory, nodes)));
+            assertThat(deciderResult.reason(), equalTo(new FixedAutoscalingDeciderService.FixedReason(storage, memory, nodes)));
             assertThat(
-                deciderDecision.reason().summary(),
+                deciderResult.reason().summary(),
                 equalTo("fixed storage [" + storage + "] memory [" + memory + "] nodes [" + nodes + "]")
             );
 
             // there is no nodes in any tier.
-            assertThat(decision.currentCapacity(), equalTo(AutoscalingCapacity.ZERO));
+            assertThat(results.currentCapacity(), equalTo(AutoscalingCapacity.ZERO));
         }
     }
 
@@ -88,7 +87,7 @@ public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
         );
     }
 
-    private AutoscalingCapacity calculateFixedDecisionCapacity(FixedAutoscalingDeciderConfiguration configuration) {
+    private AutoscalingCapacity calculateFixedDeciderCapacity(FixedAutoscalingDeciderConfiguration configuration) {
         ByteSizeValue totalStorage = configuration.storage() != null
             ? new ByteSizeValue(configuration.storage().getBytes() * configuration.nodes())
             : null;
@@ -110,8 +109,8 @@ public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
         String tier = randomAlphaOfLength(5);
         ClusterState state = ClusterState.builder(ClusterName.DEFAULT).build();
         ClusterInfo info = ClusterInfo.EMPTY;
-        AutoscalingDecisionService.DecisionAutoscalingDeciderContext context =
-            new AutoscalingDecisionService.DecisionAutoscalingDeciderContext(tier, state, info);
+        AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext context =
+            new AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext(tier, state, info);
 
         assertSame(state, context.state());
         // there is no nodes in any tier.
@@ -121,7 +120,7 @@ public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
         state = ClusterState.builder(ClusterName.DEFAULT)
             .nodes(DiscoveryNodes.builder().add(new DiscoveryNode("nodeId", buildNewFakeTransportAddress(), Version.CURRENT)))
             .build();
-        context = new AutoscalingDecisionService.DecisionAutoscalingDeciderContext(tier, state, info);
+        context = new AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext(tier, state, info);
 
         assertNull(context.currentCapacity());
 
@@ -144,7 +143,7 @@ public class AutoscalingDecisionServiceTests extends AutoscalingTestCase {
         }
         state = ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build();
         info = new ClusterInfo(leastUsages.build(), mostUsages.build(), null, null, null);
-        context = new AutoscalingDecisionService.DecisionAutoscalingDeciderContext(tier, state, info);
+        context = new AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext(tier, state, info);
 
         AutoscalingCapacity capacity = context.currentCapacity();
         assertThat(capacity.node().storage(), equalTo(new ByteSizeValue(maxTotal)));

+ 6 - 6
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisionsWireSerializingTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultWireSerializingTests.java

@@ -4,14 +4,14 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.test.AbstractWireSerializingTestCase;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
 
-public class AutoscalingDecisionsWireSerializingTests extends AbstractWireSerializingTestCase<AutoscalingDecisions> {
+public class AutoscalingDeciderResultWireSerializingTests extends AbstractWireSerializingTestCase<AutoscalingDeciderResult> {
 
     @Override
     protected NamedWriteableRegistry getNamedWriteableRegistry() {
@@ -19,13 +19,13 @@ public class AutoscalingDecisionsWireSerializingTests extends AbstractWireSerial
     }
 
     @Override
-    protected Writeable.Reader<AutoscalingDecisions> instanceReader() {
-        return AutoscalingDecisions::new;
+    protected Writeable.Reader<AutoscalingDeciderResult> instanceReader() {
+        return AutoscalingDeciderResult::new;
     }
 
     @Override
-    protected AutoscalingDecisions createTestInstance() {
-        return AutoscalingTestCase.randomAutoscalingDecisions();
+    protected AutoscalingDeciderResult createTestInstance() {
+        return AutoscalingTestCase.randomAutoscalingDeciderResult();
     }
 
 }

+ 11 - 15
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisionsTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultsTests.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.Randomness;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
@@ -21,24 +21,23 @@ import java.util.stream.IntStream;
 
 import static org.hamcrest.Matchers.equalTo;
 
-public class AutoscalingDecisionsTests extends AutoscalingTestCase {
+public class AutoscalingDeciderResultsTests extends AutoscalingTestCase {
 
-    public void testAutoscalingDecisionsRejectsEmptyDecisions() {
+    public void testAutoscalingDeciderResultsRejectsEmptyResults() {
         final IllegalArgumentException e = expectThrows(
             IllegalArgumentException.class,
-            () -> new AutoscalingDecisions(
-                randomAlphaOfLength(10),
+            () -> new AutoscalingDeciderResults(
                 new AutoscalingCapacity(randomAutoscalingResources(), randomAutoscalingResources()),
                 new TreeMap<>()
             )
         );
-        assertThat(e.getMessage(), equalTo("decisions can not be empty"));
+        assertThat(e.getMessage(), equalTo("results can not be empty"));
     }
 
     public void testRequiredCapacity() {
         AutoscalingCapacity single = randomBoolean() ? randomAutoscalingCapacity() : null;
         verifyRequiredCapacity(single, single);
-        // any undecided decider nulls out any decision making
+        // any undecided decider nulls out any required capacities
         verifyRequiredCapacity(null, single, null);
         verifyRequiredCapacity(null, null, single);
 
@@ -73,7 +72,7 @@ public class AutoscalingDecisionsTests extends AutoscalingTestCase {
         autoscalingCapacities.add(larger);
         Randomness.shuffle(autoscalingCapacities);
         AutoscalingCapacity.Builder expectedBuilder = AutoscalingCapacity.builder()
-            .tier(expectedStorage.tier().storage(), expectedMemory.tier().memory());
+            .total(expectedStorage.tier().storage(), expectedMemory.tier().memory());
         if (node) {
             expectedBuilder.node(expectedStorage.node().storage(), expectedMemory.node().memory());
         }
@@ -82,8 +81,8 @@ public class AutoscalingDecisionsTests extends AutoscalingTestCase {
 
     private void verifyRequiredCapacity(AutoscalingCapacity expected, AutoscalingCapacity... capacities) {
         AtomicInteger uniqueGenerator = new AtomicInteger();
-        SortedMap<String, AutoscalingDecision> decisions = Arrays.stream(capacities)
-            .map(AutoscalingDecisionsTests::randomAutoscalingDecisionWithCapacity)
+        SortedMap<String, AutoscalingDeciderResult> results = Arrays.stream(capacities)
+            .map(AutoscalingDeciderResultsTests::randomAutoscalingDeciderResultWithCapacity)
             .collect(
                 Collectors.toMap(
                     k -> randomAlphaOfLength(10) + "-" + uniqueGenerator.incrementAndGet(),
@@ -92,15 +91,12 @@ public class AutoscalingDecisionsTests extends AutoscalingTestCase {
                     TreeMap::new
                 )
             );
-        assertThat(
-            new AutoscalingDecisions(randomAlphaOfLength(10), randomAutoscalingCapacity(), decisions).requiredCapacity(),
-            equalTo(expected)
-        );
+        assertThat(new AutoscalingDeciderResults(randomAutoscalingCapacity(), results).requiredCapacity(), equalTo(expected));
     }
 
     private AutoscalingCapacity randomCapacity(boolean node, boolean storage, boolean memory, int lower, int upper) {
         AutoscalingCapacity.Builder builder = AutoscalingCapacity.builder();
-        builder.tier(storage ? randomLongBetween(lower, upper) : null, memory ? randomLongBetween(lower, upper) : null);
+        builder.total(storage ? randomLongBetween(lower, upper) : null, memory ? randomLongBetween(lower, upper) : null);
         if (node) {
             builder.node(storage ? randomLongBetween(lower, upper) : null, memory ? randomLongBetween(lower, upper) : null);
         }

+ 6 - 6
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/AutoscalingDecisionWireSerializingTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingDeciderResultsWireSerializingTests.java

@@ -4,14 +4,14 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.test.AbstractWireSerializingTestCase;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
 
-public class AutoscalingDecisionWireSerializingTests extends AbstractWireSerializingTestCase<AutoscalingDecision> {
+public class AutoscalingDeciderResultsWireSerializingTests extends AbstractWireSerializingTestCase<AutoscalingDeciderResults> {
 
     @Override
     protected NamedWriteableRegistry getNamedWriteableRegistry() {
@@ -19,13 +19,13 @@ public class AutoscalingDecisionWireSerializingTests extends AbstractWireSeriali
     }
 
     @Override
-    protected Writeable.Reader<AutoscalingDecision> instanceReader() {
-        return AutoscalingDecision::new;
+    protected Writeable.Reader<AutoscalingDeciderResults> instanceReader() {
+        return AutoscalingDeciderResults::new;
     }
 
     @Override
-    protected AutoscalingDecision createTestInstance() {
-        return AutoscalingTestCase.randomAutoscalingDecision();
+    protected AutoscalingDeciderResults createTestInstance() {
+        return AutoscalingTestCase.randomAutoscalingDeciderResults();
     }
 
 }

+ 1 - 1
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/FixedAutoscalingDeciderConfigurationSerializationTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderConfigurationSerializationTests.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.common.unit.ByteSizeValue;

+ 5 - 5
x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/decision/FixedAutoscalingDeciderServiceTests.java → x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/FixedAutoscalingDeciderServiceTests.java

@@ -4,7 +4,7 @@
  * you may not use this file except in compliance with the Elastic License.
  */
 
-package org.elasticsearch.xpack.autoscaling.decision;
+package org.elasticsearch.xpack.autoscaling.capacity;
 
 import org.elasticsearch.common.unit.ByteSizeValue;
 import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase;
@@ -23,20 +23,20 @@ public class FixedAutoscalingDeciderServiceTests extends AutoscalingTestCase {
         ByteSizeValue memory = storage != null ? randomNullableByteSizeValue() : randomByteSizeValue();
         verify(
             new FixedAutoscalingDeciderConfiguration(storage, memory, null),
-            AutoscalingCapacity.builder().node(storage, memory).tier(storage, memory).build()
+            AutoscalingCapacity.builder().node(storage, memory).total(storage, memory).build()
         );
 
         int nodes = randomIntBetween(1, 1000);
         verify(
             new FixedAutoscalingDeciderConfiguration(storage, memory, nodes),
-            AutoscalingCapacity.builder().node(storage, memory).tier(multiply(storage, nodes), multiply(memory, nodes)).build()
+            AutoscalingCapacity.builder().node(storage, memory).total(multiply(storage, nodes), multiply(memory, nodes)).build()
         );
     }
 
     private void verify(FixedAutoscalingDeciderConfiguration configuration, AutoscalingCapacity expected) {
         FixedAutoscalingDeciderService service = new FixedAutoscalingDeciderService();
-        AutoscalingDecision decision = service.scale(configuration, null);
-        assertThat(decision.requiredCapacity(), Matchers.equalTo(expected));
+        AutoscalingDeciderResult result = service.scale(configuration, null);
+        assertThat(result.requiredCapacity(), Matchers.equalTo(expected));
     }
 
     private ByteSizeValue multiply(ByteSizeValue bytes, int nodes) {

+ 19 - 0
x-pack/plugin/src/test/resources/rest-api-spec/api/autoscaling.get_autoscaling_capacity.json

@@ -0,0 +1,19 @@
+{
+  "autoscaling.get_autoscaling_capacity":{
+    "documentation":{
+      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-capacity.html",
+      "description": "Gets the current autoscaling capacity based on the configured autoscaling policy."
+    },
+    "stability":"experimental",
+    "url":{
+      "paths":[
+        {
+          "path":"/_autoscaling/capacity",
+          "methods":[
+            "GET"
+          ]
+        }
+      ]
+    }
+  }
+}

+ 0 - 19
x-pack/plugin/src/test/resources/rest-api-spec/api/autoscaling.get_autoscaling_decision.json

@@ -1,19 +0,0 @@
-{
-  "autoscaling.get_autoscaling_decision":{
-    "documentation":{
-      "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-decision.html",
-      "description": "Gets the current autoscaling decision based on the configured autoscaling policy, indicating whether or not autoscaling is needed."
-    },
-    "stability":"experimental",
-    "url":{
-      "paths":[
-        {
-          "path":"/_autoscaling/decision",
-          "methods":[
-            "GET"
-          ]
-        }
-      ]
-    }
-  }
-}