public class DataSerializer extends BaseSerializer
The main structure of the built message is |Header|Body|.
The header has the following structure |source|flags|destinationID|numberOfMessages|, source - source of the message flags - message flags destinationId - where the message is sent numberOfMessages - number of messages
Header can be followed by 0 or more messages, each message will have the following structure |length(integer)|message body|
For a keyed message the message body consists of two parts |key|body|
For some keys we need to send the length of the key, i.e. byte arrays and objects. In that case key consists of two parts |key length(integer)|actual key|
For other cases such as integer or double keys, we know the length of the key, so we only send the key.
MAX_SUB_MESSAGE_HEADER_SPACE, NORMAL_SUB_MESSAGE_HEADER_SIZE, sendBuffers, serializer
Constructor and Description |
---|
DataSerializer() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
serializeData(java.lang.Object payload,
SerializeState state,
DataBuffer targetBuffer,
DataPacker dataPacker)
Helper method that builds the body of the message for regular messages.
|
boolean |
serializeSingleMessage(java.lang.Object payload,
OutMessage sendMessage,
DataBuffer targetBuffer)
Builds the body of the message.
|
build, init
public boolean serializeSingleMessage(java.lang.Object payload, OutMessage sendMessage, DataBuffer targetBuffer)
serializeSingleMessage
in class BaseSerializer
payload
- the message that needs to be builtsendMessage
- the send message object that contains all the metadatatargetBuffer
- the data targetBuffer to which the built message needs to be copiedprotected boolean serializeData(java.lang.Object payload, SerializeState state, DataBuffer targetBuffer, DataPacker dataPacker)
payload
- the message that needs to be builtstate
- the state object of the messagetargetBuffer
- the data targetBuffer to which the built message needs to be copied