Search in sources :

Example 1 with CachingSchemaRegistryClient

use of org.apache.nifi.confluent.schemaregistry.client.CachingSchemaRegistryClient in project nifi by apache.

the class ConfluentSchemaRegistry method onEnabled.

@OnEnabled
public void onEnabled(final ConfigurationContext context) {
    final List<String> baseUrls = getBaseURLs(context);
    final int timeoutMillis = context.getProperty(TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
    final SSLContext sslContext;
    final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT).asControllerService(SSLContextService.class);
    if (sslContextService == null) {
        sslContext = null;
    } else {
        sslContext = sslContextService.createSSLContext(ClientAuth.REQUIRED);
    }
    final SchemaRegistryClient restClient = new RestSchemaRegistryClient(baseUrls, timeoutMillis, sslContext, getLogger());
    final int cacheSize = context.getProperty(CACHE_SIZE).asInteger();
    final long cacheExpiration = context.getProperty(CACHE_EXPIRATION).asTimePeriod(TimeUnit.NANOSECONDS).longValue();
    client = new CachingSchemaRegistryClient(restClient, cacheSize, cacheExpiration);
}
Also used : RestSchemaRegistryClient(org.apache.nifi.confluent.schemaregistry.client.RestSchemaRegistryClient) CachingSchemaRegistryClient(org.apache.nifi.confluent.schemaregistry.client.CachingSchemaRegistryClient) SSLContextService(org.apache.nifi.ssl.SSLContextService) SSLContext(javax.net.ssl.SSLContext) RestSchemaRegistryClient(org.apache.nifi.confluent.schemaregistry.client.RestSchemaRegistryClient) SchemaRegistryClient(org.apache.nifi.confluent.schemaregistry.client.SchemaRegistryClient) CachingSchemaRegistryClient(org.apache.nifi.confluent.schemaregistry.client.CachingSchemaRegistryClient) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Aggregations

SSLContext (javax.net.ssl.SSLContext)1 OnEnabled (org.apache.nifi.annotation.lifecycle.OnEnabled)1 CachingSchemaRegistryClient (org.apache.nifi.confluent.schemaregistry.client.CachingSchemaRegistryClient)1 RestSchemaRegistryClient (org.apache.nifi.confluent.schemaregistry.client.RestSchemaRegistryClient)1 SchemaRegistryClient (org.apache.nifi.confluent.schemaregistry.client.SchemaRegistryClient)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1