Search in sources :

Example 6 with Endpoint

use of org.apache.bookkeeper.stream.proto.common.Endpoint in project bookkeeper by apache.

the class TestNetUtils method testParseEndpoint.

@Test
public void testParseEndpoint() {
    String endpointStr = "10.138.10.56:12345";
    Endpoint endpoint = parseEndpoint(endpointStr);
    assertEquals("10.138.10.56", endpoint.getHostname());
    assertEquals(12345, endpoint.getPort());
}
Also used : Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) NetUtils.parseEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.parseEndpoint) NetUtils.createEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.createEndpoint) Test(org.junit.Test)

Example 7 with Endpoint

use of org.apache.bookkeeper.stream.proto.common.Endpoint in project bookkeeper by apache.

the class StreamCluster method createDefaultNamespaces.

private void createDefaultNamespaces() throws Exception {
    StorageClientSettings settings = StorageClientSettings.newBuilder().addEndpoints(getRpcEndpoints().toArray(new Endpoint[getRpcEndpoints().size()])).usePlaintext(true).build();
    log.info("RpcEndpoints are : {}", settings.endpoints());
    String namespaceName = "default";
    try (StorageAdminClient admin = StorageClientBuilder.newBuilder().withSettings(settings).buildAdmin()) {
        System.out.println("Creating namespace '" + namespaceName + "' ...");
        try {
            NamespaceProperties nsProps = result(admin.createNamespace(namespaceName, NamespaceConfiguration.newBuilder().setDefaultStreamConf(DEFAULT_STREAM_CONF).build()));
            System.out.println("Successfully created namespace '" + namespaceName + "':");
            System.out.println(nsProps);
        } catch (NamespaceExistsException nee) {
            System.out.println("Namespace '" + namespaceName + "' already exists.");
        }
    }
}
Also used : StorageClientSettings(org.apache.bookkeeper.clients.config.StorageClientSettings) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) NamespaceProperties(org.apache.bookkeeper.stream.proto.NamespaceProperties) StorageAdminClient(org.apache.bookkeeper.clients.admin.StorageAdminClient) NamespaceExistsException(org.apache.bookkeeper.clients.exceptions.NamespaceExistsException)

Example 8 with Endpoint

use of org.apache.bookkeeper.stream.proto.common.Endpoint 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();
}
Also used : ComponentStarter(org.apache.bookkeeper.common.component.ComponentStarter) Configuration(org.apache.commons.configuration.Configuration) DLNamespaceProviderService(org.apache.bookkeeper.stream.server.service.DLNamespaceProviderService) Parameter(com.beust.jcommander.Parameter) CompletableFuture(java.util.concurrent.CompletableFuture) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) InetAddress(java.net.InetAddress) GrpcServerSpec(org.apache.bookkeeper.stream.server.grpc.GrpcServerSpec) LifecycleComponentStack(org.apache.bookkeeper.common.component.LifecycleComponentStack) StorageServerConfiguration(org.apache.bookkeeper.stream.server.conf.StorageServerConfiguration) RangeStoreBuilder(org.apache.bookkeeper.stream.storage.RangeStoreBuilder) HelixStorageContainerManager(org.apache.bookkeeper.stream.storage.impl.sc.helix.HelixStorageContainerManager) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) StatsProviderService(org.apache.bookkeeper.stream.server.service.StatsProviderService) LifecycleComponent(org.apache.bookkeeper.common.component.LifecycleComponent) MalformedURLException(java.net.MalformedURLException) JCommander(com.beust.jcommander.JCommander) StorageResources(org.apache.bookkeeper.stream.storage.StorageResources) StorageService(org.apache.bookkeeper.stream.server.service.StorageService) BookieService(org.apache.bookkeeper.stream.server.service.BookieService) UnknownHostException(java.net.UnknownHostException) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) BookieConfiguration(org.apache.bookkeeper.stream.server.conf.BookieConfiguration) Slf4j(lombok.extern.slf4j.Slf4j) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) StorageConfiguration(org.apache.bookkeeper.stream.storage.conf.StorageConfiguration) DLConfiguration(org.apache.bookkeeper.stream.server.conf.DLConfiguration) GrpcService(org.apache.bookkeeper.stream.server.service.GrpcService) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) MVCCStoreFactoryImpl(org.apache.bookkeeper.stream.storage.impl.store.MVCCStoreFactoryImpl) Optional(java.util.Optional) ConfigurationException(org.apache.commons.configuration.ConfigurationException) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) StorageConfiguration(org.apache.bookkeeper.stream.storage.conf.StorageConfiguration) StorageResources(org.apache.bookkeeper.stream.storage.StorageResources) HelixStorageContainerManager(org.apache.bookkeeper.stream.storage.impl.sc.helix.HelixStorageContainerManager) BookieConfiguration(org.apache.bookkeeper.stream.server.conf.BookieConfiguration) StorageService(org.apache.bookkeeper.stream.server.service.StorageService) MVCCStoreFactoryImpl(org.apache.bookkeeper.stream.storage.impl.store.MVCCStoreFactoryImpl) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) GrpcService(org.apache.bookkeeper.stream.server.service.GrpcService) DLNamespaceProviderService(org.apache.bookkeeper.stream.server.service.DLNamespaceProviderService) RangeStoreBuilder(org.apache.bookkeeper.stream.storage.RangeStoreBuilder) StorageServerConfiguration(org.apache.bookkeeper.stream.server.conf.StorageServerConfiguration) DLConfiguration(org.apache.bookkeeper.stream.server.conf.DLConfiguration) StatsProviderService(org.apache.bookkeeper.stream.server.service.StatsProviderService) GrpcServerSpec(org.apache.bookkeeper.stream.server.grpc.GrpcServerSpec) BookieService(org.apache.bookkeeper.stream.server.service.BookieService)

