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

ludovicp
27.47.2010 7ffcb1dcabdad8f9ac5eb262d29c0570934ecdae
Fix issue #4384, a performance problem in replication monitoring
6 files modified
64 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/DataServerHandler.java 2 ●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java 4 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java 35 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java 17 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/DataServerHandler.java
@@ -309,7 +309,7 @@
    try
    {
      MonitorData md = replicationServerDomain.computeMonitorData();
      MonitorData md = replicationServerDomain.computeMonitorData(true);
      // Oldest missing update
      Long approxFirstMissingDate = md.getApproxFirstMissingDate(serverId);
opends/src/server/org/opends/server/replication/server/LightweightServerHandler.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;
@@ -269,7 +269,7 @@
    MonitorData md;
    try
    {
      md = rsDomain.computeMonitorData();
      md = rsDomain.computeMonitorData(true);
      ServerState remoteState = md.getLDAPServerState(serverId);
      if (remoteState == null)
opends/src/server/org/opends/server/replication/server/MonitoringPublisher.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 */
package org.opends.server.replication.server;
@@ -110,7 +110,7 @@
      // Send global topology information to peer DSs
      MonitorMsg monitorMsg =
        replicationServerDomain.createGlobalTopologyMonitorMsg(0, 0);
        replicationServerDomain.createGlobalTopologyMonitorMsg(0, 0, true);
      int localServerId =
          replicationServerDomain.getReplicationServer().getServerId();
      if (monitorMsg != null)
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -1615,8 +1615,8 @@
        {
          // Monitoring information requested by a DS
          MonitorMsg monitorMsg =
            createGlobalTopologyMonitorMsg(msg.getDestination(),
            msg.getsenderID());
            createGlobalTopologyMonitorMsg(
                msg.getDestination(), msg.getsenderID(), false);
           if (monitorMsg != null)
          {
@@ -1763,10 +1763,18 @@
   * whole topology.
   * @param sender The sender of this message.
   * @param destination The destination of this message.
   * @param  updateMonitorData A boolean indicating if the monitor data should
   *                           be updated. If false the last monitoring data
   *                           that was computed will be returned. This is
   *                           acceptable for most cases because the monitoring
   *                           thread computes the monitoring data frequently.
   *                           If true is used the calling thread may be
   *                           blocked for a while.
   * @return The newly created and filled MonitorMsg. Null if a problem occurred
   * during message creation.
   */
  public MonitorMsg createGlobalTopologyMonitorMsg(int sender, int destination)
  public MonitorMsg createGlobalTopologyMonitorMsg(
      int sender, int destination, boolean updateMonitorData)
  {
    MonitorMsg returnMsg =
      new MonitorMsg(sender, destination);
@@ -1776,7 +1784,7 @@
      returnMsg.setReplServerDbState(getDbServerState());
      // Update the information we have about all servers
      // in the topology.
      MonitorData md = computeMonitorData();
      MonitorData md = computeMonitorData(updateMonitorData);
      // Add the informations about the Replicas currently in
      // the topology.
@@ -2549,14 +2557,25 @@
   */
  /**
   * Retrieves the global monitor data.
   * @param  updateMonitorData A boolean indicating if the monitor data should
   *                           be updated. If false the last monitoring data
   *                           that was computed will be returned. This is
   *                           acceptable for most cases because the monitoring
   *                           thread computes the monitoring data frequently.
   *                           If true is used the calling thread may be
   *                           blocked for a while.
   * @return The monitor data.
   * @throws DirectoryException When an error occurs.
   */
  synchronized protected MonitorData computeMonitorData()
  synchronized protected MonitorData computeMonitorData(
      boolean updateMonitorData)
    throws DirectoryException
  {
    // Update the monitorData of ALL domains if this was necessary.
    replicationServer.computeMonitorData();
    if (updateMonitorData)
    {
      // Update the monitorData of ALL domains if this was necessary.
      replicationServer.computeMonitorData();
    }
    // Returns the monitorData of THIS domain
    return monitorData;
@@ -3053,7 +3072,7 @@
    try
    {
      MonitorData md = computeMonitorData();
      MonitorData md = computeMonitorData(true);
      // Missing changes
      long missingChanges =
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
@@ -780,7 +780,7 @@
    try
    {
      MonitorData md;
      md = replicationServerDomain.computeMonitorData();
      md = replicationServerDomain.computeMonitorData(true);
      // Missing changes
      long missingChanges = md.getMissingChangesRS(serverId);
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
@@ -197,6 +197,16 @@
              assertTrue(serverInfo.getStatus() == ServerStatus.NORMAL_STATUS);
            }
          }
          Map<Integer, ServerState> states1 = domain1.getReplicaStates();
          ServerState state2 = states1.get(domain2ServerId);
          assertNotNull(state2, "getReplicaStates is not showing DS2");
          Map<Integer, ServerState> states2 = domain2.getReplicaStates();
          ServerState state1 = states2.get(domain1ServerId);
          assertNotNull(state1, "getReplicaStates is not showing DS1");
          // if we reach this point all tests are OK
          break;
        }
        catch (AssertionError e)
@@ -210,13 +220,6 @@
            throw e;
        }
      }
      Map<Integer, ServerState> states1 = domain1.getReplicaStates();
      ServerState state2 = states1.get(domain2ServerId);
      assertNotNull(state2, "getReplicaStates is not showing DS2");
      Map<Integer, ServerState> states2 = domain2.getReplicaStates();
      ServerState state1 = states2.get(domain1ServerId);
      assertNotNull(state1, "getReplicaStates is not showing DS1");
    }
    finally