Search in sources :

Example 1 with StreamStorageLifecycleComponent

use of org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent in project pulsar by apache.

the class LocalBookkeeperEnsemble method runStreamStorage.

public void runStreamStorage(CompositeConfiguration conf) throws Exception {
    String zkServers = "127.0.0.1:" + zkPort;
    String metadataServiceUriStr = "zk://" + zkServers + "/ledgers";
    URI metadataServiceUri = URI.create(metadataServiceUriStr);
    // zookeeper servers
    conf.setProperty("metadataServiceUri", metadataServiceUriStr);
    // dlog settings
    conf.setProperty("dlog.bkcEnsembleSize", 1);
    conf.setProperty("dlog.bkcWriteQuorumSize", 1);
    conf.setProperty("dlog.bkcAckQuorumSize", 1);
    // stream storage port
    conf.setProperty("storageserver.grpc.port", streamStoragePort);
    // storage server settings
    conf.setProperty("storage.range.store.dirs", bkDataDirName + "/ranges/data");
    // initialize the stream storage metadata
    ClusterInitializer initializer = new ZkClusterInitializer(zkServers);
    initializer.initializeCluster(metadataServiceUri, 2);
    // load the stream storage component
    ServerConfiguration serverConf = new ServerConfiguration();
    serverConf.loadConf(conf);
    BookieConfiguration bkConf = new BookieConfiguration(serverConf);
    this.streamStorage = new StreamStorageLifecycleComponent(bkConf, NullStatsLogger.INSTANCE);
    this.streamStorage.start();
    LOG.debug("Local BK stream storage started (port: {})", streamStoragePort);
    // create a default namespace
    try (StorageAdminClient admin = StorageClientBuilder.newBuilder().withSettings(StorageClientSettings.newBuilder().serviceUri("bk://localhost:4181").backoffPolicy(Backoff.Jitter.of(Type.EXPONENTIAL, 1000, 10000, 30)).build()).buildAdmin()) {
        try {
            NamespaceProperties ns = FutureUtils.result(admin.getNamespace("default"));
            LOG.info("'default' namespace for table service : {}", ns);
        } catch (NamespaceNotFoundException nnfe) {
            LOG.info("Creating default namespace");
            try {
                NamespaceProperties ns = FutureUtils.result(admin.createNamespace("default", NamespaceConfiguration.newBuilder().setDefaultStreamConf(DEFAULT_STREAM_CONF).build()));
                LOG.info("Successfully created 'default' namespace :\n{}", ns);
            } catch (NamespaceExistsException nee) {
                // namespace already exists
                LOG.warn("Namespace 'default' already existed.");
            }
        }
    }
}
Also used : StreamStorageLifecycleComponent(org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent) NamespaceProperties(org.apache.bookkeeper.stream.proto.NamespaceProperties) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) StorageAdminClient(org.apache.bookkeeper.clients.admin.StorageAdminClient) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) URI(java.net.URI) NamespaceExistsException(org.apache.bookkeeper.clients.exceptions.NamespaceExistsException) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) ClusterInitializer(org.apache.bookkeeper.stream.storage.api.cluster.ClusterInitializer) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) NamespaceNotFoundException(org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)

Example 2 with StreamStorageLifecycleComponent

use of org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent in project incubator-pulsar by apache.

the class LocalBookkeeperEnsemble method runStreamStorage.

public void runStreamStorage(CompositeConfiguration conf) throws Exception {
    String zkServers = "127.0.0.1:" + zkPort;
    String metadataServiceUriStr = "zk://" + zkServers + "/ledgers";
    URI metadataServiceUri = URI.create(metadataServiceUriStr);
    // zookeeper servers
    conf.setProperty("metadataServiceUri", metadataServiceUriStr);
    // dlog settings
    conf.setProperty("dlog.bkcEnsembleSize", 1);
    conf.setProperty("dlog.bkcWriteQuorumSize", 1);
    conf.setProperty("dlog.bkcAckQuorumSize", 1);
    // stream storage port
    conf.setProperty("storageserver.grpc.port", streamStoragePort);
    // storage server settings
    conf.setProperty("storage.range.store.dirs", bkDataDirName + "/ranges/data");
    // initialize the stream storage metadata
    ClusterInitializer initializer = new ZkClusterInitializer(zkServers);
    initializer.initializeCluster(metadataServiceUri, 2);
    // load the stream storage component
    ServerConfiguration serverConf = new ServerConfiguration();
    serverConf.loadConf(conf);
    BookieConfiguration bkConf = new BookieConfiguration(serverConf);
    this.streamStorage = new StreamStorageLifecycleComponent(bkConf, NullStatsLogger.INSTANCE);
    this.streamStorage.start();
    LOG.debug("Local BK stream storage started (port: {})", streamStoragePort);
    // create a default namespace
    try (StorageAdminClient admin = StorageClientBuilder.newBuilder().withSettings(StorageClientSettings.newBuilder().serviceUri("bk://localhost:4181").backoffPolicy(Backoff.Jitter.of(Type.EXPONENTIAL, 1000, 10000, 30)).build()).buildAdmin()) {
        try {
            NamespaceProperties ns = FutureUtils.result(admin.getNamespace("default"));
            LOG.info("'default' namespace for table service : {}", ns);
        } catch (NamespaceNotFoundException nnfe) {
            LOG.info("Creating default namespace");
            try {
                NamespaceProperties ns = FutureUtils.result(admin.createNamespace("default", NamespaceConfiguration.newBuilder().setDefaultStreamConf(DEFAULT_STREAM_CONF).build()));
                LOG.info("Successfully created 'default' namespace :\n{}", ns);
            } catch (NamespaceExistsException nee) {
                // namespace already exists
                LOG.warn("Namespace 'default' already existed.");
            }
        }
    }
}
Also used : StreamStorageLifecycleComponent(org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent) NamespaceProperties(org.apache.bookkeeper.stream.proto.NamespaceProperties) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) StorageAdminClient(org.apache.bookkeeper.clients.admin.StorageAdminClient) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) URI(java.net.URI) NamespaceExistsException(org.apache.bookkeeper.clients.exceptions.NamespaceExistsException) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) ClusterInitializer(org.apache.bookkeeper.stream.storage.api.cluster.ClusterInitializer) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) NamespaceNotFoundException(org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)

