Search in sources :

Example 1 with StatsProviderService

use of org.apache.bookkeeper.server.service.StatsProviderService in project bookkeeper by apache.

the class Main method buildBookieServer.

/**
 * Build the bookie server.
 *
 * <p>The sequence of the components is:
 *
 * <pre>
 * - stats provider
 * - bookie server
 * - autorecovery daemon
 * - http service
 * </pre>
 *
 * @param conf bookie server configuration
 * @return lifecycle stack
 */
static LifecycleComponentStack buildBookieServer(BookieConfiguration conf) throws Exception {
    LifecycleComponentStack.Builder serverBuilder = LifecycleComponentStack.newBuilder().withName("bookie-server");
    // 1. build stats provider
    StatsProviderService statsProviderService = new StatsProviderService(conf);
    StatsLogger rootStatsLogger = statsProviderService.getStatsProvider().getStatsLogger("");
    serverBuilder.addComponent(statsProviderService);
    log.info("Load lifecycle component : {}", StatsProviderService.class.getName());
    // 2. build bookie server
    BookieService bookieService = new BookieService(conf, rootStatsLogger);
    serverBuilder.addComponent(bookieService);
    log.info("Load lifecycle component : {}", BookieService.class.getName());
    // 3. build auto recovery
    if (conf.getServerConf().isAutoRecoveryDaemonEnabled()) {
        AutoRecoveryService autoRecoveryService = new AutoRecoveryService(conf, rootStatsLogger.scope(REPLICATION_SCOPE));
        serverBuilder.addComponent(autoRecoveryService);
        log.info("Load lifecycle component : {}", AutoRecoveryService.class.getName());
    }
    // 4. build http service
    if (conf.getServerConf().isHttpServerEnabled()) {
        BKHttpServiceProvider provider = new BKHttpServiceProvider.Builder().setBookieServer(bookieService.getServer()).setServerConfiguration(conf.getServerConf()).build();
        HttpService httpService = new HttpService(provider, conf, rootStatsLogger);
        serverBuilder.addComponent(httpService);
        log.info("Load lifecycle component : {}", HttpService.class.getName());
    }
    // 5. build extra services
    String[] extraComponents = conf.getServerConf().getExtraServerComponents();
    if (null != extraComponents) {
        List<ServerLifecycleComponent> components = loadServerComponents(extraComponents, conf, rootStatsLogger);
        for (ServerLifecycleComponent component : components) {
            serverBuilder.addComponent(component);
            log.info("Load lifecycle component : {}", component.getClass().getName());
        }
    }
    return serverBuilder.build();
}
Also used : StatsLogger(org.apache.bookkeeper.stats.StatsLogger) BKHttpServiceProvider(org.apache.bookkeeper.server.http.BKHttpServiceProvider) HttpService(org.apache.bookkeeper.server.service.HttpService) ServerLifecycleComponent(org.apache.bookkeeper.server.component.ServerLifecycleComponent) AutoRecoveryService(org.apache.bookkeeper.server.service.AutoRecoveryService) LifecycleComponentStack(org.apache.bookkeeper.common.component.LifecycleComponentStack) StatsProviderService(org.apache.bookkeeper.server.service.StatsProviderService) BookieService(org.apache.bookkeeper.server.service.BookieService)

Aggregations

LifecycleComponentStack (org.apache.bookkeeper.common.component.LifecycleComponentStack)1 ServerLifecycleComponent (org.apache.bookkeeper.server.component.ServerLifecycleComponent)1 BKHttpServiceProvider (org.apache.bookkeeper.server.http.BKHttpServiceProvider)1 AutoRecoveryService (org.apache.bookkeeper.server.service.AutoRecoveryService)1 BookieService (org.apache.bookkeeper.server.service.BookieService)1 HttpService (org.apache.bookkeeper.server.service.HttpService)1 StatsProviderService (org.apache.bookkeeper.server.service.StatsProviderService)1 StatsLogger (org.apache.bookkeeper.stats.StatsLogger)1