diff options
author | jonmv <venstad@gmail.com> | 2022-11-05 09:24:21 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-11-07 09:59:27 +0100 |
commit | f8a4549269d9df145a4f27c5368a2578f18128a7 (patch) | |
tree | ee802d429172bbb301221a1dea2fe48a34bed9b6 /controller-api | |
parent | a2eca5f54c45838d072f9641505baa3ae0d26746 (diff) |
Revert "Merge pull request #24763 from vespa-engine/jonmv/revert-streams"
This reverts commit 6d8bca79a1f600501290593ecd920eca0b237c78, reversing
changes made to 36374eb2d3cc94c3792dd0a70963244abb6284b4.
Diffstat (limited to 'controller-api')
2 files changed, 46 insertions, 20 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java index d3331c3cfd4..63c744c385d 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java @@ -12,12 +12,14 @@ import com.yahoo.vespa.hosted.controller.api.integration.billing.Quota; import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateMetadata; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ContainerEndpoint; import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretStore; +import com.yahoo.yolean.concurrent.Memoized; +import java.io.InputStream; import java.security.cert.X509Certificate; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.function.Supplier; import static java.util.Objects.requireNonNull; @@ -32,40 +34,41 @@ public class DeploymentData { private final ApplicationId instance; private final Tags tags; private final ZoneId zone; - private final byte[] applicationPackage; + private final Supplier<InputStream> applicationPackage; private final Version platform; private final Set<ContainerEndpoint> containerEndpoints; - private final Optional<EndpointCertificateMetadata> endpointCertificateMetadata; + private final Supplier<Optional<EndpointCertificateMetadata>> endpointCertificateMetadata; private final Optional<DockerImage> dockerImageRepo; private final Optional<AthenzDomain> athenzDomain; - private final Quota quota; + private final Supplier<Quota> quota; private final List<TenantSecretStore> tenantSecretStores; private final List<X509Certificate> operatorCertificates; - private final Optional<CloudAccount> cloudAccount; + private final Supplier<Optional<CloudAccount>> cloudAccount; private final boolean dryRun; - public DeploymentData(ApplicationId instance, Tags tags, ZoneId zone, byte[] applicationPackage, Version platform, + public DeploymentData(ApplicationId instance, Tags tags, ZoneId zone, Supplier<InputStream> applicationPackage, Version platform, Set<ContainerEndpoint> containerEndpoints, - Optional<EndpointCertificateMetadata> endpointCertificateMetadata, + Supplier<Optional<EndpointCertificateMetadata>> endpointCertificateMetadata, Optional<DockerImage> dockerImageRepo, Optional<AthenzDomain> athenzDomain, - Quota quota, + Supplier<Quota> quota, List<TenantSecretStore> tenantSecretStores, List<X509Certificate> operatorCertificates, - Optional<CloudAccount> cloudAccount, boolean dryRun) { + Supplier<Optional<CloudAccount>> cloudAccount, + boolean dryRun) { this.instance = requireNonNull(instance); this.tags = requireNonNull(tags); this.zone = requireNonNull(zone); this.applicationPackage = requireNonNull(applicationPackage); this.platform = requireNonNull(platform); this.containerEndpoints = Set.copyOf(requireNonNull(containerEndpoints)); - this.endpointCertificateMetadata = requireNonNull(endpointCertificateMetadata); + this.endpointCertificateMetadata = new Memoized<>(requireNonNull(endpointCertificateMetadata)); this.dockerImageRepo = requireNonNull(dockerImageRepo); this.athenzDomain = athenzDomain; - this.quota = quota; + this.quota = new Memoized<>(requireNonNull(quota)); this.tenantSecretStores = List.copyOf(requireNonNull(tenantSecretStores)); this.operatorCertificates = List.copyOf(requireNonNull(operatorCertificates)); - this.cloudAccount = Objects.requireNonNull(cloudAccount); + this.cloudAccount = new Memoized<>(requireNonNull(cloudAccount)); this.dryRun = dryRun; } @@ -79,8 +82,8 @@ public class DeploymentData { return zone; } - public byte[] applicationPackage() { - return applicationPackage; + public InputStream applicationPackage() { + return applicationPackage.get(); } public Version platform() { @@ -92,7 +95,7 @@ public class DeploymentData { } public Optional<EndpointCertificateMetadata> endpointCertificateMetadata() { - return endpointCertificateMetadata; + return endpointCertificateMetadata.get(); } public Optional<DockerImage> dockerImageRepo() { @@ -104,7 +107,7 @@ public class DeploymentData { } public Quota quota() { - return quota; + return quota.get(); } public List<TenantSecretStore> tenantSecretStores() { @@ -116,9 +119,11 @@ public class DeploymentData { } public Optional<CloudAccount> cloudAccount() { - return cloudAccount; + return cloudAccount.get(); } - public boolean isDryRun() { return dryRun; } + public boolean isDryRun() { + return dryRun; + } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationStore.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationStore.java index c4db0de539e..71ec07bc2e6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationStore.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationStore.java @@ -5,6 +5,9 @@ import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; import java.time.Instant; import java.util.Optional; @@ -17,7 +20,16 @@ import java.util.Optional; public interface ApplicationStore { /** Returns the application package of the given revision. */ - byte[] get(DeploymentId deploymentId, RevisionId revisionId); + default byte[] get(DeploymentId deploymentId, RevisionId revisionId) { + try (InputStream stream = stream(deploymentId, revisionId)) { + return stream.readAllBytes(); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + InputStream stream(DeploymentId deploymentId, RevisionId revisionId); /** Returns the application package diff, compared to the previous build, for the given tenant, application and build number */ Optional<byte[]> getDiff(TenantName tenantName, ApplicationName applicationName, long buildNumber); @@ -43,7 +55,16 @@ public interface ApplicationStore { void removeAll(TenantName tenant, ApplicationName application); /** Returns the tester application package of the given revision. Does NOT contain the services.xml. */ - byte[] getTester(TenantName tenant, ApplicationName application, RevisionId revision); + default byte[] getTester(TenantName tenant, ApplicationName application, RevisionId revision) { + try (InputStream stream = streamTester(tenant, application, revision)) { + return stream.readAllBytes(); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + InputStream streamTester(TenantName tenantName, ApplicationName applicationName, RevisionId revision); /** Returns the application package diff, compared to the previous build, for the given deployment and build number */ Optional<byte[]> getDevDiff(DeploymentId deploymentId, long buildNumber); |