All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.vespa.hosted.provision.testutils.MockProvisionServiceProvider Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy