io.netty.buffer.ByteBuf.maxCapacity()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中io.netty.buffer.ByteBuf.maxCapacity()方法的一些代码示例,展示了ByteBuf.maxCapacity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.maxCapacity()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:maxCapacity

ByteBuf.maxCapacity介绍

[英]Returns the maximum allowed capacity of this buffer. If a user attempts to increase the capacity of this buffer beyond the maximum capacity using #capacity(int) or #ensureWritable(int), those methods will raise an IllegalArgumentException.
[中]返回此缓冲区允许的最大容量。如果用户试图使用#capacity(int)或#ensurewriteable(int)将此缓冲区的容量增加到超过最大容量,这些方法将引发IllegalArgumentException。

代码示例

代码示例来源:origin: netty/netty

@Override
public final int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: netty/netty

@Override
public int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: redisson/redisson

@Override
public int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: redisson/redisson

@Override
public final int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: wildfly/wildfly

@Override
public int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: wildfly/wildfly

@Override
public final int maxCapacity() {
  return buf.maxCapacity();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public int maxCapacity() {
  return delegate.maxCapacity();
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public final int maxCapacity() {
  return byteBuf.maxCapacity();
}

代码示例来源:origin: netty/netty

public ReadOnlyByteBuf(ByteBuf buffer) {
  super(buffer.maxCapacity());
  if (buffer instanceof ReadOnlyByteBuf || buffer instanceof DuplicatedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(buffer.readerIndex(), buffer.writerIndex());
}

代码示例来源:origin: redisson/redisson

public ReadOnlyByteBuf(ByteBuf buffer) {
  super(buffer.maxCapacity());
  if (buffer instanceof ReadOnlyByteBuf || buffer instanceof DuplicatedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(buffer.readerIndex(), buffer.writerIndex());
}

代码示例来源:origin: apache/drill

public MutableWrappedByteBuf(ByteBuf buffer) {
 super(buffer.maxCapacity());
 if (buffer instanceof MutableWrappedByteBuf) {
  this.buffer = ((MutableWrappedByteBuf) buffer).buffer;
 } else {
  this.buffer = buffer;
 }
 setIndex(buffer.readerIndex(), buffer.writerIndex());
}

代码示例来源:origin: netty/netty

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    try {
      final ByteBuf buffer;
      if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
        // Expand cumulation (by replace it) when either there is not more room in the buffer
        // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
        // duplicate().retain() or if its read-only.
        //
        // See:
        // - https://github.com/netty/netty/issues/2327
        // - https://github.com/netty/netty/issues/1764
        buffer = expandCumulation(alloc, cumulation, in.readableBytes());
      } else {
        buffer = cumulation;
      }
      buffer.writeBytes(in);
      return buffer;
    } finally {
      // We must release in in all cases as otherwise it may produce a leak if writeBytes(...) throw
      // for whatever release (for example because of OutOfMemoryError)
      in.release();
    }
  }
};

代码示例来源:origin: apache/drill

public static String bufferState(final ByteBuf buf) {
 final int cap = buf.capacity();
 final int mcap = buf.maxCapacity();
 final int ri = buf.readerIndex();
 final int rb = buf.readableBytes();
 final int wi = buf.writerIndex();
 final int wb = buf.writableBytes();
 return String.format("cap/max: %d/%d, ri: %d, rb: %d, wi: %d, wb: %d",
   cap, mcap, ri, rb, wi, wb);
}

代码示例来源:origin: wildfly/wildfly

public ReadOnlyByteBuf(ByteBuf buffer) {
  super(buffer.maxCapacity());
  if (buffer instanceof ReadOnlyByteBuf || buffer instanceof DuplicatedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(buffer.readerIndex(), buffer.writerIndex());
}

代码示例来源:origin: redisson/redisson

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    try {
      final ByteBuf buffer;
      if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
        // Expand cumulation (by replace it) when either there is not more room in the buffer
        // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
        // duplicate().retain() or if its read-only.
        //
        // See:
        // - https://github.com/netty/netty/issues/2327
        // - https://github.com/netty/netty/issues/1764
        buffer = expandCumulation(alloc, cumulation, in.readableBytes());
      } else {
        buffer = cumulation;
      }
      buffer.writeBytes(in);
      return buffer;
    } finally {
      // We must release in in all cases as otherwise it may produce a leak if writeBytes(...) throw
      // for whatever release (for example because of OutOfMemoryError)
      in.release();
    }
  }
};

代码示例来源:origin: wildfly/wildfly

@Override
  public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in) {
    final ByteBuf buffer;
    if (cumulation.writerIndex() > cumulation.maxCapacity() - in.readableBytes()
        || cumulation.refCnt() > 1 || cumulation.isReadOnly()) {
      // Expand cumulation (by replace it) when either there is not more room in the buffer
      // or if the refCnt is greater then 1 which may happen when the user use slice().retain() or
      // duplicate().retain() or if its read-only.
      //
      // See:
      // - https://github.com/netty/netty/issues/2327
      // - https://github.com/netty/netty/issues/1764
      buffer = expandCumulation(alloc, cumulation, in.readableBytes());
    } else {
      buffer = cumulation;
    }
    buffer.writeBytes(in);
    in.release();
    return buffer;
  }
};

代码示例来源:origin: netty/netty

DuplicatedByteBuf(ByteBuf buffer, int readerIndex, int writerIndex) {
  super(buffer.maxCapacity());
  if (buffer instanceof DuplicatedByteBuf) {
    this.buffer = ((DuplicatedByteBuf) buffer).buffer;
  } else if (buffer instanceof AbstractPooledDerivedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(readerIndex, writerIndex);
  markReaderIndex();
  markWriterIndex();
}

代码示例来源:origin: redisson/redisson

DuplicatedByteBuf(ByteBuf buffer, int readerIndex, int writerIndex) {
  super(buffer.maxCapacity());
  if (buffer instanceof DuplicatedByteBuf) {
    this.buffer = ((DuplicatedByteBuf) buffer).buffer;
  } else if (buffer instanceof AbstractPooledDerivedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(readerIndex, writerIndex);
  markReaderIndex();
  markWriterIndex();
}

代码示例来源:origin: wildfly/wildfly

DuplicatedByteBuf(ByteBuf buffer, int readerIndex, int writerIndex) {
  super(buffer.maxCapacity());
  if (buffer instanceof DuplicatedByteBuf) {
    this.buffer = ((DuplicatedByteBuf) buffer).buffer;
  } else if (buffer instanceof AbstractPooledDerivedByteBuf) {
    this.buffer = buffer.unwrap();
  } else {
    this.buffer = buffer;
  }
  setIndex(readerIndex, writerIndex);
  markReaderIndex();
  markWriterIndex();
}

代码示例来源:origin: netty/netty

final int maxCapacity = byteBuf.maxCapacity();
if (capacity == maxCapacity) {
  allocHandle.incMessagesRead(1);

相关文章

ByteBuf类方法