Search in sources :

Example 1 with LumberjackSocketChannelHandlerFactory

use of org.apache.nifi.processors.lumberjack.handler.LumberjackSocketChannelHandlerFactory in project nifi by apache.

the class ListenLumberjack method createDispatcher.

@Override
protected ChannelDispatcher createDispatcher(final ProcessContext context, final BlockingQueue<LumberjackEvent> events) throws IOException {
    final EventFactory<LumberjackEvent> eventFactory = new LumberjackEventFactory();
    final ChannelHandlerFactory<LumberjackEvent, AsyncChannelDispatcher> handlerFactory = new LumberjackSocketChannelHandlerFactory<>();
    final int maxConnections = context.getProperty(MAX_CONNECTIONS).asInteger();
    final int bufferSize = context.getProperty(RECV_BUFFER_SIZE).asDataSize(DataUnit.B).intValue();
    final Charset charSet = Charset.forName(context.getProperty(CHARSET).getValue());
    // initialize the buffer pool based on max number of connections and the buffer size
    final BlockingQueue<ByteBuffer> bufferPool = createBufferPool(maxConnections, bufferSize);
    // if an SSLContextService was provided then create an SSLContext to pass down to the dispatcher
    SSLContext sslContext = null;
    final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
    if (sslContextService != null) {
        sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED);
    }
    // if we decide to support SSL then get the context and pass it in here
    return new SocketChannelDispatcher<>(eventFactory, handlerFactory, bufferPool, events, getLogger(), maxConnections, sslContext, charSet);
}
Also used : LumberjackEventFactory(org.apache.nifi.processors.lumberjack.event.LumberjackEventFactory) LumberjackSocketChannelHandlerFactory(org.apache.nifi.processors.lumberjack.handler.LumberjackSocketChannelHandlerFactory) Charset(java.nio.charset.Charset) SSLContext(javax.net.ssl.SSLContext) ByteBuffer(java.nio.ByteBuffer) AsyncChannelDispatcher(org.apache.nifi.processor.util.listen.dispatcher.AsyncChannelDispatcher) LumberjackEvent(org.apache.nifi.processors.lumberjack.event.LumberjackEvent) SSLContextService(org.apache.nifi.ssl.SSLContextService) RestrictedSSLContextService(org.apache.nifi.ssl.RestrictedSSLContextService) SocketChannelDispatcher(org.apache.nifi.processor.util.listen.dispatcher.SocketChannelDispatcher)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 Charset (java.nio.charset.Charset)1 SSLContext (javax.net.ssl.SSLContext)1 AsyncChannelDispatcher (org.apache.nifi.processor.util.listen.dispatcher.AsyncChannelDispatcher)1 SocketChannelDispatcher (org.apache.nifi.processor.util.listen.dispatcher.SocketChannelDispatcher)1 LumberjackEvent (org.apache.nifi.processors.lumberjack.event.LumberjackEvent)1 LumberjackEventFactory (org.apache.nifi.processors.lumberjack.event.LumberjackEventFactory)1 LumberjackSocketChannelHandlerFactory (org.apache.nifi.processors.lumberjack.handler.LumberjackSocketChannelHandlerFactory)1 RestrictedSSLContextService (org.apache.nifi.ssl.RestrictedSSLContextService)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1