use of org.apache.bookkeeper.stream.storage.StorageResources in project bookkeeper by apache.
the class TestRangeStoreImpl method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
storageResources = StorageResources.create();
Endpoint endpoint = createEndpoint("127.0.0.1", 0);
// create the client manager
MVCCStoreFactory storeFactory = mock(MVCCStoreFactory.class);
MVCCAsyncStore<byte[], byte[]> store = mock(MVCCAsyncStore.class);
when(storeFactory.openStore(anyLong(), anyLong(), anyLong())).thenReturn(FutureUtils.value(store));
when(storeFactory.closeStores(anyLong())).thenReturn(FutureUtils.Void());
rangeStore = (RangeStoreImpl) RangeStoreBuilder.newBuilder().withStorageConfiguration(storageConf).withStorageResources(storageResources).withStorageContainerManagerFactory((numScs, storeConf, rgRegistry) -> new LocalStorageContainerManager(endpoint, storeConf, rgRegistry, 2)).withRangeStoreFactory(storeFactory).withDefaultBackendUri(URI.create("distributedlog://127.0.0.1/stream/storage")).build();
rangeStore.start();
}
use of org.apache.bookkeeper.stream.storage.StorageResources in project bookkeeper by apache.
the class StorageServer method startStorageServer.
public static LifecycleComponent startStorageServer(CompositeConfiguration conf, int grpcPort, int numStorageContainers, Optional<String> instanceName) throws ConfigurationException, UnknownHostException {
BookieConfiguration bkConf = BookieConfiguration.of(conf);
bkConf.validate();
DLConfiguration dlConf = DLConfiguration.of(conf);
dlConf.validate();
StorageServerConfiguration serverConf = StorageServerConfiguration.of(conf);
serverConf.validate();
StorageConfiguration storageConf = new StorageConfiguration(conf);
storageConf.validate();
// Get my local endpoint
Endpoint myEndpoint = createLocalEndpoint(grpcPort, false);
// Create shared resources
StorageResources storageResources = StorageResources.create();
// Create the stats provider
StatsProviderService statsProviderService = new StatsProviderService(bkConf);
StatsLogger rootStatsLogger = statsProviderService.getStatsProvider().getStatsLogger("");
// Create the bookie service
BookieService bookieService = new BookieService(bkConf, rootStatsLogger);
// Create the distributedlog namespace service
DLNamespaceProviderService dlNamespaceProvider = new DLNamespaceProviderService(bookieService.serverConf(), dlConf, rootStatsLogger.scope("dl"));
// Create range (stream) store
RangeStoreBuilder rangeStoreBuilder = RangeStoreBuilder.newBuilder().withStatsLogger(rootStatsLogger.scope("storage")).withStorageConfiguration(storageConf).withStorageResources(storageResources).withNumStorageContainers(numStorageContainers).withDefaultBackendUri(dlNamespaceProvider.getDlogUri()).withStorageContainerManagerFactory((ignored, storeConf, registry) -> new HelixStorageContainerManager(bookieService.serverConf().getZkServers(), "stream/helix", storeConf, registry, myEndpoint, instanceName, rootStatsLogger.scope("helix"))).withRangeStoreFactory(new MVCCStoreFactoryImpl(dlNamespaceProvider, storageConf.getRangeStoreDirs(), storageResources, storageConf.getServeReadOnlyTables()));
StorageService storageService = new StorageService(storageConf, rangeStoreBuilder, rootStatsLogger.scope("storage"));
// Create gRPC server
StatsLogger rpcStatsLogger = rootStatsLogger.scope("grpc");
GrpcServerSpec serverSpec = GrpcServerSpec.builder().storeSupplier(storageService).storeServerConf(serverConf).endpoint(myEndpoint).statsLogger(rpcStatsLogger).build();
GrpcService grpcService = new GrpcService(serverConf, serverSpec, rpcStatsLogger);
// Create all the service stack
return LifecycleComponentStack.newBuilder().withName("storage-server").addComponent(// stats provider
statsProviderService).addComponent(// bookie server
bookieService).addComponent(// service that provides dl namespace
dlNamespaceProvider).addComponent(// range (stream) store
storageService).addComponent(// range (stream) server (gRPC)
grpcService).build();
}
Aggregations