Codota Logo
ByteBuf.readableBytes
Code IndexAdd Codota to your IDE (free)

How to use
readableBytes
method
in
io.netty.buffer.ByteBuf

Best Java code snippets using io.netty.buffer.ByteBuf.readableBytes (Showing top 20 results out of 6,318)

Refine searchRefine arrow

  • ByteBuf.readShort
  • ByteBuf.readerIndex
  • Logger.isTraceEnabled
  • Logger.trace
  • ByteBuf.readInt
  • Common ways to obtain ByteBuf
private void myMethod () {
ByteBuf b =
  • Codota IconUnpooled.buffer()
  • Codota IconChannelHandlerContext ctx;ctx.alloc().buffer()
  • Smart code suggestions by Codota
}
origin: netty/netty

@Override
public int readableBytes() {
  if (terminated) {
    return buffer.readableBytes();
  } else {
    return Integer.MAX_VALUE - buffer.readerIndex();
  }
}
origin: Graylog2/graylog2-server

  @Override
  protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
    if (sourceInputLog.isTraceEnabled()) {
      sourceInputLog.trace("Recv network data: {} bytes via input '{}' <{}> from remote address {}",
          msg.readableBytes(), sourceInputName, sourceInputId, ctx.channel().remoteAddress());
    }
  }
}
origin: alibaba/fescar

  @Override
  public boolean decode(ByteBuf in) {
    int i = in.readableBytes();
    if (i < 3) {
      return false;
    }
    i -= 3;
    this.identified = (in.readByte() == 1);

    short len = in.readShort();
    if (len > 0) {
      if (i < len) {
        return false;
      }

      byte[] bs = new byte[len];
      in.readBytes(bs);
      this.setVersion(new String(bs, UTF8));
    }

    return true;
  }
}
origin: apache/drill

