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();
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations