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();
}
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);
}
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;
}
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());
}
Aggregations