com.couchbase.client.deps.io.netty.buffer.ByteBuf.writeInt()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(138)

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

ByteBuf.writeInt介绍

[英]Sets the specified 32-bit integer at the current writerIndexand increases the writerIndex by 4 in this buffer.
[中]在当前writerIndex处设置指定的32位整数,并在此缓冲区中将writerIndex增加4。

代码示例

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public ByteBuf writeInt(int value) {
  buf.writeInt(value);
  return this;
}

代码示例来源:origin: com.couchbase.client/core-io

/**
 * Creates a new 4-byte big-endian buffer that holds the specified 32-bit integer.
 */
public static ByteBuf copyInt(int value) {
  ByteBuf buf = buffer(4);
  buf.writeInt(value);
  return buf;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
public ByteBuf writeInt(int value) {
  buf.writeInt(ByteBufUtil.swapInt(value));
  return this;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

/**
 * Creates a new 4-byte big-endian buffer that holds the specified 32-bit integer.
 */
public static ByteBuf copyInt(int value) {
  ByteBuf buf = buffer(4);
  buf.writeInt(value);
  return buf;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
public ByteBuf writeInt(int value) {
  buf.writeInt(ByteBufUtil.swapInt(value));
  return this;
}

代码示例来源:origin: com.couchbase.client/core-io

public ByteBuf encodeRstStreamFrame(ByteBufAllocator allocator, int streamId, int statusCode) {
  byte flags = 0;
  int length = 8;
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  writeControlFrameHeader(frame, SPDY_RST_STREAM_FRAME, flags, length);
  frame.writeInt(streamId);
  frame.writeInt(statusCode);
  return frame;
}

代码示例来源:origin: com.couchbase.client/core-io

public ByteBuf encodeGoAwayFrame(ByteBufAllocator allocator, int lastGoodStreamId, int statusCode) {
  byte flags = 0;
  int length = 8;
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  writeControlFrameHeader(frame, SPDY_GOAWAY_FRAME, flags, length);
  frame.writeInt(lastGoodStreamId);
  frame.writeInt(statusCode);
  return frame;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

public ByteBuf encodeRstStreamFrame(ByteBufAllocator allocator, int streamId, int statusCode) {
  byte flags = 0;
  int length = 8;
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  writeControlFrameHeader(frame, SPDY_RST_STREAM_FRAME, flags, length);
  frame.writeInt(streamId);
  frame.writeInt(statusCode);
  return frame;
}

代码示例来源:origin: couchbase/java-dcp-client

/**
 * Initialize the buffer with all the values needed.
 *
 * Note that this will implicitly set the flags to "consumer".
 */
public static void init(final ByteBuf buffer) {
  MessageUtil.initRequest(OPEN_CONNECTION_OPCODE, buffer);
  ByteBuf extras = Unpooled.buffer(8);
  MessageUtil.setExtras(extras.writeInt(0).writeInt(Type.PRODUCER.value), buffer);
  extras.release();
}

代码示例来源:origin: couchbase/couchbase-jvm-core

/**
   * Calculates and writes the 4-byte checksum to the output buffer
   *
   * @param slice The data to calculate the checksum for
   * @param out The output buffer to write the checksum to
   */
  private static void calculateAndWriteChecksum(ByteBuf slice, ByteBuf out) {
    out.writeInt(ByteBufUtil.swapInt(calculateChecksum(slice)));
  }
}

代码示例来源:origin: com.couchbase.client/core-io

/**
   * Calculates and writes the 4-byte checksum to the output buffer
   *
   * @param slice The data to calculate the checksum for
   * @param out The output buffer to write the checksum to
   */
  private static void calculateAndWriteChecksum(ByteBuf slice, ByteBuf out) {
    out.writeInt(ByteBufUtil.swapInt(calculateChecksum(slice)));
  }
}

代码示例来源:origin: com.couchbase.client/core-io

public ByteBuf encodePingFrame(ByteBufAllocator allocator, int id) {
  byte flags = 0;
  int length = 4;
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  writeControlFrameHeader(frame, SPDY_PING_FRAME, flags, length);
  frame.writeInt(id);
  return frame;
}

代码示例来源:origin: couchbase/java-dcp-client

public static void ackBytes(final ByteBuf buffer, int bytes) {
  ByteBuf extras = Unpooled.buffer(4);
  MessageUtil.setExtras(extras.writeInt(bytes), buffer);
  extras.release();
}

代码示例来源:origin: couchbase/java-dcp-client

public static void opaque(final ByteBuf buffer, int opaque) {
    ByteBuf extras = Unpooled.buffer(4);
    MessageUtil.setExtras(extras.writeInt(opaque), buffer);
    extras.release();
  }
}

代码示例来源:origin: com.couchbase.client/core-io

public ByteBuf encodeHeadersFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf headerBlock) {
  int headerBlockLength = headerBlock.readableBytes();
  byte flags = last ? SPDY_FLAG_FIN : 0;
  int length = 4 + headerBlockLength;
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  writeControlFrameHeader(frame, SPDY_HEADERS_FRAME, flags, length);
  frame.writeInt(streamId);
  frame.writeBytes(headerBlock, headerBlock.readerIndex(), headerBlockLength);
  return frame;
}

代码示例来源:origin: couchbase/couchbase-jvm-core

public ByteBuf encodeDataFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf data) {
  byte flags = last ? SPDY_DATA_FLAG_FIN : 0;
  int length = data.readableBytes();
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  frame.writeInt(streamId & 0x7FFFFFFF);
  frame.writeByte(flags);
  frame.writeMedium(length);
  frame.writeBytes(data, data.readerIndex(), length);
  return frame;
}

代码示例来源:origin: com.couchbase.client/core-io

public ByteBuf encodeDataFrame(ByteBufAllocator allocator, int streamId, boolean last, ByteBuf data) {
  byte flags = last ? SPDY_DATA_FLAG_FIN : 0;
  int length = data.readableBytes();
  ByteBuf frame = allocator.ioBuffer(SPDY_HEADER_SIZE + length).order(ByteOrder.BIG_ENDIAN);
  frame.writeInt(streamId & 0x7FFFFFFF);
  frame.writeByte(flags);
  frame.writeMedium(length);
  frame.writeBytes(data, data.readerIndex(), length);
  return frame;
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponse msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getStatus());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

代码示例来源:origin: com.couchbase.client/core-io

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheRequest msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getReserved());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

代码示例来源:origin: couchbase/couchbase-jvm-core

@Override
protected void encodeHeader(ByteBuf buf, BinaryMemcacheResponse msg) {
  buf.writeByte(msg.getMagic());
  buf.writeByte(msg.getOpcode());
  buf.writeShort(msg.getKeyLength());
  buf.writeByte(msg.getExtrasLength());
  buf.writeByte(msg.getDataType());
  buf.writeShort(msg.getStatus());
  buf.writeInt(msg.getTotalBodyLength());
  buf.writeInt(msg.getOpaque());
  buf.writeLong(msg.getCAS());
}

相关文章