Examples of ChannelConfig


Examples of io.netty.channel.ChannelConfig

        private final List<Object> readBuf = new ArrayList<Object>();

        @Override
        public void read() {
            assert eventLoop().inEventLoop();
            final ChannelConfig config = config();
            if (!config.isAutoRead() && !isReadPending()) {
                // ChannelConfig.setAutoRead(false) was called in the meantime
                removeReadOp();
                return;
            }

            final int maxMessagesPerRead = config.getMaxMessagesPerRead();
            final ChannelPipeline pipeline = pipeline();
            boolean closed = false;
            Throwable exception = null;
            try {
                try {
                    for (;;) {
                        int localRead = doReadMessages(readBuf);
                        if (localRead == 0) {
                            break;
                        }
                        if (localRead < 0) {
                            closed = true;
                            break;
                        }

                        // stop reading and remove op
                        if (!config.isAutoRead()) {
                            break;
                        }

                        if (readBuf.size() >= maxMessagesPerRead) {
                            break;
                        }
                    }
                } catch (Throwable t) {
                    exception = t;
                }
                setReadPending(false);
                int size = readBuf.size();
                for (int i = 0; i < size; i ++) {
                    pipeline.fireChannelRead(readBuf.get(i));
                }

                readBuf.clear();
                pipeline.fireChannelReadComplete();

                if (exception != null) {
                    if (exception instanceof IOException && !(exception instanceof PortUnreachableException)) {
                        // ServerChannel should not be closed even on IOException because it can often continue
                        // accepting incoming connections. (e.g. too many open files)
                        closed = !(AbstractNioMessageChannel.this instanceof ServerChannel);
                    }

                    pipeline.fireExceptionCaught(exception);
                }

                if (closed) {
                    if (isOpen()) {
                        close(voidPromise());
                    }
                }
            } finally {
                // Check if there is a readPending which was not processed yet.
                // This could be for two reasons:
                // * The user called Channel.read() or ChannelHandlerContext.read() in channelRead(...) method
                // * The user called Channel.read() or ChannelHandlerContext.read() in channelReadComplete(...) method
                //
                // See https://github.com/netty/netty/issues/2254
                if (!config.isAutoRead() && !isReadPending()) {
                    removeReadOp();
                }
            }
        }
View Full Code Here

Examples of org.jboss.netty.channel.ChannelConfig

  public ChunkedBodyWritableByteChannel(Channel channel, HttpResponse response)
  {
    _channel = channel;
    _responseCode = response.getStatus();
    _response = response;
    ChannelConfig channelConfig = _channel.getConfig();
    if (channelConfig instanceof NioSocketChannelConfig)
    {
      NioSocketChannelConfig nioSocketConfig = (NioSocketChannelConfig)channelConfig;
      //FIXME: add a config for the high water-mark
      nioSocketConfig.setWriteBufferLowWaterMark(16 * 1024);
 
View Full Code Here

Examples of org.jboss.netty.channel.ChannelConfig

  private void writeToChannel(Object o, int flushSize) throws IOException
  {
    ChannelFuture channelFuture = _channel.write(o);
    if (flushSize > 0 && !_channel.isWritable())
    {
      ChannelConfig channelConfig = _channel.getConfig();
      if (channelConfig instanceof NioSocketChannelConfig)
      {
        NioSocketChannelConfig nioSocketConfig = (NioSocketChannelConfig)channelConfig;
        nioSocketConfig.setWriteBufferLowWaterMark(flushSize);
        nioSocketConfig.setWriteBufferHighWaterMark(flushSize);
View Full Code Here

Examples of org.jboss.netty.channel.ChannelConfig

        HttpDecoder decoder = new HttpDecoder(inputGate);
       
        MessageEvent msg = mock(MessageEvent.class);
        when(msg.getMessage()).thenReturn(buf);
       
        ChannelConfig channelConfig = mock(ChannelConfig.class);
        when(channelConfig.getBufferFactory()).thenReturn(new HeapChannelBufferFactory());
       
        Channel channel = mock(Channel.class);
        when(channel.getConfig()).thenReturn(channelConfig);
       
        ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.