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

Jean-Noel Rouvignac
30.24.2013 32b028879371c5786d959504d97c93c22280a304
DSInfo.java:
Added cloneWithReplicationServerId().

LightweightServerHandler.java:
Simplified ctor by just accepting a DSInfo object.
Extracted method debugInfo()
Removed redundant fields.

ReplicationServerHandler.java:
In processTopoInfoFromRS(), called DSInfo.cloneWithReplicationServerId() + consequence of the change to LightweightServerHandler.

ReplicationDomain.java:
Small code cleanup.
4 files modified
122 ■■■■ changed files
opends/src/server/org/opends/server/replication/common/DSInfo.java 16 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java 78 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/service/ReplicationDomain.java 19 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/common/DSInfo.java
@@ -239,6 +239,22 @@
  }
  /**
   * Returns a new instance of {@link DSInfo} with the specified replication
   * server Id.
   *
   * @param rsId
   *          the replication server Id to set on the new DSInfo object.
   * @return a new instance of {@link DSInfo} with the specified replication
   *         server Id.
   */
  public DSInfo cloneWithReplicationServerId(int rsId)
  {
    return new DSInfo(dsId, dsUrl, rsId, generationId, status, assuredFlag,
        assuredMode, safeDataLevel, groupId, refUrls, eclIncludes,
        eclIncludesForDeletes, protocolVersion);
  }
  /**
   * Test if the passed object is equal to this one.
   * @param obj The object to test
   * @return True if both objects are equal
opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
@@ -27,17 +27,17 @@
 */
package org.opends.server.replication.server;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.common.AssuredMode;
import org.opends.server.replication.common.DSInfo;
import org.opends.server.replication.common.ServerState;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Attributes;
@@ -62,10 +62,7 @@
  private static final DebugTracer TRACER = getTracer();
  private final ReplicationServerHandler replServerHandler;
  private final ReplicationServerDomain rsDomain;
  /** Server id of this DS. */
  private final int serverId;
  /** All the information for this DS. */
  private final DSInfo dsInfo;
@@ -74,44 +71,19 @@
   * connected to the remote Replication Server represented by
   * replServerHandler.
   *
   * @param replServerHandler The server handler of the RS this remote DS is
   * connected to
   * @param replicationServerId The serverId of the RS this remote DS is
   * connected to
   * @param serverId The serverId of this remote DS.
   * @param serverUrl The serverUrl of this remote DS.
   * @param generationId The generation id of this remote DS.
   * @param groupId The group id of the remote DS
   * @param status The  id of the remote DS
   * @param refUrls The exported referral URLs of the remote DS
   * @param assuredFlag The assured flag of the remote DS
   * @param assuredMode The assured mode of the remote DS
   * @param safeDataLevel The safe data level of the remote DS
   * @param eclInclude The list of entry attributes to be added to the ECL.
   * @param eclIncludeForDeletes The list of entry attributes to be added to
   *                             the ECL.
   * @param protocolVersion The protocol version supported by the remote DS.
   * @param replServerHandler
   *          The server handler of the RS this remote DS is connected to
   * @param dsInfo
   *          all the info for the represented DS
   */
  public LightweightServerHandler(ReplicationServerHandler replServerHandler,
      int replicationServerId, int serverId, String serverUrl,
      long generationId, byte groupId, ServerStatus status,
      List<String> refUrls, boolean assuredFlag, AssuredMode assuredMode,
      byte safeDataLevel, Set<String> eclInclude,
      Set<String> eclIncludeForDeletes, short protocolVersion)
      DSInfo dsInfo)
  {
    this.replServerHandler = replServerHandler;
    this.rsDomain = replServerHandler.getDomain();
    this.serverId = serverId;
    this.dsInfo =
        new DSInfo(serverId, serverUrl, replicationServerId, generationId,
            status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls,
            eclInclude, eclIncludeForDeletes, protocolVersion);
    this.dsInfo = dsInfo;
    if (debugEnabled())
      TRACER.debugInfo("In " + rsDomain.getLocalRSMonitorInstanceName()
          + " LWSH for remote server " + serverId + " connected to:"
          + this.replServerHandler.getMonitorInstanceName() + " ()");
      debugInfo("()");
  }
  /**
@@ -124,12 +96,13 @@
  }
  /**
   * Get the serverID associated with this LDAP server.
   * Get the serverID associated with this LDAP server / directory server.
   *
   * @return The serverId.
   */
  public int getServerId()
  {
    return serverId;
    return dsInfo.getDsId();
  }
  /**
@@ -138,9 +111,7 @@
  public void startHandler()
  {
    if (debugEnabled())
      TRACER.debugInfo("In " + rsDomain.getLocalRSMonitorInstanceName()
          + " LWSH for remote server " + this.serverId + " connected to:"
          + this.replServerHandler.getMonitorInstanceName() + " start");
      debugInfo("start");
    DirectoryServer.deregisterMonitorProvider(this);
    DirectoryServer.registerMonitorProvider(this);
  }
@@ -151,12 +122,18 @@
  public void stopHandler()
  {
    if (debugEnabled())
      TRACER.debugInfo("In " + rsDomain.getLocalRSMonitorInstanceName()
          + " LWSH for remote server " + this.serverId + " connected to:"
          + this.replServerHandler.getMonitorInstanceName() + " stop");
      debugInfo("stop");
    DirectoryServer.deregisterMonitorProvider(this);
  }
  private void debugInfo(String message)
  {
    final ReplicationServerDomain domain = replServerHandler.getDomain();
    TRACER.debugInfo("In " + domain.getLocalRSMonitorInstanceName()
        + " LWSH for remote server " + getServerId() + " connected to:"
        + replServerHandler.getMonitorInstanceName() + " " + message);
  }
  /**
   * {@inheritDoc}
   */
