diff options
author | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-08-14 12:05:31 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-08-14 13:52:48 +0200 |
commit | fbcdfe12aee0ef955bdbb804ad6b38e7efff7acb (patch) | |
tree | ed1ae16a2f31fadf7dbfcc4b875a187093641948 /controller-api | |
parent | 4381c58ec4061fa9eb2faa3b034da8b5cc7f6d59 (diff) |
Add AwsLimitsFetcher interface
Diffstat (limited to 'controller-api')
2 files changed, 65 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..d46ef1cecc4 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/Ec2InstanceCounts.java @@ -0,0 +1,51 @@ +// 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; + +/** + * @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; + } + + 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; + + if (totalCount != that.totalCount) return false; + return instanceCounts.equals(that.instanceCounts); + } + + @Override + public int hashCode() { + int result = totalCount; + result = 31 * result + instanceCounts.hashCode(); + return result; + } + + @Override + public String toString() { + return "Ec2InstanceLimits{" + + "totalLimit=" + totalCount + + ", instanceCounts=" + instanceCounts + + '}'; + } +} |