| | |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | |
| | | //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; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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. |
| | | */ |
| | |
| | | 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. |
| | |
| | | |
| | | 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); |
| | |
| | | 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)); |