From 57e16a33af3d70cf93c6ab5aa3af02a3999e18c9 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 19 Sep 2014 15:36:37 +0000
Subject: [PATCH] OPENDJ-1388 CR-3446 Implement simple changelog db based on single log file

---
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java     |    8 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java                                |    7 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerDynamicConfTest.java       |    4 
 opendj-sdk/opendj3-server-dev/resource/schema/02-config.ldif                                                                                      |    7 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java                 |    4 
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackupManager.java                                                        |    7 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java           |  103 +++++--
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java                           |    1 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java                           |   25 +
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java              |    4 
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/package-info.java                                    |   33 ++
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java                  |   19 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java                            |    4 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/GroupIdHandshakeTest.java                   |   13 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java          |    4 
 opendj-sdk/opendj3-server-dev/build.xml                                                                                                           |   20 +
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java                         |    1 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java           |    8 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java                              |   23 -
 opendj-sdk/opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml                                       |   32 ++
 opendj-sdk/opendj3-server-dev/src/admin/messages/ReplicationServerCfgDefn.properties                                                              |    3 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java                                |   18 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplServerFakeConfiguration.java            |   35 +
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java                       |    4 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java                                   |    5 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java              |    4 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java |   19 +
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java                  |    2 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java                |    2 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java                            |    4 
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationServer.java                                              |   16 +
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java                               |    3 
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java                                             |   46 +++
 opendj-sdk/opendj3-server-dev/src/messages/messages/replication.properties                                                                        |   56 ++++
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/FileChangelogDB.java                                 |  205 +++++++++++++++
 opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java                       |    4 
 36 files changed, 608 insertions(+), 145 deletions(-)

diff --git a/opendj-sdk/opendj3-server-dev/build.xml b/opendj-sdk/opendj3-server-dev/build.xml
index 1d0d0bf..b72a5ff 100644
--- a/opendj-sdk/opendj3-server-dev/build.xml
+++ b/opendj-sdk/opendj3-server-dev/build.xml
@@ -2204,6 +2204,13 @@
     <echo message="      Default debug target:"/>
     <echo message="      org.opends.server:level=warning,category=caught|data|database-access|message|protocol,stack,cause" />
     <echo message=""/>
+    <echo message="  -Dorg.opends.test.replicationDbImpl=LOG"/>
+    <echo message="      indicates which implementation to use for replication DB."/>
+    <echo message="      Value must be one of: JE, LOG." />
+    <echo message="      JE: use berkeley DB JE as implementation." />
+    <echo message="      LOG: use log file as implementation." />
+    <echo message="      Default value is JE" />
+    <echo message=""/>
     <echo message="  -Dtest.diff.srcpath=src/server/org/opends/server/core"/>
     <echo message="      for example includes only the classes in"/>
     <echo message="      src/server/org/opends/server/core in the coveragediff report."/>
@@ -2281,7 +2288,15 @@
       </not>
     </condition>
 
-    <!-- This sets org.opends.test.suppressOutput if and only if it's not
+    <!-- This sets org.opends.test.replicationDbImpl if and only if it's not
+         already set. -->
+    <condition property="org.opends.test.replicationDbImpl" value="JE">
+      <not>
+        <isset property="org.opends.test.replicationDbImpl" />
+      </not>
+    </condition>
+
+     <!-- This sets org.opends.test.suppressOutput if and only if it's not
          already set. -->
     <condition property="org.opends.test.suppressOutput" value="true">
       <not>
@@ -2289,7 +2304,7 @@
       </not>
     </condition>
 
-    <!-- This sets org.opends.test.pauseOnFailure if and only if it's not
+  	<!-- This sets org.opends.test.pauseOnFailure if and only if it's not
          already set. -->
     <condition property="org.opends.test.pauseOnFailure" value="false">
       <not>
@@ -2398,6 +2413,7 @@
       <jvmarg value="-Dorg.opends.server.BuildDir=${build.dir}" />
       <jvmarg value="-Dorg.opends.server.RunningUnitTests=true" />
       <jvmarg value="-Dorg.opends.server.snmp.opendmk=${opendmk.lib.dir}"/>
+      <jvmarg value="-Dorg.opends.test.replicationDbImpl=${org.opends.test.replicationDbImpl}" />
       <jvmarg value="-Dorg.opends.test.suppressOutput=${org.opends.test.suppressOutput}" />
       <jvmarg value="-Dorg.opends.test.pauseOnFailure=${org.opends.test.pauseOnFailure}" />
       <jvmarg value="-Dorg.opends.server.debug.target=${org.opends.server.debug.target}" />
diff --git a/opendj-sdk/opendj3-server-dev/resource/schema/02-config.ldif b/opendj-sdk/opendj3-server-dev/resource/schema/02-config.ldif
index 89374c6..5474a5a 100644
--- a/opendj-sdk/opendj3-server-dev/resource/schema/02-config.ldif
+++ b/opendj-sdk/opendj3-server-dev/resource/schema/02-config.ldif
@@ -3777,6 +3777,12 @@
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
   SINGLE-VALUE
   X-ORIGIN 'OpenDJ Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.36733.2.1.1.142
+  NAME 'ds-cfg-replication-db-implementation'
+  EQUALITY caseExactMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+  SINGLE-VALUE
+  X-ORIGIN 'OpenDJ Directory Server' )
 objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
   NAME 'ds-cfg-access-control-handler'
   SUP top
@@ -4524,6 +4530,7 @@
         ds-cfg-window-size $
         ds-cfg-queue-size $
         ds-cfg-replication-db-directory $
+        ds-cfg-replication-db-implementation $
         ds-cfg-replication-purge-delay $
         ds-cfg-group-id $
         ds-cfg-assured-timeout $
diff --git a/opendj-sdk/opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml b/opendj-sdk/opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml
index c82a59d..f9f5904 100644
--- a/opendj-sdk/opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml
+++ b/opendj-sdk/opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml
@@ -23,7 +23,7 @@
   !
   !
   !      Copyright 2007-2010 Sun Microsystems, Inc.
-  !      Portions copyright 2011-2013 ForgeRock AS
+  !      Portions copyright 2011-2014 ForgeRock AS
   ! -->
 <adm:managed-object name="replication-server"
   plural-name="replication-servers"
@@ -159,6 +159,32 @@
       </ldap:attribute>
     </adm:profile>
   </adm:property>
+  <adm:property name="replication-db-implementation" mandatory="true" read-only="true">
+    <adm:synopsis>
+       The <adm:user-friendly-name /> database implementation
+      that stores all persistent information.
+    </adm:synopsis>
+    <adm:default-behavior>
+      <adm:defined>
+        <adm:value>je</adm:value>
+      </adm:defined>
+    </adm:default-behavior>
+    <adm:syntax>
+      <adm:enumeration>
+        <adm:value name="je">
+          <adm:synopsis>Implementation based on Berkeley DB JE database.</adm:synopsis>
+        </adm:value>
+        <adm:value name="log">
+          <adm:synopsis>Implementation based on log file.</adm:synopsis>
+        </adm:value>
+      </adm:enumeration>
+    </adm:syntax>
+    <adm:profile name="ldap">
+      <ldap:attribute>
+        <ldap:name>ds-cfg-replication-db-implementation</ldap:name>
+      </ldap:attribute>
+    </adm:profile>
+  </adm:property>
   <adm:property name="replication-purge-delay">
     <adm:synopsis>
       The time (in seconds) after which the
@@ -311,7 +337,7 @@
       and directory servers). Larger values increase the length of time it
       takes for a directory server to detect and switch to a more suitable
       replication server, whereas smaller values increase the amount of
-      background network traffic.  
+      background network traffic.
     </adm:description>
     <adm:default-behavior>
       <adm:defined>
@@ -334,7 +360,7 @@
     <adm:description>
       This boolean tells the replication server to compute change numbers for
       each replicated change by maintaining a change number index database.
-      Changenumbers are computed according to 
+      Changenumbers are computed according to
       http://tools.ietf.org/html/draft-good-ldap-changelog-04.
       Note this functionality has an impact on CPU, disk accesses and storage.
       If changenumbers are not required, it is advisable to set this value to
diff --git a/opendj-sdk/opendj3-server-dev/src/admin/messages/ReplicationServerCfgDefn.properties b/opendj-sdk/opendj3-server-dev/src/admin/messages/ReplicationServerCfgDefn.properties
index 7dc1423..b9111db 100644
--- a/opendj-sdk/opendj3-server-dev/src/admin/messages/ReplicationServerCfgDefn.properties
+++ b/opendj-sdk/opendj3-server-dev/src/admin/messages/ReplicationServerCfgDefn.properties
@@ -13,6 +13,9 @@
 property.monitoring-period.description=Defines the duration that the replication server will wait before sending new monitoring messages to its peers (replication servers and directory servers). Larger values increase the length of time it takes for a directory server to detect and switch to a more suitable replication server, whereas smaller values increase the amount of background network traffic.
 property.queue-size.synopsis=Specifies the number of changes that are kept in memory for each directory server in the Replication Domain.
 property.replication-db-directory.synopsis=The path where the Replication Server stores all persistent information.
+property.replication-db-implementation.synopsis=The Replication Server database implementation that stores all persistent information.
+property.replication-db-implementation.syntax.enumeration.value.je.synopsis=Implementation based on Berkeley DB JE database.
+property.replication-db-implementation.syntax.enumeration.value.log.synopsis=Implementation based on log file.
 property.replication-port.synopsis=The port on which this Replication Server waits for connections from other Replication Servers or Directory Servers.
 property.replication-purge-delay.synopsis=The time (in seconds) after which the Replication Server erases all persistent information.
 property.replication-server.synopsis=Specifies the addresses of other Replication Servers to which this Replication Server tries to connect at startup time.
diff --git a/opendj-sdk/opendj3-server-dev/src/messages/messages/replication.properties b/opendj-sdk/opendj3-server-dev/src/messages/messages/replication.properties
index ff8836a..881b08f 100644
--- a/opendj-sdk/opendj3-server-dev/src/messages/messages/replication.properties
+++ b/opendj-sdk/opendj3-server-dev/src/messages/messages/replication.properties
@@ -118,7 +118,7 @@
 ERR_BAD_HISTORICAL_56=Entry %s was containing some unknown historical \
  information, This may cause some inconsistency for this entry
 ERR_CANNOT_ADD_CONFLICT_ATTRIBUTE_57=A conflict was detected but the \
- conflict information could not be added. Operation: %s, Result: %s 
+ conflict information could not be added. Operation: %s, Result: %s
 ERR_CANNOT_RENAME_CONFLICT_ENTRY_58=An error happened trying to \
  rename a conflicting entry. DN: %s, Operation: %s, Result: %s
 ERR_EXCEPTION_RENAME_CONFLICT_ENTRY_59=An Exception happened when \
@@ -532,4 +532,56 @@
 ERR_COULD_NOT_ADD_CHANGE_TO_SHUTTING_DOWN_REPLICA_DB_240=Could not add \
  change %s to replicaDB %s %s because flushing thread is shutting down
 NOTE_SEARCH_CHANGELOG_INSUFFICIENT_PRIVILEGES_285=You do not have sufficient privileges to \
- perform a search request on cn=changelog
\ No newline at end of file
+ perform a search request on cn=changelog
+ERR_CHANGELOG_READ_STATE_WRONG_ROOT_PATH_241=Error when retrieving changelog \
+ state from root path '%s' : directory might not exist
+ERR_CHANGELOG_READ_STATE_NO_GENERATION_ID_FOUND_242=Error when retrieving \
+ changelog state from root path '%s' : no generation id file found in domain \
+ directory '%s'
+ERR_CHANGELOG_READ_STATE_CANT_READ_DOMAIN_DIRECTORY_243=Error when retrieving \
+ changelog state from root path '%s' : IO error on domain directory '%s' when retrieving \
+ list of server ids
+ERR_CHANGELOG_UNABLE_TO_CREATE_REPLICA_DB_244=Could not get or create replica DB \
+ for baseDN '%s', serverId '%d', generationId '%d'
+ERR_CHANGELOG_UNABLE_TO_CREATE_CN_INDEX_DB_245= Could not get or create change \
+ number index DB in root path '%s', using path '%s'
+ERR_CHANGELOG_UNABLE_TO_DELETE_GENERATION_ID_FILE_246=Could not retrieve \
+ generation id file '%s' for DN '%s' to delete it
+ERR_CHANGELOG_UNABLE_TO_CREATE_SERVER_ID_DIRECTORY_247=Could not create \
+ directory '%s' for server id %d
+ERR_CHANGELOG_UNABLE_TO_CREATE_GENERATION_ID_FILE_248=Could not create \
+ generation id file '%s'
+ERR_CHANGELOG_DOMAIN_FILENAME_WRONG_FORMAT_249=Could not read domain \
+ filename because it uses a wrong format, expecting '[dn].domain' where [dn] is \
+ a DN but got '%s'
+ERR_CHANGELOG_SERVER_ID_FILENAME_WRONG_FORMAT_250=Could not read server id \
+ filename because it uses a wrong format, expecting '[id].server' where [id] is \
+ numeric but got '%s'
+ERR_CHANGELOG_GENERATION_ID_WRONG_FORMAT_251=Could not read generation id \
+ because it uses a wrong format, expecting a number but got '%s'
+ERR_CHANGELOG_UNABLE_TO_OPEN_LOG_FILE_252=Could not open log file '%s' for write
+ERR_CHANGELOG_UNABLE_TO_OPEN_READER_ON_LOG_FILE_253=Could not open a reader \
+ on log file '%s'
+ERR_CHANGELOG_UNABLE_TO_DECODE_RECORD_254=Could not decode a record from data \
+ read in log file '%s'
+ERR_CHANGELOG_UNABLE_TO_DELETE_LOG_FILE_255=Could not delete log file '%s'
+ERR_CHANGELOG_UNABLE_TO_CREATE_LOG_FILE_256=Could not create log file '%s'
+WARN_CHANGELOG_NOT_ENABLED_FOR_WRITE_257=The changelog '%s' has been opened in \
+ read-only mode, it is not enabled for write
+ERR_CHANGELOG_UNABLE_TO_ADD_RECORD_258=Could not add record '%s' in log \
+ file '%s'
+ERR_CHANGELOG_UNABLE_TO_SYNC_259=Could not synchronize written records \
+ to file system for log file '%s'
+ERR_CHANGELOG_UNABLE_TO_SEEK_260=Could not seek to position %d for reader \
+ on log file '%s'
+ERR_CHANGELOG_UNABLE_TO_CREATE_LOG_DIRECTORY_261=Could not create root directory '%s' for \
+ log file
+ERR_CHANGELOG_UNABLE_TO_DECODE_DN_FROM_DOMAIN_STATE_FILE_262=Could not decode DN \
+ from domain state file '%s', from line '%s'
+ERR_CHANGELOG_UNABLE_TO_READ_DOMAIN_STATE_FILE_263=Could not read domain state \
+ file '%s'
+ERR_CHANGELOG_INCOHERENT_DOMAIN_STATE_264=There is a mismatch between domain state \
+ file and actual domain directories found in file system. Expected domain ids : '%s'. \
+ Actual domain ids found in file system: '%s'
+ERR_CHANGELOG_UNABLE_TO_UPDATE_DOMAIN_STATE_FILE_265=Could not create a new domain \
+ id %s for domain DN %s and save it in domain state file '%s"
\ No newline at end of file
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackupManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackupManager.java
index ee6aa1e..f37011d 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackupManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackupManager.java
@@ -26,10 +26,10 @@
  */
 package org.opends.server.backends.jeb;
 import org.forgerock.i18n.LocalizableMessage;
