Search in sources :

Example 1 with CachedSchemaRegistryClient

use of io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient in project flink by apache.

the class CachedSchemaCoderProviderTest method getInternalStateFromRestService.

private <T> T getInternalStateFromRestService(String name, CachedSchemaCoderProvider provider) {
    CachedSchemaRegistryClient cachedSchemaRegistryClient = Whitebox.getInternalState(provider.get(), "schemaRegistryClient");
    RestService restService = Whitebox.getInternalState(cachedSchemaRegistryClient, "restService");
    return Whitebox.getInternalState(restService, name);
}
Also used : CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) RestService(io.confluent.kafka.schemaregistry.client.rest.RestService)

Example 2 with CachedSchemaRegistryClient

use of io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient in project kafka-rest by confluentinc.

the class DefaultKafkaRestContext method getSchemaRegistryClient.

@Override
public SchemaRegistryClient getSchemaRegistryClient() {
    if (!config.isSchemaRegistryEnabled()) {
        return null;
    }
    if (schemaRegistryClient == null) {
        SchemaRegistryConfig schemaRegistryConfig = new SchemaRegistryConfig(config.getSchemaRegistryConfigs());
        List<String> schemaRegistryUrls = schemaRegistryConfig.getSchemaRegistryUrls().stream().map(URI::create).map(Object::toString).collect(Collectors.toList());
        schemaRegistryClient = new CachedSchemaRegistryClient(schemaRegistryUrls, schemaRegistryConfig.getMaxSchemasPerSubject(), SCHEMA_PROVIDERS, config.getSchemaRegistryConfigs(), schemaRegistryConfig.requestHeaders());
    }
    return schemaRegistryClient;
}
Also used : SchemaRegistryConfig(io.confluent.kafkarest.config.SchemaRegistryConfig) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) URI(java.net.URI)

Example 3 with CachedSchemaRegistryClient

use of io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient in project flink-mirror by flink-ci.

the class CachedSchemaCoderProviderTest method getInternalStateFromRestService.

private <T> T getInternalStateFromRestService(String name, CachedSchemaCoderProvider provider) {
    CachedSchemaRegistryClient cachedSchemaRegistryClient = Whitebox.getInternalState(provider.get(), "schemaRegistryClient");
    RestService restService = Whitebox.getInternalState(cachedSchemaRegistryClient, "restService");
    return Whitebox.getInternalState(restService, name);
}
Also used : CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) RestService(io.confluent.kafka.schemaregistry.client.rest.RestService)

Example 4 with CachedSchemaRegistryClient

use of io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient in project apicurio-registry by Apicurio.

the class ClusteredRegistryIT method testConfluent.

@Test
public void testConfluent() throws Exception {
    SchemaRegistryClient client1 = new CachedSchemaRegistryClient("http://localhost:" + TestUtils.getRegistryPort() + "/apis/ccompat/v6", 3);
    int node2port = TestUtils.getRegistryPort() + 1;
    SchemaRegistryClient client2 = new CachedSchemaRegistryClient("http://localhost:" + node2port + "/apis/ccompat/v6", 3);
    String subject = UUID.randomUUID().toString();
    ParsedSchema schema = new AvroSchema("{\"type\":\"record\",\"name\":\"myrecord1\",\"fields\":[{\"name\":\"f1\",\"type\":\"string\"}]}");
    int id = client1.register(subject, schema);
    try {
        TestUtils.retry(() -> {
            Collection<String> allSubjects = client2.getAllSubjects();
            Assertions.assertTrue(allSubjects.contains(subject));
        }, "ClusterIT-SmokeTest-RegisterSchema-1", 10);
        TestUtils.retry(() -> {
            ParsedSchema s = client2.getSchemaById(id);
            Assertions.assertNotNull(s);
        }, "ClusterIT-SmokeTest-RegisterSchema-2", 10);
    } finally {
        client1.deleteSchemaVersion(subject, "1");
    }
}
Also used : AvroSchema(io.confluent.kafka.schemaregistry.avro.AvroSchema) ParsedSchema(io.confluent.kafka.schemaregistry.ParsedSchema) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) Test(org.junit.jupiter.api.Test)

Example 5 with CachedSchemaRegistryClient

use of io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient in project flink by splunk.

the class CachedSchemaCoderProviderTest method getInternalStateFromRestService.

private <T> T getInternalStateFromRestService(String name, CachedSchemaCoderProvider provider) {
    CachedSchemaRegistryClient cachedSchemaRegistryClient = Whitebox.getInternalState(provider.get(), "schemaRegistryClient");
    RestService restService = Whitebox.getInternalState(cachedSchemaRegistryClient, "restService");
    return Whitebox.getInternalState(restService, name);
}
Also used : CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) RestService(io.confluent.kafka.schemaregistry.client.rest.RestService)

Aggregations

CachedSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient)32 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)9 ProtobufSchemaProvider (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider)9 HashMap (java.util.HashMap)9 Test (org.junit.Test)8 Properties (java.util.Properties)6 ParsedSchema (io.confluent.kafka.schemaregistry.ParsedSchema)5 RestService (io.confluent.kafka.schemaregistry.client.rest.RestService)5 JsonSchemaProvider (io.confluent.kafka.schemaregistry.json.JsonSchemaProvider)5 KafkaProtobufDeserializer (io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer)5 KafkaProtobufSerializer (io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializer)5 DynamicMessage (com.google.protobuf.DynamicMessage)4 SchemaProvider (io.confluent.kafka.schemaregistry.SchemaProvider)4 AvroSchemaProvider (io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)4 Before (org.junit.Before)3 ProtobufSchema (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema)2 URI (java.net.URI)2 Map (java.util.Map)2 Schema (org.apache.avro.Schema)2 ExampleProtoAcme (com.acme.glup.ExampleProtoAcme)1