Search in sources :

Example 6 with JsonSchemaProvider

use of io.confluent.kafka.schemaregistry.json.JsonSchemaProvider in project akhq by tchiotludo.

the class KafkaModule method getRegistryClient.

public SchemaRegistryClient getRegistryClient(String clusterId) {
    if (!this.registryClient.containsKey(clusterId)) {
        Connection connection = this.getConnection(clusterId);
        List<SchemaProvider> providers = new ArrayList<>();
        providers.add(new AvroSchemaProvider());
        providers.add(new JsonSchemaProvider());
        providers.add(new ProtobufSchemaProvider());
        SchemaRegistryClient client = new CachedSchemaRegistryClient(this.getRegistryRestClient(clusterId), 1000, providers, connection.getSchemaRegistry() != null ? connection.getSchemaRegistry().getProperties() : null, null);
        this.registryClient.put(clusterId, client);
    }
    return this.registryClient.get(clusterId);
}
Also used : JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) Connection(org.akhq.configs.Connection) ProtobufSchemaProvider(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider) SchemaProvider(io.confluent.kafka.schemaregistry.SchemaProvider) JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) AvroSchemaProvider(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider) ProtobufSchemaProvider(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) AvroSchemaProvider(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient)

Example 7 with JsonSchemaProvider

use of io.confluent.kafka.schemaregistry.json.JsonSchemaProvider in project kafka-rest by confluentinc.

the class SchemaRegistryFixture method beforeEach.

@Override
public void beforeEach(ExtensionContext extensionContext) throws Exception {
    checkState(server == null);
    server = new SchemaRegistryRestApplication(createConfigs()).createServer();
    server.start();
    baseUri = server.getURI();
    client = new CachedSchemaRegistryClient(singletonList(baseUri.toString()), MAX_SCHEMAS_PER_SUBJECT_DEFAULT, Arrays.asList(new AvroSchemaProvider(), new JsonSchemaProvider(), new ProtobufSchemaProvider()), getClientConfigs());
}
Also used : SchemaRegistryRestApplication(io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication) JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient) ProtobufSchemaProvider(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider) AvroSchemaProvider(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)

Example 8 with JsonSchemaProvider

use of io.confluent.kafka.schemaregistry.json.JsonSchemaProvider in project schema-registry by confluentinc.

the class KafkaSchemaRegistry method initProviders.

private Map<String, SchemaProvider> initProviders(SchemaRegistryConfig config) {
    Map<String, Object> schemaProviderConfigs = config.originalsWithPrefix(SchemaRegistryConfig.SCHEMA_PROVIDERS_CONFIG + ".");
    schemaProviderConfigs.put(SchemaProvider.SCHEMA_VERSION_FETCHER_CONFIG, this);
    List<SchemaProvider> defaultSchemaProviders = Arrays.asList(new AvroSchemaProvider(), new JsonSchemaProvider(), new ProtobufSchemaProvider());
    for (SchemaProvider provider : defaultSchemaProviders) {
        provider.configure(schemaProviderConfigs);
    }
    Map<String, SchemaProvider> providerMap = new HashMap<>();
    registerProviders(providerMap, defaultSchemaProviders);
    List<SchemaProvider> customSchemaProviders = config.getConfiguredInstances(SchemaRegistryConfig.SCHEMA_PROVIDERS_CONFIG, SchemaProvider.class, schemaProviderConfigs);
    // Allow custom providers to override default providers
    registerProviders(providerMap, customSchemaProviders);
    metricsContainer.getCustomSchemaProviderCount().set(customSchemaProviders.size());
    return providerMap;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) ProtobufSchemaProvider(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider) SchemaProvider(io.confluent.kafka.schemaregistry.SchemaProvider) JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) AvroSchemaProvider(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider) SchemaString(io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString) ProtobufSchemaProvider(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider) AvroSchemaProvider(io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)

Example 9 with JsonSchemaProvider

use of io.confluent.kafka.schemaregistry.json.JsonSchemaProvider in project akhq by tchiotludo.

the class KafkaModule method getJsonSchemaProvider.

public JsonSchemaProvider getJsonSchemaProvider(String clusterId) {
    JsonSchemaProvider jsonSchemaProvider = new JsonSchemaProvider();
    jsonSchemaProvider.configure(Collections.singletonMap("schemaVersionFetcher", new CachedSchemaRegistryClient(this.getRegistryRestClient(clusterId), 1000)));
    return jsonSchemaProvider;
}
Also used : JsonSchemaProvider(io.confluent.kafka.schemaregistry.json.JsonSchemaProvider) CachedSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient)

Aggregations

JsonSchemaProvider (io.confluent.kafka.schemaregistry.json.JsonSchemaProvider)9 CachedSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient)6 AvroSchemaProvider (io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)4 ProtobufSchemaProvider (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider)4 SchemaProvider (io.confluent.kafka.schemaregistry.SchemaProvider)2 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)2 SchemaString (io.confluent.kafka.schemaregistry.client.rest.entities.SchemaString)2 RestService (io.confluent.kafka.schemaregistry.client.rest.RestService)1 Schema (io.confluent.kafka.schemaregistry.client.rest.entities.Schema)1 SchemaReference (io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference)1 RegisterSchemaRequest (io.confluent.kafka.schemaregistry.client.rest.entities.requests.RegisterSchemaRequest)1 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)1 JsonSchema (io.confluent.kafka.schemaregistry.json.JsonSchema)1 SchemaRegistryRestApplication (io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication)1 AbstractKafkaJsonSchemaDeserializer (io.confluent.kafka.serializers.json.AbstractKafkaJsonSchemaDeserializer)1 AbstractKafkaJsonSchemaSerializer (io.confluent.kafka.serializers.json.AbstractKafkaJsonSchemaSerializer)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Connection (org.akhq.configs.Connection)1 Test (org.junit.Test)1