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.");
}
}
}
}
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.");
}
}
}
}
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.");
}
}
}
}
Aggregations