@@ -176,7 +153,7 @@
  @Override
  public String getMonitorInstanceName()
  {
    return "Connected directory server DS(" + serverId + ") "
    return "Connected directory server DS(" + dsInfo.getDsId() + ") "
        + dsInfo.getDsUrl()
        + ",cn=" + replServerHandler.getMonitorInstanceName();
  }
@@ -194,15 +171,16 @@
  {
    List<Attribute> attributes = new ArrayList<Attribute>();
    final int serverId = dsInfo.getDsId();
    final ReplicationServerDomain domain = replServerHandler.getDomain();
    attributes.add(Attributes.create("server-id", String.valueOf(serverId)));
    attributes.add(Attributes.create("domain-name",
        rsDomain.getBaseDN().toNormalizedString()));
        domain.getBaseDN().toNormalizedString()));
    attributes.add(Attributes.create("connected-to",
        replServerHandler.getMonitorInstanceName()));
    // Retrieves the topology counters
    ReplicationDomainMonitorData md = rsDomain.getDomainMonitorData();
    final ReplicationDomainMonitorData md = domain.getDomainMonitorData();
    ServerState remoteState = md.getLDAPServerState(serverId);
    if (remoteState == null)
    {
opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
@@ -617,12 +617,9 @@
      for (DSInfo dsInfo : topoMsg.getDsList())
      {
        // For each DS connected to the peer RS
        LightweightServerHandler lsh = new LightweightServerHandler(this,
            serverId, dsInfo.getDsId(), dsInfo.getDsUrl(),
            dsInfo.getGenerationId(), dsInfo.getGroupId(), dsInfo.getStatus(),
            dsInfo.getRefUrls(), dsInfo.isAssured(), dsInfo.getAssuredMode(),
            dsInfo.getSafeDataLevel(), dsInfo.getEclIncludes(),
            dsInfo.getEclIncludesForDeletes(), dsInfo.getProtocolVersion());
        DSInfo clonedDSInfo = dsInfo.cloneWithReplicationServerId(serverId);
        LightweightServerHandler lsh =
            new LightweightServerHandler(this, clonedDSInfo);
        lsh.startHandler();
        remoteDirectoryServers.put(lsh.getServerId(), lsh);
      }
opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -1592,15 +1592,14 @@
   */
  private void waitForRemoteStartOfInit()
  {
    int waitResultAttempt = 0;
    Set<Integer> replicasWeAreWaitingFor = new HashSet<Integer>(0);
    replicasWeAreWaitingFor.addAll(ieContext.startList);
    final Set<Integer> replicasWeAreWaitingFor =
        new HashSet<Integer>(ieContext.startList);
    if (debugEnabled())
      TRACER.debugInfo(
      "[IE] wait for start replicasWeAreWaitingFor=" + replicasWeAreWaitingFor);
    int waitResultAttempt = 0;
    boolean done;
    do
    {
@@ -1609,7 +1608,7 @@
      {
        if (debugEnabled())
          TRACER.debugInfo(
            "[IE] wait for start dsid " + dsi.getDsId()
            "[IE] wait for start dsId " + dsi.getDsId()
            + " " + dsi.getStatus()
            + " " + dsi.getGenerationId()
            + " " + getGenerationID());
@@ -1651,8 +1650,8 @@
   */
  private void waitForRemoteEndOfInit()
  {
    Set<Integer> replicasWeAreWaitingFor =  new HashSet<Integer>(
        ieContext.startList);
    final Set<Integer> replicasWeAreWaitingFor =
        new HashSet<Integer>(ieContext.startList);
    if (debugEnabled())
      TRACER.debugInfo(
@@ -1670,8 +1669,8 @@
    do
    {
      done = true;
      short reconnectMaxDelayInSec = 10;
      short reconnectWait = 0;
      int reconnectMaxDelayInSec = 10;
      int reconnectWait = 0;
      Iterator<Integer> it = replicasWeAreWaitingFor.iterator();
      while (it.hasNext())
      {
@@ -1735,8 +1734,6 @@
    if (debugEnabled())
      TRACER.debugInfo(
        "[IE] wait for end ends with " + ieContext.failureList);
  }
  /**