use of org.apache.flume.PollableSource in project nifi by apache.
the class ExecuteFlumeSource method stopped.
@OnStopped
public void stopped() {
if (source instanceof PollableSource) {
source.stop();
} else {
EventDrivenSourceRunner runner = runnerRef.get();
if (runner != null) {
runner.stop();
runnerRef.compareAndSet(runner, null);
}
NifiSessionFactoryChannel eventDrivenSourceChannel = eventDrivenSourceChannelRef.get();
if (eventDrivenSourceChannel != null) {
eventDrivenSourceChannel.stop();
eventDrivenSourceChannelRef.compareAndSet(eventDrivenSourceChannel, null);
}
}
sessionFactoryRef.set(null);
}
use of org.apache.flume.PollableSource in project nifi by apache.
the class ExecuteFlumeSource method onTrigger.
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
if (source instanceof PollableSource) {
PollableSource pollableSource = (PollableSource) source;
try {
pollableSourceChannel.setSession(session);
pollableSource.process();
} catch (EventDeliveryException ex) {
throw new ProcessException("Error processing pollable source", ex);
}
} else {
throw new ProcessException("Invalid source type: " + source.getClass().getSimpleName());
}
}
use of org.apache.flume.PollableSource in project nifi by apache.
the class ExecuteFlumeSource method onScheduled.
@OnScheduled
public void onScheduled(final ProcessContext context) {
try {
source = SOURCE_FACTORY.create(context.getProperty(SOURCE_NAME).getValue(), context.getProperty(SOURCE_TYPE).getValue());
String flumeConfig = context.getProperty(FLUME_CONFIG).getValue();
String agentName = context.getProperty(AGENT_NAME).getValue();
String sourceName = context.getProperty(SOURCE_NAME).getValue();
Configurables.configure(source, getFlumeSourceContext(flumeConfig, agentName, sourceName));
if (source instanceof PollableSource) {
source.setChannelProcessor(new ChannelProcessor(new NifiChannelSelector(pollableSourceChannel)));
source.start();
}
} catch (Throwable th) {
getLogger().error("Error creating source", th);
throw Throwables.propagate(th);
}
}
Aggregations