From b4f8838b15342670c31753a484abf0129e3c9653 Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features : - An updated version of the underlying database. BDB JE 3.3 is now used. - Attribute API refactoring providing a better abstraction and offering improved performances. - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this GUI are available on OpenDS Wiki and contains a link to a mockup. See <https://www.opends.org/wiki/page/ControlPanelUISpecification>. - Some changes in the replication protocol to implement "Assured Replication Mode". The specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7 described some of the replication changes required to support this. Assured Replication is not finished, but the main replication protocol changes to support it are done. As explained by Gilles on an email on the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions of OpenDS may not be able to replicate with OpenDS 1.0 instances. - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>. - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service has been added, dedicated to the administration, configuration and monitoring of the server. An overview of the Admin Connector service and it's use is available on the OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer> - Updates to the various command line tools to support the Admin Connector service. - Some internal re-architecting of the server to put the foundation of future developments such as virtual directory services. The new NetworkGroups and WorkFlow internal services which have been specified in <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented. - Many bug fixes...
---
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java | 138 +++++++++++++++++++++++++++-------------------
1 files changed, 81 insertions(+), 57 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
index d5397b8..5416659 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ModifyMsg.java
@@ -56,11 +56,9 @@
/**
* Message used to send Modify information.
*/
-public class ModifyMsg extends UpdateMessage
+public class ModifyMsg extends UpdateMsg
{
- private static final long serialVersionUID = -4905520652801395185L;
private byte[] encodedMods = null;
- private byte[] encodedMsg = null;
/**
* Creates a new Modify message from a ModifyOperation.
@@ -95,31 +93,49 @@
* Creates a new Modify message from a byte[].
*
* @param in The byte[] from which the operation must be read.
- * @throws DataFormatException If the input byte[] is not a valid modifyMsg
+ * @throws DataFormatException If the input byte[] is not a valid ModifyMsg
* @throws UnsupportedEncodingException If UTF8 is not supported by the JVM.
*/
public ModifyMsg(byte[] in) throws DataFormatException,
UnsupportedEncodingException
{
- super(in);
- encodedMsg = in;
+ // Decode header
+ byte[] allowedPduTypes = new byte[2];
+ allowedPduTypes[0] = MSG_TYPE_MODIFY;
+ allowedPduTypes[1] = MSG_TYPE_MODIFY_V1;
+ int pos = decodeHeader(allowedPduTypes, in);
+
+ /* Read the mods : all the remaining bytes but the terminating 0 */
+ int length = in.length - pos - 1;
+ encodedMods = new byte[length];
+ try
+ {
+ System.arraycopy(in, pos, encodedMods, 0, length);
+ } catch (IndexOutOfBoundsException e)
+ {
+ throw new DataFormatException(e.getMessage());
+ } catch (ArrayStoreException e)
+ {
+ throw new DataFormatException(e.getMessage());
+ } catch (NullPointerException e)
+ {
+ throw new DataFormatException(e.getMessage());
+ }
}
/**
- * Get the byte array representation of this Message.
- *
- * @return The byte array representation of this Message.
- *
- * @throws UnsupportedEncodingException When the encoding of the message
- * failed because the UTF-8 encoding is not supported.
+ * {@inheritDoc}
*/
@Override
public byte[] getBytes() throws UnsupportedEncodingException
{
- if (encodedMsg == null)
- {
- encode();
- }
+ /* encode the header in a byte[] large enough to also contain the mods */
+ byte[] encodedMsg = encodeHeader(MSG_TYPE_MODIFY, encodedMods.length + 1);
+
+ /* add the mods */
+ int pos = encodedMsg.length - (encodedMods.length + 1);
+ addByteArray(encodedMods, encodedMsg, pos);
+
return encodedMsg;
}
@@ -131,11 +147,6 @@
String newDn)
throws LDAPException, ASN1Exception, DataFormatException
{
- if (encodedMods == null)
- {
- decode();
- }
-
if (newDn == null)
newDn = getDn();
@@ -159,39 +170,6 @@
}
/**
- * Encode the Msg information into a byte array.
- *
- * @throws UnsupportedEncodingException If utf8 is not suported.
- */
- private void encode() throws UnsupportedEncodingException
- {
- /* encode the header in a byte[] large enough to also contain the mods */
- encodedMsg = encodeHeader(MSG_TYPE_MODIFY_REQUEST, encodedMods.length + 1);
- int pos = encodedMsg.length - (encodedMods.length + 1);
-
- /* add the mods */
- pos = addByteArray(encodedMods, encodedMsg, pos);
- }
-
- /**
- * Decode the encodedMsg into mods and dn.
- *
- * @throws DataFormatException when the encodedMsg is no a valid modify.
- */
- private void decode() throws DataFormatException
- {
- int pos = decodeHeader(MSG_TYPE_MODIFY_REQUEST, encodedMsg);
-
- /* Read the mods : all the remaining bytes but the terminating 0 */
- encodedMods = new byte[encodedMsg.length-pos-1];
- int i =0;
- while (pos<encodedMsg.length-1)
- {
- encodedMods[i++] = encodedMsg[pos++];
- }
- }
-
- /**
* Encode an ArrayList of Modification into a byte[] suitable
* for storage in a database or send on the network.
*
@@ -233,7 +211,37 @@
@Override
public String toString()
{
- return("MOD " + getDn() + " " + getChangeNumber());
+ if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V1)
+ {
+ return "ModifyMsg content: " +
+ "\nprotocolVersion: " + protocolVersion +
+ "\ndn: " + dn +
+ "\nchangeNumber: " + changeNumber +
+ "\nuniqueId: " + uniqueId +
+ "\nassuredFlag: " + assuredFlag;
+ }
+ if (protocolVersion == ProtocolVersion.REPLICATION_PROTOCOL_V2)
+ {
+ return "ModifyMsg content: " +
+ "\nprotocolVersion: " + protocolVersion +
+ "\ndn: " + dn +
+ "\nchangeNumber: " + changeNumber +
+ "\nuniqueId: " + uniqueId +
+ "\nassuredFlag: " + assuredFlag +
+ "\nassuredMode: " + assuredMode +
+ "\nsafeDataLevel: " + safeDataLevel;
+ }
+ return "!!! Unknown version: " + protocolVersion + "!!!";
+ }
+
+ /**
+ * Set the Modification associated to the UpdateMsg to the provided value.
+ *
+ * @param mods The new Modification associated to this ModifyMsg.
+ */
+ public void setMods(List<Modification> mods)
+ {
+ encodedMods = modsToByte(mods);
}
/**
@@ -242,9 +250,25 @@
@Override
public int size()
{
- // The ModifyMsh can be very large when added or deleted attribute
+ // The ModifyMsg can be very large when added or deleted attribute
// values are very large. We therefore need to count the
// whole encoded msg.
- return encodedMsg.length;
+ return encodedMods.length + 100; // 100 let's assume header size is 100
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getBytes_V1() throws UnsupportedEncodingException
+ {
+ /* encode the header in a byte[] large enough to also contain the mods */
+ byte[] encodedMsg = encodeHeader_V1(MSG_TYPE_MODIFY_V1, encodedMods.length +
+ 1);
+
+ /* add the mods */
+ int pos = encodedMsg.length - (encodedMods.length + 1);
+ addByteArray(encodedMods, encodedMsg, pos);
+
+ return encodedMsg;
}
}
--
Gitblit v1.10.0