use of org.apache.bookkeeper.clients.config.StorageClientSettings in project bookkeeper by apache.
the class TableClientSimpleTest method doSetup.
@Override
protected void doSetup() throws Exception {
defaultBackendUri = URI.create("distributedlog://" + cluster.getZkServers() + "/stream/storage");
scheduler = OrderedScheduler.newSchedulerBuilder().name("table-client-test").numThreads(1).build();
StorageClientSettings settings = StorageClientSettings.newBuilder().addEndpoints(cluster.getRpcEndpoints().toArray(new Endpoint[cluster.getRpcEndpoints().size()])).usePlaintext(true).build();
String namespace = "test_namespace";
adminClient = StorageClientBuilder.newBuilder().withSettings(settings).buildAdmin();
storageClient = StorageClientBuilder.newBuilder().withSettings(settings).withNamespace(namespace).build();
}
use of org.apache.bookkeeper.clients.config.StorageClientSettings in project bookkeeper by apache.
the class TableClientTest method doSetup.
@Override
protected void doSetup() throws Exception {
defaultBackendUri = URI.create("distributedlog://" + cluster.getZkServers() + "/stream/storage");
scheduler = OrderedScheduler.newSchedulerBuilder().name("table-client-test").numThreads(1).build();
StorageClientSettings settings = StorageClientSettings.newBuilder().addEndpoints(cluster.getRpcEndpoints().toArray(new Endpoint[cluster.getRpcEndpoints().size()])).usePlaintext(true).build();
String namespace = "test_namespace";
adminClient = StorageClientBuilder.newBuilder().withSettings(settings).buildAdmin();
storageClient = StorageClientBuilder.newBuilder().withSettings(settings).withNamespace(namespace).build();
}
use of org.apache.bookkeeper.clients.config.StorageClientSettings in project incubator-pulsar by apache.
the class JavaInstanceRunnable method setupStateTable.
private void setupStateTable() throws Exception {
if (null == stateStorageServiceUrl) {
return;
}
String tableNs = String.format("%s_%s", instanceConfig.getFunctionConfig().getTenant(), instanceConfig.getFunctionConfig().getNamespace()).replace('-', '_');
String tableName = instanceConfig.getFunctionConfig().getName();
// TODO (sijie): use endpoint for now
StorageClientSettings settings = StorageClientSettings.newBuilder().addEndpoints(NetUtils.parseEndpoint(stateStorageServiceUrl)).clientName("function-" + tableNs + "/" + tableName).build();
// TODO (sijie): provide a better way to provision the state table for functions
try (StorageAdminClient storageAdminClient = StorageClientBuilder.newBuilder().withSettings(settings).buildAdmin()) {
try {
result(storageAdminClient.getStream(tableNs, tableName));
} catch (NamespaceNotFoundException nnfe) {
result(storageAdminClient.createNamespace(tableNs, NamespaceConfiguration.newBuilder().setDefaultStreamConf(DEFAULT_STREAM_CONF).build()));
result(storageAdminClient.createStream(tableNs, tableName, DEFAULT_STREAM_CONF));
} catch (StreamNotFoundException snfe) {
result(storageAdminClient.createStream(tableNs, tableName, DEFAULT_STREAM_CONF));
}
}
log.info("Starting state table for function {}", instanceConfig.getFunctionConfig().getName());
this.storageClient = StorageClientBuilder.newBuilder().withSettings(settings).withNamespace(tableNs).build();
this.stateTable = result(storageClient.openTable(tableName));
}
Aggregations