Search in sources :

Example 1 with NifiRestClientConfig

use of com.thinkbiganalytics.nifi.rest.client.NifiRestClientConfig in project kylo by Teradata.

the class SpringNifiRestConfiguration method nifiRestClientConfig.

/**
 * Gets the configuration for the NiFi REST client.
 *
 * <p>Looks for {@code thinkbig.nifi.rest} properties first then for {@code nifi.rest} properties.</p>
 *
 * @return the NiFi REST client configuration
 */
@Bean(name = "nifiRestClientConfig")
@ConfigurationProperties(prefix = "nifi.rest")
public NifiRestClientConfig nifiRestClientConfig() {
    final NifiRestClientConfig config = new NifiRestClientConfig();
    config.setUsername(env.getProperty("thinkbig.nifi.rest.username"));
    config.setPassword(env.getProperty("thinkbig.nifi.rest.password") == null ? null : env.getProperty("thinkbig.nifi.rest.password").toCharArray());
    config.setHttps(BooleanUtils.toBoolean(env.getProperty("thinkbig.nifi.rest.https")));
    config.setUseConnectionPooling(BooleanUtils.toBoolean(env.getProperty("thinkbig.nifi.rest.useConnectionPooling")));
    config.setTruststorePath(env.getProperty("thinkbig.nifi.rest.truststorePath"));
    config.setTruststorePassword(env.getProperty("thinkbig.nifi.rest.truststorePassword") == null ? null : env.getProperty("thinkbig.nifi.rest.truststorePassword").toCharArray());
    config.setKeystorePassword(env.getProperty("thinkbig.nifi.rest.keystorePassword") == null ? null : env.getProperty("thinkbig.nifi.rest.keystorePassword").toCharArray());
    config.setKeystorePath(env.getProperty("thinkbig.nifi.rest.keystorePath"));
    config.setTrustStoreType(env.getProperty("thinkbig.nifi.rest.truststoreType"));
    config.setKeystoreType(env.getProperty("thinkbig.nifi.rest.keystoreType"));
    final String host = env.getProperty("thinkbig.nifi.rest.host");
    if (host != null) {
        try {
            final URL url = new URL(host);
            config.setHost(url.getHost());
            config.setPort((url.getPort() > -1) ? url.getPort() : 8079);
        } catch (final MalformedURLException e) {
            throw new IllegalArgumentException("Invalid thinkbig.nifi.rest.host: " + host, e);
        }
    }
    return config;
}
Also used : MalformedURLException(java.net.MalformedURLException) NifiRestClientConfig(com.thinkbiganalytics.nifi.rest.client.NifiRestClientConfig) URL(java.net.URL) ConfigurationProperties(org.springframework.boot.context.properties.ConfigurationProperties) Bean(org.springframework.context.annotation.Bean)

Example 2 with NifiRestClientConfig

use of com.thinkbiganalytics.nifi.rest.client.NifiRestClientConfig in project kylo by Teradata.

the class NifiRestTest method setupRestClient.

@Before
public void setupRestClient() {
    restClient = new LegacyNifiRestClient();
    NifiRestClientConfig clientConfig = new NifiRestClientConfig();
    // clientConfig.setHost("localhost");
    clientConfig.setHost("34.208.236.190");
    clientConfig.setPort(8079);
    NiFiRestClient c = new NiFiRestClientV1(clientConfig);
    restClient.setClient(c);
    nifiFlowCache = new NifiFlowCacheImpl();
    propertyDescriptorTransform = new NiFiPropertyDescriptorTransformV1();
    createFeedBuilderCache = new NiFiObjectCache();
    createFeedBuilderCache.setRestClient(restClient);
    templateConnectionUtil = new TemplateConnectionUtil();
    templateConnectionUtil.setRestClient(restClient);
    templateConnectionUtil.setNifiFlowCache(nifiFlowCache);
    templateConnectionUtil.setNiFiObjectCache(createFeedBuilderCache);
    templateConnectionUtil.setPropertyDescriptorTransform(propertyDescriptorTransform);
}
Also used : NiFiRestClient(com.thinkbiganalytics.nifi.rest.client.NiFiRestClient) NiFiPropertyDescriptorTransformV1(com.thinkbiganalytics.nifi.v1.rest.model.NiFiPropertyDescriptorTransformV1) NifiRestClientConfig(com.thinkbiganalytics.nifi.rest.client.NifiRestClientConfig) TemplateConnectionUtil(com.thinkbiganalytics.feedmgr.nifi.TemplateConnectionUtil) LegacyNifiRestClient(com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient) NiFiRestClientV1(com.thinkbiganalytics.nifi.v1.rest.client.NiFiRestClientV1) NifiFlowCacheImpl(com.thinkbiganalytics.feedmgr.nifi.cache.NifiFlowCacheImpl) Before(org.junit.Before)

Aggregations

NifiRestClientConfig (com.thinkbiganalytics.nifi.rest.client.NifiRestClientConfig)2 TemplateConnectionUtil (com.thinkbiganalytics.feedmgr.nifi.TemplateConnectionUtil)1 NifiFlowCacheImpl (com.thinkbiganalytics.feedmgr.nifi.cache.NifiFlowCacheImpl)1 LegacyNifiRestClient (com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient)1 NiFiRestClient (com.thinkbiganalytics.nifi.rest.client.NiFiRestClient)1 NiFiRestClientV1 (com.thinkbiganalytics.nifi.v1.rest.client.NiFiRestClientV1)1 NiFiPropertyDescriptorTransformV1 (com.thinkbiganalytics.nifi.v1.rest.model.NiFiPropertyDescriptorTransformV1)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Before (org.junit.Before)1 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)1 Bean (org.springframework.context.annotation.Bean)1