Search in sources :

Example 1 with AppendDecoder

use of io.pravega.shared.protocol.netty.AppendDecoder in project pravega by pravega.

the class AppendTest method createChannel.

static EmbeddedChannel createChannel(StreamSegmentStore store) {
    ServerConnectionInboundHandler lsh = new ServerConnectionInboundHandler();
    EmbeddedChannel channel = new EmbeddedChannel(new ExceptionLoggingHandler(""), new CommandEncoder(null, MetricNotifier.NO_OP_METRIC_NOTIFIER), new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4), new CommandDecoder(), new AppendDecoder(), lsh);
    lsh.setRequestProcessor(AppendProcessor.defaultBuilder().store(store).connection(new TrackedConnection(lsh)).nextRequestProcessor(new PravegaRequestProcessor(store, mock(TableStore.class), lsh)).build());
    return channel;
}
Also used : AppendDecoder(io.pravega.shared.protocol.netty.AppendDecoder) CommandDecoder(io.pravega.shared.protocol.netty.CommandDecoder) ServerConnectionInboundHandler(io.pravega.segmentstore.server.host.handler.ServerConnectionInboundHandler) PravegaRequestProcessor(io.pravega.segmentstore.server.host.handler.PravegaRequestProcessor) ExceptionLoggingHandler(io.pravega.shared.protocol.netty.ExceptionLoggingHandler) TrackedConnection(io.pravega.segmentstore.server.host.handler.TrackedConnection) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) CommandEncoder(io.pravega.shared.protocol.netty.CommandEncoder) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder)

Example 2 with AppendDecoder

use of io.pravega.shared.protocol.netty.AppendDecoder in project pravega by pravega.

the class PravegaConnectionListener method createEncodingStack.

@Override
public List<ChannelHandler> createEncodingStack(String connectionName) {
    List<ChannelHandler> stack = new ArrayList<>();
    stack.add(new ExceptionLoggingHandler(connectionName));
    stack.add(new CommandEncoder(null, NO_OP_METRIC_NOTIFIER));
    stack.add(new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4));
    stack.add(new CommandDecoder());
    stack.add(new AppendDecoder());
    return stack;
}
Also used : AppendDecoder(io.pravega.shared.protocol.netty.AppendDecoder) CommandDecoder(io.pravega.shared.protocol.netty.CommandDecoder) ExceptionLoggingHandler(io.pravega.shared.protocol.netty.ExceptionLoggingHandler) ArrayList(java.util.ArrayList) ChannelHandler(io.netty.channel.ChannelHandler) CommandEncoder(io.pravega.shared.protocol.netty.CommandEncoder) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder)

Example 3 with AppendDecoder

use of io.pravega.shared.protocol.netty.AppendDecoder in project pravega by pravega.

the class AppendProcessorTest method createChannel.

private EmbeddedChannel createChannel(StreamSegmentStore store) {
    ServerConnectionInboundHandler lsh = new ServerConnectionInboundHandler();
    EmbeddedChannel channel = new EmbeddedChannel(new ExceptionLoggingHandler(""), new CommandEncoder(null, MetricNotifier.NO_OP_METRIC_NOTIFIER), new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4), new CommandDecoder(), new AppendDecoder(), lsh);
    lsh.setRequestProcessor(AppendProcessor.defaultBuilder().store(store).connection(new TrackedConnection(lsh)).nextRequestProcessor(new PravegaRequestProcessor(store, mock(TableStore.class), lsh)).build());
    return channel;
}
Also used : AppendDecoder(io.pravega.shared.protocol.netty.AppendDecoder) CommandDecoder(io.pravega.shared.protocol.netty.CommandDecoder) ExceptionLoggingHandler(io.pravega.shared.protocol.netty.ExceptionLoggingHandler) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) CommandEncoder(io.pravega.shared.protocol.netty.CommandEncoder) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder)

Example 4 with AppendDecoder

use of io.pravega.shared.protocol.netty.AppendDecoder in project pravega by pravega.

