use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.
the class Admin method addFileDistribution.
private void addFileDistribution(HostResource host) {
FileDistributor fileDistributor = fileDistribution.getFileDistributor();
HostResource deployHost = getHostSystem().getHostByHostname(fileDistributor.fileSourceHost());
if (deployHostIsMissing(deployHost)) {
throw new RuntimeException("Could not find host in the application's host system: '" + fileDistributor.fileSourceHost() + "'. Hostsystem=" + getHostSystem());
}
FileDistributionConfigProvider configProvider = new FileDistributionConfigProvider(fileDistribution, fileDistributor, host == deployHost, host.getHost());
fileDistribution.addFileDistributionConfigProducer(host.getHost(), configProvider);
}
use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.
the class Admin method createDefaultSlobrokSetup.
// If not configured by user: Use default setup: max 3 slobroks, 1 on the default configserver host
private List<Slobrok> createDefaultSlobrokSetup() {
List<HostResource> hosts = getHostSystem().getHosts();
List<Slobrok> slobs = new ArrayList<>();
if (logserver != null) {
Slobrok slobrok = new Slobrok(this, 0);
addAndInitializeService(logserver.getHostResource(), slobrok);
slobs.add(slobrok);
}
int n = 0;
while ((n < hosts.size()) && (slobs.size() < 3)) {
HostResource host = hosts.get(n);
if ((logserver == null || host != logserver.getHostResource()) && !host.getHost().runsConfigServer()) {
Slobrok newSlobrok = new Slobrok(this, slobs.size());
addAndInitializeService(host, newSlobrok);
slobs.add(newSlobrok);
}
n++;
}
int j = 0;
for (Slobrok s : slobs) {
s.setProp("index", j);
j++;
}
return slobs;
}
use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.
the class DomAdminV4Builder method createSlobroks.
private void createSlobroks(Admin admin, Collection<HostResource> hosts) {
// No slobroks can be created (and none are needed)
if (hosts.isEmpty())
return;
List<Slobrok> slobroks = new ArrayList<>();
int index = 0;
for (HostResource host : hosts) {
Slobrok slobrok = new Slobrok(admin, index++);
slobrok.setHostResource(host);
slobroks.add(slobrok);
slobrok.initService();
}
admin.addSlobroks(slobroks);
}
use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.
the class DomAdminV4Builder method pickContainerHostsForSlobrok.
/**
* Returns a list of container hosts to use for an auxiliary cluster.
* The list returns the same nodes on each invocation given the same available nodes.
*
* @param count the desired number of nodes. More nodes may be returned to ensure a smooth transition
* on topology changes, and less nodes may be returned if fewer are available
* @param minHostsPerContainerCluster the desired number of hosts per cluster
*/
private List<HostResource> pickContainerHostsForSlobrok(int count, int minHostsPerContainerCluster) {
Collection<ContainerModel> containerModelsWithSlobrok = containerModels.stream().filter(this::shouldHaveSlobrok).collect(Collectors.toList());
int hostsPerCluster = (int) Math.max(minHostsPerContainerCluster, Math.ceil((double) count / containerModelsWithSlobrok.size()));
// Pick from all container clusters to make sure we don't lose all nodes at once if some clusters are removed.
// This will overshoot the desired size (due to ceil and picking at least one node per cluster).
List<HostResource> picked = new ArrayList<>();
for (ContainerModel containerModel : containerModelsWithSlobrok) picked.addAll(pickContainerHostsFrom(containerModel, hostsPerCluster));
return picked;
}
use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.
the class ContainerModelBuilder method createNodesFromHosts.
private List<Container> createNodesFromHosts(Map<HostResource, ClusterMembership> hosts, ContainerCluster cluster) {
List<Container> nodes = new ArrayList<>();
for (Map.Entry<HostResource, ClusterMembership> entry : hosts.entrySet()) {
String id = "container." + entry.getValue().index();
Container container = new Container(cluster, id, entry.getValue().retired(), entry.getValue().index());
container.setHostResource(entry.getKey());
container.initService();
nodes.add(container);
}
return nodes;
}
Aggregations