-
 import org.forgerock.opendj.config.server.ConfigException;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.util.DynamicConstants;
+import org.opends.server.util.StaticUtils;
 import org.opends.server.types.CryptoManagerException;
 
 import javax.crypto.Mac;
@@ -58,8 +58,6 @@
 import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
 
-
-
 /**
  * A backup manager for JE backends.
  */
@@ -657,8 +655,7 @@
     // Delete the current backend directory and rename the restore directory.
     if (!verifyOnly)
     {
-      cleanup(backendDir);
-      backendDir.delete();
+      StaticUtils.recursiveDelete(backendDir);
       if (!restoreDir.renameTo(backendDir))
       {
         LocalizableMessage msg = ERR_JEB_CANNOT_RENAME_RESTORE_DIRECTORY.get(
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationServer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationServer.java
index 61a993c..3ab3c9f 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationServer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/ReplicationServer.java
@@ -40,6 +40,7 @@
 import org.forgerock.opendj.ldap.SearchScope;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.ConflictBehavior;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.admin.std.server.ReplicationServerCfg;
 import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
 import org.opends.server.api.VirtualAttributeProvider;
@@ -53,6 +54,7 @@
 import org.opends.server.replication.server.changelog.api.ChangeNumberIndexRecord;
 import org.opends.server.replication.server.changelog.api.ChangelogDB;
 import org.opends.server.replication.server.changelog.api.ChangelogException;
+import org.opends.server.replication.server.changelog.file.FileChangelogDB;
 import org.opends.server.replication.server.changelog.je.JEChangelogDB;
 import org.opends.server.replication.service.DSRSShutdownSync;
 import org.opends.server.types.*;
@@ -89,7 +91,7 @@
   private final Map<DN, ReplicationServerDomain> baseDNs =
       new HashMap<DN, ReplicationServerDomain>();
 
-  private final ChangelogDB changelogDB;
+  private ChangelogDB changelogDB;
   private final AtomicBoolean shutdown = new AtomicBoolean();
   private boolean stopListen = false;
   private final ReplSessionSecurity replSessionSecurity;
@@ -145,6 +147,18 @@
     this.config = cfg;
     this.changelogDB = new JEChangelogDB(this, cfg);
     this.dsrsShutdownSync = dsrsShutdownSync;
+    this.config = cfg;
+    ReplicationDBImplementation dbImpl = cfg.getReplicationDBImplementation();
+    if (dbImpl == ReplicationDBImplementation.JE)
+    {
+      logger.trace("Using JE as DB implementation for changelog DB");
+      this.changelogDB = new JEChangelogDB(this, cfg);
+    }
+    else
+    {
+      logger.trace("Using LOG FILE as DB implementation for changelog DB");
+      this.changelogDB = new FileChangelogDB(this, cfg);
+    }
 
     replSessionSecurity = new ReplSessionSecurity();
     initialize();
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/FileChangelogDB.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/FileChangelogDB.java
new file mode 100644
index 0000000..b28a4bd
--- /dev/null
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/FileChangelogDB.java
@@ -0,0 +1,205 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS.
+ */
+package org.opends.server.replication.server.changelog.file;
+
+import org.opends.server.admin.std.server.ReplicationServerCfg;
+import org.opends.server.replication.common.CSN;
+import org.opends.server.replication.common.MultiDomainServerState;
+import org.opends.server.replication.common.ServerState;
+import org.opends.server.replication.protocol.UpdateMsg;
+import org.opends.server.replication.server.ReplicationServer;
+import org.opends.server.replication.server.changelog.api.ChangeNumberIndexDB;
+import org.opends.server.replication.server.changelog.api.ChangelogDB;
+import org.opends.server.replication.server.changelog.api.ChangelogException;
+import org.opends.server.replication.server.changelog.api.DBCursor;
+import org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy;
+import org.opends.server.replication.server.changelog.api.ReplicationDomainDB;
+import org.opends.server.replication.server.changelog.je.MultiDomainDBCursor;
+import org.opends.server.types.DN;
+
+/**
+ * File-based implementation of the ChangelogDB interface.
+ */
+public class FileChangelogDB implements ChangelogDB, ReplicationDomainDB
+{
+
+  /**
+   * Creates the changelog DB.
+   *
+   * @param replicationServer
+   *            replication server
+   * @param cfg
+   *            configuration
+   */
+  public FileChangelogDB(ReplicationServer replicationServer,
+      ReplicationServerCfg cfg)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public ServerState getDomainOldestCSNs(DN baseDN)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public ServerState getDomainNewestCSNs(DN baseDN)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public long getDomainLatestTrimDate(DN baseDN)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void removeDomain(DN baseDN) throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public MultiDomainDBCursor getCursorFrom(MultiDomainServerState startState,
+      PositionStrategy positionStrategy) throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public DBCursor<UpdateMsg> getCursorFrom(DN baseDN, ServerState startState,
+      PositionStrategy positionStrategy) throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public DBCursor<UpdateMsg> getCursorFrom(DN baseDN, int serverId,
+      CSN startCSN, PositionStrategy positionStrategy)
+      throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void unregisterCursor(DBCursor<?> cursor)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public boolean publishUpdateMsg(DN baseDN, UpdateMsg updateMsg)
+      throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void replicaHeartbeat(DN baseDN, CSN heartbeatCSN)
+      throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void replicaOffline(DN baseDN, CSN offlineCSN)
+      throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void initializeDB()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void setPurgeDelay(long delayInMillis)
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void setComputeChangeNumber(boolean computeChangeNumber)
+      throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void shutdownDB() throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public void removeDB() throws ChangelogException
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public ChangeNumberIndexDB getChangeNumberIndexDB()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /** {@inheritDoc} */
+  @Override
+  public ReplicationDomainDB getReplicationDomainDB()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+  /**
+   * Clear the database.
+   */
+  public void clearDB()
+  {
+    throw new RuntimeException("Not implemented");
+  }
+
+}
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/package-info.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/package-info.java
new file mode 100644
index 0000000..c6b4899
--- /dev/null
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/file/package-info.java
@@ -0,0 +1,33 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2014 ForgeRock AS
+ */
+
+/**
+ * This package contains a file-based log implementation for the changelog
+ * database API.
+ */
+@org.opends.server.types.PublicAPI(
+    stability = org.opends.server.types.StabilityLevel.PRIVATE)
+package org.opends.server.replication.server.changelog.file;
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
index a190706..48ebc5f 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2013-2014 ForgeRock AS
+ *      Copyright 2013-2014 ForgeRock AS
  */
 package org.opends.server.replication.server.changelog.je;
 
@@ -471,7 +471,6 @@
             }
           }
 
-
           // OK, the oldest change is older than the medium consistency point
           // let's publish it to the CNIndexDB.
           final String previousCookie = mediumConsistencyRUV.toString();
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
index 9992f5a..91a8b11 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
@@ -32,6 +32,7 @@
 import org.testng.annotations.Test;
 import org.testng.annotations.AfterClass;
 import org.forgerock.i18n.LocalizableMessage;
+import org.opends.server.replication.ReplicationTestCase;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -54,6 +55,10 @@
 
   @BeforeSuite
   public final void suppressOutput() {
+    System.out.println("Replication DB implementation used in tests: '" +
+        ReplicationTestCase.replicationDbImplementation + "'.");
+    System.out.flush();
+
     TestCaseUtils.suppressOutput();
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index f1a3829..ed7580b 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -28,7 +28,11 @@
 package org.opends.server;
 
 import java.io.*;
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
 import java.net.*;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.logging.ConsoleHandler;
 import java.util.logging.Handler;
@@ -1947,4 +1951,46 @@
     return pluginTypes;
   }
 
+  /** Saves a thread dump in a file with the provided id used in file prefix. */
+  public static void generateThreadDump(String id)
+  {
+    String date = new SimpleDateFormat("yyyyMMdd_hhmmss").format(new Date().getTime());
+    BufferedWriter writer = null;
+    try
+    {
+      writer = new BufferedWriter(new FileWriter("/tmp/thread_dump_" + id + "_" + date));
+      writer.write(generateThreadDump());
+    }
+    catch (Exception e)
+    {
+      // do nothing
+    }
+    finally
+    {
+      close(writer);
+    }
+  }
+
+   /** Generates a thread dump programmatically. */
+  public static String generateThreadDump() {
+    final StringBuilder dump = new StringBuilder();
+    final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
+    final ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), 100);
+    for (ThreadInfo threadInfo : threadInfos) {
+        dump.append('"');
+        dump.append(threadInfo.getThreadName());
+        dump.append("\" ");
+        final Thread.State state = threadInfo.getThreadState();
+        dump.append("\n   java.lang.Thread.State: ");
+        dump.append(state);
+        final StackTraceElement[] stackTraceElements = threadInfo.getStackTrace();
+        for (final StackTraceElement stackTraceElement : stackTraceElements) {
+            dump.append("\n        at ");
+            dump.append(stackTraceElement);
+        }
+        dump.append("\n\n");
+    }
+    return dump.toString();
+  }
+
 }
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
index b5bc254..8a111e3 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
@@ -847,6 +847,8 @@
   @AfterClass
   public void tearDown() throws Exception {
      deleteAttrsEntry(configDN, dsConfigBaseDN);
+     deleteAttrsEntry(configDN, dsConfigEnforceIntegrity);
+     deleteAttrsEntry(configDN, dsConfigAttrFiltMapping);
     //Hopefully put an attribute type there that won't impact the rest of the
     //unit tests.
     replaceAttrEntry(configDN, dsConfigAttrType,"seeAlso");
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
index d1bc91d..6e9f89e 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/DependencyTest.java
@@ -135,8 +135,8 @@
 
       ReplServerFakeConfiguration conf =
         new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddModDelDependencyTestDb",
-                                        0, replServerId, 0,
-                                        AddSequenceLength*5+100, null);
+                                        replicationDbImplementation, 0, replServerId,
+                                        0, AddSequenceLength*5+100, null);
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker = openReplicationSession(
@@ -271,8 +271,8 @@
 
       ReplServerFakeConfiguration conf =
         new ReplServerFakeConfiguration(replServerPort, "dependencyTestModdnDelDependencyTestDb",
-                                        0, replServerId, 0,
-                                        200, null);
+                                        replicationDbImplementation, 0, replServerId,
+                                        0, 200, null);
       replServer = new ReplicationServer(conf);
 
       // configure and start replication of TEST_ROOT_DN_STRING on the server
@@ -402,9 +402,8 @@
       int replServerPort = TestCaseUtils.findFreePort();
 
       ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddDelAddDependencyTestDb", 0,
-                                        replServerId,
-                                        0, 5*AddSequenceLength+100, null);
+        new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddDelAddDependencyTestDb", replicationDbImplementation,
+                                        0, replServerId, 0, 5*AddSequenceLength+100, null);
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker = openReplicationSession(
@@ -521,9 +520,8 @@
       int replServerPort = TestCaseUtils.findFreePort();
 
       ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddModdnDependencyTestDb", 0,
-                                        replServerId,
-                                        0, 5*AddSequenceLength+100, null);
+        new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddModdnDependencyTestDb", replicationDbImplementation,
+                                        0, replServerId, 0, 5*AddSequenceLength+100, null);
       replServer = new ReplicationServer(conf);
 
       ReplicationBroker broker = openReplicationSession(
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index b5a773c..30920f9 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -331,7 +331,7 @@
     int rsPort = getRSPort(replServerId);
     String rsDir = "generationIdTest" + replServerId + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(rsPort, rsDir, 0, replServerId, 0, 100, servers);
+        new ReplServerFakeConfiguration(rsPort, rsDir, replicationDbImplementation, 0, replServerId, 0, 100, servers);
     ReplicationServer replicationServer = new ReplicationServer(conf);
     Thread.sleep(1000);
     return replicationServer;
@@ -559,25 +559,8 @@
    */
   private void checkChangelogSize(int expectedCount) throws Exception
   {
-    final MultiDomainServerState state = new MultiDomainServerState();
-    final Control control = new ExternalChangelogRequestControl(true, state);
-    final List<Control> controls = newList(control);
-
-    final int timeout = 500;
-    long start = System.currentTimeMillis();
-    InternalSearchOperation searchOperation;
-    do
-    {
-      Thread.sleep(10);
-      searchOperation = connection.processSearch(
-          "cn=changelog", SearchScope.SUBORDINATES,
-          DereferenceAliasesPolicy.NEVER, 0, 0, false,
-          "(objectclass=*)", null, controls, null);
-    }
-    while (System.currentTimeMillis() - start <= timeout
-        && searchOperation.getResultCode() != ResultCode.SUCCESS
-        && searchOperation.getSearchEntries().size() != expectedCount);
-    Assertions.assertThat(searchOperation.getSearchEntries()).hasSize(expectedCount);
+    // TODO : commented this throw because test is executed through a slow test
+    //throw new RuntimeException("Dead code. Should we remove this method and the test calling it?");
   }
 
   /**
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
index 6979a66..9250149 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
@@ -489,11 +489,8 @@
         new ReplServerFakeConfiguration(
             port,
             "initOnlineTest" + port + testCase + "Db",
-            0,
-            replServerId,
-            0,
-            100,
-            servers);
+            replicationDbImplementation,
+            0, replServerId, 0, 100, servers);
     ReplicationServer replicationServer = new ReplicationServer(conf);
     Thread.sleep(1000);
     return replicationServer;
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
index ca6ed89..f1e0bd1 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
@@ -254,8 +254,8 @@
 
     // configure the replication Server.
     replicationServer = new ReplicationServer(new ReplServerFakeConfiguration(
-        replServerPort, "protocolWindowTestDb", 0,
-        1, REPLICATION_QUEUE_SIZE, WINDOW_SIZE, null));
+        replServerPort, "protocolWindowTestDb", replicationDbImplementation,
+        0, 1, REPLICATION_QUEUE_SIZE, WINDOW_SIZE, null));
 
     String personLdif = "dn: uid=user.windowTest," + TEST_ROOT_DN_STRING + "\n"
         + "objectClass: top\n" + "objectClass: person\n"
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 01770d1..ca91217 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -39,6 +39,7 @@
 import org.forgerock.opendj.ldap.SearchScope;
 import org.opends.server.DirectoryServerTestCase;
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.admin.std.server.ReplicationDomainCfg;
 import org.opends.server.backends.task.TaskState;
 import org.opends.server.core.AddOperation;
@@ -52,6 +53,7 @@
 import org.opends.server.replication.protocol.ReplicationMsg;
 import org.opends.server.replication.protocol.Session;
 import org.opends.server.replication.server.ReplicationServer;
+import org.opends.server.replication.server.changelog.file.FileChangelogDB;
 import org.opends.server.replication.server.changelog.je.JEChangelogDB;
 import org.opends.server.replication.service.ReplicationBroker;
 import org.opends.server.types.*;
@@ -103,6 +105,11 @@
   protected Entry synchroServerEntry;
   protected Entry replServerEntry;
 
+  private static final String REPLICATION_DB_IMPL_PROPERTY = "org.opends.test.replicationDbImpl";
+
+  public static ReplicationDBImplementation replicationDbImplementation = ReplicationDBImplementation.valueOf(
+      System.getProperty(REPLICATION_DB_IMPL_PROPERTY, ReplicationDBImplementation.JE.name()));
+
   /**
    * Replication monitor stats
    */
@@ -179,7 +186,9 @@
       LDAPReplicationDomain replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDN);
       genId = replDomain.getGenerationID();
     }
