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

gbellato
04.13.2007 63f1d8aa27cd58a798acc351e69fa36d9ef810b6
Fixes for the 2 replication problems : 

- Missing cn attribute in replication.ldif


- When at least 2 replication servers are used, they will both try to connect to each other.
Since there must be only one connection, one of the connection is rejected.
Unfortunately in some cases the replication server fails to recognize that they are
already connected and keep trying to connect to the other replication server
every second.

The reason while they fail to notice that they are already connected is because
there is a confusion in the code between the IP address and the hostname.
This fix uses the IP address everywhere and also add checks between the IP address
and the local IP address : 127.0.0.1.



3 files modified
39 ■■■■ changed files
opends/resource/config/replication.ldif 1 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/messages/ReplicationMessages.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServer.java 29 ●●●● patch | view | raw | blame | history
opends/resource/config/replication.ldif
@@ -14,6 +14,7 @@
objectClass: top
objectClass: ds-cfg-synchronization-provider
objectClass: ds-cfg-multimaster-synchronization-provider
cn: Multimaster Synchronization
ds-cfg-synchronization-provider-enabled: true
ds-cfg-synchronization-provider-class: org.opends.server.replication.plugin.MultimasterReplication
opends/src/server/org/opends/server/messages/ReplicationMessages.java
@@ -361,6 +361,13 @@
    CATEGORY_MASK_SYNC | SEVERITY_MASK_SEVERE_ERROR | 50;
  /**
   * The message ID for the message that will be used when
   * a replication server hostname cannot be resolved as an IP address.
   */
  public static final int  MSGID_COULD_NOT_SOLVE_HOSTNAME =
    CATEGORY_MASK_SYNC | SEVERITY_MASK_SEVERE_ERROR | 51;
  /**
   * Register the messages from this class in the core server.
   *
   */
@@ -495,5 +502,7 @@
        "Multiple domains match the base DN provided");
    registerMessage(MSGID_INVALID_PROVIDER,
        "The provider class does not allow the operation requested");
    registerMessage(MSGID_COULD_NOT_SOLVE_HOSTNAME,
        "The hostname %s could not be resolved as an IP address");
  }
}
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -103,6 +103,7 @@
  private int queueSize;
  private String dbDirname = null;
  private long trimAge; // the time (in sec) after which the  changes must
  private int replicationPort;
                        // de deleted from the persistent storage.
  /**
@@ -116,7 +117,7 @@
  {
    shutdown = false;
    runListen = true;
    int replicationPort = configuration.getReplicationPort();
    replicationPort = configuration.getReplicationPort();
    replicationServerId = (short) configuration.getReplicationServerId();
    replicationServers = configuration.getReplicationServer();
    if (replicationServers == null)
@@ -254,10 +255,29 @@
         */
        for (String serverURL : replicationServers)
        {
          if ((serverURL.compareTo(this.serverURL) != 0) &&
              (!connectedReplServers.contains(serverURL)))
          String token[] = serverURL.split(":");
          String hostname = token[0];
          String port = token[1];
          try
          {
            this.connect(serverURL, replicationCache.getBaseDn());
            InetAddress inetAddress = InetAddress.getByName(hostname);
            String serverAddress = inetAddress.getHostAddress() + ":" + port;
            if ((serverAddress.compareTo("127.0.0.1:" + replicationPort) != 0)
                && (serverAddress.compareTo(this.localURL) != 0)
                && (!connectedReplServers.contains(serverAddress)))
            {
              this.connect(serverURL, replicationCache.getBaseDn());
            }
          }
          catch (IOException e)
          {
            int msgID = MSGID_COULD_NOT_SOLVE_HOSTNAME;
            String message = getMessage(msgID, hostname);
            logError(ErrorLogCategory.SYNCHRONIZATION,
                     ErrorLogSeverity.SEVERE_ERROR,
                     message, msgID);
          }
        }
      }
@@ -510,7 +530,6 @@
  public boolean isConfigurationChangeAcceptable(
      ReplicationServerCfg configuration, List<String> unacceptableReasons)
  {
    // TODO : implement this
    return true;
  }
}