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

Jean-Noel Rouvignac
30.30.2013 cc21522ea71015c75a82ebf285644fa5ff57f46a
opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -65,7 +65,6 @@
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.types.ResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -143,17 +142,6 @@
  private long monitoringPublisherPeriod = 3000;
  /**
   * The handler of the changelog database, the database stores the relation
   * between a change number and the associated cookie.
   * <p>
   * Guarded by cnIndexDBLock
   */
  private ChangeNumberIndexDB cnIndexDB;
  /** Used for protecting {@link ChangeNumberIndexDB} related state. */
  private final Object cnIndexDBLock = new Object();
  /**
   * The tracer object for the debug logger.
   */
  private static final DebugTracer TRACER = getTracer();
@@ -645,29 +633,6 @@
      DirectoryServer.deregisterWorkflowElement(eclwe);
      eclwe.finalizeWorkflowElement();
    }
    shutdownCNIndexDB();
  }
  private void shutdownCNIndexDB()
  {
    synchronized (cnIndexDBLock)
    {
      if (cnIndexDB != null)
      {
        try
        {
          cnIndexDB.shutdown();
        }
        catch (ChangelogException ignored)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.WARNING, ignored);
          }
        }
      }
    }
  }
  /**
@@ -802,34 +767,6 @@
  }
  /**
   * Clears the generationId for the replicationServerDomain related to the
   * provided baseDN.
   *
   * @param baseDN
   *          The baseDN for which to delete the generationId.
   */
  public void clearGenerationId(DN baseDN)
  {
    synchronized (cnIndexDBLock)
    {
      if (cnIndexDB != null)
      {
        try
        {
          cnIndexDB.clear(baseDN);
        }
        catch (Exception ignored)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.WARNING, ignored);
          }
        }
      }
    }
  }
  /**
   * Retrieves the time after which changes must be deleted from the
   * persistent storage (in milliseconds).
   *
@@ -1282,27 +1219,7 @@
      rsd.clearDbs();
    }
    synchronized (cnIndexDBLock)
    {
      if (cnIndexDB != null)
      {
        try
        {
          cnIndexDB.clear();
        }
        catch (Exception ignored)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.WARNING, ignored);
          }
        }
        shutdownCNIndexDB();
        cnIndexDB = null;
      }
    }
    this.changelogDB.clearCNIndexDB();
  }
  /**
@@ -1508,29 +1425,10 @@
   * changelog.
   *
   * @return the handler.
   * @throws DirectoryException
   *           when needed.
   */
  ChangeNumberIndexDB getChangeNumberIndexDB() throws DirectoryException
  ChangeNumberIndexDB getChangeNumberIndexDB()
  {
    synchronized (cnIndexDBLock)
    {
      try
      {
        if (cnIndexDB == null)
        {
          cnIndexDB = this.changelogDB.newChangeNumberIndexDB();
        }
        return cnIndexDB;
      }
      catch (Exception e)
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
        Message message =
            ERR_CHANGENUMBER_DATABASE.get(e.getLocalizedMessage());
        throw new DirectoryException(OPERATIONS_ERROR, message, e);
      }
    }
    return this.changelogDB.getChangeNumberIndexDB();
  }
  /**
@@ -1567,14 +1465,13 @@
     *     replchangelog FROM that genState TO the crossDomainEligibleCSN
     *     (this diff is done domain by domain)
     */
    final ChangeNumberIndexDB cnIndexDB = getChangeNumberIndexDB();
    try
    {
      boolean dbEmpty = true;
      long firstChangeNumber = 0;
      long lastChangeNumber = 0;
      final ChangeNumberIndexDB cnIndexDB = getChangeNumberIndexDB();
      final CNIndexRecord firstCNRecord = cnIndexDB.getFirstRecord();
      final CNIndexRecord lastCNRecord = cnIndexDB.getLastRecord();
@@ -1657,7 +1554,7 @@
      {
        // The database was empty, just keep increasing numbers since last time
        // we generated one change number.
        long lastGeneratedCN = this.cnIndexDB.getLastGeneratedChangeNumber();
        long lastGeneratedCN = cnIndexDB.getLastGeneratedChangeNumber();
        firstChangeNumber += lastGeneratedCN;
        lastChangeNumber += lastGeneratedCN;
      }