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/ServerWriter.java
@@ -24,11 +24,13 @@
import org.forgerock.opendj.ldap.DN;
import org.opends.server.api.DirectoryThread;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.ServerStatus;
import org.opends.server.replication.protocol.ReplicaOfflineMsg;
import org.opends.server.replication.protocol.Session;
import org.opends.server.replication.protocol.UpdateMsg;
import org.opends.server.replication.service.DSRSShutdownSync;
import org.opends.server.replication.service.DSRSShutdownSync.ForwardingPeer;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.replication.common.ServerStatus.*;
@@ -121,10 +123,14 @@
           * as sent (issue #1080).
           */
          handler.releasePermitInSendWindow();
          if (handler instanceof ReplicationServerHandler && updateMsg.contributesToDomainState())
          {
            ((ReplicationServerHandler) handler).updateDiscardedState(updateMsg.getCSN());
          }
          if (updateMsg instanceof ReplicaOfflineMsg && !handler.isDataServer())
          {
            dsrsShutdownSync.replicaOfflineMsgNotForwarded(
                replicationServerDomain.getBaseDN(), handler.getServerId());
                replicationServerDomain.getBaseDN(), handler.offlineForwarder());
          }
        }
        else
@@ -134,6 +140,14 @@
          {
            forwardReplicaOfflineMsg((ReplicaOfflineMsg) updateMsg);
          }
          else if (handler instanceof ReplicationServerHandler && updateMsg.contributesToDomainState())
          {
            // take() already advanced the handler state, while publish() may only enqueue.
            // A shutdown must wait until the session publisher has written the change.
            final CSN csn = updateMsg.getCSN();
            session.publish(updateMsg,
                () -> ((ReplicationServerHandler) handler).updatePublishedState(csn));
          }
          else
          {
            // Publish the update to the remote server using a protocol version it supports
@@ -216,12 +230,12 @@
  private void forwardReplicaOfflineMsg(final ReplicaOfflineMsg msg) throws IOException
  {
    final DN baseDN = replicationServerDomain.getBaseDN();
    final int serverId = handler.getServerId();
    final ForwardingPeer peer = handler.offlineForwarder();
    final boolean accepted = session.publish(msg,
        () -> dsrsShutdownSync.replicaOfflineMsgForwarded(baseDN, msg.getCSN(), serverId));
        () -> dsrsShutdownSync.replicaOfflineMsgForwarded(baseDN, msg.getCSN(), peer));
    if (!accepted)
    {
      dsrsShutdownSync.replicaOfflineMsgNotForwarded(baseDN, serverId);
      dsrsShutdownSync.replicaOfflineMsgNotForwarded(baseDN, peer);
    }
  }