Search in sources :

Example 1 with GetSchemaResponse

use of org.apache.pulsar.common.protocol.schema.GetSchemaResponse in project pulsar by apache.

the class SchemasImpl method getAllSchemasAsync.

@Override
public CompletableFuture<List<SchemaInfo>> getAllSchemasAsync(String topic) {
    WebTarget path = schemasPath(TopicName.get(topic));
    TopicName topicName = TopicName.get(topic);
    final CompletableFuture<List<SchemaInfo>> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<GetAllVersionsSchemaResponse>() {

        @Override
        public void completed(GetAllVersionsSchemaResponse response) {
            future.complete(response.getGetSchemaResponses().stream().map(getSchemaResponse -> convertGetSchemaResponseToSchemaInfo(topicName, getSchemaResponse)).collect(Collectors.toList()));
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : GetAllVersionsSchemaResponse(org.apache.pulsar.common.protocol.schema.GetAllVersionsSchemaResponse) TopicName(org.apache.pulsar.common.naming.TopicName) IsCompatibilityResponse(org.apache.pulsar.common.protocol.schema.IsCompatibilityResponse) UTF_8(java.nio.charset.StandardCharsets.UTF_8) PulsarAdminException(org.apache.pulsar.client.admin.PulsarAdminException) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) Schemas(org.apache.pulsar.client.admin.Schemas) DeleteSchemaResponse(org.apache.pulsar.common.protocol.schema.DeleteSchemaResponse) Collectors(java.util.stream.Collectors) Entity(javax.ws.rs.client.Entity) SchemaType(org.apache.pulsar.common.schema.SchemaType) LongSchemaVersionResponse(org.apache.pulsar.common.protocol.schema.LongSchemaVersionResponse) DefaultImplementation(org.apache.pulsar.client.internal.DefaultImplementation) List(java.util.List) GetSchemaResponse(org.apache.pulsar.common.protocol.schema.GetSchemaResponse) SchemaInfoWithVersion(org.apache.pulsar.common.schema.SchemaInfoWithVersion) Authentication(org.apache.pulsar.client.api.Authentication) InvocationCallback(javax.ws.rs.client.InvocationCallback) WebTarget(javax.ws.rs.client.WebTarget) PostSchemaPayload(org.apache.pulsar.common.protocol.schema.PostSchemaPayload) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) CompletableFuture(java.util.concurrent.CompletableFuture) GetAllVersionsSchemaResponse(org.apache.pulsar.common.protocol.schema.GetAllVersionsSchemaResponse) List(java.util.List) WebTarget(javax.ws.rs.client.WebTarget) TopicName(org.apache.pulsar.common.naming.TopicName)

Example 2 with GetSchemaResponse

use of org.apache.pulsar.common.protocol.schema.GetSchemaResponse in project pulsar by apache.

the class SchemasImpl method getSchemaInfoAsync.

@Override
public CompletableFuture<SchemaInfo> getSchemaInfoAsync(String topic, long version) {
    TopicName tn = TopicName.get(topic);
    WebTarget path = schemaPath(tn).path(Long.toString(version));
    final CompletableFuture<SchemaInfo> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<GetSchemaResponse>() {

        @Override
        public void completed(GetSchemaResponse response) {
            future.complete(convertGetSchemaResponseToSchemaInfo(tn, response));
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) WebTarget(javax.ws.rs.client.WebTarget) GetSchemaResponse(org.apache.pulsar.common.protocol.schema.GetSchemaResponse) TopicName(org.apache.pulsar.common.naming.TopicName) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Example 3 with GetSchemaResponse

use of org.apache.pulsar.common.protocol.schema.GetSchemaResponse in project pulsar by yahoo.

the class SchemasImpl method getSchemaInfoWithVersionAsync.

@Override
public CompletableFuture<SchemaInfoWithVersion> getSchemaInfoWithVersionAsync(String topic) {
    TopicName tn = TopicName.get(topic);
    final CompletableFuture<SchemaInfoWithVersion> future = new CompletableFuture<>();
    asyncGetRequest(schemaPath(tn), new InvocationCallback<GetSchemaResponse>() {

        @Override
        public void completed(GetSchemaResponse response) {
            future.complete(convertGetSchemaResponseToSchemaInfoWithVersion(tn, response));
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SchemaInfoWithVersion(org.apache.pulsar.common.schema.SchemaInfoWithVersion) GetSchemaResponse(org.apache.pulsar.common.protocol.schema.GetSchemaResponse) TopicName(org.apache.pulsar.common.naming.TopicName)

Example 4 with GetSchemaResponse

use of org.apache.pulsar.common.protocol.schema.GetSchemaResponse in project pulsar by yahoo.

the class SchemasImpl method getSchemaInfoAsync.

@Override
public CompletableFuture<SchemaInfo> getSchemaInfoAsync(String topic, long version) {
    TopicName tn = TopicName.get(topic);
    WebTarget path = schemaPath(tn).path(Long.toString(version));
    final CompletableFuture<SchemaInfo> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<GetSchemaResponse>() {

        @Override
        public void completed(GetSchemaResponse response) {
            future.complete(convertGetSchemaResponseToSchemaInfo(tn, response));
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) WebTarget(javax.ws.rs.client.WebTarget) GetSchemaResponse(org.apache.pulsar.common.protocol.schema.GetSchemaResponse) TopicName(org.apache.pulsar.common.naming.TopicName) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Example 5 with GetSchemaResponse

use of org.apache.pulsar.common.protocol.schema.GetSchemaResponse in project incubator-pulsar by apache.

the class SchemasImpl method getSchemaInfoAsync.

@Override
public CompletableFuture<SchemaInfo> getSchemaInfoAsync(String topic, long version) {
    TopicName tn = TopicName.get(topic);
    WebTarget path = schemaPath(tn).path(Long.toString(version));
    final CompletableFuture<SchemaInfo> future = new CompletableFuture<>();
    asyncGetRequest(path, new InvocationCallback<GetSchemaResponse>() {

        @Override
        public void completed(GetSchemaResponse response) {
            future.complete(convertGetSchemaResponseToSchemaInfo(tn, response));
        }

        @Override
        public void failed(Throwable throwable) {
            future.completeExceptionally(getApiException(throwable.getCause()));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) WebTarget(javax.ws.rs.client.WebTarget) GetSchemaResponse(org.apache.pulsar.common.protocol.schema.GetSchemaResponse) TopicName(org.apache.pulsar.common.naming.TopicName) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)12 TopicName (org.apache.pulsar.common.naming.TopicName)12 GetSchemaResponse (org.apache.pulsar.common.protocol.schema.GetSchemaResponse)12 SchemaInfo (org.apache.pulsar.common.schema.SchemaInfo)9 WebTarget (javax.ws.rs.client.WebTarget)6 SchemaInfoWithVersion (org.apache.pulsar.common.schema.SchemaInfoWithVersion)6 IOException (java.io.IOException)3 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Entity (javax.ws.rs.client.Entity)3 InvocationCallback (javax.ws.rs.client.InvocationCallback)3 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)3 Schemas (org.apache.pulsar.client.admin.Schemas)3 Authentication (org.apache.pulsar.client.api.Authentication)3 DefaultImplementation (org.apache.pulsar.client.internal.DefaultImplementation)3 DeleteSchemaResponse (org.apache.pulsar.common.protocol.schema.DeleteSchemaResponse)3 GetAllVersionsSchemaResponse (org.apache.pulsar.common.protocol.schema.GetAllVersionsSchemaResponse)3 IsCompatibilityResponse (org.apache.pulsar.common.protocol.schema.IsCompatibilityResponse)3 LongSchemaVersionResponse (org.apache.pulsar.common.protocol.schema.LongSchemaVersionResponse)3