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

pgamba
20.46.2007 3298001b86b35e1a05ff9d6a2f0ac402d674400a
opends/src/server/org/opends/server/replication/server/ReplicationCache.java
@@ -1037,42 +1037,7 @@
      if (this.generationId != newGenId)
      {
        // Reset the localchange and state db for the current domain
        synchronized (sourceDbHandlers)
        {
          for (DbHandler dbHandler : sourceDbHandlers.values())
          {
            try
            {
              dbHandler.clear();
            }
            catch (Exception e)
            {
              // TODO: i18n
              logError(Message.raw(
                  "Exception caught while clearing dbHandler:" +
                  e.getLocalizedMessage()));
            }
          }
          sourceDbHandlers.clear();
          if (debugEnabled())
            TRACER.debugInfo(
                "In " + this.replicationServer.getMonitorInstanceName() +
                " baseDN=" + baseDn +
            " The source db handler has been cleared");
        }
        try
        {
          replicationServer.clearGenerationId(baseDn);
        }
        catch (Exception e)
        {
          // TODO: i18n
          logError(Message.raw(
              "Exception caught while clearing generationId:" +
              e.getLocalizedMessage()));
        }
        clearDbs();
        // Reset the in memory domain generationId
        generationId = newGenId;
@@ -1080,6 +1045,49 @@
    }
    /**
     * Clears the Db associated with that cache.
     */
    public void clearDbs()
    {
      // Reset the localchange and state db for the current domain
      synchronized (sourceDbHandlers)
      {
        for (DbHandler dbHandler : sourceDbHandlers.values())
        {
          try
          {
            dbHandler.clear();
          }
          catch (Exception e)
          {
            // TODO: i18n
            logError(Message.raw(
                "Exception caught while clearing dbHandler:" +
                e.getLocalizedMessage()));
          }
        }
        sourceDbHandlers.clear();
        if (debugEnabled())
          TRACER.debugInfo(
              "In " + this.replicationServer.getMonitorInstanceName() +
              " baseDN=" + baseDn +
          " The source db handler has been cleared");
      }
      try
      {
        replicationServer.clearGenerationId(baseDn);
      }
      catch (Exception e)
      {
        // TODO: i18n
        logError(Message.raw(
            "Exception caught while clearing generationId:" +
            e.getLocalizedMessage()));
      }
    }
    /**
     * Returns whether the provided server is in degraded
     * state due to the fact that the peer server has an invalid
     * generationId for this domain.
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -989,4 +989,20 @@
    else
      return null;
  }
}
  /**
   * Clears the Db associated with that server.
   */
  public void clearDb()
  {
    Iterator<ReplicationCache> rcachei = getCacheIterator();
    if (rcachei != null)
    {
      while (rcachei.hasNext())
      {
        ReplicationCache rc = rcachei.next();
        rc.clearDbs();
      }
    }
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -41,6 +41,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
@@ -74,6 +75,7 @@
import org.opends.server.replication.protocol.ReplServerStartMessage;
import org.opends.server.replication.protocol.ReplSessionSecurity;
import org.opends.server.replication.protocol.ReplicationMessage;
import org.opends.server.replication.protocol.ResetGenerationId;
import org.opends.server.replication.protocol.ServerStartMessage;
import org.opends.server.replication.protocol.UpdateMessage;
import org.opends.server.replication.protocol.WindowMessage;
@@ -1237,7 +1239,9 @@
   public void searchBackend() throws Exception
   {
     debugInfo("Starting searchBackend");
     replicationServer.clearDb();
     LDIFWriter ldifWriter = null;
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     LDIFExportConfig exportConfig = new LDIFExportConfig(stream);