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

Valery Kharseko
20 hours ago 400fb2694641b05e53217d3c742a6e49e3a254c6
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -13,7 +13,7 @@
 *
 * Copyright 2006-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyrighted 2026 3A Systems, LLC.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.opends.server.replication.server;
@@ -718,7 +718,7 @@
        throw new ConnectException("Connection to " + remoteServerAddress
            + " is a TCP self-connect, no replication server is listening");
      }
      session = replSessionSecurity.createClientSession(socket, timeoutMS);
      session = replSessionSecurity.createClientSession(socket, timeoutMS, "RS", getServerId(), baseDN);
      ReplicationServerHandler rsHandler = new ReplicationServerHandler(
          session, config.getQueueSize(), this, config.getWindowSize());
@@ -1694,6 +1694,22 @@
      listenThread.interrupt();
    }
    // Remote DSs may still write while this RS stops. End their readers first, then
    // drain those accepted updates while the peer writers and their sessions remain up.
    // Unlike a collocated DS, they need not send a ReplicaOfflineMsg at this shutdown.
    for (ReplicationServerDomain domain : getReplicationServerDomains())
    {
      domain.stopDirectoryServers();
    }
    try
    {
      awaitDirectUpdatesForwarded(TimeUnit.SECONDS.toNanos(30));
    }
    catch (InterruptedException e)
    {
      Thread.currentThread().interrupt();
    }
    for (ReplicationServerDomain domain : getReplicationServerDomains())
    {
      domain.shutdown();
@@ -1714,6 +1730,16 @@
    allInstances.remove(this);
  }
  /** Waits for all domains within one direct-update forwarding budget. */
  void awaitDirectUpdatesForwarded(long timeoutNanos) throws InterruptedException
  {
    final long deadline = System.nanoTime() + timeoutNanos;
    for (ReplicationServerDomain domain : getReplicationServerDomains())
    {
      domain.awaitDirectUpdatesForwarded(deadline);
    }
  }
  /**
   * Waits for the ReplicaOfflineMsg of every domain which has a replication server to forward it
   * to. With no such server connected there is nobody to forward the message to, and waiting