Class UpdateMsg
- java.lang.Object
-
- org.opends.server.replication.protocol.ReplicationMsg
-
- org.opends.server.replication.protocol.UpdateMsg
-
- All Implemented Interfaces:
Comparable<UpdateMsg>
- Direct Known Subclasses:
LDAPUpdateMsg,ReplicaOfflineMsg
public class UpdateMsg extends ReplicationMsg implements Comparable<UpdateMsg>
Abstract class that must be extended to define a message used for sending Updates between servers.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanassuredFlagTrue when the update must use assured replication.protected AssuredModeassuredModeWhen assuredFlag is true, defines the requested assured mode.protected CSNcsnThe CSN of this update.protected shortprotocolVersionProtocol version.protected bytesafeDataLevelWhen assured mode is safe data, gives the requested level.-
Fields inherited from class org.opends.server.replication.protocol.ReplicationMsg
MSG_TYPE_DISK_ENCODING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(UpdateMsg msg)booleancontributesToDomainState()Whether the current message can update the "ds-sync-state" attribute.protected voiddecodeHeader(byte allowedType, ByteArrayScanner scanner)Decode the Header part of this Update message, and check its type.protected ByteArrayBuilderencodeHeader(byte msgType, short protocolVersion)Encode the common header for all the UpdateMsg.booleanequals(Object obj)AssuredModegetAssuredMode()Get the assured mode in this message.byte[]getBytes()Returns the encoded representation of this update message using the current protocol version.byte[]getBytes(short protocolVersion)This implementation is only called during unit testing, so we are free to force the protocol version.CSNgetCSN()Get the CSN from the message.byte[]getPayload()Get the payload of the UpdateMsg.bytegetSafeDataLevel()Get the safe data level in this message.shortgetVersion()Get the version included in the update message.inthashCode()booleanisAssured()Get a boolean indicating if the Update must be processed as an Asynchronous or as an assured replication.voidsetAssured(boolean assured)Set the Update message as an assured message.voidsetAssuredMode(AssuredMode assuredMode)Set the assured mode.voidsetSafeDataLevel(byte safeDataLevel)Set the safe data level.intsize()Return the number of bytes used by this message.-
Methods inherited from class org.opends.server.replication.protocol.ReplicationMsg
generateMsg, isEncodableFor
-
-
-
-
Field Detail
-
protocolVersion
protected short protocolVersion
Protocol version.
-
csn
protected CSN csn
The CSN of this update.
-
assuredFlag
protected boolean assuredFlag
True when the update must use assured replication.
-
assuredMode
protected AssuredMode assuredMode
When assuredFlag is true, defines the requested assured mode.
-
safeDataLevel
protected byte safeDataLevel
When assured mode is safe data, gives the requested level.
-
-
Constructor Detail
-
UpdateMsg
protected UpdateMsg()
Creates a new empty UpdateMsg.
-
UpdateMsg
public UpdateMsg(CSN csn, byte[] payload)
Creates a new UpdateMsg with the given informations.This constructor is only used for testing.
- Parameters:
csn- The CSN associated with the change encoded in this message.payload- The payload that must be encoded in this message.
-
-
Method Detail
-
getCSN
public CSN getCSN()
Get the CSN from the message.- Returns:
- the CSN
-
isAssured
public boolean isAssured()
Get a boolean indicating if the Update must be processed as an Asynchronous or as an assured replication.- Returns:
- Returns the assuredFlag.
-
setAssured
public void setAssured(boolean assured)
Set the Update message as an assured message.- Parameters:
assured- If the message is assured or not. Using true implies setAssuredMode method must be called.
-
compareTo
public int compareTo(UpdateMsg msg)
- Specified by:
compareToin interfaceComparable<UpdateMsg>
-
getAssuredMode
public AssuredMode getAssuredMode()
Get the assured mode in this message.- Returns:
- The assured mode in this message
-
getSafeDataLevel
public byte getSafeDataLevel()
Get the safe data level in this message.- Returns:
- The safe data level in this message
-
setAssuredMode
public void setAssuredMode(AssuredMode assuredMode)
Set the assured mode. Assured boolean must be set to true for this field to mean something.- Parameters:
assuredMode- The chosen assured mode.
-
setSafeDataLevel
public void setSafeDataLevel(byte safeDataLevel)
Set the safe data level. Assured mode should be set to safe data for this field to mean something.- Parameters:
safeDataLevel- The chosen safe data level.
-
getVersion
public short getVersion()
Get the version included in the update message. Means the replication protocol version with which this update message was instantiated.- Returns:
- The version with which this update message was instantiated.
-
size
public int size()
Return the number of bytes used by this message.- Returns:
- The number of bytes used by this message.
-
encodeHeader
protected ByteArrayBuilder encodeHeader(byte msgType, short protocolVersion)
Encode the common header for all the UpdateMsg. This uses the current protocol version.- Parameters:
msgType- The type of UpdateMsg to encode.protocolVersion- The ProtocolVersion to use when encoding.- Returns:
- a byte array builder containing the common header
-
decodeHeader
protected void decodeHeader(byte allowedType, ByteArrayScanner scanner) throws DataFormatExceptionDecode the Header part of this Update message, and check its type.- Parameters:
allowedType- The allowed type of this Update Message.scanner- The encoded form of the UpdateMsg.- Throws:
DataFormatException- if the scanner does not contain a valid common header.
-
getBytes
public byte[] getBytes()
Returns the encoded representation of this update message using the current protocol version.- Returns:
- The encoded representation of this update message.
-
getBytes
public byte[] getBytes(short protocolVersion)
This implementation is only called during unit testing, so we are free to force the protocol version. Underlying implementations override this method in order to provide version specific encodings. 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.- Specified by:
getBytesin classReplicationMsg- 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.
-
getPayload
public byte[] getPayload()
Get the payload of the UpdateMsg.- Returns:
- The payload of the UpdateMsg.
-
contributesToDomainState
public boolean contributesToDomainState()
Whether the current message can update the "ds-sync-state" attribute.- Returns:
- true if current message can update the "ds-sync-state" attribute, false otherwise.
-
-