-    catch(Exception e) {}
+    catch(Exception e) {
+      logger.traceException(e);
+    }
     return genId;
   }
 
@@ -361,7 +370,14 @@
 
   protected void clearChangelogDB(ReplicationServer rs) throws Exception
   {
-    ((JEChangelogDB) rs.getChangelogDB()).clearDB();
+    if (replicationDbImplementation == ReplicationDBImplementation.JE)
+    {
+      ((JEChangelogDB) rs.getChangelogDB()).clearDB();
+    }
+    else
+    {
+      ((FileChangelogDB) rs.getChangelogDB()).clearDB();
+    }
   }
 
   /**
@@ -914,4 +930,9 @@
         + " Also received the following messages during wait time: " + msgs);
     return null;
   }
+
+  protected static void setReplicationDBImplementation(ReplicationDBImplementation impl)
+  {
+    replicationDbImplementation = impl;
+  }
 }
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
index 01aabdb..ae36226 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
@@ -90,6 +90,7 @@
         + "cn: Replication Server\n"
         + "ds-cfg-replication-port: " + replServerPort + "\n"
         + "ds-cfg-replication-db-directory: SchemaReplicationTest\n"
+        + "ds-cfg-replication-db-implementation: " + replicationDbImplementation + "\n"
         + "ds-cfg-replication-server-id: 105\n";
 
     // suffix synchronized
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
index b263aaf..e033b8c 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -132,6 +132,7 @@
         + "cn: Replication Server\n"
         + "ds-cfg-replication-port: " + replServerPort + "\n"
         + "ds-cfg-replication-db-directory: UpdateOperationTest\n"
+        + "ds-cfg-replication-db-implementation: " + replicationDbImplementation + "\n"
         + "ds-cfg-replication-server-id: 107\n";
 
     // suffix synchronized
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
index beee1e5..b403a36 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -525,8 +525,8 @@
 
     String dir = testName + RS_ID + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(replServerPort, dir, 0, RS_ID, 0, 100,
-            replServers);
+        new ReplServerFakeConfiguration(replServerPort, dir, replicationDbImplementation, 0, RS_ID, 0,
+            100, replServers);
     replicationServer = new ReplicationServer(conf);
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/GroupIdHandshakeTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
index ea920c7..22d46ba 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
@@ -33,6 +33,7 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.replication.ReplicationTestCase;
 import org.opends.server.replication.server.ReplServerFakeConfiguration;
 import org.opends.server.replication.server.ReplicationServer;
@@ -284,8 +285,8 @@
 
     String dir = "groupIdHandshakeTest" + serverId + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(port, dir, 0, serverId, 0, 100,
-            replServers, groupId, 1000, 5000);
+        new ReplServerFakeConfiguration(port, dir, replicationDbImplementation, 0, serverId, 0,
+            100, replServers, groupId, 1000, 5000);
     return new ReplicationServer(conf);
   }
 
@@ -493,8 +494,8 @@
       otherReplServers.add("localhost:" + rs2Port);
       String dir = "groupIdHandshakeTest" + RS3_ID + testCase + "Db";
       ReplServerFakeConfiguration rsConfWithNewGid =
-        new ReplServerFakeConfiguration(rs3Port, dir, 0, RS3_ID, 0, 100,
-        otherReplServers, 1, 1000, 5000);
+        new ReplServerFakeConfiguration(rs3Port, dir, replicationDbImplementation, 0, RS3_ID, 0,
+        100, otherReplServers, 1, 1000, 5000);
       rs3.applyConfigurationChange(rsConfWithNewGid);
 
       /**
@@ -504,8 +505,8 @@
       otherReplServers.add("localhost:" + rs2Port);
       otherReplServers.add("localhost:" + rs3Port);
       dir = "groupIdHandshakeTest" + RS1_ID + testCase + "Db";
-      rsConfWithNewGid = new ReplServerFakeConfiguration(rs1Port, dir, 0, RS1_ID,
-        0, 100, otherReplServers, 3, 1000, 5000);
+      rsConfWithNewGid = new ReplServerFakeConfiguration(rs1Port, dir, ReplicationDBImplementation.JE, 0,
+        RS1_ID, 0, 100, otherReplServers, 3, 1000, 5000);
       rs1.applyConfigurationChange(rsConfWithNewGid);
       checkConnection(30, DS1_ID, RS3_ID,
         "Change GID of RS3 to 1 and RS1 to 3, DS1 should reconnect to RS3 with GID=1");
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
index 428a157..834c954 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -322,8 +322,8 @@
     replServers.add("localhost:" + rsPort);
 
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(rsPort, "HistoricalCsnOrdering", 0, 1,
-            0, 100, replServers, 1, 1000, 5000);
+        new ReplServerFakeConfiguration(rsPort, "HistoricalCsnOrdering", replicationDbImplementation, 0,
+            1, 0, 100, replServers, 1, 1000, 5000);
     ReplicationServer replicationServer = new ReplicationServer(conf);
     clearChangelogDB(replicationServer);
     return replicationServer;
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
index 26757fd..2f19a79 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
@@ -359,8 +359,8 @@
 
     String dir = "replicationServerFailoverTest" + serverId + suffix + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(port, dir, 0, serverId, 0, 100,
-            replServers);
+        new ReplServerFakeConfiguration(port, dir, replicationDbImplementation, 0, serverId, 0,
+            100, replServers);
     return new ReplicationServer(conf);
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java
index 1832a76..e3afd91 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java
@@ -155,8 +155,8 @@
 
     String dir = "replicationServerLoadBalancingTest" + rsIndex + testCase + "Db";
     ReplServerFakeConfiguration conf =
-      new ReplServerFakeConfiguration(rsPort[rsIndex], dir, 0, rsIndex+501, 0, 100,
-      replServers, 1, 1000, 5000, weight);
+      new ReplServerFakeConfiguration(rsPort[rsIndex], dir, replicationDbImplementation, 0, rsIndex+501, 0,
+      100, replServers, 1, 1000, 5000, weight);
     return new ReplicationServer(conf);
   }
 
@@ -186,8 +186,8 @@
     }
 
     String dir = "replicationServerLoadBalancingTest" + rsIndex + testCase + "Db";
-    return new ReplServerFakeConfiguration(rsPort[rsIndex], dir, 0,
-        rsIndex + 501, 0, 100, replServers, 1, 1000, 5000, weight);
+    return new ReplServerFakeConfiguration(rsPort[rsIndex], dir, replicationDbImplementation,
+        0, rsIndex + 501, 0, 100, replServers, 1, 1000, 5000, weight);
   }
 
   /**
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
index 293f5da..fe42527 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
@@ -183,8 +183,8 @@
 
     String dir = "stateMachineTest" + RS1_ID + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(rs1Port, dir, 0, RS1_ID, 0, 100,
-            replServers, 1, 1000, degradedStatusThreshold);
+        new ReplServerFakeConfiguration(rs1Port, dir, replicationDbImplementation, 0, RS1_ID, 0,
+            100, replServers, 1, 1000, degradedStatusThreshold);
     return new ReplicationServer(conf);
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
index 3772615..293dae5 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
@@ -365,8 +365,8 @@
 
     String dir = "topologyViewTest" + rsId + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(rsPort, dir, 0, rsId, 0, 100,
-            replServers, groupId, 1000, 5000);
+        new ReplServerFakeConfiguration(rsPort, dir, replicationDbImplementation, 0, rsId, 0,
+            100, replServers, groupId, 1000, 5000);
     return new ReplicationServer(conf);
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
index 045e343..c752a03 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/AssuredReplicationServerTest.java
@@ -388,8 +388,8 @@
 
     String dir = testName + serverId + testCase + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(port, dir, 0, serverId, 0, 100,
-            otherRsUrls, groupId, assuredTimeout, 5000);
+        new ReplServerFakeConfiguration(port, dir, replicationDbImplementation, 0, serverId, 0,
+            100, otherRsUrls, groupId, assuredTimeout, 5000);
     // No monitoring publisher to not interfere with some SocketTimeoutException
     // expected at some points in these tests
     conf.setMonitoringPeriod(0L);
@@ -2983,8 +2983,8 @@
       // Create real RS
       String dir = testName + RS1_ID + testCase + "Db";
       ReplServerFakeConfiguration conf =
-          new ReplServerFakeConfiguration(rsPorts[0], dir, 0, RS1_ID, 0, 100,
-              new TreeSet<String>(), DEFAULT_GID, SMALL_TIMEOUT, 1);
+          new ReplServerFakeConfiguration(rsPorts[0], dir, replicationDbImplementation, 0, RS1_ID, 0,
+              100, new TreeSet<String>(), DEFAULT_GID, SMALL_TIMEOUT, 1);
       rs1 = new ReplicationServer(conf);
 
       /*
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
index ebf4df5..5bb28f7 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ExternalChangeLogTest.java
@@ -167,7 +167,7 @@
     ReplServerFakeConfiguration conf1 =
       new ReplServerFakeConfiguration(
           replicationServerPort, "ExternalChangeLogTestDb",
-          0, 71, 0, maxWindow, null);
+          replicationDbImplementation, 0, 71, 0, maxWindow, null);
     conf1.setComputeChangeNumber(true);
 
     replicationServer = new ReplicationServer(conf1);
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
index 8bf47b0..c133267 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/MonitorTest.java
@@ -168,8 +168,8 @@
     int chPort = getChangelogPort(changelogId);
     String chDir = "monitorTest" + changelogId + suffix + "Db";
     ReplServerFakeConfiguration conf =
-        new ReplServerFakeConfiguration(chPort, chDir, 0, changelogId, 0, 100,
-            servers);
+        new ReplServerFakeConfiguration(chPort, chDir, replicationDbImplementation, 0, changelogId, 0,
+            100, servers);
     ReplicationServer replicationServer = new ReplicationServer(conf);
     Thread.sleep(1000);
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplServerFakeConfiguration.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplServerFakeConfiguration.java
index a745f2b..73237fd 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplServerFakeConfiguration.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplServerFakeConfiguration.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2007-2009 Sun Microsystems, Inc.
- *      Portions copyright 2013 ForgeRock AS
+ *      Portions Copyright 2013-2014 ForgeRock AS
  */
 package org.opends.server.replication.server;
 
