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

pgamba
13.45.2007 8e41745b17b37a2a508ba6a016eddf9c6f219125
opends/src/server/org/opends/server/replication/server/DbHandler.java
@@ -217,6 +217,23 @@
  }
  /**
   * Get the number of changes.
   *
   * @return Returns the number of changes.
   */
  public long getChangesCount()
  {
    try
    {
      return lastChange.getSeqnum() - firstChange.getSeqnum() + 1;
    }
    catch (Exception e)
    {
      return 0;
    }
  }
  /**
   * Generate a new ReplicationIterator that allows to browse the db
   * managed by this dbHandler and starting at the position defined
   * by a given changeNumber.
opends/src/server/org/opends/server/replication/server/ReplicationBackend.java
@@ -331,23 +331,14 @@
    //This method only returns the number of actual change entries, the
    //domain and any baseDN entries are not counted.
    long retNum=0;
    try {
        InternalClientConnection conn =
                    InternalClientConnection.getRootConnection();
        SearchFilter filter=
                       SearchFilter.createFilterFromString("(changetype=*)");
        InternalSearchOperation searchOperation =
                new InternalSearchOperation(conn,
                        InternalClientConnection.nextOperationID(),
                        InternalClientConnection.nextMessageID(), null,
                        baseDNs[0],
                        SearchScope.WHOLE_SUBTREE,
                        DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false,
                        filter, null, null);
      search(searchOperation);
      retNum=searchOperation.getSearchEntries().size();
    } catch (DirectoryException ex) {
      retNum=0;
    Iterator<ReplicationCache> rcachei = server.getCacheIterator();
    if (rcachei != null)
    {
      while (rcachei.hasNext())
      {
        ReplicationCache rc = rcachei.next();
        retNum += rc.getChangesCount();
      }
    }
    return retNum;
opends/src/server/org/opends/server/replication/server/ReplicationCache.java
@@ -531,6 +531,21 @@
  }
  /**
   * Returns the change count for that ReplicationCache.
   *
   * @return the change count.
   */
  public long getChangesCount()
  {
    long entryCount = 0;
    for (DbHandler dbHandler : sourceDbHandlers.values())
    {
      entryCount += dbHandler.getChangesCount();
    }
    return entryCount;
  }
  /**
   * Get the baseDn.
   * @return Returns the baseDn.
   */
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -83,6 +83,10 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.loggers.ErrorLogger;
/**
 * Tests for the replicationServer code.
@@ -131,7 +135,7 @@
  private void debugInfo(String s)
  {
    // logError(Message.raw(Category.SYNC, Severity.NOTICE, "** TEST **" + s));
    // ErrorLogger.logError(Message.raw(Category.SYNC, Severity.NOTICE, "** TEST **" + s));
    if (debugEnabled())
    {
      TRACER.debugInfo("** TEST **" + s);
@@ -1258,7 +1262,7 @@
     ReplicationBackend b =
       (ReplicationBackend)DirectoryServer.getBackend("replicationChanges");
     b.setServer(replicationServer);
     assertTrue(b.getEntryCount() == msgs.size());
     assertEquals(b.getEntryCount(), msgs.size());
     assertTrue(b.entryExists(DN.decode("dc=replicationChanges")));
     SearchFilter filter=SearchFilter.createFilterFromString("(objectclass=*)");
     assertTrue(b.isIndexed(filter));