com.taobao.metamorphosis.utils
类 MessageUtils
java.lang.Object
com.taobao.metamorphosis.utils.MessageUtils
public final class MessageUtils
- extends Object
字段摘要 |
static int |
HEADER_LEN
20个字节的头部 *
message length(4 bytes),including attribute and payload
checksum(4 bytes)
message id(8 bytes)
message flag(4 bytes)
|
static int |
MAX_READ_BUFFER_SIZE
|
方法摘要 |
static MessageUtils.DecodedMessage |
decodeMessage(String topic,
byte[] data,
int offset)
从binary数据中解出消息 |
static byte[] |
encodePayload(Message message)
将消息属性和消息payload打包,结构如下: 0或者1个定长attribute + payload |
static int |
getInt(int offset,
byte[] data)
|
static ByteBuffer |
makeMessageBuffer(List<Long> msgIds,
List<PutCommand> reqs)
|
static ByteBuffer |
makeMessageBuffer(long msgId,
PutCommand req)
创建消息buffer,实际存储在服务器的结构如下:
message length(4 bytes),including attribute and payload
checksum(4 bytes)
message id(8 bytes)
message flag(4 bytes)
attribute length(4 bytes) + attribute,optional
payload
|
static void |
vailidateMessage(int offset,
int msgLen,
int checksum,
byte[] data)
校验checksum |
从类 java.lang.Object 继承的方法 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HEADER_LEN
public static final int HEADER_LEN
- 20个字节的头部 *
- message length(4 bytes),including attribute and payload
- checksum(4 bytes)
- message id(8 bytes)
- message flag(4 bytes)
- 另请参见:
- 常量字段值
MAX_READ_BUFFER_SIZE
public static final int MAX_READ_BUFFER_SIZE
MessageUtils
public MessageUtils()
makeMessageBuffer
public static final ByteBuffer makeMessageBuffer(long msgId,
PutCommand req)
- 创建消息buffer,实际存储在服务器的结构如下:
- message length(4 bytes),including attribute and payload
- checksum(4 bytes)
- message id(8 bytes)
- message flag(4 bytes)
- attribute length(4 bytes) + attribute,optional
- payload
- 参数:
req
-
- 返回:
makeMessageBuffer
public static final ByteBuffer makeMessageBuffer(List<Long> msgIds,
List<PutCommand> reqs)
decodeMessage
public static final MessageUtils.DecodedMessage decodeMessage(String topic,
byte[] data,
int offset)
throws InvalidMessageException
- 从binary数据中解出消息
- 参数:
topic
- data
- offset
-
- 返回:
-
- 抛出:
InvalidMessageException
vailidateMessage
public static final void vailidateMessage(int offset,
int msgLen,
int checksum,
byte[] data)
throws InvalidMessageException
- 校验checksum
- 参数:
msg
- checksum
-
- 抛出:
InvalidMessageException
getInt
public static final int getInt(int offset,
byte[] data)
encodePayload
public static final byte[] encodePayload(Message message)
- 将消息属性和消息payload打包,结构如下: 0或者1个定长attribute + payload
- 参数:
message
-
- 返回:
Copyright © 2010–2013. All rights reserved.