com.yahoo.vespa.hosted.provision.testutils.MockProvisionServiceProvider 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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.testutils;
import com.yahoo.component.annotation.Inject;
import com.yahoo.vespa.hosted.provision.lb.LoadBalancerService;
import com.yahoo.vespa.hosted.provision.lb.LoadBalancerServiceMock;
import com.yahoo.vespa.hosted.provision.provisioning.EmptyProvisionServiceProvider;
import com.yahoo.vespa.hosted.provision.provisioning.HostProvisioner;
import com.yahoo.vespa.hosted.provision.provisioning.HostResourcesCalculator;
import com.yahoo.vespa.hosted.provision.provisioning.ProvisionServiceProvider;
import java.util.Optional;
/**
* @author freva
*/
public class MockProvisionServiceProvider implements ProvisionServiceProvider {
private final Optional loadBalancerService;
private final Optional hostProvisioner;
private final HostResourcesCalculator hostResourcesCalculator;
@Inject
public MockProvisionServiceProvider() {
this(new LoadBalancerServiceMock(), null);
}
public MockProvisionServiceProvider(LoadBalancerService loadBalancerService, HostProvisioner hostProvisioner) {
this(loadBalancerService, hostProvisioner, new EmptyProvisionServiceProvider().getHostResourcesCalculator());
}
public MockProvisionServiceProvider(LoadBalancerService loadBalancerService, HostProvisioner hostProvisioner,
HostResourcesCalculator hostResourcesCalculator) {
this.loadBalancerService = Optional.ofNullable(loadBalancerService);
this.hostProvisioner = Optional.ofNullable(hostProvisioner);
this.hostResourcesCalculator = hostResourcesCalculator;
}
@Override
public Optional getLoadBalancerService() {
return loadBalancerService;
}
@Override
public Optional getHostProvisioner() {
return hostProvisioner;
}
@Override
public HostResourcesCalculator getHostResourcesCalculator() {
return hostResourcesCalculator;
}
}