本文整理了Java中io.netty.buffer.ByteBuf.resetWriterIndex()
方法的一些代码示例,展示了ByteBuf.resetWriterIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.resetWriterIndex()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:resetWriterIndex
[英]Repositions the current writerIndex to the marked writerIndex in this buffer.
[中]将当前writerIndex重新定位到此缓冲区中标记的writerIndex。
代码示例来源:origin: netty/netty
@Override
public ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void resetWriterIndex() {
buffer.resetWriterIndex();
}
代码示例来源:origin: netty/netty
@Override
public final ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: redisson/redisson
@Override
public final ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: wildfly/wildfly
@Override
public ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: wildfly/wildfly
@Override
public final ByteBuf resetWriterIndex() {
buf.resetWriterIndex();
return this;
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public final ByteBuf resetWriterIndex() {
byteBuf.resetWriterIndex();
return this;
}
代码示例来源:origin: wildfly/wildfly
@Override
public void resetWriterIndex() {
buffer.resetWriterIndex();
}
代码示例来源:origin: fengjiachun/Jupiter
private ByteBuf doEncodeRequest(JRequestPayload request) {
byte sign = JProtocolHeader.toSign(request.serializerCode(), JProtocolHeader.REQUEST);
long invokeId = request.invokeId();
ByteBuf byteBuf = (ByteBuf) request.outputBuf().backingObject();
int length = byteBuf.readableBytes();
byteBuf.markWriterIndex();
byteBuf.writerIndex(byteBuf.writerIndex() - length);
byteBuf.writeShort(JProtocolHeader.MAGIC)
.writeByte(sign)
.writeByte(0x00)
.writeLong(invokeId)
.writeInt(length - JProtocolHeader.HEADER_SIZE);
byteBuf.resetWriterIndex();
return byteBuf;
}
代码示例来源:origin: fengjiachun/Jupiter
private ByteBuf doEncodeRequest(JRequestPayload request) {
byte sign = JProtocolHeader.toSign(request.serializerCode(), JProtocolHeader.REQUEST);
long invokeId = request.invokeId();
ByteBuf byteBuf = (ByteBuf) request.outputBuf().backingObject();
int length = byteBuf.readableBytes();
byteBuf.markWriterIndex();
byteBuf.writerIndex(byteBuf.writerIndex() - length);
byteBuf.writeShort(JProtocolHeader.MAGIC)
.writeByte(sign)
.writeByte(0x00)
.writeLong(invokeId)
.writeInt(length - JProtocolHeader.HEADER_SIZE);
byteBuf.resetWriterIndex();
return byteBuf;
}
代码示例来源:origin: fengjiachun/Jupiter
private ByteBuf doEncodeResponse(JResponsePayload response) {
byte sign = JProtocolHeader.toSign(response.serializerCode(), JProtocolHeader.RESPONSE);
byte status = response.status();
long invokeId = response.id();
ByteBuf byteBuf = (ByteBuf) response.outputBuf().backingObject();
int length = byteBuf.readableBytes();
byteBuf.markWriterIndex();
byteBuf.writerIndex(byteBuf.writerIndex() - length);
byteBuf.writeShort(JProtocolHeader.MAGIC)
.writeByte(sign)
.writeByte(status)
.writeLong(invokeId)
.writeInt(length - JProtocolHeader.HEADER_SIZE);
byteBuf.resetWriterIndex();
return byteBuf;
}
}
代码示例来源:origin: fengjiachun/Jupiter
private ByteBuf doEncodeResponse(JResponsePayload response) {
byte sign = JProtocolHeader.toSign(response.serializerCode(), JProtocolHeader.RESPONSE);
byte status = response.status();
long invokeId = response.id();
ByteBuf byteBuf = (ByteBuf) response.outputBuf().backingObject();
int length = byteBuf.readableBytes();
byteBuf.markWriterIndex();
byteBuf.writerIndex(byteBuf.writerIndex() - length);
byteBuf.writeShort(JProtocolHeader.MAGIC)
.writeByte(sign)
.writeByte(status)
.writeLong(invokeId)
.writeInt(length - JProtocolHeader.HEADER_SIZE);
byteBuf.resetWriterIndex();
return byteBuf;
}
}
代码示例来源:origin: lettuce-io/lettuce-core
private void encode(ChannelHandlerContext ctx, ByteBuf out, RedisCommand<?, ?, ?> command) {
try {
out.markWriterIndex();
command.encode(out);
} catch (RuntimeException e) {
out.resetWriterIndex();
command.completeExceptionally(new EncoderException(
"Cannot encode command. Please close the connection as the connection state may be out of sync.",
e));
}
if (debugEnabled) {
logger.debug("{} writing command {}", logPrefix(ctx.channel()), command);
if (traceEnabled) {
logger.trace("{} Sent: {}", logPrefix(ctx.channel()), out.toString(Charset.defaultCharset()).trim());
}
}
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
/**
* Replaces an HTTP entity body with the specified binary contents.
* TODO: Currently this method only works for FullHttpMessages, since it must modify the Content-Length header; determine if this may be applied to chunked messages as well
*
* @param message the HTTP message to manipulate
* @param newBinaryContents the new entity body contents
*/
public static void replaceBinaryHttpEntityBody(FullHttpMessage message, byte[] newBinaryContents) {
message.content().resetWriterIndex();
// resize the buffer if needed, since the new message may be longer than the old one
message.content().ensureWritable(newBinaryContents.length, true);
message.content().writeBytes(newBinaryContents);
// update the Content-Length header, since the size may have changed
message.headers().set(HttpHeaders.Names.CONTENT_LENGTH, newBinaryContents.length);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Benchmark
public void vertxSmall() throws Exception {
byteBuf.resetWriterIndex();
encoder.encodeHeaders(vertxSmallHeaders, byteBuf);
consume(byteBuf);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Benchmark
public void baseline() throws Exception {
byteBuf.resetWriterIndex();
encoder.encodeHeaders(emptyHeaders, byteBuf);
consume(byteBuf);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Benchmark
public void nettySmall() throws Exception {
byteBuf.resetWriterIndex();
encoder.encodeHeaders(nettySmallHeaders, byteBuf);
consume(byteBuf);
}
代码示例来源:origin: qunarcorp/qmq
out.resetWriterIndex();
out.writeInt(bodyLen);
代码示例来源:origin: io.vertx/vertx-core
@Benchmark
public void vertxSmall() throws Exception {
byteBuf.resetWriterIndex();
encoder.encodeHeaders(vertxSmallHeaders, byteBuf);
consume(byteBuf);
}
}
内容来源于网络,如有侵权,请联系作者删除!