Search in sources :

Example 1 with RELPEventFactory

use of org.apache.nifi.processors.standard.relp.event.RELPEventFactory in project nifi by apache.

the class ListenRELP method createDispatcher.

@Override
protected ChannelDispatcher createDispatcher(final ProcessContext context, final BlockingQueue<RELPEvent> events) throws IOException {
    final EventFactory<RELPEvent> eventFactory = new RELPEventFactory();
    final ChannelHandlerFactory<RELPEvent, AsyncChannelDispatcher> handlerFactory = new RELPSocketChannelHandlerFactory<>();
    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;
    SslContextFactory.ClientAuth clientAuth = null;
    final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
    if (sslContextService != null) {
        final String clientAuthValue = context.getProperty(CLIENT_AUTH).getValue();
        sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.valueOf(clientAuthValue));
        clientAuth = SslContextFactory.ClientAuth.valueOf(clientAuthValue);
    }
    // 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, clientAuth, charSet);
}
Also used : RELPSocketChannelHandlerFactory(org.apache.nifi.processors.standard.relp.handler.RELPSocketChannelHandlerFactory) RELPEventFactory(org.apache.nifi.processors.standard.relp.event.RELPEventFactory) Charset(java.nio.charset.Charset) SSLContext(javax.net.ssl.SSLContext) ByteBuffer(java.nio.ByteBuffer) SslContextFactory(org.apache.nifi.security.util.SslContextFactory) AsyncChannelDispatcher(org.apache.nifi.processor.util.listen.dispatcher.AsyncChannelDispatcher) SSLContextService(org.apache.nifi.ssl.SSLContextService) RestrictedSSLContextService(org.apache.nifi.ssl.RestrictedSSLContextService) SocketChannelDispatcher(org.apache.nifi.processor.util.listen.dispatcher.SocketChannelDispatcher) RELPEvent(org.apache.nifi.processors.standard.relp.event.RELPEvent)

Example 2 with RELPEventFactory

use of org.apache.nifi.processors.standard.relp.event.RELPEventFactory in project nifi by apache.

the class TestRELPFrameHandler method setup.

@Before
public void setup() {
    this.charset = StandardCharsets.UTF_8;
    this.eventFactory = new RELPEventFactory();
    this.events = new LinkedBlockingQueue<>();
    this.key = Mockito.mock(SelectionKey.class);
    this.dispatcher = Mockito.mock(AsyncChannelDispatcher.class);
    this.logger = Mockito.mock(ComponentLog.class);
    this.frameHandler = new RELPFrameHandler<>(key, charset, eventFactory, events, dispatcher, logger);
}
Also used : SelectionKey(java.nio.channels.SelectionKey) AsyncChannelDispatcher(org.apache.nifi.processor.util.listen.dispatcher.AsyncChannelDispatcher) RELPEventFactory(org.apache.nifi.processors.standard.relp.event.RELPEventFactory) ComponentLog(org.apache.nifi.logging.ComponentLog) Before(org.junit.Before)

Aggregations

AsyncChannelDispatcher (org.apache.nifi.processor.util.listen.dispatcher.AsyncChannelDispatcher)2 RELPEventFactory (org.apache.nifi.processors.standard.relp.event.RELPEventFactory)2 ByteBuffer (java.nio.ByteBuffer)1 SelectionKey (java.nio.channels.SelectionKey)1 Charset (java.nio.charset.Charset)1 SSLContext (javax.net.ssl.SSLContext)1 ComponentLog (org.apache.nifi.logging.ComponentLog)1 SocketChannelDispatcher (org.apache.nifi.processor.util.listen.dispatcher.SocketChannelDispatcher)1 RELPEvent (org.apache.nifi.processors.standard.relp.event.RELPEvent)1 RELPSocketChannelHandlerFactory (org.apache.nifi.processors.standard.relp.handler.RELPSocketChannelHandlerFactory)1 SslContextFactory (org.apache.nifi.security.util.SslContextFactory)1 RestrictedSSLContextService (org.apache.nifi.ssl.RestrictedSSLContextService)1 SSLContextService (org.apache.nifi.ssl.SSLContextService)1 Before (org.junit.Before)1