the class PravegaConnectionListener method startListening.

// endregion
public void startListening() {
    // Configure SSL.
    final SslContext sslCtx;
    if (ssl) {
        try {
            sslCtx = SslContextBuilder.forServer(new File(this.certFile), new File(this.keyFile)).build();
        } catch (SSLException e) {
            throw new RuntimeException(e);
        }
    } else {
        sslCtx = null;
    }
    boolean nio = false;
    try {
        bossGroup = new EpollEventLoopGroup(1);
        workerGroup = new EpollEventLoopGroup();
    } catch (ExceptionInInitializerError | UnsatisfiedLinkError | NoClassDefFoundError e) {
        nio = true;
        bossGroup = new NioEventLoopGroup(1);
        workerGroup = new NioEventLoopGroup();
    }
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup).channel(nio ? NioServerSocketChannel.class : EpollServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {

        @Override
        public void initChannel(SocketChannel ch) throws Exception {
            ChannelPipeline p = ch.pipeline();
            if (sslCtx != null) {
                SslHandler handler = sslCtx.newHandler(ch.alloc());
                p.addLast(handler);
            }
            ServerConnectionInboundHandler lsh = new ServerConnectionInboundHandler();
            // p.addLast(new LoggingHandler(LogLevel.INFO));
            p.addLast(new ExceptionLoggingHandler(ch.remoteAddress().toString()), new CommandEncoder(null), new LengthFieldBasedFrameDecoder(MAX_WIRECOMMAND_SIZE, 4, 4), new CommandDecoder(), new AppendDecoder(), lsh);
            lsh.setRequestProcessor(new AppendProcessor(store, lsh, new PravegaRequestProcessor(store, lsh, statsRecorder, tokenVerifier), statsRecorder, tokenVerifier));
        }
    });
    // Start the server.
    serverChannel = b.bind(host, port).awaitUninterruptibly().channel();
}
Also used : EpollServerSocketChannel(io.netty.channel.epoll.EpollServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) LoggingHandler(io.netty.handler.logging.LoggingHandler) ExceptionLoggingHandler(io.pravega.shared.protocol.netty.ExceptionLoggingHandler) CommandEncoder(io.pravega.shared.protocol.netty.CommandEncoder) SSLException(javax.net.ssl.SSLException) ExceptionLoggingHandler(io.pravega.shared.protocol.netty.ExceptionLoggingHandler) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) SslContext(io.netty.handler.ssl.SslContext) AppendDecoder(io.pravega.shared.protocol.netty.AppendDecoder) CommandDecoder(io.pravega.shared.protocol.netty.CommandDecoder) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) SSLException(javax.net.ssl.SSLException) ChannelPipeline(io.netty.channel.ChannelPipeline) SslHandler(io.netty.handler.ssl.SslHandler) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) File(java.io.File)

Aggregations

LengthFieldBasedFrameDecoder (io.netty.handler.codec.LengthFieldBasedFrameDecoder)4 AppendDecoder (io.pravega.shared.protocol.netty.AppendDecoder)4 CommandDecoder (io.pravega.shared.protocol.netty.CommandDecoder)4 CommandEncoder (io.pravega.shared.protocol.netty.CommandEncoder)4 ExceptionLoggingHandler (io.pravega.shared.protocol.netty.ExceptionLoggingHandler)4 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)2 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelHandler (io.netty.channel.ChannelHandler)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)1 EpollServerSocketChannel (io.netty.channel.epoll.EpollServerSocketChannel)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 SslContext (io.netty.handler.ssl.SslContext)1 SslHandler (io.netty.handler.ssl.SslHandler)1 PravegaRequestProcessor (io.pravega.segmentstore.server.host.handler.PravegaRequestProcessor)1 ServerConnectionInboundHandler (io.pravega.segmentstore.server.host.handler.ServerConnectionInboundHandler)1 TrackedConnection (io.pravega.segmentstore.server.host.handler.TrackedConnection)1