diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2019-08-29 12:38:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-29 12:38:40 +0200 |
commit | 8d1aeda7204c7bd12d3b11108e3982565de4571f (patch) | |
tree | 71d2212f88814624486ab8ef725cd5301255eeb6 | |
parent | 556079bc3100db395b624b79cd1c85ee0aebf898 (diff) | |
parent | b0f6b443d8e9cbbd0d3b11841560be876969417a (diff) |
Merge pull request #10457 from vespa-engine/andreer/hashed-dns-name
make hashed dns name from application id
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java index ef1ce19b167..fa6498e995e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java @@ -1,12 +1,15 @@ // 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.application; +import com.google.common.hash.Hashing; +import com.google.common.io.BaseEncoding; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.ZoneId; import java.net.URI; +import java.nio.charset.Charset; import java.util.Objects; /** @@ -212,6 +215,13 @@ public class Endpoint { } + /** Create a DNS name based on a hash of the ApplicationId. This should always be < 64 characters long. */ + public static String createHashedCn(ApplicationId application, SystemName system) { + var hashCode = Hashing.sha1().hashString(application.serializedForm(), Charset.defaultCharset()); + var base32encoded = BaseEncoding.base32().omitPadding().lowerCase().encode(hashCode.asBytes()); + return 'v' + base32encoded + dnsSuffix(system, false); + } + /** Build an endpoint for given application */ public static EndpointBuilder of(ApplicationId application) { return new EndpointBuilder(application); |