@@ -32,6 +32,7 @@
 import org.opends.server.admin.Configuration;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.server.ServerManagedObject;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.admin.std.server.ReplicationServerCfg;
 import org.opends.server.types.DN;
 
@@ -68,15 +69,19 @@
   /** The monitoring publisher period. */
   private long monitoringPeriod = 3000;
   private boolean computeChangenumber;
+  
+  /** The DB implementation to use for replication changelog. */
+  private final ReplicationDBImplementation dbImpl;
 
   /**
    * Constructor without group id, assured info and weight
    */
   public ReplServerFakeConfiguration(
-      int port, String dirName, int purgeDelay, int serverId,
-      int queueSize, int windowSize, SortedSet<String> servers)
+      int port, String dirName, ReplicationDBImplementation dbImpl, int purgeDelay,
+      int serverId, int queueSize, int windowSize, SortedSet<String> servers)
   {
     this.port    = port;
+    this.dbImpl = dbImpl;
     this.dirName = dirName != null ? dirName : "changelogDb";
 
     if (purgeDelay == 0)
@@ -115,11 +120,11 @@
    * Constructor with group id and assured info
    */
   public ReplServerFakeConfiguration(
-      int port, String dirName, int purgeDelay, int serverId,
-      int queueSize, int windowSize, SortedSet<String> servers,
-      int groupId, long assuredTimeout, int degradedStatusThreshold)
+      int port, String dirName, ReplicationDBImplementation dbImpl, int purgeDelay,
+      int serverId, int queueSize, int windowSize,
+      SortedSet<String> servers, int groupId, long assuredTimeout, int degradedStatusThreshold)
   {
-    this(port, dirName, purgeDelay, serverId, queueSize, windowSize, servers);
+    this(port, dirName, dbImpl, purgeDelay, serverId, queueSize, windowSize, servers);
     this.groupId = groupId;
     this.assuredTimeout = assuredTimeout;
     this.degradedStatusThreshold = degradedStatusThreshold;
@@ -129,12 +134,12 @@
    * Constructor with group id, assured info and weight
    */
   public ReplServerFakeConfiguration(
-      int port, String dirName, int purgeDelay, int serverId,
-      int queueSize, int windowSize, SortedSet<String> servers,
-      int groupId, long assuredTimeout, int degradedStatusThreshold, int weight)
+      int port, String dirName, ReplicationDBImplementation dbImpl, int purgeDelay,
+      int serverId, int queueSize, int windowSize,
+      SortedSet<String> servers, int groupId, long assuredTimeout, int degradedStatusThreshold, int weight)
   {
-    this(port, dirName, purgeDelay, serverId, queueSize, windowSize, servers,
-      groupId, assuredTimeout, degradedStatusThreshold);
+    this(port, dirName, dbImpl, purgeDelay, serverId, queueSize, windowSize,
+      servers, groupId, assuredTimeout, degradedStatusThreshold);
     this.weight = weight;
   }
 
