use of org.apache.nifi.processor.util.put.sender.DatagramChannelSender in project nifi by apache.
the class PutSyslog method createSender.
// visible for testing to override and provide a mock sender if desired
protected ChannelSender createSender(final SSLContextService sslContextService, final String protocol, final String host, final int port, final int maxSendBufferSize, final int timeout) throws IOException {
ChannelSender sender;
if (protocol.equals(UDP_VALUE.getValue())) {
sender = new DatagramChannelSender(host, port, maxSendBufferSize, getLogger());
} else {
// if an SSLContextService is provided then we make a secure sender
if (sslContextService != null) {
final SSLContext sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED);
sender = new SSLSocketChannelSender(host, port, maxSendBufferSize, sslContext, getLogger());
} else {
sender = new SocketChannelSender(host, port, maxSendBufferSize, getLogger());
}
}
sender.setTimeout(timeout);
sender.open();
return sender;
}
use of org.apache.nifi.processor.util.put.sender.DatagramChannelSender in project nifi by apache.
the class AbstractPutEventProcessor method createSender.
/**
* Helper for sub-classes to create a sender.
*
* @param protocol the protocol for the sender
* @param host the host to send to
* @param port the port to send to
* @param timeout the timeout for connecting and communicating over the channel
* @param maxSendBufferSize the maximum size of the socket send buffer
* @param sslContext an SSLContext, or null if not using SSL
*
* @return a ChannelSender based on the given properties
*
* @throws IOException if an error occurs creating the sender
*/
protected ChannelSender createSender(final String protocol, final String host, final int port, final int timeout, final int maxSendBufferSize, final SSLContext sslContext) throws IOException {
ChannelSender sender;
if (protocol.equals(UDP_VALUE.getValue())) {
sender = new DatagramChannelSender(host, port, maxSendBufferSize, getLogger());
} else {
// if an SSLContextService is provided then we make a secure sender
if (sslContext != null) {
sender = new SSLSocketChannelSender(host, port, maxSendBufferSize, sslContext, getLogger());
} else {
sender = new SocketChannelSender(host, port, maxSendBufferSize, getLogger());
}
}
sender.setTimeout(timeout);
sender.open();
return sender;
}
Aggregations