com.yahoo.vespa.hosted.provision.testutils.MockDuperModel 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 ai.vespa.http.DomainName;
import com.yahoo.component.annotation.Inject;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.service.monitor.DuperModelInfraApi;
import com.yahoo.vespa.service.monitor.InfraApplicationApi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author hakonhall
*/
public class MockDuperModel implements DuperModelInfraApi {
private final Map supportedInfraApps = new HashMap<>();
private final ConcurrentHashMap> activeApps = new ConcurrentHashMap<>();
@Inject
public MockDuperModel() {
}
public MockDuperModel support(InfraApplicationApi infraApplication) {
supportedInfraApps.put(infraApplication.getApplicationId(), infraApplication);
return this;
}
@Override
public List getSupportedInfraApplications() {
return new ArrayList<>(supportedInfraApps.values());
}
@Override
public Optional getInfraApplication(ApplicationId applicationId) {
return Optional.ofNullable(supportedInfraApps.get(applicationId));
}
@Override
public boolean infraApplicationIsActive(ApplicationId applicationId) {
return activeApps.containsKey(applicationId);
}
public List hostnamesOf(ApplicationId applicationId) {
return activeApps.getOrDefault(applicationId, List.of());
}
@Override
public void infraApplicationActivated(ApplicationId applicationId, List hostnames) {
activeApps.put(applicationId, hostnames);
}
@Override
public void infraApplicationRemoved(ApplicationId applicationId) {
activeApps.remove(applicationId);
}
@Override
public void infraApplicationsIsNowComplete() {
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy