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

Valery Kharseko
11 hours ago c6650aedac5c1ade8aee9e7a76eb0dd100a3e179
opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
@@ -20,6 +20,8 @@
import static org.opends.messages.BackendMessages.*;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -76,6 +78,39 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** Process-lifetime write barriers for data which cannot safely be used after an online replacement. */
  private static final Map<DN, LocalizableMessage> writeFailures = new ConcurrentHashMap<>();
  /**
   * Prevents writes overlapping a failed data replacement until the server process is restarted.
   * An in-core restart keeps the barrier, as it keeps the JVM running.
   * The barrier survives backend and synchronization-provider reconfiguration.
   * @param baseDN the suffix whose data cannot safely be written
   * @param reason the reason to report to the operator and to rejected updates
   */
  public static void quarantineWrites(DN baseDN, LocalizableMessage reason)
  {
    writeFailures.putIfAbsent(baseDN, reason);
  }
  /**
   * Returns the reason writes overlapping a suffix are forbidden, or null if none are forbidden.
   * Ancestors are included because deleting or moving a subtree affects the suffix below it.
   * @param dn the DN of the entry or subtree an operation changes
   * @return the recorded failure, or null
   */
  public static LocalizableMessage getWriteFailure(DN dn)
  {
    for (Map.Entry<DN, LocalizableMessage> failure : writeFailures.entrySet())
    {
      if (dn.isSubordinateOrEqualTo(failure.getKey()) || dn.isSuperiorOrEqualTo(failure.getKey()))
      {
        return failure.getValue();
      }
    }
    return null;
  }
  /** Indicates whether this is a private backend or one that holds user data. */
  private boolean isPrivateBackend;