Search in sources :

Example 21 with ChannelException

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project netty by netty.

the class KQueueSocketChannelConfig method setSendBufferSize.

@Override
public KQueueSocketChannelConfig setSendBufferSize(int sendBufferSize) {
    try {
        ((KQueueSocketChannel) channel).socket.setSendBufferSize(sendBufferSize);
        calculateMaxBytesPerGatheringWrite();
        return this;
    } catch (IOException e) {
        throw new ChannelException(e);
    }
}
Also used : IOException(java.io.IOException) ChannelException(io.netty.channel.ChannelException)

Example 22 with ChannelException

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project JaPS by JackWhite20.

the class ServerChannelInitializer method initChannel.

@Override
protected void initChannel(Channel channel) throws Exception {
    try {
        channel.config().setOption(ChannelOption.IP_TOS, 0x18);
    } catch (ChannelException e) {
    // Not supported
    }
    channel.config().setAllocator(PooledByteBufAllocator.DEFAULT);
    channel.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4));
    channel.pipeline().addLast(new JSONObjectDecoder());
    channel.pipeline().addLast(new LengthFieldPrepender(4));
    channel.pipeline().addLast(new JSONObjectEncoder());
    channel.pipeline().addLast(new Connection(jaPSServer, channel));
}
Also used : JSONObjectEncoder(de.jackwhite20.japs.shared.pipeline.handler.JSONObjectEncoder) Connection(de.jackwhite20.japs.server.network.Connection) JSONObjectDecoder(de.jackwhite20.japs.shared.pipeline.handler.JSONObjectDecoder) LengthFieldPrepender(io.netty.handler.codec.LengthFieldPrepender) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder) ChannelException(io.netty.channel.ChannelException)

Example 23 with ChannelException

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project JaPS by JackWhite20.

the class ClientChannelInitializer method initChannel.

@Override
protected void initChannel(Channel channel) throws Exception {
    try {
        channel.config().setOption(ChannelOption.IP_TOS, 0x18);
    } catch (ChannelException e) {
    // Not supported
    }
    channel.config().setAllocator(PooledByteBufAllocator.DEFAULT);
    channel.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4));
    channel.pipeline().addLast(new JSONObjectDecoder());
    channel.pipeline().addLast(new LengthFieldPrepender(4));
    channel.pipeline().addLast(new JSONObjectEncoder());
    channel.pipeline().addLast(nioSocketClient);
}
Also used : JSONObjectEncoder(de.jackwhite20.japs.shared.pipeline.handler.JSONObjectEncoder) JSONObjectDecoder(de.jackwhite20.japs.shared.pipeline.handler.JSONObjectDecoder) LengthFieldPrepender(io.netty.handler.codec.LengthFieldPrepender) LengthFieldBasedFrameDecoder(io.netty.handler.codec.LengthFieldBasedFrameDecoder) ChannelException(io.netty.channel.ChannelException)

Example 24 with ChannelException

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project rest.li by linkedin.

the class Http2AlpnHandler method handlerAdded.

@Override
public void handlerAdded(ChannelHandlerContext ctx) {
    _alpnPromise = ctx.channel().newPromise();
    // the class will take care of establishing the SSL connection
    ctx.pipeline().addFirst(SessionResumptionSslHandler.PIPELINE_SESSION_RESUMPTION_HANDLER, new SessionResumptionSslHandler(_sslContext, _enableSSLSessionResumption, _sslHandShakeTimeout));
    // Fail the ALPN promise when channel is closed
    ctx.channel().closeFuture().addListener(future -> {
        if (!_alpnPromise.isDone()) {
            _alpnPromise.setFailure(new ChannelException("HTTP/2 ALPN did not complete before channel closed"));
        }
    });
}
Also used : SessionResumptionSslHandler(com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler) ChannelException(io.netty.channel.ChannelException)

Example 25 with ChannelException

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelException in project rest.li by linkedin.

the class ErrorChannelFutureListener method operationComplete.

@Override
public void operationComplete(ChannelFuture future) throws Exception {
    if (!future.isSuccess()) {
        Channel channel = future.channel();
        Long createTime = channel.attr(ChannelPoolLifecycle.CHANNEL_CREATION_TIME_KEY).get();
        String message = String.format("Channel %s encountered exception on write and flush, remote=%s, createTime=%s", channel.id(), channel.remoteAddress(), createTime);
        channel.pipeline().fireExceptionCaught(new ChannelException(message, future.cause()));
    }
}
Also used : Channel(io.netty.channel.Channel) ChannelException(io.netty.channel.ChannelException)

Aggregations

ChannelException (io.netty.channel.ChannelException)23 IOException (java.io.IOException)10 LengthFieldBasedFrameDecoder (io.netty.handler.codec.LengthFieldBasedFrameDecoder)4 ClosedChannelException (java.nio.channels.ClosedChannelException)4 JSONObjectDecoder (de.jackwhite20.japs.shared.pipeline.handler.JSONObjectDecoder)3 JSONObjectEncoder (de.jackwhite20.japs.shared.pipeline.handler.JSONObjectEncoder)3 Channel (io.netty.channel.Channel)3 LengthFieldPrepender (io.netty.handler.codec.LengthFieldPrepender)3 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)2 ByteBuf (io.netty.buffer.ByteBuf)2 ChannelFuture (io.netty.channel.ChannelFuture)2 BindException (java.net.BindException)2 InetSocketAddress (java.net.InetSocketAddress)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Send (com.github.ambry.network.Send)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SessionResumptionSslHandler (com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler)1 Config (com.typesafe.config.Config)1 PulsarClientException (com.yahoo.pulsar.client.api.PulsarClientException)1 Connection (de.jackwhite20.japs.server.network.Connection)1