diff options
author | Valerij Fredriksen <valerij92@gmail.com> | 2021-05-31 12:58:39 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerij92@gmail.com> | 2021-05-31 15:52:41 +0200 |
commit | cfeaa14b4d036146dada3388cd8cad825fd08caf (patch) | |
tree | cb10dddeb277281c6c4c652e5e7b7b014863392f /controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java | |
parent | 0a84d8be46ade948a40a57be59590c3655130314 (diff) |
Remove redundant filter: all public zones are in AWS
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java index b40f2232504..d9cd7941a87 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java @@ -20,6 +20,7 @@ import java.time.Duration; import java.time.Instant; import java.util.Collection; import java.util.Collections; +import java.util.EnumSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeoutException; @@ -33,8 +34,16 @@ import java.util.stream.Collectors; */ public class ResourceMeterMaintainer extends ControllerMaintainer { - private final Clock clock; - private final Metric metric; + /** + * Checks if the node is in some state where it is in active use by the tenant, + * and not transitioning out of use, in a failed state, etc. + */ + private static final Set<Node.State> METERABLE_NODE_STATES = EnumSet.of( + Node.State.reserved, // an application will soon use this node + Node.State.active, // an application is currently using this node + Node.State.inactive // an application is not using it, but it is reserved for being re-introduced or decommissioned + ); + private final NodeRepository nodeRepository; private final MeteringClient meteringClient; private final CuratorDb curator; @@ -89,9 +98,8 @@ public class ResourceMeterMaintainer extends ControllerMaintainer { } } - private Collection<ResourceSnapshot> getAllResourceSnapshots() { + private List<ResourceSnapshot> getAllResourceSnapshots() { return controller().zoneRegistry().zones() - .ofCloud(CloudName.from("aws")) .reachable().zones().stream() .map(ZoneApi::getId) .map(zoneId -> createResourceSnapshotsFromNodes(zoneId, nodeRepository.list(zoneId, false))) @@ -120,21 +128,11 @@ public class ResourceMeterMaintainer extends ControllerMaintainer { .orElse(false); } - /** - * Checks if the node is in some state where it is in active use by the tenant, - * and not transitioning out of use, in a failed state, etc. - */ - private static final Set<Node.State> METERABLE_NODE_STATES = Set.of( - Node.State.reserved, // an application will soon use this node - Node.State.active, // an application is currently using this node - Node.State.inactive // an application is not using it, but it is reserved for being re-introduced or decommissioned - ); - private boolean isNodeStateMeterable(Node node) { return METERABLE_NODE_STATES.contains(node.state()); } - private boolean isNodeTypeMeterable(Node node) { + private boolean isClusterTypeMeterable(Node node) { return node.clusterType() != Node.ClusterType.admin; // log servers and shared cluster controllers } |