Search in sources :

Example 1 with ServerProvider

use of com.yahoo.jdisc.service.ServerProvider in project vespa by vespa-engine.

the class ConfiguredApplication method startAndStopServers.

private static void startAndStopServers() {
    List<ServerProvider> currentServers = Container.get().getServerProviderRegistry().allComponents();
    HashSet<ServerProvider> serversToClose = new HashSet<>(startedServers);
    serversToClose.removeAll(currentServers);
    for (ServerProvider server : serversToClose) {
        closeServer(server);
    }
    for (ServerProvider server : currentServers) {
        if (!startedServers.contains(server)) {
            server.start();
            startedServers.add(server);
        }
    }
}
Also used : ServerProvider(com.yahoo.jdisc.service.ServerProvider) HashSet(java.util.HashSet)

Example 2 with ServerProvider

use of com.yahoo.jdisc.service.ServerProvider in project vespa by vespa-engine.

the class ConfiguredApplication method stop.

@Override
public void stop() {
    startShutdownDeadlineExecutor();
    shutdownReconfigurerThread();
    configurer.shutdown(new Deconstructor(false));
    for (ServerProvider server : Container.get().getServerProviderRegistry().allComponents()) {
        if (startedServers.contains(server)) {
            closeServer(server);
        }
    }
    Container.get().shutdown();
}
Also used : ServerProvider(com.yahoo.jdisc.service.ServerProvider) Deconstructor(com.yahoo.container.jdisc.component.Deconstructor)

Example 3 with ServerProvider

use of com.yahoo.jdisc.service.ServerProvider in project vespa by vespa-engine.

the class ServerRepository method install.

public ServerProvider install(Bundle bundle, String serverName) throws ClassNotFoundException {
    log.finer("Installing server provider '" + serverName + "'.");
    Class<?> namedClass = bundle.loadClass(serverName);
    Class<ServerProvider> serverClass = ContainerBuilder.safeClassCast(ServerProvider.class, namedClass);
    ServerProvider server = guice.getInstance(serverClass);
    install(server);
    return server;
}
Also used : ServerProvider(com.yahoo.jdisc.service.ServerProvider)

Example 4 with ServerProvider

use of com.yahoo.jdisc.service.ServerProvider in project vespa by vespa-engine.

the class ActiveContainerTestCase method requireThatServerAccessorWorks.

@Test
public void requireThatServerAccessorWorks() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    ServerProvider foo = new NonWorkingServerProvider();
    builder.serverProviders().install(foo);
    ServerProvider bar = new NonWorkingServerProvider();
    builder.serverProviders().install(bar);
    ActiveContainer container = new ActiveContainer(builder);
    Iterator<ServerProvider> it = container.serverProviders().iterator();
    assertTrue(it.hasNext());
    assertSame(foo, it.next());
    assertTrue(it.hasNext());
    assertSame(bar, it.next());
    assertFalse(it.hasNext());
    driver.close();
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) NonWorkingServerProvider(com.yahoo.jdisc.test.NonWorkingServerProvider) ServerProvider(com.yahoo.jdisc.service.ServerProvider) NonWorkingServerProvider(com.yahoo.jdisc.test.NonWorkingServerProvider) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 5 with ServerProvider

use of com.yahoo.jdisc.service.ServerProvider in project vespa by vespa-engine.

the class ServerRepositoryTestCase method requireThatUninstallAllWorks.

@Test
public void requireThatUninstallAllWorks() {
    ServerRepository servers = newServerRepository();
    ServerProvider foo = new MyServer();
    ServerProvider bar = new MyServer();
    ServerProvider baz = new MyServer();
    servers.installAll(Arrays.asList(foo, bar, baz));
    servers.uninstallAll(Arrays.asList(foo, bar));
    Iterator<ServerProvider> it = servers.iterator();
    assertNotNull(it);
    assertTrue(it.hasNext());
    assertSame(baz, it.next());
    assertFalse(it.hasNext());
}
Also used : ServerProvider(com.yahoo.jdisc.service.ServerProvider) Test(org.junit.Test)

Aggregations

ServerProvider (com.yahoo.jdisc.service.ServerProvider)13 Test (org.junit.Test)10 TestDriver (com.yahoo.jdisc.test.TestDriver)3 Bundle (org.osgi.framework.Bundle)2 Deconstructor (com.yahoo.container.jdisc.component.Deconstructor)1 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)1 NonWorkingServerProvider (com.yahoo.jdisc.test.NonWorkingServerProvider)1 HashSet (java.util.HashSet)1