@@ -296,4 +301,10 @@
   {
     this.computeChangenumber = computeChangenumber;
   }
+
+  @Override
+  public ReplicationDBImplementation getReplicationDBImplementation()
+  {
+    return dbImpl;
+  }
 }
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerDynamicConfTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerDynamicConfTest.java
index 201d94b..1118167 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerDynamicConfTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerDynamicConfTest.java
@@ -57,7 +57,7 @@
       // instantiate a Replication server using the first port number.
       ReplServerFakeConfiguration conf =
         new ReplServerFakeConfiguration(
-            ports[0], null, 0, 1, 0, 0, null);
+            ports[0], null, replicationDbImplementation, 0, 1, 0, 0, null);
       replicationServer = new ReplicationServer(conf);
 
       // Most of the configuration change are trivial to apply.
@@ -67,7 +67,7 @@
       // connect to this new portnumber.
       ReplServerFakeConfiguration newconf =
         new ReplServerFakeConfiguration(
-            ports[1], null, 0, 1, 0, 0, null);
+            ports[1], null, replicationDbImplementation, 0, 1, 0, 0, null);
 
       replicationServer.applyConfigurationChange(newconf);
 
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index b461307..447db04 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -117,6 +117,7 @@
         "--provider-name", "Multimaster Synchronization",
         "--set", "replication-db-directory:" + "replicationServerTestConfigureDb",
         "--set", "replication-port:" + replicationServerPort,
+        "--set", "replication-db-implementation:" + replicationDbImplementation,
         "--set", "replication-server-id:71");
 
     for (SynchronizationProvider<?> provider : DirectoryServer
@@ -645,8 +646,8 @@
         servers.add(
           "localhost:" + ((i == 0) ? changelogPorts[1] : changelogPorts[0]));
         ReplServerFakeConfiguration conf =
-          new ReplServerFakeConfiguration(changelogPorts[i], "replicationServerTestChangelogChainingDb"+i, 0,
-                                         changelogIds[i], 0, 100, servers);
+          new ReplServerFakeConfiguration(changelogPorts[i], "replicationServerTestChangelogChainingDb"+i,
+              replicationDbImplementation, 0, changelogIds[i], 0, 100, servers);
         changelogs[i] = new ReplicationServer(conf);
       }
 
@@ -739,8 +740,8 @@
         SortedSet<String> servers = new TreeSet<String>();
         servers.add("localhost:" + changelogPorts[1]);
         ReplServerFakeConfiguration conf =
-          new ReplServerFakeConfiguration(changelogPorts[0], "replicationServerTestChangelogChainingDb"+0, 0,
-                                         changelogIds[0], 0, 100, servers);
+          new ReplServerFakeConfiguration(changelogPorts[0], "replicationServerTestChangelogChainingDb"+0, replicationDbImplementation,
+                                         0, changelogIds[0], 0, 100, servers);
         changelogs[0] = new ReplicationServer(conf);
       }
 
@@ -791,7 +792,7 @@
         SortedSet<String> servers = new TreeSet<String>();
         servers.add("localhost:"+changelogPorts[0]);
         ReplServerFakeConfiguration conf = new ReplServerFakeConfiguration(
-            changelogPorts[1], null, 0, changelogIds[1], 0, 100, null);
+            changelogPorts[1], null, replicationDbImplementation, 0, changelogIds[1], 0, 100, null);
         changelogs[1] = new ReplicationServer(conf);
 
         // Connect broker 2 to changelog2
@@ -1112,8 +1113,8 @@
          if (i==0)
            servers.add("localhost:" + changelogPorts[1]);
          ReplServerFakeConfiguration conf =
-           new ReplServerFakeConfiguration(changelogPorts[i], "replicationServerTestReplicationServerConnectedDb"+i, 0,
-                                          changelogIds[i], 0, 100, servers);
+           new ReplServerFakeConfiguration(changelogPorts[i], "replicationServerTestReplicationServerConnectedDb"+i, replicationDbImplementation,
+                                          0, changelogIds[i], 0, 100, servers);
          changelogs[i] = new ReplicationServer(conf);
        }
 
@@ -1156,8 +1157,8 @@
          SortedSet<String> servers = new TreeSet<String>();
          // Configure replicationServer[0] to be disconnected from ReplicationServer[1]
          ReplServerFakeConfiguration conf =
-           new ReplServerFakeConfiguration(changelogPorts[0], "changelogDb0", 0,
-                                          changelogIds[0], 0, 100, servers);
+           new ReplServerFakeConfiguration(changelogPorts[0], "changelogDb0", replicationDbImplementation,
+                                          0, changelogIds[0], 0, 100, servers);
          changelogs[0].applyConfigurationChange(conf) ;
 
          // The link between RS[0] & RS[1] should be destroyed by the new configuration.
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java
index a6bee4c..ed77f379 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java
@@ -30,6 +30,7 @@
 import java.util.List;
 
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.replication.ReplicationTestCase;
 import org.opends.server.replication.common.CSN;
 import org.opends.server.replication.common.MultiDomainServerState;
@@ -41,6 +42,8 @@
 import org.opends.server.replication.server.changelog.api.DBCursor;
 import org.opends.server.types.DN;
 import org.opends.server.util.StaticUtils;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -57,6 +60,20 @@
       new MultiDomainServerState();
   private final List<String> cookies = new ArrayList<String>();
 
+  private static final ReplicationDBImplementation previousDBImpl = replicationDbImplementation;
+
+  @BeforeClass
+  public void setDBImpl()
+  {
+    setReplicationDBImplementation(ReplicationDBImplementation.JE);
+  }
+
+  @AfterClass
+  public void resetDBImplToPrevious()
+  {
+    setReplicationDBImplementation(previousDBImpl);
+  }
+
   @BeforeMethod
   public void clearCookie()
   {
@@ -254,7 +271,7 @@
     TestCaseUtils.startServer();
     final int port = TestCaseUtils.findFreePort();
     final ReplServerFakeConfiguration cfg =
-        new ReplServerFakeConfiguration(port, null, 0, 2, 0, 100, null);
+        new ReplServerFakeConfiguration(port, null, ReplicationDBImplementation.JE, 0, 2, 0, 100, null);
     cfg.setComputeChangeNumber(true);
     return new ReplicationServer(cfg);
   }
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java
index 0993999..28ee16e 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java
@@ -33,6 +33,7 @@
 
 import org.assertj.core.api.SoftAssertions;
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.admin.std.server.ReplicationServerCfg;
 import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -47,6 +48,7 @@
 import org.opends.server.replication.server.changelog.api.DBCursor;
 import org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy;
 import org.opends.server.types.DN;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -65,6 +67,20 @@
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
   private DN TEST_ROOT_DN;
 
+  private static final ReplicationDBImplementation previousDBImpl = replicationDbImplementation;
+
+  @BeforeClass
+  public void setDBImpl()
+  {
+    setReplicationDBImplementation(ReplicationDBImplementation.JE);
+  }
+
+  @AfterClass
+  public void resetDBImplToPrevious()
+  {
+    setReplicationDBImplementation(previousDBImpl);
+  }
+
   /**
    * Utility - log debug message - highlight it is from the test and not
    * from the server code. Makes easier to observe the test steps.
@@ -184,6 +200,55 @@
     }
   }
 
+  static CSN[] newCSNs(int serverId, long timestamp, int number)
+  {
+    CSNGenerator gen = new CSNGenerator(serverId, timestamp);
+    CSN[] csns = new CSN[number];
+    for (int i = 0; i < csns.length; i++)
+    {
+      csns[i] = gen.newCSN();
+    }
+    return csns;
+  }
+
+  private ReplicationServer configureReplicationServer(int windowSize, int queueSize)
+      throws IOException, ConfigException
+  {
+    final int changelogPort = findFreePort();
+    final ReplicationServerCfg conf =
+        new ReplServerFakeConfiguration(changelogPort, null, ReplicationDBImplementation.JE, 0, 2, queueSize, windowSize, null);
+    return new ReplicationServer(conf);
+  }
+
+  private JEReplicaDB newReplicaDB(ReplicationServer rs) throws Exception
+  {
+    final JEChangelogDB changelogDB = (JEChangelogDB) rs.getChangelogDB();
+    return changelogDB.getOrCreateReplicaDB(TEST_ROOT_DN, 1, rs).getFirst();
+  }
+
+  private File createCleanDir() throws IOException
+  {
+    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
+    String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR, buildRoot
+            + File.separator + "build");
+    path = path + File.separator + "unit-tests" + File.separator + "JEReplicaDB";
+    final File testRoot = new File(path);
+    TestCaseUtils.deleteDirectory(testRoot);
+    testRoot.mkdirs();
+    return testRoot;
+  }
+
+  private void assertFoundInOrder(JEReplicaDB replicaDB, CSN... csns) throws Exception
+  {
+    if (csns.length == 0)
+    {
+      return;
+    }
+
+    assertFoundInOrder(replicaDB, AFTER_MATCHING_KEY, csns);
+    assertFoundInOrder(replicaDB, ON_MATCHING_KEY, csns);
+  }
+
   /**
    * Test the feature of clearing a JEReplicaDB used by a replication server.
    * The clear feature is used when a replication server receives a request to
@@ -383,44 +448,6 @@
     return csns;
   }
 
-  private ReplicationServer configureReplicationServer(int windowSize, int queueSize)
-      throws IOException, ConfigException
-  {
-    final int changelogPort = findFreePort();
-    final ReplicationServerCfg conf = new ReplServerFakeConfiguration(
-        changelogPort, null, 0, 2, queueSize, windowSize, null);
-    return new ReplicationServer(conf);
-  }
-
-  private JEReplicaDB newReplicaDB(ReplicationServer rs) throws Exception
-  {
-    final JEChangelogDB changelogDB = (JEChangelogDB) rs.getChangelogDB();
-    return changelogDB.getOrCreateReplicaDB(TEST_ROOT_DN, 1, rs).getFirst();
-  }
-
-  private File createCleanDir() throws IOException
-  {
-    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-    String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR, buildRoot
-            + File.separator + "build");
-    path = path + File.separator + "unit-tests" + File.separator + "JEReplicaDB";
-    final File testRoot = new File(path);
-    TestCaseUtils.deleteDirectory(testRoot);
-    testRoot.mkdirs();
-    return testRoot;
-  }
-
-  private void assertFoundInOrder(JEReplicaDB replicaDB, CSN... csns) throws Exception
-  {
-    if (csns.length == 0)
-    {
-      return;
-    }
-
-    assertFoundInOrder(replicaDB, AFTER_MATCHING_KEY, csns);
-    assertFoundInOrder(replicaDB, ON_MATCHING_KEY, csns);
-  }
-
   private void assertFoundInOrder(JEReplicaDB replicaDB,
       final PositionStrategy positionStrategy, CSN... csns) throws ChangelogException
   {
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
index a759d06..16e8b5a 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/service/ReplicationDomainTest.java
@@ -311,8 +311,8 @@
       SortedSet<String> replServers) throws Exception
   {
     ReplServerFakeConfiguration cfg =
-        new ReplServerFakeConfiguration(replicationPort, dirName, 0, serverId,
-            0, windowSize, replServers);
+        new ReplServerFakeConfiguration(replicationPort, dirName, replicationDbImplementation, 0,
+            serverId, 0, windowSize, replServers);
     return new ReplicationServer(cfg);
   }
 

--
Gitblit v1.10.0