mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
31.36.2010 03413ef56a2c56131da520ea4ea1697814433943
Fix issue #4083. Handle correctly the Byte Count in Replication Server monitor when the same update message is received twice
3 files modified
64 ■■■■ changed files
opends/src/messages/messages/replication.properties 5 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/MsgQueue.java 37 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java 22 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/replication.properties
@@ -379,7 +379,8 @@
 required because the provided cookie is missing the replicated domain(s) %s. \
 The following cookie value can be used to retrieve the missing changes, \
 including the COMPLETE record of changes for the missing domain(s) : %s
SEVERE_ERR_BYTE_COUNT_159=The Server Handler byte count is not correct (Fixed)
SEVERE_ERR_BYTE_COUNT_159=The Server Handler byte count is not correct: \
 Byte Count=%s (Fixed)
NOTICE_ERR_FRACTIONAL_CONFIG_UNKNOWN_OBJECT_CLASS_160=Wrong fractional \
 replication configuration: could not find object class definition for %s in \
 schema
@@ -492,3 +493,5 @@
 due to the root error : %s
NOTICE_ERR_WHILE_TRYING_TO_DECODE_RUV_IN_STATE_200=Error while trying to \
 translate RUV into state for suffix %s
SEVERE_ERR_RSQUEUE_DIFFERENT_MSGS_WITH_SAME_CN_201=Processing two different \
 changes with same changeNumber=%s. Previous msg=<%s>, New msg=<%s>
opends/src/server/org/opends/server/replication/server/MsgQueue.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.replication.server;
@@ -35,6 +35,7 @@
import org.opends.messages.Message;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.protocol.UpdateMsg;
import java.util.Arrays;
/**
 * This class is used to build ordered lists of UpdateMsg.
@@ -125,8 +126,35 @@
  {
    synchronized (lock)
    {
      map.put(update.getChangeNumber(), update);
      bytesCount += update.size();
      UpdateMsg msgSameChangeNumber = map.put(update.getChangeNumber(), update);
      if (msgSameChangeNumber != null)
      {
        boolean sameMsgs = false;
        try
        {
          sameMsgs = Arrays.equals(
              msgSameChangeNumber.getBytes(),update.getBytes());
        }
        catch(Exception e)
        {}
        if (!sameMsgs)
        {
          // Adding 2 msgs with the same ChangeNumber is ok only when the 2 msgs
          // are the same
          bytesCount += (update.size() - msgSameChangeNumber.size());
          Message errMsg = ERR_RSQUEUE_DIFFERENT_MSGS_WITH_SAME_CN.get(
              msgSameChangeNumber.toString(),
              msgSameChangeNumber.toString(),
              update.toString());
          logError(errMsg);
        }
      }
      else
      {
        // it is really an ADD
        bytesCount += update.size();
      }
    }
  }
@@ -144,7 +172,8 @@
      bytesCount -= update.size();
      if ((map.size() == 0) && (bytesCount != 0))
      {
        Message msg = ERR_BYTE_COUNT.get();
        // should never happen
        Message msg = ERR_BYTE_COUNT.get(Integer.toString(bytesCount));
        logError(msg);
        bytesCount = 0;
      }
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.server.replication.server;
@@ -52,6 +52,7 @@
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.replication.common.ChangeNumberGenerator;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.replication.protocol.AddMsg;
import org.opends.server.replication.protocol.ReplicationMsg;
@@ -319,19 +320,14 @@
        + "userPassword: password\n" + "initials: AA\n");
  }
  static protected ReplicationMsg createAddMsg(int serverId)
  static protected ReplicationMsg createAddMsg(ChangeNumber cn,
      int serverId)
  {
    Entry personWithUUIDEntry = null;
    String user1entryUUID;
    String baseUUID = null;
    String user1dn;
    /*
     * Create a Change number generator to generate new changenumbers
     * when we need to send operation messages to the replicationServer.
     */
    ChangeNumberGenerator gen = new ChangeNumberGenerator(serverId, 0);
    user1entryUUID = "33333333-3333-3333-3333-333333333333";
    user1dn = "uid=user1,ou=People," + baseDnStr;
    String entryWithUUIDldif = "dn: "+ user1dn + "\n"
@@ -360,7 +356,7 @@
    }
    // Create and publish an update message to add an entry.
    AddMsg addMsg = new AddMsg(gen.newChangeNumber(),
    AddMsg addMsg = new AddMsg(cn,
        personWithUUIDEntry.getDN().toString(),
        user1entryUUID,
        baseUUID,
@@ -438,9 +434,15 @@
        this.addTestEntriesToDB(ent1);
      }
      /*
       * Create a Change number generator to generate new changenumbers
       * when we need to send operation messages to the replicationServer.
       */
      ChangeNumberGenerator gen = new ChangeNumberGenerator(server3ID, 0);
      for (int i = 0; i < 10; i++)
      {
        broker3.publish(createAddMsg(server3ID));
        broker3.publish(createAddMsg(gen.newChangeNumber(), server3ID));
      }
      searchMonitor();