Example 9 with Endpoint

use of org.apache.bookkeeper.stream.proto.common.Endpoint in project bookkeeper by apache.

the class GrpcStorageContainerService method getStorageContainerEndpoint.

@Override
public void getStorageContainerEndpoint(GetStorageContainerEndpointRequest request, StreamObserver<GetStorageContainerEndpointResponse> responseObserver) {
    GetStorageContainerEndpointResponse.Builder responseBuilder = GetStorageContainerEndpointResponse.newBuilder().setStatusCode(StatusCode.SUCCESS);
    for (int i = 0; i < request.getRequestsCount(); i++) {
        Endpoint endpoint = rangeStore.getRoutingService().getStorageContainer(request.getRequests(i).getStorageContainer());
        OneStorageContainerEndpointResponse.Builder oneRespBuilder;
        if (null != endpoint) {
            oneRespBuilder = OneStorageContainerEndpointResponse.newBuilder().setStatusCode(StatusCode.SUCCESS).setEndpoint(StorageContainerEndpoint.newBuilder().setRwEndpoint(endpoint).addRoEndpoint(endpoint).setRevision(0L));
        } else {
            oneRespBuilder = OneStorageContainerEndpointResponse.newBuilder().setStatusCode(StatusCode.INTERNAL_SERVER_ERROR);
        }
        responseBuilder = responseBuilder.addResponses(oneRespBuilder);
    }
    responseObserver.onNext(responseBuilder.build());
    responseObserver.onCompleted();
}
Also used : Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) StorageContainerEndpoint(org.apache.bookkeeper.stream.proto.storage.StorageContainerEndpoint) GetStorageContainerEndpointResponse(org.apache.bookkeeper.stream.proto.storage.GetStorageContainerEndpointResponse) OneStorageContainerEndpointResponse(org.apache.bookkeeper.stream.proto.storage.OneStorageContainerEndpointResponse) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) StorageContainerEndpoint(org.apache.bookkeeper.stream.proto.storage.StorageContainerEndpoint)

Example 10 with Endpoint

use of org.apache.bookkeeper.stream.proto.common.Endpoint in project bookkeeper by apache.

the class TestNetUtils method testCreateEndpoint.

@Test
public void testCreateEndpoint() {
    String hostname = "10.138.10.56";
    int port = 12345;
    Endpoint endpoint = createEndpoint(hostname, port);
    assertEquals(hostname, endpoint.getHostname());
    assertEquals(port, endpoint.getPort());
}
Also used : Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) NetUtils.parseEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.parseEndpoint) NetUtils.createEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.createEndpoint) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint) NetUtils.parseEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.parseEndpoint) NetUtils.createEndpoint(org.apache.bookkeeper.clients.utils.NetUtils.createEndpoint) Test(org.junit.Test)

Aggregations

Endpoint (org.apache.bookkeeper.stream.proto.common.Endpoint)20 Test (org.junit.Test)8 StorageClientSettings (org.apache.bookkeeper.clients.config.StorageClientSettings)7 NetUtils.createEndpoint (org.apache.bookkeeper.clients.utils.NetUtils.createEndpoint)3 NetUtils.parseEndpoint (org.apache.bookkeeper.clients.utils.NetUtils.parseEndpoint)3 OneStorageContainerEndpointResponse (org.apache.bookkeeper.stream.proto.storage.OneStorageContainerEndpointResponse)3 StorageConfiguration (org.apache.bookkeeper.stream.storage.conf.StorageConfiguration)3 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)3 JCommander (com.beust.jcommander.JCommander)2 Optional (java.util.Optional)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 Slf4j (lombok.extern.slf4j.Slf4j)2 StorageServerChannel (org.apache.bookkeeper.clients.impl.channel.StorageServerChannel)2 StorageContainerEndpoint (org.apache.bookkeeper.stream.proto.storage.StorageContainerEndpoint)2 RangeStoreBuilder (org.apache.bookkeeper.stream.storage.RangeStoreBuilder)2 StorageResources (org.apache.bookkeeper.stream.storage.StorageResources)2 Parameter (com.beust.jcommander.Parameter)1 ByteString (com.google.protobuf.ByteString)1 Server (io.grpc.Server)1