Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.readerIndex()


         ChannelBuffer chunk = getChunk();
         if (chunk == null)
            return -1;
         if (chunk.readableBytes() < 1)
            return -1;
         int readIndex = chunk.readerIndex();
         byte abyte = chunk.getByte(readIndex);
         chunk.readerIndex(readIndex + 1);
         return (int) abyte;
      } catch (Exception e) {
         throw new IOException(e);
View Full Code Here


            return -1;
         if (chunk.readableBytes() < 1)
            return -1;
         int readIndex = chunk.readerIndex();
         byte abyte = chunk.getByte(readIndex);
         chunk.readerIndex(readIndex + 1);
         return (int) abyte;
      } catch (Exception e) {
         throw new IOException(e);
      }
   }
View Full Code Here

         if (readable < 1)
            return -1;
         if (readable > len) {
            readable = len;
         }
         int readIndex = chunk.readerIndex();
         chunk.getBytes(readIndex, b, off, readable);
         chunk.readerIndex(readIndex + readable);
         return readable;
      } catch (Exception e) {
         throw new IOException(e);
View Full Code Here

         if (readable > len) {
            readable = len;
         }
         int readIndex = chunk.readerIndex();
         chunk.getBytes(readIndex, b, off, readable);
         chunk.readerIndex(readIndex + readable);
         return readable;
      } catch (Exception e) {
         throw new IOException(e);
      }
   }
View Full Code Here

                int contentLength = content.readableBytes();

                return wrappedBuffer(
                        copiedBuffer(Integer.toHexString(contentLength), "ASCII"),
                        wrappedBuffer(CRLF),
                        content.slice(content.readerIndex(), contentLength),
                        wrappedBuffer(CRLF));
            }
        }

        // Unknown message type.
View Full Code Here

        OutputStream out = channel.getOutputStream();
        try {
            ChannelBuffer a = (ChannelBuffer) message;
            int bytes = a.readableBytes();
            synchronized (out) {
                a.getBytes(a.readerIndex(), out, bytes);
            }
            fireWriteComplete(channel, bytes);
            future.setSuccess();
        } catch (Throwable t) {
            // Convert 'SocketException: Socket closed' to
View Full Code Here

        if (!(m instanceof ChannelBuffer)) {
            ctx.sendUpstream(e);
            return;
        }
        ChannelBuffer buffer = (ChannelBuffer) m;
        int size = buffer.getInt(buffer.readerIndex() - 4);
        transportServiceAdapter.received(size + 4);

        int markedReaderIndex = buffer.readerIndex();
        int expectedIndexReader = markedReaderIndex + size;
View Full Code Here

        }
        ChannelBuffer buffer = (ChannelBuffer) m;
        int size = buffer.getInt(buffer.readerIndex() - 4);
        transportServiceAdapter.received(size + 4);

        int markedReaderIndex = buffer.readerIndex();
        int expectedIndexReader = markedReaderIndex + size;

        // netty always copies a buffer, either in NioWorker in its read handler, where it copies to a fresh
        // buffer, or in the cumlation buffer, which is cleaned each time
        StreamInput streamIn = ChannelBufferStreamInputFactory.create(buffer, size);
View Full Code Here

        // !!! compression handling removed !!!
        StreamInput wrappedStream = CachedStreamInput.cachedHandles(streamIn);

        if (TransportStatus.isRequest(status)) {
            String action = handleRequest(ctx.getChannel(), wrappedStream, requestId, version);
            if (buffer.readerIndex() != expectedIndexReader) {
                if (buffer.readerIndex() < expectedIndexReader) {
                    logger.warn("Message not fully read (request) for [{}] and action [{}], resetting", requestId, action);
                } else {
                    logger.warn("Message read past expected size (request) for [{}] and action [{}], resetting", requestId, action);
                }
View Full Code Here

        StreamInput wrappedStream = CachedStreamInput.cachedHandles(streamIn);

        if (TransportStatus.isRequest(status)) {
            String action = handleRequest(ctx.getChannel(), wrappedStream, requestId, version);
            if (buffer.readerIndex() != expectedIndexReader) {
                if (buffer.readerIndex() < expectedIndexReader) {
                    logger.warn("Message not fully read (request) for [{}] and action [{}], resetting", requestId, action);
                } else {
                    logger.warn("Message read past expected size (request) for [{}] and action [{}], resetting", requestId, action);
                }
                buffer.readerIndex(expectedIndexReader);
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.