Search in sources :

Example 1 with SSLSocketChannelSender

use of org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender 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;
}
Also used : DatagramChannelSender(org.apache.nifi.processor.util.put.sender.DatagramChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender) ChannelSender(org.apache.nifi.processor.util.put.sender.ChannelSender) SocketChannelSender(org.apache.nifi.processor.util.put.sender.SocketChannelSender) DatagramChannelSender(org.apache.nifi.processor.util.put.sender.DatagramChannelSender) SSLContext(javax.net.ssl.SSLContext) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender) SocketChannelSender(org.apache.nifi.processor.util.put.sender.SocketChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender)

Example 2 with SSLSocketChannelSender

use of org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender 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;
}
Also used : DatagramChannelSender(org.apache.nifi.processor.util.put.sender.DatagramChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender) ChannelSender(org.apache.nifi.processor.util.put.sender.ChannelSender) SocketChannelSender(org.apache.nifi.processor.util.put.sender.SocketChannelSender) DatagramChannelSender(org.apache.nifi.processor.util.put.sender.DatagramChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender) SocketChannelSender(org.apache.nifi.processor.util.put.sender.SocketChannelSender) SSLSocketChannelSender(org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender)

Aggregations

ChannelSender (org.apache.nifi.processor.util.put.sender.ChannelSender)2 DatagramChannelSender (org.apache.nifi.processor.util.put.sender.DatagramChannelSender)2 SSLSocketChannelSender (org.apache.nifi.processor.util.put.sender.SSLSocketChannelSender)2 SocketChannelSender (org.apache.nifi.processor.util.put.sender.SocketChannelSender)2 SSLContext (javax.net.ssl.SSLContext)1