Search in sources :

Example 1 with MetadataClient

use of com.thinkbiganalytics.metadata.rest.client.MetadataClient in project kylo by Teradata.

the class MetadataProviderSelectorService method onConfigured.

@OnEnabled
public void onConfigured(final ConfigurationContext context) {
    PropertyValue impl = context.getProperty(IMPLEMENTATION);
    if (impl.getValue().equalsIgnoreCase("REMOTE")) {
        URI uri = URI.create(context.getProperty(CLIENT_URL).getValue());
        String user = context.getProperty(CLIENT_USERNAME).getValue();
        String password = context.getProperty(CLIENT_PASSWORD).getValue();
        MetadataClient client;
        SSLContext sslContext = null;
        if (context.getProperty(SSL_CONTEXT_SERVICE) != null && context.getProperty(SSL_CONTEXT_SERVICE).isSet()) {
            this.sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
            sslContext = this.sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED);
        }
        if (StringUtils.isEmpty(user)) {
            client = new MetadataClient(uri, sslContext);
        } else {
            client = new MetadataClient(uri, user, password, sslContext);
        }
        this.provider = new MetadataClientProvider(client);
        this.recorder = new MetadataClientRecorder(client);
        this.kyloProvenanceClientProvider = new KyloProvenanceClientProvider(client);
        getSpringContextService(context).ifPresent(springService -> {
            CancelActiveWaterMarkEventConsumer waterMarkConsumer = springService.getBean(CancelActiveWaterMarkEventConsumer.class);
            waterMarkConsumer.addMetadataRecorder(this.recorder);
            FeedInitializationChangeEventConsumer initChangeConsumer = springService.getBean(FeedInitializationChangeEventConsumer.class);
            initChangeConsumer.addMetadataRecorder(this.recorder);
        });
    } else {
        throw new UnsupportedOperationException("Provider implementations not currently supported: " + impl.getValue());
    }
}
Also used : FeedInitializationChangeEventConsumer(com.thinkbiganalytics.nifi.v2.core.feedinit.FeedInitializationChangeEventConsumer) MetadataClient(com.thinkbiganalytics.metadata.rest.client.MetadataClient) SSLContextService(org.apache.nifi.ssl.SSLContextService) PropertyValue(org.apache.nifi.components.PropertyValue) CancelActiveWaterMarkEventConsumer(com.thinkbiganalytics.nifi.v2.core.watermark.CancelActiveWaterMarkEventConsumer) SSLContext(javax.net.ssl.SSLContext) URI(java.net.URI) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Aggregations

MetadataClient (com.thinkbiganalytics.metadata.rest.client.MetadataClient)1 FeedInitializationChangeEventConsumer (com.thinkbiganalytics.nifi.v2.core.feedinit.FeedInitializationChangeEventConsumer)1 CancelActiveWaterMarkEventConsumer (com.thinkbiganalytics.nifi.v2.core.watermark.CancelActiveWaterMarkEventConsumer)1 URI (java.net.URI)1 SSLContext (javax.net.ssl.SSLContext)1 OnEnabled (org.apache.nifi.annotation.lifecycle.OnEnabled)1 PropertyValue (org.apache.nifi.components.PropertyValue)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1