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

Jean-Noel Rouvignac
07.02.2013 e828cedbf4a929233339ac8c8bdb03134eb155c1
opendj-sdk/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -716,7 +716,7 @@
        // Assign the start state for the domain
        if (isPersistent == PERSISTENT_CHANGES_ONLY)
        {
          newDomainCtxt.startState = rsd.getEligibleState(eligibleCSN);
          newDomainCtxt.startState = rsd.getLatestServerState().duplicate();
          startStatesFromProvidedCookie.remove(rsd.getBaseDN());
        }
        else
@@ -760,8 +760,7 @@
            }
          }
          // Set the stop state for the domain from the eligibleCSN
          newDomainCtxt.stopState = rsd.getEligibleState(eligibleCSN);
          newDomainCtxt.stopState = rsd.getLatestServerState().duplicate();
        }
        newDomainCtxt.currentState = new ServerState();
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -1507,12 +1507,12 @@
    MultiDomainServerState result = new MultiDomainServerState();
    for (ReplicationServerDomain rsd : getReplicationServerDomains())
    {
      final ServerState latestDBServerState = rsd.getLatestServerState();
      if (contains(excludedBaseDNs, rsd.getBaseDN().toNormalizedString())
          || rsd.getLatestServerState().isEmpty())
          || latestDBServerState.isEmpty())
        continue;
      final CSN eligibleCSN = getEligibleCSN(excludedBaseDNs);
      result.update(rsd.getBaseDN(), rsd.getEligibleState(eligibleCSN));
      result.update(rsd.getBaseDN(), latestDBServerState);
    }
    return result;
  }
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -2561,71 +2561,6 @@
  }
  /**
   * Computes the eligible server state for the domain.
   *
   * <pre>
   *     s1               s2          s3
   *     --               --          --
   *                                 csn31
   *     csn15
   *
   *  ----------------------------------------- eligibleCSN
   *     csn14
   *                     csn26
   *     csn13
   * </pre>
   *
   * The eligibleState is : s1;csn14 / s2;csn26 / s3;csn31
   *
   * @param eligibleCSN
   *          The provided eligible CSN.
   * @return The computed eligible server state.
   */
  public ServerState getEligibleState(CSN eligibleCSN)
  {
    ServerState latestState = getLatestServerState();
    // The result is initialized from the dbState.
    // From it, we don't want to keep the changes newer than eligibleCSN.
    ServerState result = latestState.duplicate();
    if (eligibleCSN != null)
    {
      for (CSN mostRecentDbCSN : latestState)
      {
        try {
          // Is the most recent change in the Db newer than eligible CSN ?
          // if yes (like csn15 in the example above, then we have to go back
          // to the Db and look for the change older than eligible CSN (csn14)
          if (eligibleCSN.olderOrEqual(mostRecentDbCSN))
          {
            // let's try to seek the first change <= eligibleCSN
            CSN newCSN = domainDB.getCSNAfter(baseDN,
                mostRecentDbCSN.getServerId(), eligibleCSN);
            result.update(newCSN);
          }
          else
          {
            // for this serverId, all changes in the ChangelogDb are holder
            // than eligibleCSN, the most recent in the db is our guy.
            result.update(mostRecentDbCSN);
          }
        } catch (Exception e) {
          logError(ERR_WRITER_UNEXPECTED_EXCEPTION
              .get(stackTraceToSingleLineString(e)));
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
      }
    }
    if (debugEnabled())
    {
      debug("getEligibleState() result is " + result);
    }
    return result;
  }
  /**
   * Returns the start state of the domain, made of the oldest CSN stored for
   * each serverId.
   * <p>
opendj-sdk/opends/src/server/org/opends/server/replication/server/changelog/api/ReplicationDomainDB.java
@@ -171,24 +171,6 @@
  long getCount(DN baseDN, int serverId, CSN from, CSN to);
  /**
   * Returns the {@link CSN} situated immediately after the specified
   * {@link CSN} for the specified serverId and replication domain according to
   * the order specified by {@link CSN#compareTo(CSN)}. If an Exception occurs
   * in this method, then it returns the oldest possible CSN for the provided
   * serverId.
   *
   * @param baseDN
   *          the replication domain baseDN
   * @param serverId
   *          the serverId for which we want the information
   * @param startAfterCSN
   *          The position where the iterator must start
   * @return the CSN immediately after startAfterCSN, or null if no CSN exist
   *         after startAfterCSN
   */
  CSN getCSNAfter(DN baseDN, int serverId, CSN startAfterCSN);
  /**
   * Generates a {@link ReplicaDBCursor} for the specified serverId and
   * replication domain starting after the provided CSN.
   * <p>
opendj-sdk/opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
@@ -537,33 +537,6 @@
  /** {@inheritDoc} */
  @Override
  public CSN getCSNAfter(DN baseDN, int serverId, CSN startAfterCSN)
  {
    final JEReplicaDB replicaDB = getReplicaDB(baseDN, serverId);
    ReplicaDBCursor cursor = null;
    try
    {
      cursor = replicaDB.generateCursorFrom(startAfterCSN);
      if (cursor != null && cursor.getChange() != null)
      {
        return cursor.getChange().getCSN();
      }
      return null;
    }
    catch (ChangelogException e)
    {
      // there's no change older than startAfterCSN
      return new CSN(0, 0, serverId);
    }
    finally
    {
      close(cursor);
    }
  }
  /** {@inheritDoc} */
  @Override
  public ChangeNumberIndexDB getChangeNumberIndexDB()
  {
    synchronized (cnIndexDBLock)