Search in sources :

Example 1 with BookieConfiguration

use of org.apache.bookkeeper.server.conf.BookieConfiguration in project bookkeeper by apache.

the class TestMain method testBuildBookieServer.

@Test
public void testBuildBookieServer() throws Exception {
    ServerConfiguration serverConf = new ServerConfiguration().setAutoRecoveryDaemonEnabled(false).setHttpServerEnabled(false).setExtraServerComponents(new String[] { TestComponent.class.getName() });
    BookieConfiguration conf = new BookieConfiguration(serverConf);
    BookieServer mockServer = PowerMockito.mock(BookieServer.class);
    whenNew(BookieServer.class).withArguments(any(ServerConfiguration.class), any(StatsLogger.class)).thenReturn(mockServer);
    LifecycleComponentStack stack = buildBookieServer(conf);
    assertEquals(3, stack.getNumComponents());
    assertTrue(stack.getComponent(2) instanceof TestComponent);
    stack.start();
    verify(mockServer, times(1)).start();
    stack.stop();
    stack.close();
    verify(mockServer, times(1)).shutdown();
}
Also used : ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieServer(org.apache.bookkeeper.proto.BookieServer) Main.buildBookieServer(org.apache.bookkeeper.server.Main.buildBookieServer) LifecycleComponentStack(org.apache.bookkeeper.common.component.LifecycleComponentStack) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with BookieConfiguration

use of org.apache.bookkeeper.server.conf.BookieConfiguration in project bookkeeper by apache.

the class TestServerLifecycleComponent method testLoadServerComponents.

@Test
public void testLoadServerComponents() throws Exception {
    BookieConfiguration conf = new BookieConfiguration(new ServerConfiguration());
    StatsLogger statsLogger = NullStatsLogger.INSTANCE;
    String[] clsNames = new String[] { TestComponent.class.getName(), TestComponent2.class.getName() };
    List<ServerLifecycleComponent> components = loadServerComponents(clsNames, conf, statsLogger);
    assertEquals(2, components.size());
    assertTrue(components.get(0) instanceof TestComponent);
    assertTrue(components.get(1) instanceof TestComponent2);
}
Also used : NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) Test(org.junit.Test)

Example 3 with BookieConfiguration

use of org.apache.bookkeeper.server.conf.BookieConfiguration in project bookkeeper by apache.

the class Main method doMain.

static int doMain(String[] args) {
    ServerConfiguration conf;
    // 0. parse command line
    try {
        conf = parseCommandLine(args);
    } catch (IllegalArgumentException iae) {
        return ExitCode.INVALID_CONF;
    }
    // 1. building the component stack:
    LifecycleComponent server;
    try {
        server = buildBookieServer(new BookieConfiguration(conf));
    } catch (Exception e) {
        log.error("Failed to build bookie server", e);
        return ExitCode.SERVER_EXCEPTION;
    }
    // 2. start the server
    try {
        ComponentStarter.startComponent(server).get();
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
        // the server is interrupted
        log.info("Bookie server is interrupted. Exiting ...");
    } catch (ExecutionException ee) {
        log.error("Error in bookie shutdown", ee.getCause());
        return ExitCode.SERVER_EXCEPTION;
    }
    return ExitCode.OK;
}
Also used : ServerLifecycleComponent(org.apache.bookkeeper.server.component.ServerLifecycleComponent) LifecycleComponent(org.apache.bookkeeper.common.component.LifecycleComponent) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) ExecutionException(java.util.concurrent.ExecutionException) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) MalformedURLException(java.net.MalformedURLException) ExecutionException(java.util.concurrent.ExecutionException) ParseException(org.apache.commons.cli.ParseException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 4 with BookieConfiguration

use of org.apache.bookkeeper.server.conf.BookieConfiguration in project bookkeeper by apache.

the class TestServerLifecycleComponent method testNewComponent.

@Test
public void testNewComponent() throws Exception {
    BookieConfiguration conf = new BookieConfiguration(new ServerConfiguration());
    StatsLogger statsLogger = NullStatsLogger.INSTANCE;
    ServerLifecycleComponent component = newComponent(TestComponent.class, conf, statsLogger);
    assertEquals("test-component", component.getName());
    assertEquals(conf, component.getConf());
}
Also used : NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) Test(org.junit.Test)

Aggregations

ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)4 BookieConfiguration (org.apache.bookkeeper.server.conf.BookieConfiguration)4 Test (org.junit.Test)3 NullStatsLogger (org.apache.bookkeeper.stats.NullStatsLogger)2 StatsLogger (org.apache.bookkeeper.stats.StatsLogger)2 MalformedURLException (java.net.MalformedURLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 LifecycleComponent (org.apache.bookkeeper.common.component.LifecycleComponent)1 LifecycleComponentStack (org.apache.bookkeeper.common.component.LifecycleComponentStack)1 BookieServer (org.apache.bookkeeper.proto.BookieServer)1 Main.buildBookieServer (org.apache.bookkeeper.server.Main.buildBookieServer)1 ServerLifecycleComponent (org.apache.bookkeeper.server.component.ServerLifecycleComponent)1 ParseException (org.apache.commons.cli.ParseException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1