diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2019-08-14 14:30:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-14 14:30:37 +0200 |
commit | 0a4669d973810e02fd7a6be10b5a1ee03142d5b4 (patch) | |
tree | 99c1b799c3d1d91844f32bfe7068b0cd3f8ec073 | |
parent | 4135bb0abbbe1eb6cf2e3607ca457a57d8c77d12 (diff) | |
parent | 60c06435def8dc357813ffea0d68e225774d43c3 (diff) |
Merge pull request #10272 from vespa-engine/freva/aws-limits
Add AwsLimitsFetcher interface
2 files changed, 63 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsLimitsFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsLimitsFetcher.java new file mode 100644 index 00000000000..4e76f67e7cf --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsLimitsFetcher.java @@ -0,0 +1,14 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.aws; + +/** + * @author freva + */ +public interface AwsLimitsFetcher { + + /** Returns the AWS EC2 instance limits in the given AWS region */ + Ec2InstanceCounts getEc2InstanceLimits(String awsRegion); + + /** Returns the current usage of AWS EC2 instances in the given AWS region */ + Ec2InstanceCounts getEc2InstanceUsage(String awsRegion); +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/Ec2InstanceCounts.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/Ec2InstanceCounts.java new file mode 100644 index 00000000000..d5e65cfa2bd --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/Ec2InstanceCounts.java @@ -0,0 +1,49 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration.aws; + +import java.util.Map; +import java.util.Objects; + +/** + * @author freva + */ +public class Ec2InstanceCounts { + private final int totalCount; + private final Map<String, Integer> instanceCounts; + + private Ec2InstanceCounts(int totalCount, Map<String, Integer> instanceCounts) { + this.totalCount = totalCount; + this.instanceCounts = Map.copyOf(instanceCounts); + } + + public int getTotalCount() { + return totalCount; + } + + /** Returns map of counts by instance type, e.g. 'r5.2xlarge' */ + public Map<String, Integer> getInstanceCounts() { + return instanceCounts; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Ec2InstanceCounts that = (Ec2InstanceCounts) o; + return totalCount == that.totalCount && + instanceCounts.equals(that.instanceCounts); + } + + @Override + public int hashCode() { + return Objects.hash(totalCount, instanceCounts); + } + + @Override + public String toString() { + return "Ec2InstanceLimits{" + + "totalLimit=" + totalCount + + ", instanceCounts=" + instanceCounts + + '}'; + } +} |