Search in sources :

Example 1 with HostRegistry

use of com.yahoo.vespa.config.server.host.HostRegistry in project vespa by vespa-engine.

the class SessionPreparerTest method require_no_warning_for_overlapping_host_for_same_appid.

@Test
public void require_no_warning_for_overlapping_host_for_same_appid() throws IOException {
    SessionContext ctx = getContext(getApplicationPackage(testApp));
    ((HostRegistry<ApplicationId>) ctx.getHostValidator()).update(applicationId("default"), Collections.singletonList("mytesthost"));
    final StringBuilder logged = new StringBuilder();
    DeployLogger logger = (level, message) -> {
        System.out.println(level + ": " + message);
        if (level.equals(LogLevel.WARNING) && message.contains("The host mytesthost is already in use"))
            logged.append("ok");
    };
    preparer.prepare(ctx, logger, new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now());
    assertEquals(logged.toString(), "");
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) java.util(java.util) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) ApplicationId(com.yahoo.config.provision.ApplicationId) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Slime(com.yahoo.slime.Slime) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) IOUtils(com.yahoo.io.IOUtils) InvalidApplicationException(com.yahoo.vespa.config.server.http.InvalidApplicationException) DeployLogger(com.yahoo.config.application.api.DeployLogger) TenantName(com.yahoo.config.provision.TenantName) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) Path(com.yahoo.path.Path) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) LogLevel(com.yahoo.log.LogLevel) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) Before(org.junit.Before) Rotation(com.yahoo.config.provision.Rotation) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction) ImmutableSet(com.google.common.collect.ImmutableSet) ModelContext(com.yahoo.config.model.api.ModelContext) MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) Test(org.junit.Test) IOException(java.io.IOException) Instant(java.time.Instant) com.yahoo.config.model.application.provider(com.yahoo.config.model.application.provider) File(java.io.File) RestartActions(com.yahoo.vespa.config.server.configchange.RestartActions) Rule(org.junit.Rule) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) Matchers.contains(org.hamcrest.Matchers.contains) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) SAXException(org.xml.sax.SAXException) ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) Version(com.yahoo.config.provision.Version) com.yahoo.vespa.config.server(com.yahoo.vespa.config.server) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) Assert(org.junit.Assert) TemporaryFolder(org.junit.rules.TemporaryFolder) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) DeployLogger(com.yahoo.config.application.api.DeployLogger) Test(org.junit.Test)

Example 2 with HostRegistry

use of com.yahoo.vespa.config.server.host.HostRegistry in project vespa by vespa-engine.

the class LocalSessionTest method createSession.

private LocalSession createSession(TenantName tenant, long sessionId, SessionTest.MockSessionPreparer preparer, Optional<AllocatedHosts> allocatedHosts) throws Exception {
    SessionZooKeeperClient zkc = new MockSessionZKClient(curator, tenant, sessionId, allocatedHosts);
    zkc.createWriteStatusTransaction(Session.Status.NEW).commit();
    ZooKeeperClient zkClient = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, Tenants.getSessionsPath(tenant).append(String.valueOf(sessionId)));
    if (allocatedHosts.isPresent()) {
        zkClient.write(allocatedHosts.get());
    }
    zkClient.write(Collections.singletonMap(Version.fromIntValues(0, 0, 0), new MockFileRegistry()));
    File sessionDir = new File(tenantFileSystemDirs.sessionsPath(), String.valueOf(sessionId));
    sessionDir.createNewFile();
    return new LocalSession(tenant, sessionId, preparer, new SessionContext(FilesApplicationPackage.fromFile(testApp), zkc, sessionDir, new MemoryTenantApplications(), new HostRegistry<>(), superModelGenerationCounter));
}
Also used : MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) ZooKeeperClient(com.yahoo.vespa.config.server.deploy.ZooKeeperClient) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) File(java.io.File)

Aggregations

MemoryTenantApplications (com.yahoo.vespa.config.server.application.MemoryTenantApplications)2 HostRegistry (com.yahoo.vespa.config.server.host.HostRegistry)2 File (java.io.File)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)1 DeployLogger (com.yahoo.config.application.api.DeployLogger)1 ConfigChangeAction (com.yahoo.config.model.api.ConfigChangeAction)1 ModelContext (com.yahoo.config.model.api.ModelContext)1 ModelCreateResult (com.yahoo.config.model.api.ModelCreateResult)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1 com.yahoo.config.model.application.provider (com.yahoo.config.model.application.provider)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ApplicationName (com.yahoo.config.provision.ApplicationName)1 InstanceName (com.yahoo.config.provision.InstanceName)1 Rotation (com.yahoo.config.provision.Rotation)1 TenantName (com.yahoo.config.provision.TenantName)1 Version (com.yahoo.config.provision.Version)1 IOUtils (com.yahoo.io.IOUtils)1 LogLevel (com.yahoo.log.LogLevel)1 Path (com.yahoo.path.Path)1