diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2017-10-24 15:23:17 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2017-10-24 15:23:17 +0200 |
commit | 8c34ea2b1e8b7e255571f12fd5c85942edd4503a (patch) | |
tree | a70f080edeec914f4186b25ca3deaa5bf59826f7 /controller-api/src | |
parent | e5afd0ea72b735adf1d755c35f38e9dabe682b02 (diff) | |
parent | c668472b01ea333135a5c09300f8816d9d774cc2 (diff) |
Resolved ocnflicts
Diffstat (limited to 'controller-api/src')
40 files changed, 77 insertions, 1363 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/ApplicationApi.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/ApplicationApi.java index 4233f6308d5..c938b1cd515 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/ApplicationApi.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/ApplicationApi.java @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.application.v4; -import com.yahoo.vespa.hosted.controller.api.application.v4.model.AthensDomainsResponse; +import com.yahoo.vespa.hosted.controller.api.application.v4.model.AthenzDomainsResponse; import com.yahoo.vespa.hosted.controller.api.application.v4.model.TenantInfo; import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; import com.yahoo.vespa.hosted.controller.api.application.v4.model.TenantPipelinesInfo; @@ -34,7 +34,7 @@ public interface ApplicationApi { @GET @Path("athensDomain") - AthensDomainsResponse listAthensDomains(@DefaultValue("") @QueryParam("prefix") String prefix); + AthenzDomainsResponse listAthensDomains(@DefaultValue("") @QueryParam("prefix") String prefix); @GET @Path("tenant-pipeline") diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/AthensDomainsResponse.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/AthenzDomainsResponse.java index 400b973a4e1..e5a8e0b4a53 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/AthensDomainsResponse.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/AthenzDomainsResponse.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; import java.util.List; @@ -10,8 +10,8 @@ import java.util.List; * @author gv */ @JsonIgnoreProperties(ignoreUnknown = true) -public class AthensDomainsResponse extends JsonResponse<List<AthensDomain>> { - public AthensDomainsResponse(List<AthensDomain> athensDomainList) { +public class AthenzDomainsResponse extends JsonResponse<List<AthenzDomain>> { + public AthenzDomainsResponse(List<AthenzDomain> athensDomainList) { super(athensDomainList); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java index e862bd744dc..391aaa4639e 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/InstanceInformation.java @@ -2,7 +2,6 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.yahoo.vespa.hosted.controller.api.cost.CostJsonModel; import com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch; import com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit; import com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository; @@ -29,6 +28,4 @@ public class InstanceInformation { public GitRepository gitRepository; public GitBranch gitBranch; public GitCommit gitCommit; - - public CostJsonModel.Application cost; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantCreateOptions.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantCreateOptions.java index 4032a960b3c..69658ca4052 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantCreateOptions.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantCreateOptions.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId; import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; @@ -14,7 +14,7 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(value = JsonInclude.Include.NON_NULL) public class TenantCreateOptions { - public AthensDomain athensDomain; + public AthenzDomain athensDomain; public Property property; public PropertyId propertyId; public UserGroup userGroup; @@ -27,7 +27,7 @@ public class TenantCreateOptions { this.propertyId = propertyId; } - public TenantCreateOptions(AthensDomain athensDomain, Property property, PropertyId propertyId) { + public TenantCreateOptions(AthenzDomain athensDomain, Property property, PropertyId propertyId) { this.athensDomain = athensDomain; this.property = property; this.propertyId = propertyId; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMetaData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMetaData.java index 5ded1d8030e..a8544226f39 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMetaData.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMetaData.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; @@ -17,7 +17,7 @@ import java.util.Optional; @JsonInclude(value = Include.NON_EMPTY) public class TenantMetaData { public TenantType type; - public Optional<AthensDomain> athensDomain; + public Optional<AthenzDomain> athensDomain; public Optional<Property> property; public Optional<UserGroup> userGroup; @@ -25,7 +25,7 @@ public class TenantMetaData { public TenantMetaData() {} public TenantMetaData(TenantType type, - Optional<AthensDomain> athensDomain, + Optional<AthenzDomain> athensDomain, Optional<Property> property, Optional<UserGroup> userGroup) { this.type = type; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMigrateOptions.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMigrateOptions.java index 9c748eafd38..7e30ae6c2c2 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMigrateOptions.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantMigrateOptions.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; /** * @author bjorncs @@ -12,11 +12,11 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; @JsonInclude(value = JsonInclude.Include.NON_NULL) public class TenantMigrateOptions { - public AthensDomain athensDomain; + public AthenzDomain athensDomain; public TenantMigrateOptions() {} - public TenantMigrateOptions(AthensDomain athensDomain) { + public TenantMigrateOptions(AthenzDomain athensDomain) { this.athensDomain = athensDomain; } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantUpdateOptions.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantUpdateOptions.java index 9b2f24e2f62..f0d218fa3ad 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantUpdateOptions.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantUpdateOptions.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; @@ -21,12 +21,12 @@ import java.util.Optional; public class TenantUpdateOptions { public final Property property; public final Optional<UserGroup> userGroup; - public final Optional<AthensDomain> athensDomain; + public final Optional<AthenzDomain> athensDomain; @JsonCreator public TenantUpdateOptions(@JsonProperty("property") Property property, @JsonProperty("userGroup") Optional<UserGroup> userGroup, - @JsonProperty("athensDomain") Optional<AthensDomain> athensDomain) { + @JsonProperty("athensDomain") Optional<AthenzDomain> athensDomain) { this.userGroup = userGroup; this.property = property; this.athensDomain = athensDomain; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantWithApplications.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantWithApplications.java index de731d5c971..e34e9e74065 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantWithApplications.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/TenantWithApplications.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.application.v4.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; +import com.yahoo.vespa.hosted.controller.api.identifiers.AthenzDomain; import com.yahoo.vespa.hosted.controller.api.identifiers.Property; import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; @@ -17,7 +17,7 @@ import java.util.List; public class TenantWithApplications { // TODO: use TenantMetaData instead of individual fields (requires dashboard updates) public TenantType type; - public AthensDomain athensDomain; + public AthenzDomain athensDomain; public Property property; public UserGroup userGroup; public List<ApplicationReference> applications; @@ -26,7 +26,7 @@ public class TenantWithApplications { public TenantWithApplications( TenantType type, - AthensDomain athensDomain, + AthenzDomain athensDomain, Property property, UserGroup userGroup, List<ApplicationReference> applications) { diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostJsonModel.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostJsonModel.java deleted file mode 100644 index bfc451946f6..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostJsonModel.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.cost; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -/** - * JSON datamodel for the cost api. - * - * @author smorgrav - */ -public class CostJsonModel { - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Application { - - @JsonProperty - public String zone; - @JsonProperty - public String tenant; - @JsonProperty - public String app; - @JsonProperty - public int tco; - @JsonProperty - public float utilization; - @JsonProperty - public float waste; - @JsonProperty - public Map<String, Cluster> cluster; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class Cluster { - - @JsonProperty - public int count; - @JsonProperty - public String resource; - @JsonProperty - public float utilization; - @JsonProperty - public int tco; - @JsonProperty - public String flavor; - @JsonProperty - public int waste; - @JsonProperty - public String type; - @JsonProperty - public HardwareResources util; - @JsonProperty - public HardwareResources usage; - @JsonProperty - public List<String> hostnames; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class HardwareResources { - - @JsonProperty - public float mem; - @JsonProperty - public float disk; - @JsonProperty - public float cpu; - @JsonProperty("diskbusy") - public float diskBusy; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostResource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostResource.java deleted file mode 100644 index 3cc6d682f4a..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/CostResource.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.cost; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.util.List; - -/** - * Cost and Utilization APi for hosted Vespa. - * - * Used to give insight to PEG and application owners about - * TOC and if the application is reasonable scaled. - * - * @author smorgrav - */ -@Path("v1") -@Produces(MediaType.APPLICATION_JSON) -public interface CostResource { - - @GET - @Path("/analysis/cpu") - List<CostJsonModel.Application> getCPUAnalysis(); - - @GET - @Produces("text/csv") - @Path("/csv") - String getCSV(); - - @GET - @Path("/apps") - List<CostJsonModel.Application> getApplicationsCost(); - - @GET - @Path("/apps/{environment}/{region}/{application}") - CostJsonModel.Application getApplicationCost(@PathParam("application") String appName, - @PathParam("region") String regionName, - @PathParam("environment") String envName); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/package-info.java deleted file mode 100644 index 8e95bd4f6f1..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/cost/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.cost; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/AthensDomain.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/AthenzDomain.java index eb8b5c5256b..42240a72339 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/AthensDomain.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/AthenzDomain.java @@ -2,11 +2,12 @@ package com.yahoo.vespa.hosted.controller.api.identifiers; /** + * @author bjorncs * @author smorgrav */ -public class AthensDomain extends Identifier { +public class AthenzDomain extends Identifier { - public AthensDomain(String id) { + public AthenzDomain(String id) { super(id); } @@ -14,11 +15,11 @@ public class AthensDomain extends Identifier { return !id().contains("."); } - public AthensDomain getParent() { - return new AthensDomain(id().substring(0, lastDot())); + public AthenzDomain getParent() { + return new AthenzDomain(id().substring(0, lastDot())); } - public String getName() { + public String getNameSuffix() { return id().substring(lastDot() + 1); } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ApplicationAction.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ApplicationAction.java deleted file mode 100644 index cb5731164c8..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ApplicationAction.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -/** - * @author mpolden - */ -public enum ApplicationAction { - deploy("deployer"), - read("reader"), - write("writer"); - - public final String roleName; - - ApplicationAction(String roleName) { - this.roleName = roleName; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/Athens.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/Athens.java deleted file mode 100644 index 0635fb850b7..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/Athens.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId; -import com.yahoo.vespa.hosted.controller.api.identifiers.UserId; - -/** - * Interface for integrating controller with Athens. - * - * @author mpolden - */ -public interface Athens { - - String principalTokenHeader(); - AthensPrincipal principalFrom(ScrewdriverId screwdriverId); - AthensPrincipal principalFrom(UserId userId); - NTokenValidator validator(); - NToken nTokenFrom(String rawToken); - ZmsClientFactory zmsClientFactory(); - AthensDomain screwdriverDomain(); - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPrincipal.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPrincipal.java deleted file mode 100644 index 58b878870b9..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPrincipal.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.identifiers.UserId; - -import java.security.Principal; -import java.util.Objects; - -/** - * @author bjorncs - */ -public class AthensPrincipal implements Principal { - - private final AthensDomain domain; - private final UserId userId; - - public AthensPrincipal(AthensDomain domain, UserId userId) { - this.domain = domain; - this.userId = userId; - } - - public UserId getUserId() { - return userId; - } - - public AthensDomain getDomain() { - return domain; - } - - public String toYRN() { - return domain.id() + "." + userId.id(); - } - - @Override - public String toString() { - return toYRN(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AthensPrincipal that = (AthensPrincipal) o; - return Objects.equals(domain, that.domain) && - Objects.equals(userId, that.userId); - } - - @Override - public int hashCode() { - return Objects.hash(domain, userId); - } - - @Override - public String getName() { - return userId.id(); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPublicKey.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPublicKey.java deleted file mode 100644 index 9bbb5f28d8f..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensPublicKey.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import java.security.PublicKey; -import java.util.Objects; - -/** - * @author bjorncs - */ -public class AthensPublicKey { - private final PublicKey publicKey; - private final String keyId; - - public AthensPublicKey(PublicKey publicKey, String keyId) { - this.publicKey = publicKey; - this.keyId = keyId; - } - - public PublicKey getPublicKey() { - return publicKey; - } - - public String getKeyId() { - return keyId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AthensPublicKey that = (AthensPublicKey) o; - return Objects.equals(publicKey, that.publicKey) && - Objects.equals(keyId, that.keyId); - } - - @Override - public int hashCode() { - return Objects.hash(publicKey, keyId); - } - - @Override - public String toString() { - return "AthensPublicKey{" + - "publicKey=" + publicKey + - ", keyId='" + keyId + '\'' + - '}'; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensService.java deleted file mode 100644 index 42af966be3d..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/AthensService.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; - -import java.util.Objects; - -/** - * @author bjorncs - */ -public class AthensService { - - private final AthensDomain domain; - private final String serviceName; - - public AthensService(AthensDomain domain, String serviceName) { - this.domain = domain; - this.serviceName = serviceName; - } - - public String toFullServiceName() { - return domain.id() + "." + serviceName; - } - - public AthensDomain getDomain() { - return domain; - } - - public String getServiceName() { - return serviceName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AthensService that = (AthensService) o; - return Objects.equals(domain, that.domain) && - Objects.equals(serviceName, that.serviceName); - } - - @Override - public int hashCode() { - return Objects.hash(domain, serviceName); - } - - @Override - public String toString() { - return String.format("AthensService(%s)", toFullServiceName()); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/InvalidTokenException.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/InvalidTokenException.java deleted file mode 100644 index 9c21d5814cb..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/InvalidTokenException.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -/** - * @author bjorncs - */ -public class InvalidTokenException extends Exception { - public InvalidTokenException(String message) { - super(message); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NToken.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NToken.java deleted file mode 100644 index b74872b4c6a..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NToken.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.identifiers.UserId; - -import java.security.PublicKey; - -/** - * @author mpolden - */ -public interface NToken { - - AthensPrincipal getPrincipal(); - UserId getUser(); - AthensDomain getDomain(); - String getToken(); - String getKeyId(); - void validateSignatureAndExpiration(PublicKey publicKey) throws InvalidTokenException; - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NTokenValidator.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NTokenValidator.java deleted file mode 100644 index 905d7d864a3..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/NTokenValidator.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -/** - * @author mpolden - */ -public interface NTokenValidator { - - void preloadPublicKeys(); - AthensPrincipal validate(NToken nToken) throws InvalidTokenException; - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClient.java deleted file mode 100644 index 7ff54957e16..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClient.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; - -import java.util.List; - -/** - * @author bjorncs - */ -public interface ZmsClient { - void createTenant(AthensDomain tenantDomain); - - void deleteTenant(AthensDomain tenantDomain); - - void addApplication(AthensDomain tenantDomain, ApplicationId applicationName); - - void deleteApplication(AthensDomain tenantDomain, ApplicationId applicationName); - - boolean hasApplicationAccess(AthensPrincipal principal, ApplicationAction action, AthensDomain tenantDomain, ApplicationId applicationName); - - boolean hasTenantAdminAccess(AthensPrincipal principal, AthensDomain tenantDomain); - - // Used before vespa tenancy is established for the domain. - boolean isDomainAdmin(AthensPrincipal principal, AthensDomain domain); - - List<AthensDomain> getDomainList(String prefix); - - List<AthensDomain> getTenantDomainsForUser(AthensPrincipal principal); - - AthensPublicKey getPublicKey(AthensService service, String keyId); - - List<AthensPublicKey> getPublicKeys(AthensService service); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClientFactory.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClientFactory.java deleted file mode 100644 index e00f3ce2f64..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsClientFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -/** - * @author bjorncs - */ -public interface ZmsClientFactory { - ZmsClient createClientWithServicePrincipal(); - - ZmsClient createClientWithAuthorizedServiceToken(NToken authorizedServiceToken); -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsException.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsException.java deleted file mode 100644 index ed5b2daca86..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsException.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -/** - * @author bjorncs - */ -public class ZmsException extends RuntimeException { - - private final int code; - - public ZmsException(Throwable t, int code) { - super(t.getMessage(), t); - this.code = code; - } - - public ZmsException(int code) { - this.code = code; - } - - public int getCode() { - return code; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsKeystore.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsKeystore.java deleted file mode 100644 index 4f8e5f5ff05..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/ZmsKeystore.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import java.security.PublicKey; -import java.util.Optional; - -/** - * Interface for a keystore containing public keys for Athens services - * - * @author bjorncs - */ -@FunctionalInterface -public interface ZmsKeystore { - Optional<PublicKey> getPublicKey(AthensService service, String keyId); - - default void preloadKeys(AthensService service) { - // Default implementation is noop - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensDbMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensDbMock.java deleted file mode 100644 index 8a02d0dcff5..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensDbMock.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.yahoo.vespa.hosted.controller.api.integration.athens.ApplicationAction; -import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPrincipal; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * @author bjorncs - */ -public class AthensDbMock { - - public final Map<AthensDomain, Domain> domains = new HashMap<>(); - - public AthensDbMock addDomain(Domain domain) { - domains.put(domain.name, domain); - return this; - } - - public static class Domain { - - public final AthensDomain name; - public final Set<AthensPrincipal> admins = new HashSet<>(); - public final Set<AthensPrincipal> tenantAdmins = new HashSet<>(); - public final Map<ApplicationId, Application> applications = new HashMap<>(); - public boolean isVespaTenant = false; - - public Domain(AthensDomain name) { - this.name = name; - } - - public Domain admin(AthensPrincipal user) { - admins.add(user); - return this; - } - - public Domain tenantAdmin(AthensPrincipal user) { - tenantAdmins.add(user); - return this; - } - - /** - * Simulates establishing Vespa tenancy in Athens. - */ - public void markAsVespaTenant() { - isVespaTenant = true; - } - - } - - public static class Application { - - public final Map<ApplicationAction, Set<AthensPrincipal>> acl = new HashMap<>(); - - public Application() { - acl.put(ApplicationAction.deploy, new HashSet<>()); - acl.put(ApplicationAction.read, new HashSet<>()); - acl.put(ApplicationAction.write, new HashSet<>()); - } - - public Application addRoleMember(ApplicationAction action, AthensPrincipal user) { - acl.get(action).add(user); - return this; - } - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensMock.java deleted file mode 100644 index 8bed95bfcd4..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/AthensMock.java +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.google.inject.Inject; -import com.yahoo.component.AbstractComponent; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId; -import com.yahoo.vespa.hosted.controller.api.identifiers.UserId; -import com.yahoo.vespa.hosted.controller.api.integration.athens.Athens; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPrincipal; -import com.yahoo.vespa.hosted.controller.api.integration.athens.InvalidTokenException; -import com.yahoo.vespa.hosted.controller.api.integration.athens.NToken; -import com.yahoo.vespa.hosted.controller.api.integration.athens.NTokenValidator; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ZmsClientFactory; - -/** - * @author mpolden - */ -public class AthensMock extends AbstractComponent implements Athens { - - private static final AthensDomain userDomain = new AthensDomain("domain1"); - private static final AthensDomain screwdriverDomain = new AthensDomain("screwdriver-domain"); - - private final ZmsClientFactory zmsClientFactory; - private final NTokenValidator nTokenValidator; - - public AthensMock(AthensDbMock athensDb, NTokenValidator nTokenValidator) { - this.zmsClientFactory = new ZmsClientFactoryMock(athensDb); - this.nTokenValidator = nTokenValidator; - } - - public AthensMock(AthensDbMock athensDbMock) { - this(athensDbMock, mockValidator); - } - - @Inject - public AthensMock() { - this(new AthensDbMock(), mockValidator); - } - - @Override - public String principalTokenHeader() { - return "X-Athens-Token"; - } - - @Override - public AthensPrincipal principalFrom(ScrewdriverId screwdriverId) { - return new AthensPrincipal(screwdriverDomain, new UserId("screwdriver-" + screwdriverId.id())); - } - - @Override - public AthensPrincipal principalFrom(UserId userId) { - return new AthensPrincipal(userDomain, userId); - } - - @Override - public NTokenValidator validator() { - return nTokenValidator; - } - - @Override - public NToken nTokenFrom(String rawToken) { - return new NTokenMock(rawToken); - } - - @Override - public ZmsClientFactory zmsClientFactory() { - return zmsClientFactory; - } - - @Override - public AthensDomain screwdriverDomain() { - return screwdriverDomain; - } - - private static final NTokenValidator mockValidator = new NTokenValidator() { - @Override - public void preloadPublicKeys() { - } - - @Override - public AthensPrincipal validate(NToken nToken) throws InvalidTokenException { - return nToken.getPrincipal(); - } - }; - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/NTokenMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/NTokenMock.java deleted file mode 100644 index ae23a69e409..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/NTokenMock.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.identifiers.UserId; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPrincipal; -import com.yahoo.vespa.hosted.controller.api.integration.athens.InvalidTokenException; -import com.yahoo.vespa.hosted.controller.api.integration.athens.NToken; - -import java.security.PublicKey; -import java.util.Objects; - -/** - * @author mpolden - */ -public class NTokenMock implements NToken { - - private static final AthensDomain domain = new AthensDomain("test"); - private static final UserId userId = new UserId("user"); - - private final String rawToken; - - public NTokenMock(String rawToken) { - this.rawToken = rawToken; - } - - @Override - public AthensPrincipal getPrincipal() { - return new AthensPrincipal(domain, userId); - } - - @Override - public UserId getUser() { - return userId; - } - - @Override - public AthensDomain getDomain() { - return domain; - } - - @Override - public String getToken() { - return "test-token"; - } - - @Override - public String getKeyId() { - return "test-key"; - } - - @Override - public void validateSignatureAndExpiration(PublicKey publicKey) throws InvalidTokenException { - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof NTokenMock)) return false; - NTokenMock that = (NTokenMock) o; - return Objects.equals(rawToken, that.rawToken); - } - - @Override - public int hashCode() { - return Objects.hash(rawToken); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientFactoryMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientFactoryMock.java deleted file mode 100644 index 8bc8b29fb4c..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientFactoryMock.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.yahoo.component.AbstractComponent; -import com.yahoo.vespa.hosted.controller.api.integration.athens.NToken; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ZmsClient; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ZmsClientFactory; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * @author bjorncs - */ -public class ZmsClientFactoryMock extends AbstractComponent implements ZmsClientFactory { - - private static final Logger log = Logger.getLogger(ZmsClientFactoryMock.class.getName()); - - private final AthensDbMock athens; - - public ZmsClientFactoryMock() { - this(new AthensDbMock()); - } - - ZmsClientFactoryMock(AthensDbMock athens) { - this.athens = athens; - } - - public AthensDbMock getSetup() { - return athens; - } - - @Override - public ZmsClient createClientWithServicePrincipal() { - log("createClientWithServicePrincipal()"); - return new ZmsClientMock(athens); - } - - @Override - public ZmsClient createClientWithAuthorizedServiceToken(NToken authorizedServiceToken) { - log("createClientWithAuthorizedServiceToken(authorizedServiceToken='%s')", authorizedServiceToken); - return new ZmsClientMock(athens); - } - - private static void log(String format, Object... args) { - log.log(Level.INFO, String.format(format, args)); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientMock.java deleted file mode 100644 index 97f391f792d..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/ZmsClientMock.java +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId; -import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ApplicationAction; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPrincipal; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPublicKey; -import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensService; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ZmsClient; -import com.yahoo.vespa.hosted.controller.api.integration.athens.ZmsException; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static java.util.stream.Collectors.toList; - -/** - * @author bjorncs - */ -public class ZmsClientMock implements ZmsClient { - - private static final Logger log = Logger.getLogger(ZmsClientMock.class.getName()); - - private final AthensDbMock athens; - - public ZmsClientMock(AthensDbMock athens) { - this.athens = athens; - } - - @Override - public void createTenant(AthensDomain tenantDomain) { - log("createTenant(tenantDomain='%s')", tenantDomain); - getDomainOrThrow(tenantDomain, false).isVespaTenant = true; - } - - @Override - public void deleteTenant(AthensDomain tenantDomain) { - log("deleteTenant(tenantDomain='%s')", tenantDomain); - AthensDbMock.Domain domain = getDomainOrThrow(tenantDomain, false); - domain.isVespaTenant = false; - domain.applications.clear(); - domain.tenantAdmins.clear(); - } - - @Override - public void addApplication(AthensDomain tenantDomain, ApplicationId applicationName) { - log("addApplication(tenantDomain='%s', applicationName='%s')", tenantDomain, applicationName); - AthensDbMock.Domain domain = getDomainOrThrow(tenantDomain, true); - if (!domain.applications.containsKey(applicationName)) { - domain.applications.put(applicationName, new AthensDbMock.Application()); - } - } - - @Override - public void deleteApplication(AthensDomain tenantDomain, ApplicationId applicationName) { - log("addApplication(tenantDomain='%s', applicationName='%s')", tenantDomain, applicationName); - getDomainOrThrow(tenantDomain, true).applications.remove(applicationName); - } - - @Override - public boolean hasApplicationAccess(AthensPrincipal principal, ApplicationAction action, AthensDomain tenantDomain, ApplicationId applicationName) { - log("hasApplicationAccess(principal='%s', action='%s', tenantDomain='%s', applicationName='%s')", - principal, action, tenantDomain, applicationName); - AthensDbMock.Domain domain = getDomainOrThrow(tenantDomain, true); - AthensDbMock.Application application = domain.applications.get(applicationName); - if (application == null) { - throw zmsException(400, "Application '%s' not found", applicationName); - } - return domain.admins.contains(principal) || application.acl.get(action).contains(principal); - } - - @Override - public boolean hasTenantAdminAccess(AthensPrincipal principal, AthensDomain tenantDomain) { - log("hasTenantAdminAccess(principal='%s', tenantDomain='%s')", principal, tenantDomain); - return isDomainAdmin(principal, tenantDomain) || - getDomainOrThrow(tenantDomain, true).tenantAdmins.contains(principal); - } - - @Override - public boolean isDomainAdmin(AthensPrincipal principal, AthensDomain domain) { - log("isDomainAdmin(principal='%s', domain='%s')", principal, domain); - return getDomainOrThrow(domain, false).admins.contains(principal); - } - - @Override - public List<AthensDomain> getDomainList(String prefix) { - log("getDomainList()"); - return new ArrayList<>(athens.domains.keySet()); - } - - @Override - public List<AthensDomain> getTenantDomainsForUser(AthensPrincipal principal) { - log("getTenantDomainsForUser(principal='%s')", principal); - return athens.domains.values().stream() - .filter(domain -> domain.tenantAdmins.contains(principal) || domain.admins.contains(principal)) - .map(domain -> domain.name) - .collect(toList()); - } - - @Override - public AthensPublicKey getPublicKey(AthensService service, String keyId) { - throw new UnsupportedOperationException(); - } - - @Override - public List<AthensPublicKey> getPublicKeys(AthensService service) { - throw new UnsupportedOperationException(); - } - - private AthensDbMock.Domain getDomainOrThrow(AthensDomain domainName, boolean verifyVespaTenant) { - AthensDbMock.Domain domain = Optional.ofNullable(athens.domains.get(domainName)) - .orElseThrow(() -> zmsException(400, "Domain '%s' not found", domainName)); - if (verifyVespaTenant && !domain.isVespaTenant) { - throw zmsException(400, "Domain not a Vespa tenant: '%s'", domainName); - } - return domain; - } - - private static ZmsException zmsException(int code, String message, Object... args) { - return new ZmsException(new RuntimeException(String.format(message, args)), code); - } - - private static void log(String format, Object... args) { - log.log(Level.INFO, String.format(format, args)); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/package-info.java deleted file mode 100644 index d4454503786..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/mock/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @author bjorncs - */ -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.integration.athens.mock; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/package-info.java deleted file mode 100644 index eabe214abf2..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/athens/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.integration.athens; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java index 1958c5bd0ff..8c8b5fdf22e 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerClient.java @@ -66,4 +66,13 @@ public interface ConfigServerClient { * @throws IOException If trouble contacting the server */ EndpointStatus getGlobalRotationStatus(DeploymentId deployment, String endpoint) throws IOException; + + /** + * The nodes allocated to the deployment + * + * @param deployment The application/zone pair + * @return The nodes for this deployment + * @throws IOException If unable to retrieve the node list + */ + NodeList getNodeList(DeploymentId deployment) throws IOException; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java new file mode 100644 index 00000000000..755bec2fcec --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/NodeList.java @@ -0,0 +1,36 @@ +package com.yahoo.vespa.hosted.controller.api.integration.configserver;// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * @author smorgrav + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeList { + + @JsonProperty("nodes") + public List<Node> nodes; + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Node { + @JsonProperty("hostname") + public String hostname; + @JsonProperty("flavor") + public String flavor; + @JsonProperty("membership") + public Membership membership; + @JsonProperty("cost") + public int cost; + + @JsonIgnoreProperties(ignoreUnknown = true) + public static class Membership { + @JsonProperty("clustertype") + public String clusterType; + @JsonProperty("clusterid") + public String clusterId; + } + } +}
\ No newline at end of file diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ApplicationCost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ApplicationCost.java deleted file mode 100644 index 9bc9cfa8ed0..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ApplicationCost.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import java.util.HashMap; -import java.util.Map; - -/** - * Cost data model for an application instance. I.e one running vespa application in one zone. - * - * @author smorgrav - */ -// TODO: Make immutable -// TODO: Make the Application own this and rename to Cost -// TODO: Enforce constraints -// TODO: Remove application id elements -// TODO: Model zone as Zone -// TODO: Cost per zone + total -// TODO: Use doubles -public class ApplicationCost { - - /** This contains environment.region */ - private String zone; - - private String tenant; - - // This must contain applicationName.instanceName. TODO: Fix - private String app; - - private int tco; - private float utilization; - private float waste; - Map<String, ClusterCost> cluster; - - /** Create an empty (invalid) application cost */ - public ApplicationCost() {} - - public ApplicationCost(String zone, String tenant, String app, int tco, float utilization, float waste, - Map<String, ClusterCost> clusterCost) { - this.zone = zone; - this.tenant = tenant; - this.app = app; - this.tco = tco; - this.utilization = utilization; - this.waste = waste; - cluster = new HashMap<>(clusterCost); - } - - public String getZone() { - return zone; - } - - public void setZone(String zone) { - this.zone = zone; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public Map<String, ClusterCost> getCluster() { - return cluster; - } - - public void setCluster(Map<String, ClusterCost> cluster) { - this.cluster = cluster; - } - - public int getTco() { - return tco; - } - - public void setTco(int tco) { - if (tco < 0) throw new IllegalArgumentException("TCO cannot be negative"); - this.tco = tco; - } - - public String getTenant() { - return tenant; - } - - public void setTenant(String tenant) { - this.tenant = tenant; - } - - public float getUtilization() { - return utilization; - } - - public void setUtilization(float utilization) { - if (utilization < 0) throw new IllegalArgumentException("Utilization cannot be negative"); - this.utilization = utilization; - } - - public float getWaste() { - return waste; - } - - public void setWaste(float waste) { - this.waste = waste; - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Backend.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Backend.java deleted file mode 100644 index d9edf22d42c..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Backend.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.RegionName; -import com.yahoo.vespa.hosted.controller.common.NotFoundCheckedException; - -import java.util.List; - -/** - * Interface for retrieving cost data directly or indirectly from yamas and - * the noderepository. - * - * - * @author smorgrav - */ -public interface Backend { - List<ApplicationCost> getApplicationCost(); - ApplicationCost getApplicationCost(Environment env, RegionName region, ApplicationId appId) throws NotFoundCheckedException; -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ClusterCost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ClusterCost.java deleted file mode 100644 index 1e41325a4fd..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/ClusterCost.java +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import java.util.List; - -/** - * Cost data model for a cluster. I.e one cluster within one vespa application in one zone. - * - * @author smorgrav - */ -// TODO: Use doubles -// TODO: Make immutable -// TODO: Enforce constraints -// TODO: Document content -public class ClusterCost { - - private int count; - private String resource; - private float utilization; - private int tco; - private String flavor; - private int waste; - private String type; - private float utilMem; - private float utilCpu; - private float utilDisk; - private float utilDiskBusy; - private float usageMem; - private float usageCpu; - private float usageDisk; - private float usageDiskBusy; - private List<String> hostnames; - - /** Create an empty (invalid) cluster cost */ - public ClusterCost() {} - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } - - public String getFlavor() { - return flavor; - } - - public void setFlavor(String flavor) { - this.flavor = flavor; - } - - public List<String> getHostnames() { - return hostnames; - } - - public void setHostnames(List<String> hostnames) { - this.hostnames = hostnames; - } - - public String getResource() { - return resource; - } - - public void setResource(String resource) { - this.resource = resource; - } - - public int getTco() { - return tco; - } - - public void setTco(int tco) { - this.tco = tco; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public float getUtilization() { - return utilization; - } - - public void setUtilization(float utilization) { - validateUtilRatio(utilization); - this.utilization = utilization; - } - - public int getWaste() { - return waste; - } - - public void setWaste(int waste) { - this.waste = waste; - } - - public float getUsageCpu() { - return usageCpu; - } - - public void setUsageCpu(float usageCpu) { - validateUsageRatio(usageCpu); - this.usageCpu = usageCpu; - } - - public float getUsageDisk() { - return usageDisk; - } - - public void setUsageDisk(float usageDisk) { - validateUsageRatio(usageDisk); - this.usageDisk = usageDisk; - } - - public float getUsageMem() { - return usageMem; - } - - public void setUsageMem(float usageMem) { - validateUsageRatio(usageMem); - this.usageMem = usageMem; - } - - public float getUtilCpu() { - return utilCpu; - } - - public void setUtilCpu(float utilCpu) { - validateUtilRatio(utilCpu); - this.utilCpu = utilCpu; - } - - public float getUtilDisk() { - return utilDisk; - } - - public void setUtilDisk(float utilDisk) { - validateUtilRatio(utilDisk); - this.utilDisk = utilDisk; - } - - public float getUtilMem() { - return utilMem; - } - - public void setUtilMem(float utilMem) { - validateUsageRatio(utilMem); - this.utilMem = utilMem; - } - - public float getUsageDiskBusy() { - return usageDiskBusy; - } - - public void setUsageDiskBusy(float usageDiskBusy) { - validateUsageRatio(usageDiskBusy); - this.usageDiskBusy = usageDiskBusy; - } - - public float getUtilDiskBusy() { - return utilDiskBusy; - } - - public void setUtilDiskBusy(float utilDiskBusy) { - validateUtilRatio(utilDiskBusy); - this.utilDiskBusy = utilDiskBusy; - } - - private void validateUsageRatio(float ratio) { - if (ratio < 0) throw new IllegalArgumentException("Usage cannot be negative"); - if (ratio > 1) throw new IllegalArgumentException("Usage exceed 1 (using more than it has available)"); - } - - private void validateUtilRatio(float ratio) { - if (ratio < 0) throw new IllegalArgumentException("Utilization cannot be negative"); - } -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java deleted file mode 100644 index 7297b60de5c..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/Cost.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.RegionName; -import com.yahoo.vespa.hosted.controller.common.NotFoundCheckedException; - -import java.util.List; - -/** - * Cost domain model declaration - * - * @author smorgrav - */ -public interface Cost { - - /** - * Calculate a list of the applications that is wasting most - * in absolute terms. To improve utilization, it should make - * sense to focus on this list. - * - * @return An ordered set of applications with the highest potential for - * improved CPU utilization across all environments and regions. - */ - List<ApplicationCost> getCPUAnalysis(int nofApplications); - - /** - * Collect all information and format it as a Cvs blob for download. - * - * @return A String with comma separated values. Can be big! - */ - String getCsvForLocalAnalysis(); - - /** - * Get application costs for all applications across all regions and environments - * - * @return A list of applications in given zone - */ - List<ApplicationCost> getApplicationCost(); - - /** - * Get application costs for a given application instance in a given zone. - * - * @param env Environment like test, dev, perf, staging or prod - * @param region Region name like us-east-1 - * @param app ApplicationId like tenant:application:instance - * - * @return A list of applications in given zone - */ - ApplicationCost getApplicationCost(Environment env, RegionName region, ApplicationId app) - throws NotFoundCheckedException; -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostJsonModelAdapter.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostJsonModelAdapter.java deleted file mode 100644 index 088b1fa12bc..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/CostJsonModelAdapter.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import com.yahoo.slime.Cursor; -import com.yahoo.vespa.hosted.controller.api.cost.CostJsonModel; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -/** - * Converting from cost data model to the JSON data model used in the cost REST API. - * - * @author smorgrav - */ -public class CostJsonModelAdapter { - - public static CostJsonModel.Application toJsonModel(ApplicationCost appCost) { - CostJsonModel.Application app = new CostJsonModel.Application(); - app.zone = appCost.getZone(); - app.tenant = appCost.getTenant(); - app.app = appCost.getApp(); - app.tco = appCost.getTco(); - app.utilization = appCost.getUtilization(); - app.waste = appCost.getWaste(); - app.cluster = new HashMap<>(); - Map<String, ClusterCost> clusterMap = appCost.getCluster(); - for (String key : clusterMap.keySet()) { - app.cluster.put(key, toJsonModel(clusterMap.get(key))); - } - - return app; - } - - public static void toSlime(ApplicationCost appCost, Cursor object) { - object.setString("zone", appCost.getZone()); - object.setString("tenant", appCost.getTenant()); - object.setString("app", appCost.getApp()); - object.setLong("tco", appCost.getTco()); - object.setDouble("utilization", appCost.getUtilization()); - object.setDouble("waste", appCost.getWaste()); - Cursor clustersObject = object.setObject("cluster"); - for (Map.Entry<String, ClusterCost> clusterEntry : appCost.getCluster().entrySet()) - toSlime(clusterEntry.getValue(), clustersObject.setObject(clusterEntry.getKey())); - } - - public static CostJsonModel.Cluster toJsonModel(ClusterCost clusterCost) { - CostJsonModel.Cluster cluster = new CostJsonModel.Cluster(); - cluster.count = clusterCost.getCount(); - cluster.resource = clusterCost.getResource(); - cluster.utilization = clusterCost.getUtilization(); - cluster.tco = clusterCost.getTco(); - cluster.flavor = clusterCost.getFlavor(); - cluster.waste = clusterCost.getWaste(); - cluster.type = clusterCost.getType(); - cluster.util = new CostJsonModel.HardwareResources(); - cluster.util.cpu = clusterCost.getUtilCpu(); - cluster.util.mem = clusterCost.getUtilMem(); - cluster.util.disk = clusterCost.getUtilDisk(); - cluster.usage = new CostJsonModel.HardwareResources(); - cluster.usage.cpu = clusterCost.getUsageCpu(); - cluster.usage.mem = clusterCost.getUsageMem(); - cluster.usage.disk = clusterCost.getUsageDisk(); - cluster.hostnames = new ArrayList<>(clusterCost.getHostnames()); - cluster.usage.diskBusy = clusterCost.getUsageDiskBusy(); - cluster.util.diskBusy = clusterCost.getUtilDiskBusy(); - return cluster; - } - - private static void toSlime(ClusterCost clusterCost, Cursor object) { - object.setLong("count", clusterCost.getCount()); - object.setString("resource", clusterCost.getResource()); - object.setDouble("utilization", clusterCost.getUtilization()); - object.setLong("tco", clusterCost.getTco()); - object.setString("flavor", clusterCost.getFlavor()); - object.setLong("waste", clusterCost.getWaste()); - object.setString("type", clusterCost.getType()); - Cursor utilObject = object.setObject("util"); - utilObject.setDouble("cpu", clusterCost.getUtilCpu()); - utilObject.setDouble("mem", clusterCost.getUtilMem()); - utilObject.setDouble("disk", clusterCost.getUtilDisk()); - utilObject.setDouble("diskBusy", clusterCost.getUtilDiskBusy()); - Cursor usageObject = object.setObject("usage"); - usageObject.setDouble("cpu", clusterCost.getUsageCpu()); - usageObject.setDouble("mem", clusterCost.getUsageMem()); - usageObject.setDouble("disk", clusterCost.getUsageDisk()); - usageObject.setDouble("diskBusy", clusterCost.getUsageDiskBusy()); - Cursor hostnamesArray = object.setArray("hostnames"); - for (String hostname : clusterCost.getHostnames()) - hostnamesArray.addString(hostname); - } - -} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java deleted file mode 100644 index f08e6cc9b36..00000000000 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/cost/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -package com.yahoo.vespa.hosted.controller.api.integration.cost; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java index 56825cf7c61..1bd5feb1966 100644 --- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java +++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/identifiers/IdentifierTest.java @@ -118,19 +118,19 @@ public class IdentifierTest { } @Test - public void athens_parent_domain_is_without_name_suffix() { - assertEquals(new AthensDomain("yby.john"), new AthensDomain("yby.john.myapp").getParent()); + public void athenz_parent_domain_is_without_name_suffix() { + assertEquals(new AthenzDomain("yby.john"), new AthenzDomain("yby.john.myapp").getParent()); } @Test - public void athens_domain_name_is_last_suffix() { - assertEquals("myapp", new AthensDomain("yby.john.myapp").getName()); + public void athenz_domain_name_is_last_suffix() { + assertEquals("myapp", new AthenzDomain("yby.john.myapp").getNameSuffix()); } @Test public void domain_without_dot_is_toplevel() { - assertTrue(new AthensDomain("toplevel").isTopLevelDomain()); - assertFalse(new AthensDomain("not.toplevel").isTopLevelDomain()); + assertTrue(new AthenzDomain("toplevel").isTopLevelDomain()); + assertFalse(new AthenzDomain("not.toplevel").isTopLevelDomain()); } @Test |