Example 3 with StreamStorageLifecycleComponent

use of org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent in project pulsar by yahoo.

the class LocalBookkeeperEnsemble method runStreamStorage.

public void runStreamStorage(CompositeConfiguration conf) throws Exception {
    String zkServers = "127.0.0.1:" + zkPort;
    String metadataServiceUriStr = "zk://" + zkServers + "/ledgers";
    URI metadataServiceUri = URI.create(metadataServiceUriStr);
    // zookeeper servers
    conf.setProperty("metadataServiceUri", metadataServiceUriStr);
    // dlog settings
    conf.setProperty("dlog.bkcEnsembleSize", 1);
    conf.setProperty("dlog.bkcWriteQuorumSize", 1);
    conf.setProperty("dlog.bkcAckQuorumSize", 1);
    // stream storage port
    conf.setProperty("storageserver.grpc.port", streamStoragePort);
    // storage server settings
    conf.setProperty("storage.range.store.dirs", bkDataDirName + "/ranges/data");
    // initialize the stream storage metadata
    ClusterInitializer initializer = new ZkClusterInitializer(zkServers);
    initializer.initializeCluster(metadataServiceUri, 2);
    // load the stream storage component
    ServerConfiguration serverConf = new ServerConfiguration();
    serverConf.loadConf(conf);
    BookieConfiguration bkConf = new BookieConfiguration(serverConf);
    this.streamStorage = new StreamStorageLifecycleComponent(bkConf, NullStatsLogger.INSTANCE);
    this.streamStorage.start();
    LOG.debug("Local BK stream storage started (port: {})", streamStoragePort);
    // create a default namespace
    try (StorageAdminClient admin = StorageClientBuilder.newBuilder().withSettings(StorageClientSettings.newBuilder().serviceUri("bk://localhost:4181").backoffPolicy(Backoff.Jitter.of(Type.EXPONENTIAL, 1000, 10000, 30)).build()).buildAdmin()) {
        try {
            NamespaceProperties ns = FutureUtils.result(admin.getNamespace("default"));
            LOG.info("'default' namespace for table service : {}", ns);
        } catch (NamespaceNotFoundException nnfe) {
            LOG.info("Creating default namespace");
            try {
                NamespaceProperties ns = FutureUtils.result(admin.createNamespace("default", NamespaceConfiguration.newBuilder().setDefaultStreamConf(DEFAULT_STREAM_CONF).build()));
                LOG.info("Successfully created 'default' namespace :\n{}", ns);
            } catch (NamespaceExistsException nee) {
                // namespace already exists
                LOG.warn("Namespace 'default' already existed.");
            }
        }
    }
}
Also used : StreamStorageLifecycleComponent(org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent) NamespaceProperties(org.apache.bookkeeper.stream.proto.NamespaceProperties) ServerConfiguration(org.apache.bookkeeper.conf.ServerConfiguration) StorageAdminClient(org.apache.bookkeeper.clients.admin.StorageAdminClient) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) URI(java.net.URI) NamespaceExistsException(org.apache.bookkeeper.clients.exceptions.NamespaceExistsException) ZkClusterInitializer(org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer) ClusterInitializer(org.apache.bookkeeper.stream.storage.api.cluster.ClusterInitializer) BookieConfiguration(org.apache.bookkeeper.server.conf.BookieConfiguration) NamespaceNotFoundException(org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)

Aggregations

URI (java.net.URI)3 StorageAdminClient (org.apache.bookkeeper.clients.admin.StorageAdminClient)3 NamespaceExistsException (org.apache.bookkeeper.clients.exceptions.NamespaceExistsException)3 NamespaceNotFoundException (org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)3 ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)3 BookieConfiguration (org.apache.bookkeeper.server.conf.BookieConfiguration)3 NamespaceProperties (org.apache.bookkeeper.stream.proto.NamespaceProperties)3 StreamStorageLifecycleComponent (org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent)3 ClusterInitializer (org.apache.bookkeeper.stream.storage.api.cluster.ClusterInitializer)3 ZkClusterInitializer (org.apache.bookkeeper.stream.storage.impl.cluster.ZkClusterInitializer)3