Java Code Examples for io.netty.buffer.ByteBuf#touch()

The following examples show how to use io.netty.buffer.ByteBuf#touch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LargeFieldValue.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch(Object hint) {
    if (this.buffers.isEmpty()) {
        return this;
    }

    for (ByteBuf buf : this.buffers) {
        buf.touch(hint);
    }

    return this;
}
 
Example 2
Source File: LargeFieldReader.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public LargeFieldReader touch(Object hint) {
    for (ByteBuf buffer : buffers) {
        buffer.touch(hint);
    }
    return this;
}
 
Example 3
Source File: InternalAttribute.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public InterfaceHttpData touch() {
    for (ByteBuf buf: value) {
        buf.touch();
    }
    return this;
}
 
Example 4
Source File: InternalAttribute.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public InterfaceHttpData touch(Object hint) {
    for (ByteBuf buf: value) {
        buf.touch(hint);
    }
    return this;
}
 
Example 5
Source File: LargeFieldValue.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public ReferenceCounted touch(Object hint) {
    if (this.buffers.isEmpty()) {
        return this;
    }

    for (ByteBuf buf : this.buffers) {
        buf.touch(hint);
    }

    return this;
}
 
Example 6
Source File: LargeFieldReader.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public LargeFieldReader touch(Object hint) {
    for (ByteBuf buffer : buffers) {
        buffer.touch(hint);
    }
    return this;
}
 
Example 7
Source File: ServletHttpExchange.java    From spring-boot-protocol with Apache License 2.0 5 votes vote down vote up
public void touch(Object hit){
    if(request != null){
        ByteBuf byteBuf = request.getInputStream0().unwrap();
        if(byteBuf != null){
            byteBuf.touch(hit);
        }
    }
}
 
Example 8
Source File: MessageDefragmenter.java    From tchannel-java with MIT License 5 votes vote down vote up
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception {

    buf.touch("MessageDefragmenter.decode(...)");
    Frame frame = MessageCodec.decode(
        MessageCodec.decode(buf)
    );

    TChannelMessage msg = null;
    switch (frame.getType()) {
        case CallRequest:
        case CallResponse:
            msg = decodeCallFrame(ctx, (CallFrame) frame);
            break;
        case CallRequestContinue:
        case CallResponseContinue:
            msg = decodeCallContinueFrame((CallFrame) frame);
            break;
        case Error:
            msg = MessageCodec.decodeErrorResponse((ErrorFrame) frame);
            break;
        default:
            break;
    }

    if (msg != null) {
        out.add(msg);
    }
}
 
Example 9
Source File: InitRequestInitiator.java    From tchannel-java with MIT License 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws TChannelError {

    buf.touch("InitRequestInitiator.channelRead0(...)");
    Frame frame = MessageCodec.decode(
        MessageCodec.decode(buf)
    );

    switch (frame.getType()) {

        case InitResponse:

            InitResponseFrame initResponseFrameMessage = (InitResponseFrame) frame;

            if (initResponseFrameMessage.getVersion() == InitFrame.DEFAULT_VERSION) {
                ctx.pipeline().remove(this);
                peerManager.setIdentified(ctx.channel(), initResponseFrameMessage.getHeaders());
            } else {

                // This will lead to a connection reset
                throw new TChannelProtocol(
                    String.format("Expected Protocol version: %d, got version: %d",
                        InitFrame.DEFAULT_VERSION, initResponseFrameMessage.getVersion())
                );
            }

            break;

        default:

            // This will lead to a connection reset
            throw new TChannelProtocol(
                "Frame recieved before Init Response" // FIXME typo
            );
    }
}
 
Example 10
Source File: ByteBufHttpData.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
public ByteBufHttpData replace(ByteBuf content) {
    requireNonNull(content, "content");
    content.touch();
    return new ByteBufHttpData(content, endOfStream);
}
 
Example 11
Source File: InitRequestHandler.java    From tchannel-java with MIT License 4 votes vote down vote up
@Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {

    buf.touch("InitRequestHandler.channelRead0(...)");
    Frame frame = MessageCodec.decode(
        MessageCodec.decode(buf)
    );

    switch (frame.getType()) {

        case InitRequest:

            InitRequestFrame initRequestFrameMessage = (InitRequestFrame) frame;

            if (initRequestFrameMessage.getVersion() == InitFrame.DEFAULT_VERSION) {

                InitResponseFrame initResponseFrame = new InitResponseFrame(
                    initRequestFrameMessage.getId(),
                    InitFrame.DEFAULT_VERSION
                );

                initResponseFrame.setHostPort(this.peerManager.getHostPort());

                // TODO: figure out what to put here
                initResponseFrame.setProcessName("java-process");
                MessageCodec.write(ctx, initResponseFrame);
                ctx.pipeline().remove(this);
                peerManager.setIdentified(ctx.channel(), initRequestFrameMessage.getHeaders());

            } else {
                sendError(ErrorType.FatalProtocolError,
                    String.format("Expected Protocol version: %d, got version: %d", InitFrame.DEFAULT_VERSION,
                        initRequestFrameMessage.getVersion()),
                    frame.getId(), ctx);
            }

            break;

        default:
            sendError(ErrorType.FatalProtocolError,
                "The first frame should be an Init Request",
                frame.getId(), ctx);
            break;
    }
}
 
Example 12
Source File: NettyDataBufferFactory.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Wrap the given Netty {@link ByteBuf} in a {@code NettyDataBuffer}.
 * @param byteBuf the Netty byte buffer to wrap
 * @return the wrapped buffer
 */
public NettyDataBuffer wrap(ByteBuf byteBuf) {
	byteBuf.touch();
	return new NettyDataBuffer(byteBuf, this);
}