org.opends.server.replication.protocol
Class UpdateMessage

java.lang.Object
  extended by org.opends.server.replication.protocol.ReplicationMessage
      extended by org.opends.server.replication.protocol.UpdateMessage
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<UpdateMessage>
Direct Known Subclasses:
AddMsg, DeleteMsg, ModifyDNMsg, ModifyMsg

public abstract class UpdateMessage
extends ReplicationMessage
implements java.io.Serializable, java.lang.Comparable<UpdateMessage>

Abstract class that must be extended to define a message used for sending Updates between servers.

See Also:
Serialized Form

Constructor Summary
protected UpdateMessage(byte[] in)
          Creates a new UpdateMessage from an ecoded byte array.
  UpdateMessage(OperationContext ctx, java.lang.String dn)
          Creates a new UpdateMessage with the given informations.
 
Method Summary
 int compareTo(UpdateMessage msg)
          
 AbstractOperation createOperation(InternalClientConnection conn)
          Create and Operation from the message.
abstract  AbstractOperation createOperation(InternalClientConnection conn, java.lang.String newDn)
          Create and Operation from the message using the provided DN.
 int decodeHeader(byte type, byte[] encodedMsg)
          Decode the Header part of this Update Message, and check its type.
 byte[] encodeHeader(byte type, int additionalLength)
          Encode the common header for all the UpdateMessage.
 boolean equals(java.lang.Object obj)
          
static UpdateMessage generateMsg(PostOperationOperation op, boolean isAssured)
          Generates an Update Message which the provided information.
 ChangeNumber getChangeNumber()
          Get the ChangeNumber from the message.
 java.lang.String getDn()
          Get the DN on which the operation happened.
 java.lang.String getUniqueId()
          Get the Unique Identifier of the entry on which the operation happened.
 int hashCode()
          
 boolean isAssured()
          Get a boolean indicating if the Update must be processed as an Asynchronous or as an assured replication.
 void setAssured()
          Set the Update message as an assured message.
 void setDn(java.lang.String dn)
          Set the DN.
 
Methods inherited from class org.opends.server.replication.protocol.ReplicationMessage
addByteArray, generateMsg, getBytes, getNextLength
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateMessage

public UpdateMessage(OperationContext ctx,
                     java.lang.String dn)
Creates a new UpdateMessage with the given informations.

Parameters:
ctx - The replication Context of the operation for which the update message must be created,.
dn - The dn of the entry on which the change that caused the creation of this object happened

UpdateMessage

protected UpdateMessage(byte[] in)
                 throws java.util.zip.DataFormatException,
                        java.io.UnsupportedEncodingException
Creates a new UpdateMessage from an ecoded byte array.

Parameters:
in - The encoded byte array containind the UpdateMessage.
Throws:
java.util.zip.DataFormatException - if the encoded byte array is not valid.
java.io.UnsupportedEncodingException - if UTF-8 is not supprted.
Method Detail

generateMsg

public static UpdateMessage generateMsg(PostOperationOperation op,
                                        boolean isAssured)
Generates an Update Message which the provided information.

Parameters:
op - The operation for which the message must be created.
isAssured - flag indicating if the operation is an assured operation.
Returns:
The generated message.

getChangeNumber

public ChangeNumber getChangeNumber()
Get the ChangeNumber from the message.

Returns:
the ChangeNumber

getDn

public java.lang.String getDn()
Get the DN on which the operation happened.

Returns:
The DN on which the operations happened.

setDn

public void setDn(java.lang.String dn)
Set the DN.

Parameters:
dn - The dn that must now be used for this message.

getUniqueId

public java.lang.String getUniqueId()
Get the Unique Identifier of the entry on which the operation happened.

Returns:
The Unique Identifier of the entry on which the operation happened.

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()
Set the Update message as an assured message.


equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(UpdateMessage msg)

Specified by:
compareTo in interface java.lang.Comparable<UpdateMessage>

createOperation

public AbstractOperation createOperation(InternalClientConnection conn)
                                  throws LDAPException,
                                         ASN1Exception,
                                         java.util.zip.DataFormatException
Create and Operation from the message.

Parameters:
conn - connection to use when creating the message
Returns:
the created Operation
Throws:
LDAPException - In case of LDAP decoding exception.
ASN1Exception - In case of ASN1 decoding exception.
java.util.zip.DataFormatException - In case of bad msg format.

createOperation

public abstract AbstractOperation createOperation(InternalClientConnection conn,
                                                  java.lang.String newDn)
                                           throws LDAPException,
                                                  ASN1Exception,
                                                  java.util.zip.DataFormatException
Create and Operation from the message using the provided DN.

Parameters:
conn - connection to use when creating the message.
newDn - the DN to use when creating the operation.
Returns:
the created Operation.
Throws:
LDAPException - In case of LDAP decoding exception.
ASN1Exception - In case of ASN1 decoding exception.
java.util.zip.DataFormatException - In case of bad msg format.

encodeHeader

public byte[] encodeHeader(byte type,
                           int additionalLength)
                    throws java.io.UnsupportedEncodingException
Encode the common header for all the UpdateMessage.

Parameters:
type - the type of UpdateMessage to encode.
additionalLength - additional length needed to encode the remaining part of the UpdateMessage.
Returns:
a byte array containing the common header and enough space to encode the reamining bytes of the UpdateMessage as was specified by the additionalLength. (byte array length = common header length + additionalLength)
Throws:
java.io.UnsupportedEncodingException - if UTF-8 is not supported.

decodeHeader

public int decodeHeader(byte type,
                        byte[] encodedMsg)
                 throws java.util.zip.DataFormatException
Decode the Header part of this Update Message, and check its type.

Parameters:
type - The type of this Update Message.
encodedMsg - the encoded form of the UpdateMessage.
Returns:
the position at which the remaining part of the message starts.
Throws:
java.util.zip.DataFormatException - if the encodedMsg does not contain a valid common header.