Search in sources :

Example 1 with SchemaInfoWithVersion

use of org.apache.pulsar.common.schema.SchemaInfoWithVersion 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 2 with SchemaInfoWithVersion

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

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 3 with SchemaInfoWithVersion

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

the class AdminApiSchemaTest method testSchemaInfoWithVersionApi.

private <T> void testSchemaInfoWithVersionApi(Schema<T> schema, String topicName) throws Exception {
    SchemaInfo si = schema.getSchemaInfo();
    admin.schemas().createSchema(topicName, si);
    log.info("Upload schema to topic {} : {}", topicName, si);
    SchemaInfoWithVersion readSi = admin.schemas().getSchemaInfoWithVersion(topicName);
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
    readSi = admin.schemas().getSchemaInfoWithVersion(topicName + "-partition-0");
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
}
Also used : SchemaInfoWithVersion(org.apache.pulsar.common.schema.SchemaInfoWithVersion) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Example 4 with SchemaInfoWithVersion

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

the class AdminApiSchemaTest method testSchemaInfoWithVersionApi.

private <T> void testSchemaInfoWithVersionApi(Schema<T> schema, String topicName) throws Exception {
    SchemaInfo si = schema.getSchemaInfo();
    admin.schemas().createSchema(topicName, si);
    log.info("Upload schema to topic {} : {}", topicName, si);
    SchemaInfoWithVersion readSi = admin.schemas().getSchemaInfoWithVersion(topicName);
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
    readSi = admin.schemas().getSchemaInfoWithVersion(topicName + "-partition-0");
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
}
Also used : SchemaInfoWithVersion(org.apache.pulsar.common.schema.SchemaInfoWithVersion) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Example 5 with SchemaInfoWithVersion

use of org.apache.pulsar.common.schema.SchemaInfoWithVersion in project pulsar by apache.

the class AdminApiSchemaTest method testSchemaInfoWithVersionApi.

private <T> void testSchemaInfoWithVersionApi(Schema<T> schema, String topicName) throws Exception {
    SchemaInfo si = schema.getSchemaInfo();
    admin.schemas().createSchema(topicName, si);
    log.info("Upload schema to topic {} : {}", topicName, si);
    SchemaInfoWithVersion readSi = admin.schemas().getSchemaInfoWithVersion(topicName);
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
    readSi = admin.schemas().getSchemaInfoWithVersion(topicName + "-partition-0");
    log.info("Read schema of topic {} : {}", topicName, readSi);
    assertEquals(readSi.getSchemaInfo(), si);
    assertEquals(readSi.getVersion(), 0);
}
Also used : SchemaInfoWithVersion(org.apache.pulsar.common.schema.SchemaInfoWithVersion) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo)

Aggregations

SchemaInfoWithVersion (org.apache.pulsar.common.schema.SchemaInfoWithVersion)6 CompletableFuture (java.util.concurrent.CompletableFuture)3 TopicName (org.apache.pulsar.common.naming.TopicName)3 GetSchemaResponse (org.apache.pulsar.common.protocol.schema.GetSchemaResponse)3 SchemaInfo (org.apache.pulsar.common.schema.SchemaInfo)3