RaulGracia commented on code in PR #3489: URL: https://github.com/apache/bookkeeper/pull/3489#discussion_r970875276
########## bookkeeper-server/src/main/java/org/apache/bookkeeper/server/EmbeddedServer.java: ########## @@ -0,0 +1,636 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.bookkeeper.server; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.apache.bookkeeper.bookie.BookKeeperServerStats.BOOKIE_SCOPE; +import static org.apache.bookkeeper.bookie.BookKeeperServerStats.LD_INDEX_SCOPE; +import static org.apache.bookkeeper.bookie.BookKeeperServerStats.LD_LEDGER_SCOPE; +import static org.apache.bookkeeper.client.BookKeeperClientStats.CLIENT_SCOPE; +import static org.apache.bookkeeper.replication.ReplicationStats.REPLICATION_SCOPE; +import static org.apache.bookkeeper.server.Main.storageDirectoriesFromConf; +import static org.apache.bookkeeper.server.component.ServerLifecycleComponent.loadServerComponents; + +import com.google.common.base.Ticker; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import io.netty.buffer.CompositeByteBuf; +import io.reactivex.rxjava3.core.Scheduler; +import io.reactivex.rxjava3.schedulers.Schedulers; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import org.apache.bookkeeper.bookie.Bookie; +import org.apache.bookkeeper.bookie.BookieImpl; +import org.apache.bookkeeper.bookie.BookieResources; +import org.apache.bookkeeper.bookie.CookieValidation; +import org.apache.bookkeeper.bookie.LedgerDirsManager; +import org.apache.bookkeeper.bookie.LedgerStorage; +import org.apache.bookkeeper.bookie.LegacyCookieValidation; +import org.apache.bookkeeper.bookie.ReadOnlyBookie; +import org.apache.bookkeeper.bookie.ScrubberStats; +import org.apache.bookkeeper.bookie.UncleanShutdownDetection; +import org.apache.bookkeeper.bookie.UncleanShutdownDetectionImpl; +import org.apache.bookkeeper.bookie.datainteg.DataIntegrityCheck; +import org.apache.bookkeeper.bookie.datainteg.DataIntegrityCheckImpl; +import org.apache.bookkeeper.bookie.datainteg.DataIntegrityCookieValidation; +import org.apache.bookkeeper.bookie.datainteg.DataIntegrityService; +import org.apache.bookkeeper.bookie.datainteg.EntryCopier; +import org.apache.bookkeeper.bookie.datainteg.EntryCopierImpl; +import org.apache.bookkeeper.client.BookKeeper; +import org.apache.bookkeeper.client.BookKeeperAdmin; +import org.apache.bookkeeper.common.allocator.ByteBufAllocatorWithOomHandler; +import org.apache.bookkeeper.common.component.AutoCloseableLifecycleComponent; +import org.apache.bookkeeper.common.component.ComponentInfoPublisher; +import org.apache.bookkeeper.common.component.LifecycleComponentStack; +import org.apache.bookkeeper.common.component.RxSchedulerLifecycleComponent; +import org.apache.bookkeeper.conf.ClientConfiguration; +import org.apache.bookkeeper.discover.BookieServiceInfo; +import org.apache.bookkeeper.discover.RegistrationManager; +import org.apache.bookkeeper.meta.LedgerManager; +import org.apache.bookkeeper.meta.LedgerManagerFactory; +import org.apache.bookkeeper.meta.MetadataBookieDriver; +import org.apache.bookkeeper.net.BookieId; +import org.apache.bookkeeper.server.component.ServerLifecycleComponent; +import org.apache.bookkeeper.server.conf.BookieConfiguration; +import org.apache.bookkeeper.server.http.BKHttpServiceProvider; +import org.apache.bookkeeper.server.service.AutoRecoveryService; +import org.apache.bookkeeper.server.service.BookieService; +import org.apache.bookkeeper.server.service.HttpService; +import org.apache.bookkeeper.server.service.ScrubberService; +import org.apache.bookkeeper.server.service.StatsProviderService; +import org.apache.bookkeeper.stats.StatsLogger; +import org.apache.bookkeeper.stats.StatsProvider; +import org.apache.bookkeeper.util.DiskChecker; +import org.apache.commons.lang3.StringUtils; + +/** + * An embedded server is a server that run bookie and serving rpc requests. + * + * <p> + * It is a rewritten server using {@link org.apache.bookkeeper.common.component.LifecycleComponent}, replacing the + * legacy server {@link org.apache.bookkeeper.proto.BookieServer}. + */ +public class EmbeddedServer { Review Comment: If I understand correctly, this is embedding the Bookie server and resources, right? So it can be used both in tests or when running a real Bookie. I think that I'm in favor of this approach, mainly because it facilitates testing to other projects using Bookkeeper. For instance, in this PR I had to do some gymnastics to instantiate test Bookies when upgrading to Bookkeeper 4.15 in Pravega: https://github.com/pravega/pravega/pull/6676 My understanding is that, with this change, just instantiating a new `EmbeddedServer` (maybe the name of the class could be discussed) with the right configuration, the external code should not care about the resources of the Bookie itself, right? If this is the case, I think that it is an improvement in usability. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
