// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.component;

import com.yahoo.vespa.athenz.api.AthenzIdentity;

import java.net.URI;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Information necessary to e.g. establish communication with the config servers
 *
 * @author hakon
 */
public class ConfigServerInfo {
    private final URI loadBalancerEndpoint;
    private final AthenzIdentity configServerIdentity;
    private final Function<String, URI> configServerHostnameToUriMapper;
    private final List<URI> configServerURIs;

    public ConfigServerInfo(String loadBalancerHostName, List<String> configServerHostNames,
                            String scheme, int port, AthenzIdentity configServerAthenzIdentity) {
        this.loadBalancerEndpoint = createLoadBalancerEndpoint(loadBalancerHostName, scheme, port);
        this.configServerIdentity = configServerAthenzIdentity;
        this.configServerHostnameToUriMapper = hostname -> URI.create(scheme + "://" + hostname + ":" + port);
        this.configServerURIs = configServerHostNames.stream()
                .map(configServerHostnameToUriMapper)
                .collect(Collectors.toUnmodifiableList());
    }

    private static URI createLoadBalancerEndpoint(String loadBalancerHost, String scheme, int port) {
        return URI.create(scheme + "://" + loadBalancerHost + ":" + port);
    }

    public List<URI> getConfigServerUris() {
        return configServerURIs;
    }

    public URI getConfigServerUri(String hostname) {
        return configServerHostnameToUriMapper.apply(hostname);
    }

    public URI getLoadBalancerEndpoint() {
        return loadBalancerEndpoint;
    }

    public AthenzIdentity getConfigServerIdentity() {
        return configServerIdentity;
    }
}

@@ -708,22 +708,19 @@
 verInfo(
-String
+URI
  loadBal
@@ -724,24 +724,24 @@
 Balancer
-HostName
+Endpoint
 , List%3CS
@@ -801,33 +801,8 @@
     
- String scheme, int port,
  Ath
@@ -879,23 +879,17 @@
 point = 
-createL
+l
 oadBalan
@@ -903,44 +903,8 @@
 oint
-(loadBalancerHostName, scheme, port)
 ;%0A  
@@ -1031,34 +1031,30 @@
  URI.create(
-scheme + %22
+%22https
 ://%22 + hostn
@@ -1057,32 +1057,29 @@
 ostname + %22:
-%22 + port
+4443%22
 );%0A        t
@@ -1256,192 +1256,8 @@
  %7D%0A%0A
-    private static URI createLoadBalancerEndpoint(String loadBalancerHost, String scheme, int port) %7B%0A        return URI.create(scheme + %22://%22 + loadBalancerHost + %22:%22 + port);%0A    %7D%0A%0A
     

Use correct port for config server LB in GCP