org.opends.server.replication.protocol
Class StartMessage

java.lang.Object
  extended by org.opends.server.replication.protocol.ReplicationMessage
      extended by org.opends.server.replication.protocol.StartMessage
Direct Known Subclasses:
ReplServerStartMessage, ServerStartMessage

public abstract class StartMessage
extends ReplicationMessage

This abstract message class is the superclass for start messages used by LDAP servers and Replication servers to initiate their communications. This class specifies a message header that contains the Replication Protocol version.


Field Summary
protected  int headerLength
          The length of the header of this message.
 
Constructor Summary
StartMessage(byte type, byte[] encodedMsg)
          Creates a new ServerStartMessage from its encoded form.
StartMessage(short protocolVersion, long generationId)
          Create a new StartMessage.
 
Method Summary
 int decodeHeader(byte type, byte[] encodedMsg)
          Decode the Header part of this message, and check its type.
 byte[] encodeHeader(byte type, int additionalLength)
          Encode the header for the start message.
 long getGenerationId()
          Get the generationId from this message.
 short getVersion()
          Get the version included in the Start Message mean the replication protocol version used by the server that created the message.
 
Methods inherited from class org.opends.server.replication.protocol.ReplicationMessage
addByteArray, generateMsg, getBytes, getNextLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headerLength

protected int headerLength
The length of the header of this message.

Constructor Detail

StartMessage

public StartMessage(short protocolVersion,
                    long generationId)
Create a new StartMessage.

Parameters:
protocolVersion - The Replication Protocol version of the server for which the StartMessage is created.
generationId - The generationId for this server.

StartMessage

public StartMessage(byte type,
                    byte[] encodedMsg)
             throws java.util.zip.DataFormatException
Creates a new ServerStartMessage from its encoded form.

Parameters:
type - The type of the message to create.
encodedMsg - The byte array containing the encoded form of the StartMessage.
Throws:
java.util.zip.DataFormatException - If the byte array does not contain a valid encoded form of the ServerStartMessage.
Method Detail

encodeHeader

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

Parameters:
type - The type of the message to create.
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 message, and check its type.

Parameters:
type - The type of this message.
encodedMsg - the encoded form of the message.
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.

getVersion

public short getVersion()
Get the version included in the Start Message mean the replication protocol version used by the server that created the message.

Returns:
The version used by the server that created the message.

getGenerationId

public long getGenerationId()
Get the generationId from this message.

Returns:
The generationId.