if (component.readableBytes() > wrapSizeLimit) {
 throw new RpcException(String.format("Component Chunk size: %d is greater than the wrapSizeLimit: %d",
   component.readableBytes(), wrapSizeLimit));
component.getBytes(component.readerIndex(), origMsg, 0, component.readableBytes());
if(logger.isTraceEnabled()) {
 logger.trace("Trying to encrypt chunk of size:{} with wrapSizeLimit:{} and chunkMode: {}",
   component.readableBytes(), wrapSizeLimit);
final byte[] wrappedMsg = saslCodec.wrap(origMsg, 0, component.readableBytes());
if(logger.isTraceEnabled()) {
 logger.trace("Successfully encrypted message, original size: {} Final Size: {}",
   component.readableBytes(), wrappedMsg.length);
msg.skipBytes(component.readableBytes());
component.skipBytes(component.readableBytes());
origin: Graylog2/graylog2-server

LOG.trace("Attempting to decode DNS record [{}]", dnsRecord);
try {
  final ByteBuf byteBuf = dnsRawRecord.content();
  ipAddressBytes = new byte[byteBuf.readableBytes()];
  int readerIndex = byteBuf.readerIndex();
  byteBuf.getBytes(readerIndex, ipAddressBytes);
} finally {
LOG.trace("The IP address has [{}] bytes", ipAddressBytes.length);
LOG.trace("The resulting IP address is [{}]", ipAddress.getHostAddress());
origin: ethereum/ethereumj

protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws IOException {
  if (in.readableBytes() == 0) {
    loggerWire.trace("in.readableBytes() == 0");
    return;
  }
  loggerWire.trace("Decoding frame (" + in.readableBytes() + " bytes)");
  List<FrameCodec.Frame> frames = frameCodec.readFrames(in);
  // Check if a full frame was available.  If not, we'll try later when more bytes come in.
  if (frames == null || frames.isEmpty()) return;
  for (int i = 0; i < frames.size(); i++) {
    FrameCodec.Frame frame = frames.get(i);
    channel.getNodeStatistics().rlpxInMessages.add();
  }
  out.addAll(frames);
}
origin: apache/hive

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
  throws Exception {
 if (in.readableBytes() < 4) {
  return;
 }
 in.markReaderIndex();
 int msgSize = in.readInt();
 checkSize(msgSize);
 if (in.readableBytes() < msgSize) {
  // Incomplete message in buffer.
  in.resetReaderIndex();
  return;
 }
 try {
  ByteBuffer nioBuffer = maybeDecrypt(in.nioBuffer(in.readerIndex(), msgSize));
  Input kryoIn = new Input(new ByteBufferInputStream(nioBuffer));
  Object msg = kryos.get().readClassAndObject(kryoIn);
  LOG.trace("Decoded message of type {} ({} bytes)",
    msg != null ? msg.getClass().getName() : msg, msgSize);
  out.add(msg);
 } finally {
  in.skipBytes(msgSize);
 }
}
origin: runelite/runelite

@Override
public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception
  if (in.readableBytes() < 8)
  int compressedFileSize = copy.readInt();
  if (size + 3 + breaks > in.readableBytes())
    logger.trace("Index {} archive {}: Not enough data yet {} > {}", index, file, size + 3 + breaks, in.readableBytes());
    return;
    int bytesToRead = Math.min(bytesInBlock, size - compressedData.writerIndex());
    logger.trace("{}/{}: reading block {}/{}, read so far this block: {}, file status: {}/{}",
      index, file,
      (totalRead % CHUNK_SIZE), CHUNK_SIZE,
  logger.trace("{}/{}: done downloading file, remaining buffer {}",
    index, file,
    in.readableBytes());
origin: org.apache.plc4x/plc4j-protocol-s7

protected void decode(ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out) {
  if (logger.isTraceEnabled()) {
    logger.trace("Got Data: {}", ByteBufUtil.hexDump(in.getUserData()));
  if (userData.readableBytes() == 0) {
    return;
  userData.readShort();  // Reserved (is always constant 0x0000)
  short tpduReference = userData.readShort();
  short headerParametersLength = userData.readShort();
  short userDataLength = userData.readShort();
  byte errorClass = 0;
origin: redisson/redisson

  @Override
  public Object decode(ByteBuf buf, State state) throws IOException {
    int decompressSize = buf.readInt();
    ByteBuf out = ByteBufAllocator.DEFAULT.buffer(decompressSize);
    try {
      LZ4SafeDecompressor decompressor = factory.safeDecompressor();
      ByteBuffer outBuffer = out.internalNioBuffer(out.writerIndex(), out.writableBytes());
      int pos = outBuffer.position();
      decompressor.decompress(buf.internalNioBuffer(buf.readerIndex(), buf.readableBytes()), outBuffer);
      int compressedLength = outBuffer.position() - pos;
      out.writerIndex(compressedLength);
      return innerCodec.getValueDecoder().decode(out, state);
    } finally {
      out.release();
    }
  }
};
origin: weibocom/motan

private void decodeV1(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
  long startTime = System.currentTimeMillis();
  in.resetReaderIndex();
  in.skipBytes(2);// skip magic num
  byte messageType = (byte) in.readShort();
  long requestId = in.readLong();
  int dataLength = in.readInt();
  // FIXME 如果dataLength过大,可能导致问题
  if (in.readableBytes() < dataLength) {
    in.resetReaderIndex();
    return;
  }
  checkMaxContext(dataLength, ctx, messageType == MotanConstants.FLAG_REQUEST, requestId);
  byte[] data = new byte[dataLength];
  in.readBytes(data);
  decode(data, out, messageType == MotanConstants.FLAG_REQUEST, requestId).setStartTime(startTime);
}
origin: qunarcorp/qmq

@Override
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> list) throws Exception {
  if (in.readableBytes() < RemotingHeader.MIN_HEADER_SIZE + RemotingHeader.LENGTH_FIELD) return;
  int magicCode = in.getInt(in.readerIndex() + RemotingHeader.LENGTH_FIELD);
  if (DEFAULT_MAGIC_CODE != magicCode) {
    throw new IOException("Illegal Data, MagicCode=" + Integer.toHexString(magicCode));
  int total = in.readInt();
  if (in.readableBytes() < total) {
    in.resetReaderIndex();
    return;
  short headerSize = in.readShort();
  RemotingHeader remotingHeader = decodeHeader(in);
origin: alibaba/fescar

@Override
public boolean decode(ByteBuf in) {
  int i = in.readableBytes();
  try {
    short len = in.readShort();
    if (len > 0) {
      byte[] bs = new byte[len];
      this.setVersion(new String(bs, UTF8));
    len = in.readShort();
    if (len > 0) {
      byte[] bs = new byte[len];
      this.setApplicationId(new String(bs, UTF8));
    len = in.readShort();
    if (len > 0) {
      byte[] bs = new byte[len];
    LOGGER.debug(in.writerIndex() == in.readerIndex() ? "true" : "false" + this);
origin: apache/zookeeper

if (LOG.isTraceEnabled()) {
  LOG.trace("0x{} buf {}",
      Long.toHexString(sessionId),
      ByteBufUtil.hexDump(buf));
    queuedBuffer = channel.alloc().buffer(buf.readableBytes());
  if (LOG.isTraceEnabled()) {
    LOG.trace("0x{} queuedBuffer {}",
        Long.toHexString(sessionId),
        ByteBufUtil.hexDump(queuedBuffer));
      if (LOG.isTraceEnabled()) {
        LOG.trace("Before copy {}", buf);
        queuedBuffer = channel.alloc().buffer(buf.readableBytes());
origin: apache/drill

public void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws IOException {
  logger.trace("Channel closed before decoding the message of {} bytes", msg.readableBytes());
  msg.skipBytes(msg.readableBytes());
  return;
  if(logger.isTraceEnabled()) {
   logger.trace("Trying to decrypt the encrypted message of size: {} with maxWrappedSize", msg.readableBytes());
  msg.getBytes(msg.readerIndex(), lengthOctets.array(), 0, RpcConstants.LENGTH_FIELD_LENGTH);
  final int wrappedMsgLength = lengthOctets.getInt(0);
  msg.skipBytes(RpcConstants.LENGTH_FIELD_LENGTH);
  assert(msg.readableBytes() == wrappedMsgLength);
  msg.getBytes(msg.readerIndex(), wrappedMsg, 0, wrappedMsgLength);
  if(logger.isTraceEnabled()) {
   logger.trace("Successfully decrypted incoming message. Length after decryption: {}", decodedMsg.length);
origin: whizzosoftware/WZWave

  cbuf.addComponent(previousBuf.copy());
  cbuf.addComponent(in);
  cbuf.writerIndex(previousBuf.readableBytes() + in.readableBytes());
  data = cbuf;
  if (data.readableBytes() == 1 && isSingleByteFrame(data, data.readerIndex())) {
    out.add(createSingleByteFrame(data));
  } else {
    boolean foundFrame = false;
    for (int searchStartIx = data.readerIndex(); searchStartIx < data.readerIndex() + data.readableBytes(); searchStartIx++) {
      if (data.getByte(searchStartIx) == DataFrame.START_OF_FRAME) {
        int frameEndIx = scanForFrame(data, searchStartIx);
in.readBytes(in.readableBytes());
logger.trace("Done processing received data: {}", out);
origin: kaaproject/kaa

@Override
public HttpResponse getResponse() {
 LOG.trace("CommandName: " + COMMAND_NAME + ": getHttpResponse..");
 ByteBuf data = Unpooled.copiedBuffer(responseBody);
 LOG.warn("Response data: {}", Arrays.toString(data.array()));
 FullHttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, OK, data);
 httpResponse.headers().set(CONTENT_TYPE, CommonEpConstans.RESPONSE_CONTENT_TYPE);
 httpResponse.headers().set(CONTENT_LENGTH, data.readableBytes());
 LOG.warn("Response size: {}", data.readableBytes());
 httpResponse
   .headers()
   .set(CommonEpConstans.RESPONSE_TYPE, CommonEpConstans.RESPONSE_TYPE_OPERATION);
 if (responseSignature != null) {
  httpResponse
    .headers()
    .set(CommonEpConstans.SIGNATURE_HEADER_NAME, encodeBase64String(responseSignature));
 }
 if (isNeedConnectionClose()) {
  httpResponse.headers().set(CONNECTION, HttpHeaders.Values.CLOSE);
 } else {
  if (HttpHeaders.isKeepAlive(getRequest())) {
   httpResponse.headers().set(CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
  } else {
   httpResponse.headers().set(CONNECTION, HttpHeaders.Values.CLOSE);
  }
 }
 return httpResponse;
}
origin: netty/netty

@Override
public long skip(long bytes) throws IOException {
  int readable = buffer.readableBytes();
  if (readable < bytes) {
    bytes = readable;
  }
  buffer.readerIndex((int) (buffer.readerIndex() + bytes));
  return bytes;
}
origin: redisson/redisson

  @Override
  public Object decode(ByteBuf buf, State state) throws IOException {
    int decompressSize = buf.readInt();
    ByteBuf out = ByteBufAllocator.DEFAULT.buffer(decompressSize);
    try {
      LZ4SafeDecompressor decompressor = factory.safeDecompressor();
      ByteBuffer outBuffer = out.internalNioBuffer(out.writerIndex(), out.writableBytes());
      int pos = outBuffer.position();
      decompressor.decompress(buf.internalNioBuffer(buf.readerIndex(), buf.readableBytes()), outBuffer);
      int compressedLength = outBuffer.position() - pos;
      out.writerIndex(compressedLength);
      return innerCodec.getValueDecoder().decode(out, state);
    } finally {
      out.release();
    }
  }
};
origin: alibaba/fescar

@Override
public boolean decode(ByteBuf in) {
  int leftLen = in.readableBytes();
  int read = 0;
  int xidLen = in.readShort();
  if (xidLen > 0) {
    if (leftLen < xidLen) {
  leftLen --;
  int resourceIdLen = in.readShort();
  if (resourceIdLen > 0) {
    if (leftLen < resourceIdLen) {
  int applicationDataLen = in.readInt();
  if (applicationDataLen > 0) {
    if (leftLen < applicationDataLen) {
io.netty.bufferByteBufreadableBytes

Javadoc

Returns the number of readable bytes which is equal to (this.writerIndex - this.readerIndex).

Popular methods of ByteBuf

  • writeBytes
    Transfers the specified source array's data to this buffer starting at the current writerIndex and i
  • readBytes
    Transfers this buffer's data to the specified destination starting at the current readerIndex and in
  • release
  • readerIndex
  • writeByte
    Sets the specified byte at the current writerIndexand increases the writerIndex by 1 in this buffer.
  • readByte
    Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
  • writeInt
    Sets the specified 32-bit integer at the current writerIndexand increases the writerIndex by 4 in th
  • readInt
    Gets a 32-bit integer at the current readerIndexand increases the readerIndex by 4 in this buffer.
  • toString
    Decodes this buffer's readable bytes into a string with the specified character set name. This metho
  • retain
  • writerIndex
    Sets the writerIndex of this buffer.
  • isReadable
    Returns true if and only if this buffer contains equal to or more than the specified number of eleme
  • writerIndex,
  • isReadable,
  • writeLong,
  • writeShort,
  • skipBytes,
  • readLong,
  • array,
  • nioBuffer,
  • resetReaderIndex

Popular in Java

  • Updating database using SQL prepared statement
  • putExtra (Intent)
  • orElseThrow (Optional)
  • onCreateOptionsMenu (Activity)
  • Kernel (java.awt.image)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Table (org.hibernate.mapping)
    A relational table
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now