REQ
- Type of the requests of the protocol.RESP
- Type of the responses of the protocol.@Internal public final class MessageSerializer<REQ extends MessageBody,RESP extends MessageBody> extends Object
client
and server
.
The binary messages have the following format:
<------ Frame -------------------------> +----------------------------------------+ | HEADER (8) | PAYLOAD (VAR) | +------------------+----------------------------------------+ | FRAME LENGTH (4) | VERSION (4) | TYPE (4) | CONTENT (VAR) | +------------------+----------------------------------------+
The concrete content of a message depends on the MessageType
.
Constructor and Description |
---|
MessageSerializer(MessageDeserializer<REQ> requestDeser,
MessageDeserializer<RESP> responseDeser) |
Modifier and Type | Method and Description |
---|---|
static MessageType |
deserializeHeader(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the header and returns the
MessageType . |
REQ |
deserializeRequest(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the request sent to the
AbstractServerBase . |
static RequestFailure |
deserializeRequestFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the
RequestFailure sent to the Client in case of protocol related errors. |
RESP |
deserializeResponse(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the response sent to the
Client . |
static Throwable |
deserializeServerFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the failure message sent to the
Client in case of server related errors. |
static long |
getRequestId(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
De-serializes the header and returns the
MessageType . |
static <REQ extends MessageBody> |
serializeRequest(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc,
long requestId,
REQ request)
Serializes the request sent to the
AbstractServerBase . |
static org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf |
serializeRequestFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc,
long requestId,
Throwable cause)
Serializes the exception containing the failure message sent to the
Client in case of protocol related errors. |
static <RESP extends MessageBody> |
serializeResponse(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc,
long requestId,
RESP response)
Serializes the response sent to the
Client . |
static org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf |
serializeServerFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc,
Throwable cause)
Serializes the failure message sent to the
Client in case of server related errors. |
public MessageSerializer(MessageDeserializer<REQ> requestDeser, MessageDeserializer<RESP> responseDeser)
public static <REQ extends MessageBody> org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf serializeRequest(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc, long requestId, REQ request)
AbstractServerBase
.alloc
- The ByteBufAllocator
used to allocate the buffer to serialize the
message into.requestId
- The id of the request to which the message refers to.request
- The request to be serialized.ByteBuf
containing the serialized message.public static <RESP extends MessageBody> org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf serializeResponse(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc, long requestId, RESP response)
Client
.alloc
- The ByteBufAllocator
used to allocate the buffer to serialize the
message into.requestId
- The id of the request to which the message refers to.response
- The response to be serialized.ByteBuf
containing the serialized message.public static org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf serializeRequestFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc, long requestId, Throwable cause) throws IOException
Client
in case of protocol related errors.alloc
- The ByteBufAllocator
used to allocate the buffer to serialize the
message into.requestId
- The id of the request to which the message refers to.cause
- The exception thrown at the server.ByteBuf
containing the serialized message.IOException
public static org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf serializeServerFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufAllocator alloc, Throwable cause) throws IOException
Client
in case of server related errors.alloc
- The ByteBufAllocator
used to allocate the buffer to serialize the
message into.cause
- The exception thrown at the server.IOException
public static MessageType deserializeHeader(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
MessageType
.
The buffer is expected to be at the header position.
buf
- The ByteBuf
containing the serialized header.IllegalStateException
- If unexpected message version or message type.public static long getRequestId(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
MessageType
.
The buffer is expected to be at the request id position.
buf
- The ByteBuf
containing the serialized request id.public REQ deserializeRequest(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
AbstractServerBase
.
The buffer is expected to be at the request position.
buf
- The ByteBuf
containing the serialized request.public RESP deserializeResponse(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf)
Client
.
The buffer is expected to be at the response position.
buf
- The ByteBuf
containing the serialized response.public static RequestFailure deserializeRequestFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf) throws IOException, ClassNotFoundException
RequestFailure
sent to the Client
in case of protocol related errors.
The buffer is expected to be at the correct position.
buf
- The ByteBuf
containing the serialized failure message.IOException
ClassNotFoundException
public static Throwable deserializeServerFailure(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf buf) throws IOException, ClassNotFoundException
Client
in case of server related errors.
The buffer is expected to be at the correct position.
buf
- The ByteBuf
containing the serialized failure message.IOException
ClassNotFoundException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.