Search in sources :

Example 6 with StorageClientSettings

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();
}
Also used : StorageClientSettings(org.apache.bookkeeper.clients.config.StorageClientSettings) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint)

Example 7 with StorageClientSettings

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();
}
Also used : StorageClientSettings(org.apache.bookkeeper.clients.config.StorageClientSettings) Endpoint(org.apache.bookkeeper.stream.proto.common.Endpoint)

Example 8 with StorageClientSettings

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));
}
Also used : StorageClientSettings(org.apache.bookkeeper.clients.config.StorageClientSettings) StorageAdminClient(org.apache.bookkeeper.clients.admin.StorageAdminClient) StreamNotFoundException(org.apache.bookkeeper.clients.exceptions.StreamNotFoundException) ToString(lombok.ToString) NamespaceNotFoundException(org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)

Aggregations

StorageClientSettings (org.apache.bookkeeper.clients.config.StorageClientSettings)8 Endpoint (org.apache.bookkeeper.stream.proto.common.Endpoint)6 StorageAdminClient (org.apache.bookkeeper.clients.admin.StorageAdminClient)2 ToString (lombok.ToString)1 NamespaceExistsException (org.apache.bookkeeper.clients.exceptions.NamespaceExistsException)1 NamespaceNotFoundException (org.apache.bookkeeper.clients.exceptions.NamespaceNotFoundException)1 StreamNotFoundException (org.apache.bookkeeper.clients.exceptions.StreamNotFoundException)1 LocationClientImpl (org.apache.bookkeeper.clients.impl.internal.LocationClientImpl)1 NamespaceProperties (org.apache.bookkeeper.stream.proto.NamespaceProperties)1