Class ReplicationMsg
- java.lang.Object
-
- org.opends.server.replication.protocol.ReplicationMsg
-
- Direct Known Subclasses:
AckMsg,ChangeStatusMsg,ChangeTimeHeartbeatMsg,HeartbeatMsg,MonitorMsg,MonitorRequestMsg,ResetGenerationIdMsg,RoutableMsg,StartMsg,StartSessionMsg,StopMsg,TopologyMsg,UpdateMsg,WindowMsg,WindowProbeMsg
public abstract class ReplicationMsg extends Object
Abstract class that must be used when defining messages that can be sent for replication purpose between servers. When extending this class one should also create a new MSG_TYPE and should update the generateMsg() method.
-
-
Field Summary
Fields Modifier and Type Field Description static byteMSG_TYPE_DISK_ENCODINGReserved type for uses other than protocol messages.
-
Constructor Summary
Constructors Modifier Constructor Description protectedReplicationMsg()Protected constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ReplicationMsggenerateMsg(byte[] buffer, short protocolVersion)Generates a ReplicationMsg from its encoded form.abstract byte[]getBytes(short protocolVersion)Serializes the PDU using the provided replication protocol version.booleanisEncodableFor(short protocolVersion)Whether this message has an encoding for a peer which negotiated the provided replication protocol version.
-
-
-
Field Detail
-
MSG_TYPE_DISK_ENCODING
public static final byte MSG_TYPE_DISK_ENCODING
Reserved type for uses other than protocol messages.- See Also:
- Constant Field Values
-
-
Method Detail
-
getBytes
public abstract byte[] getBytes(short protocolVersion)
Serializes the PDU using the provided replication protocol version. WARNING: should be overwritten by a PDU (sub class) we want to support older protocol version serialization for.- Parameters:
protocolVersion- The protocol version to use for serialization. The version should normally be older than the current one.- Returns:
- The encoded PDU, or
nullif the message isn't supported in that protocol version.
-
isEncodableFor
public boolean isEncodableFor(short protocolVersion)
Whether this message has an encoding for a peer which negotiated the provided replication protocol version.A message which has none is dropped by
Session.publish(ReplicationMsg)- itsgetBytes(short)returnsnull- with nothing on the wire and nothing in the log, so a caller which goes on to report what the peer was told must ask this before it publishes.- Parameters:
protocolVersion- The protocol version negotiated with the peer.- Returns:
trueif this message can be encoded for that version,falseif it has no encoding for it at all.
-
generateMsg
public static ReplicationMsg generateMsg(byte[] buffer, short protocolVersion) throws DataFormatException, NotSupportedOldVersionPDUException
Generates a ReplicationMsg from its encoded form. This un-serialization is done taking into account the various supported replication protocol versions.- Parameters:
buffer- The encode form of the ReplicationMsg.protocolVersion- The version to use to decode the msg.- Returns:
- The generated SynchronizationMessage.
- Throws:
DataFormatException- If the encoded form was not a valid msg.NotSupportedOldVersionPDUException- If the PDU is part of an old protocol version and we do not support it.
-
-