Search in sources :

Example 1 with StaticProvisioner

use of com.yahoo.vespa.config.server.provision.StaticProvisioner in project vespa by vespa-engine.

the class PreparedModelsBuilder method createHostProvisioner.

// This method is an excellent demonstration of what happens when one is too liberal with Optional
// -bratseth, who had to write the below  :-\
private Optional<HostProvisioner> createHostProvisioner(Optional<AllocatedHosts> allocatedHosts) {
    Optional<HostProvisioner> nodeRepositoryProvisioner = createNodeRepositoryProvisioner(properties);
    if (!allocatedHosts.isPresent())
        return nodeRepositoryProvisioner;
    Optional<HostProvisioner> staticProvisioner = createStaticProvisioner(allocatedHosts);
    // Since we have hosts allocated this means we are on non-hosted
    if (!staticProvisioner.isPresent())
        return Optional.empty();
    // The following option should not be possible, but since there is a right action for it we can take it
    if (!nodeRepositoryProvisioner.isPresent())
        return Optional.of(new StaticProvisioner(allocatedHosts.get()));
    // previously unallocated cluster. This allows future models to stop allocate certain clusters.
    return Optional.of(new StaticProvisioner(allocatedHosts.get(), nodeRepositoryProvisioner.get()));
}
Also used : StaticProvisioner(com.yahoo.vespa.config.server.provision.StaticProvisioner) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Aggregations

HostProvisioner (com.yahoo.config.model.api.HostProvisioner)1 StaticProvisioner (com.yahoo.vespa.config.server.provision.StaticProvisioner)1