Search in sources :

Example 1 with OnEnabled

use of org.apache.nifi.annotation.lifecycle.OnEnabled in project kylo by Teradata.

the class DistributedSavepointController method onConfigured.

@OnEnabled
public void onConfigured(final ConfigurationContext context) throws InitializationException {
    getLogger().info("Configuring Savepoint controller.");
    final DistributedMapCacheClient cacheClient = context.getProperty(DISTRIBUTED_CACHE_SERVICE).asControllerService(DistributedMapCacheClient.class);
    this.provider = new DistributedSavepointProviderImpl(cacheClient);
    this.provider.subscribeDistributedSavepointChanges(this.cache);
    this.springService = context.getProperty(SPRING_SERVICE).asControllerService(SpringContextService.class);
    addJmsListeners();
}
Also used : DistributedMapCacheClient(org.apache.nifi.distributed.cache.client.DistributedMapCacheClient) SpringContextService(com.thinkbiganalytics.nifi.core.api.spring.SpringContextService) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Example 2 with OnEnabled

use of org.apache.nifi.annotation.lifecycle.OnEnabled in project kylo by Teradata.

the class SpringContextLoaderService method loadConfiurations.

/**
 * Called by the framework to load controller configurations, this method
 * will create a spring context
 *
 * @param context not used in this case
 * @throws InitializationException an except thrown if there are any errors
 */
@OnEnabled
public void loadConfiurations(final ConfigurationContext context) throws InitializationException {
    try {
        AbstractRefreshableConfigApplicationContext appContext = new ClassPathXmlApplicationContext();
        appContext.setClassLoader(getClass().getClassLoader());
        appContext.setConfigLocation("application-context.xml");
        getLogger().info("Refreshing spring context");
        appContext.refresh();
        getLogger().info("Spring context refreshed");
        this.contextFuture.set(appContext);
    } catch (BeansException | IllegalStateException e) {
        getLogger().error("Failed to load spring configurations", e);
        throw new InitializationException(e);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AbstractRefreshableConfigApplicationContext(org.springframework.context.support.AbstractRefreshableConfigApplicationContext) InitializationException(org.apache.nifi.reporting.InitializationException) BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) BeansException(org.springframework.beans.BeansException) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Example 3 with OnEnabled

use of org.apache.nifi.annotation.lifecycle.OnEnabled 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)

Example 4 with OnEnabled

use of org.apache.nifi.annotation.lifecycle.OnEnabled in project nifi by apache.

the class CouchbaseClusterService method onConfigured.

/**
 * Establish a connection to a Couchbase cluster.
 * @param context the configuration context
 * @throws InitializationException if unable to connect a Couchbase cluster
 */
@OnEnabled
public void onConfigured(final ConfigurationContext context) throws InitializationException {
    for (PropertyDescriptor p : context.getProperties().keySet()) {
        if (p.isDynamic() && p.getName().startsWith(DYNAMIC_PROP_BUCKET_PASSWORD)) {
            String bucketName = p.getName().substring(DYNAMIC_PROP_BUCKET_PASSWORD.length());
            String password = context.getProperty(p).getValue();
            bucketPasswords.put(bucketName, password);
        }
    }
    try {
        cluster = CouchbaseCluster.fromConnectionString(context.getProperty(CONNECTION_STRING).getValue());
    } catch (CouchbaseException e) {
        throw new InitializationException(e);
    }
}
Also used : CouchbaseException(com.couchbase.client.core.CouchbaseException) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) InitializationException(org.apache.nifi.reporting.InitializationException) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Example 5 with OnEnabled

use of org.apache.nifi.annotation.lifecycle.OnEnabled in project nifi by apache.

the class ElasticSearchClientServiceImpl method onEnabled.

@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException {
    try {
        setupClient(context);
        charset = Charset.forName(context.getProperty(CHARSET).getValue());
    } catch (Exception ex) {
        getLogger().error("Could not initialize ElasticSearch client.", ex);
        throw new InitializationException(ex);
    }
}
Also used : InitializationException(org.apache.nifi.reporting.InitializationException) InitializationException(org.apache.nifi.reporting.InitializationException) KeyStoreException(java.security.KeyStoreException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) OnEnabled(org.apache.nifi.annotation.lifecycle.OnEnabled)

Aggregations

OnEnabled (org.apache.nifi.annotation.lifecycle.OnEnabled)24 InitializationException (org.apache.nifi.reporting.InitializationException)7 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)4 ComponentLog (org.apache.nifi.logging.ComponentLog)4 SSLContextService (org.apache.nifi.ssl.SSLContextService)4 IOException (java.io.IOException)3 File (java.io.File)2 URI (java.net.URI)2 Map (java.util.Map)2 SSLContext (javax.net.ssl.SSLContext)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 ProcessException (org.apache.nifi.processor.exception.ProcessException)2 LastModifiedMonitor (org.apache.nifi.util.file.monitor.LastModifiedMonitor)2 SynchronousFileWatcher (org.apache.nifi.util.file.monitor.SynchronousFileWatcher)2 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)2 CouchbaseException (com.couchbase.client.core.CouchbaseException)1 JsonPath (com.jayway.jsonpath.JsonPath)1 Timestamper (com.metamx.tranquility.typeclass.Timestamper)1 MetadataClient (com.thinkbiganalytics.metadata.rest.client.MetadataClient)1 SpringContextService (com.thinkbiganalytics.nifi.core.api.spring.SpringContextService)1