com.yahoo.vespa.hosted.provision.lb.LoadBalancerServiceMock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of node-repository Show documentation
Show all versions of node-repository Show documentation
Keeps track of node assignment in a multi-application setup.
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.lb;
import com.google.common.collect.ImmutableSet;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.HostName;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
/**
* @author mpolden
*/
public class LoadBalancerServiceMock implements LoadBalancerService {
private final Map instances = new HashMap<>();
public Map instances() {
return Collections.unmodifiableMap(instances);
}
@Override
public Protocol protocol() {
return Protocol.ipv4;
}
@Override
public LoadBalancerInstance create(ApplicationId application, ClusterSpec.Id cluster, Set reals) {
LoadBalancerId id = new LoadBalancerId(application, cluster);
LoadBalancerInstance instance = new LoadBalancerInstance(
HostName.from("lb-" + application.toShortString() + "-" + cluster.value()),
Optional.of(new DnsZone("zone-id-1")),
Collections.singleton(4443),
ImmutableSet.of("10.2.3.0/24", "10.4.5.0/24"),
reals);
instances.put(id, instance);
return instance;
}
@Override
public void remove(ApplicationId application, ClusterSpec.Id cluster) {
instances.remove(new LoadBalancerId(application, cluster));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy