[prev in list] [next in list] [prev in thread] [next in thread] 

List:       forgerock-opendj-dev
Subject:    [Opendj-dev] [10967] branches/opendj3-server-dev: Aligned (JE|File) ReplicaDB and their tests for ea
From:       noreply () forgerock ! org
Date:       2014-08-20 14:16:56
Message-ID: 20140820141656.CBEF040994 () sources ! internal ! forgerock ! com
[Download RAW message or body]

[Attachment #2 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[10967] branches/opendj3-server-dev: Aligned (JE|File)ReplicaDB and their \
tests for easier comparison with each other.</title> </head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt;  } #msg dl a { font-weight: \
bold} #msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
 #patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
                .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://sources.forgerock.org/changelog/opendj/?cs=10967">10967</a></dd> \
<dt>Author</dt> <dd>JnRouvignac</dd> <dt>Date</dt> <dd>2014-08-20 15:16:56 +0100 \
(Wed, 20 Aug 2014)</dd> </dl>

<h3>Log Message</h3>
<pre>Aligned (JE|File)ReplicaDB and their tests for easier comparison with each \
other.

Ported to FileReplicaDBTest additional checks for PositionStrategy.ON_MATCHING_KEY. \
These are the same that were previously added to JEReplicaDBTest.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesopendj3serverdevsrcserverorgopendsserverreplicationserverchangel \
ogjeJEReplicaDBjava">branches/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java</a></li>
 <li><a href="#branchesopendj3serverdevtestsunitteststestngsrcserverorgopendsserverrep \
licationserverchangelogjeJEChangeNumberIndexDBTestjava">branches/opendj3-server-dev/te \
sts/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java</a></li>
 <li><a href="#branchesopendj3serverdevtestsunitteststestngsrcserverorgopendsserverrep \
licationserverchangelogjeJEReplicaDBTestjava">branches/opendj3-server-dev/tests/unit-t \
ests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java</a></li>
 </ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branchesopendj3serverdev">branches/opendj3-server-dev/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesopendj3serverdev"></a>
<div class="propset"><h4>Property changes: branches/opendj3-server-dev</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx">/branches/b2.6:9071,9084,9090,9095,9116,9122,9126,9174
</span><span class="cx">/branches/native-packaging:7849-8851
</span><span class="cx">/trunk/opends:10098,10103,10105,10113,10133,10137,10155-10156, \
10159,10189,10200,10202,10229,10242,10252,10280,10316,10333,10592,10594,10601,10603,10 \
608,10614,10617,10655,10662,10665-10667,10669,10671,10678,10680,10682,10688,10703,1070 \
5,10719,10722-10723,10727-10728,10733,10736,10745,10752-10755,10757,10761-10762,10781, \
10786,10796,10800,10807,10809,10821-10823,10830,10833,10840,10845,10853,10855-10858,10861,10868-10869,10930,10955,10958-10959,10964
 </span><span class="cx">   + /branches/b2.4:7093
</span><span class="cx">/branches/b2.6:9071,9084,9090,9095,9116,9122,9126,9174
</span><span class="cx">/branches/native-packaging:7849-8851
</span><span class="cx">/trunk/opends:10098,10103,10105,10113,10133,10137,10155-10156, \
10159,10189,10200,10202,10229,10242,10252,10280,10316,10333,10592,10594,10601,10603,10 \
608,10614,10617,10655,10662,10665-10667,10669,10671,10678,10680,10682,10688,10703,1070 \
5,10719,10722-10723,10727-10728,10733,10736,10745,10752-10755,10757,10761-10762,10781, \
10786,10796,10800,10807,10809,10821-10823,10830,10833,10840,10845,10853,10855-10858,10861,10868-10869,10930,10955,10958-10959,10964,10966
 </span><a id="branchesopendj3serverdevsrcserverorgopendsserverreplicationserverchangelogjeJEReplicaDBjava"></a>
 <div class="modfile"><h4>Modified: \
branches/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java \
(10966 => 10967)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java	2014-08-20 \
                13:26:09 UTC (rev 10966)
+++ branches/opendj3-server-dev/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java	2014-08-20 \
14:16:56 UTC (rev 10967) </span><span class="lines">@@ -51,18 +51,17 @@
</span><span class="cx"> import static org.opends.messages.ReplicationMessages.*;
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * This class is used for managing the replicationServer database for \
                each
- * server in the topology.
</del><ins>+ * Represents a replication server database for one server in the \
topology. </ins><span class="cx">  * &lt;p&gt;
</span><span class="cx">  * It is responsible for efficiently saving the updates that \
is received from </span><span class="cx">  * each master server into stable storage.
</span><span class="cx">  * &lt;p&gt;
</span><del>- * This class is also able to generate a {@link DBCursor} that can be \
used to </del><ins>+ * It is also able to generate a {@link DBCursor} that can be \
used to </ins><span class="cx">  * read all changes from a given {@link CSN}.
</span><span class="cx">  * &lt;p&gt;
</span><del>- * This class publish some monitoring information below cn=monitor.
</del><ins>+ * It publishes some monitoring information below cn=monitor.
</ins><span class="cx">  */
</span><del>-public class JEReplicaDB
</del><ins>+class JEReplicaDB
</ins><span class="cx"> {
</span><span class="cx"> 
</span><span class="cx">   /**
</span><span class="lines">@@ -81,41 +80,44 @@
</span><span class="cx">       this.oldestCSN = oldestCSN;
</span><span class="cx">       this.newestCSN = newestCSN;
</span><span class="cx">     }
</span><del>-
</del><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   private final AtomicBoolean shutdown = new \
AtomicBoolean(false); </span><del>-  private ReplicationDB db;
</del><span class="cx">   /**
</span><span class="cx">    * Holds the oldest and newest CSNs for this replicaDB for \
fast retrieval. </span><span class="cx">    *
</span><span class="cx">    * @NonNull
</span><span class="cx">    */
</span><span class="cx">   private volatile CSNLimits csnLimits;
</span><del>-  private int serverId;
-  private DN baseDN;
-  private DbMonitorProvider dbMonitor = new DbMonitorProvider();
-  private ReplicationServer replicationServer;
</del><ins>+  private final int serverId;
+  private final DN baseDN;
+  private final DbMonitorProvider dbMonitor = new DbMonitorProvider();
+  private final ReplicationServer replicationServer;
+  private final ReplicationDB db;
</ins><span class="cx"> 
</span><span class="cx">   /**
</span><span class="cx">    * Creates a new ReplicaDB associated to a given LDAP \
server. </span><span class="cx">    *
</span><del>-   * @param serverId The serverId for which changes will be stored in \
                the DB.
-   * @param baseDN the baseDN for which this DB was created.
-   * @param replicationServer The ReplicationServer that creates this ReplicaDB.
-   * @param dbenv the Database Env to use to create the ReplicationServer DB.
-   * server for this domain.
-   * @throws ChangelogException If a database problem happened
</del><ins>+   * @param serverId
+   *          Id of this server.
+   * @param baseDN
+   *          the replication domain baseDN.
+   * @param replicationServer
+   *          The ReplicationServer that creates this ReplicaDB.
+   * @param replicationEnv
+   *          the Database Env to use to create the ReplicationServer DB. server
+   *          for this domain.
+   * @throws ChangelogException
+   *           If a database problem happened
</ins><span class="cx">    */
</span><del>-  public JEReplicaDB(int serverId, DN baseDN,
-      ReplicationServer replicationServer, ReplicationDbEnv dbenv)
-      throws ChangelogException
</del><ins>+  JEReplicaDB(final int serverId, final DN baseDN, final \
ReplicationServer replicationServer, +      final ReplicationDbEnv replicationEnv) \
throws ChangelogException </ins><span class="cx">   {
</span><del>-    this.replicationServer = replicationServer;
</del><span class="cx">     this.serverId = serverId;
</span><span class="cx">     this.baseDN = baseDN;
</span><del>-    db = new ReplicationDB(serverId, baseDN, replicationServer, dbenv);
-    csnLimits = new CSNLimits(db.readOldestCSN(), db.readNewestCSN());
</del><ins>+    this.replicationServer = replicationServer;
+    this.db = new ReplicationDB(serverId, baseDN, replicationServer, \
replicationEnv); +    this.csnLimits = new CSNLimits(db.readOldestCSN(), \
db.readNewestCSN()); </ins><span class="cx"> 
</span><span class="cx">     DirectoryServer.deregisterMonitorProvider(dbMonitor);
</span><span class="cx">     DirectoryServer.registerMonitorProvider(dbMonitor);
</span><span class="lines">@@ -143,8 +145,7 @@
</span><span class="cx">     db.addEntry(updateMsg);
</span><span class="cx"> 
</span><span class="cx">     final CSNLimits limits = csnLimits;
</span><del>-    final boolean updateNew = limits.newestCSN == null
-        || limits.newestCSN.isOlderThan(updateMsg.getCSN());
</del><ins>+    final boolean updateNew = limits.newestCSN == null || \
limits.newestCSN.isOlderThan(updateMsg.getCSN()); </ins><span class="cx">     final \
boolean updateOld = limits.oldestCSN == null; </span><span class="cx">     if \
(updateOld || updateNew) </span><span class="cx">     {
</span><span class="lines">@@ -159,7 +160,7 @@
</span><span class="cx">    *
</span><span class="cx">    * @return the oldest CSN that has not been purged yet.
</span><span class="cx">    */
</span><del>-  public CSN getOldestCSN()
</del><ins>+  CSN getOldestCSN()
</ins><span class="cx">   {
</span><span class="cx">     return csnLimits.oldestCSN;
</span><span class="cx">   }
</span><span class="lines">@@ -169,7 +170,7 @@
</span><span class="cx">    *
</span><span class="cx">    * @return the newest CSN that has not been purged yet.
</span><span class="cx">    */
</span><del>-  public CSN getNewestCSN()
</del><ins>+  CSN getNewestCSN()
</ins><span class="cx">   {
</span><span class="cx">     return csnLimits.newestCSN;
</span><span class="cx">   }
</span><span class="lines">@@ -188,7 +189,7 @@
</span><span class="cx">    * @throws ChangelogException
</span><span class="cx">    *           if a database problem happened
</span><span class="cx">    */
</span><del>-  public DBCursor&lt;UpdateMsg&gt; generateCursorFrom(CSN startCSN, \
PositionStrategy positionStrategy) </del><ins>+  DBCursor&lt;UpdateMsg&gt; \
generateCursorFrom(final CSN startCSN, final PositionStrategy positionStrategy) \
</ins><span class="cx">       throws ChangelogException </span><span class="cx">   {
</span><span class="cx">     return new JEReplicaDBCursor(db, startCSN, \
positionStrategy, this); </span><span class="lines">@@ -197,7 +198,7 @@
</span><span class="cx">   /**
</span><span class="cx">    * Shutdown this ReplicaDB.
</span><span class="cx">    */
</span><del>-  public void shutdown()
</del><ins>+  void shutdown()
</ins><span class="cx">   {
</span><span class="cx">     if (shutdown.compareAndSet(false, true))
</span><span class="cx">     {
</span><span class="lines">@@ -211,7 +212,7 @@
</span><span class="cx">    *
</span><span class="cx">    * @param purgeCSN
</span><span class="cx">    *          The CSN up to which changes can be purged. No \
purging happens when </span><del>-   *          it is null.
</del><ins>+   *          it is {@code null}.
</ins><span class="cx">    * @throws ChangelogException
</span><span class="cx">    *           In case of database problem.
</span><span class="cx">    */
</span><span class="lines">@@ -279,8 +280,7 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   /**
</span><del>-   * This internal class is used to implement the Monitoring \
                capabilities of the
-   * ReplicaDB.
</del><ins>+   * Implements monitoring capabilities of the ReplicaDB.
</ins><span class="cx">    */
</span><span class="cx">   private class DbMonitorProvider extends \
MonitorProvider&lt;MonitorProviderCfg&gt; </span><span class="cx">   {
</span><span class="lines">@@ -288,7 +288,7 @@
</span><span class="cx">     @Override
</span><span class="cx">     public List&lt;Attribute&gt; getMonitorData()
</span><span class="cx">     {
</span><del>-      List&lt;Attribute&gt; attributes = new \
ArrayList&lt;Attribute&gt;(); </del><ins>+      final List&lt;Attribute&gt; \
attributes = new ArrayList&lt;Attribute&gt;(); </ins><span class="cx">       \
create(attributes, &quot;replicationServer-database&quot;,String.valueOf(serverId)); \
</span><span class="cx">       create(attributes, &quot;domain-name&quot;, \
baseDN.toNormalizedString()); </span><span class="cx">       final CSNLimits limits = \
csnLimits; </span><span class="lines">@@ -303,12 +303,12 @@
</span><span class="cx">       return attributes;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    private void create(List&lt;Attribute&gt; attributes, String name, \
String value) </del><ins>+    private void create(final List&lt;Attribute&gt; \
attributes, final String name, final String value) </ins><span class="cx">     {
</span><span class="cx">       attributes.add(Attributes.create(name, value));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    private String encode(CSN csn)
</del><ins>+    private String encode(final CSN csn)
</ins><span class="cx">     {
</span><span class="cx">       return csn + &quot; &quot; + new Date(csn.getTime());
</span><span class="cx">     }
</span><span class="lines">@@ -317,16 +317,14 @@
</span><span class="cx">     @Override
</span><span class="cx">     public String getMonitorInstanceName()
</span><span class="cx">     {
</span><del>-      ReplicationServerDomain domain = replicationServer
-          .getReplicationServerDomain(baseDN);
-      return &quot;Changelog for DS(&quot; + serverId + &quot;),cn=&quot;
-          + domain.getMonitorInstanceName();
</del><ins>+      ReplicationServerDomain domain = \
replicationServer.getReplicationServerDomain(baseDN); +      return &quot;Changelog \
for DS(&quot; + serverId + &quot;),cn=&quot; + domain.getMonitorInstanceName(); \
</ins><span class="cx">     } </span><span class="cx"> 
</span><span class="cx">     /** {@inheritDoc} */
</span><span class="cx">     @Override
</span><span class="cx">     public void initializeMonitorProvider(MonitorProviderCfg \
configuration) </span><del>-                            throws \
ConfigException,InitializationException </del><ins>+        throws \
ConfigException,InitializationException </ins><span class="cx">     {
</span><span class="cx">       // Nothing to do for now
</span><span class="cx">     }
</span><span class="lines">@@ -346,7 +344,7 @@
</span><span class="cx">    * @throws ChangelogException When an exception occurs \
while removing the </span><span class="cx">    * changes from the DB.
</span><span class="cx">    */
</span><del>-  public void clear() throws ChangelogException
</del><ins>+  void clear() throws ChangelogException
</ins><span class="cx">   {
</span><span class="cx">     db.clear();
</span><span class="cx">     csnLimits = new CSNLimits(null, null);
</span></span></pre></div>
<a id="branchesopendj3serverdevtestsunitteststestngsrcserverorgopendsserverreplicationserverchangelogjeJEChangeNumberIndexDBTestjava"></a>
 <div class="modfile"><h4>Modified: \
branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java \
(10966 => 10967)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java	2014-08-20 \
                13:26:09 UTC (rev 10966)
+++ branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java	2014-08-20 \
14:16:56 UTC (rev 10967) </span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">       DN baseDN2 = DN.valueOf(&quot;o=baseDN2&quot;);
</span><span class="cx">       DN baseDN3 = DN.valueOf(&quot;o=baseDN3&quot;);
</span><span class="cx"> 
</span><del>-      CSN[] csns = newCSNs(1, 0, 3);
</del><ins>+      CSN[] csns = generateCSNs(1, 0, 3);
</ins><span class="cx"> 
</span><span class="cx">       // Add records
</span><span class="cx">       final JEChangeNumberIndexDB cnIndexDB = \
getCNIndexDB(replicationServer); </span><span class="lines">@@ -187,7 +187,7 @@
</span><span class="cx">       DN baseDN2 = DN.valueOf(&quot;o=baseDN2&quot;);
</span><span class="cx">       DN baseDN3 = DN.valueOf(&quot;o=baseDN3&quot;);
</span><span class="cx"> 
</span><del>-      CSN[] csns = newCSNs(1, 0, 3);
</del><ins>+      CSN[] csns = generateCSNs(1, 0, 3);
</ins><span class="cx"> 
</span><span class="cx">       // Add records
</span><span class="cx">       final JEChangeNumberIndexDB cnIndexDB = \
getCNIndexDB(replicationServer); </span></span></pre></div>
<a id="branchesopendj3serverdevtestsunitteststestngsrcserverorgopendsserverreplicationserverchangelogjeJEReplicaDBTestjava"></a>
 <div class="modfile"><h4>Modified: \
branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java \
(10966 => 10967)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java	2014-08-20 \
                13:26:09 UTC (rev 10966)
+++ branches/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDBTest.java	2014-08-20 \
14:16:56 UTC (rev 10967) </span><span class="lines">@@ -83,7 +83,46 @@
</span><span class="cx">     TEST_ROOT_DN = DN.valueOf(TEST_ROOT_DN_STRING);
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  @Test(enabled=true)
</del><ins>+  @Test
+  public void testGenerateCursorFrom() throws Exception
+  {
+    ReplicationServer replicationServer = null;
+    JEReplicaDB replicaDB = null;
+    try
+    {
+      TestCaseUtils.startServer();
+      replicationServer = configureReplicationServer(100000, 10);
+      replicaDB = newReplicaDB(replicationServer);
+
+      final CSN[] csns = generateCSNs(1, System.currentTimeMillis(), 5);
+      final ArrayList&lt;CSN&gt; csns2 = new \
ArrayList&lt;CSN&gt;(Arrays.asList(csns)); +      csns2.remove(csns[3]);
+
+      for (CSN csn : csns2)
+      {
+        replicaDB.add(new DeleteMsg(TEST_ROOT_DN, csn, &quot;uid&quot;));
+      }
+
+      for (CSN csn : csns2)
+      {
+        assertNextCSN(replicaDB, csn, ON_MATCHING_KEY, csn);
+      }
+      assertNextCSN(replicaDB, csns[3], ON_MATCHING_KEY, csns[4]);
+
+      for (int i = 0; i &lt; csns2.size() - 1; i++)
+      {
+        assertNextCSN(replicaDB, csns2.get(i), AFTER_MATCHING_KEY, csns2.get(i + \
1)); +      }
+      assertNotFound(replicaDB, csns[4], AFTER_MATCHING_KEY);
+    }
+    finally
+    {
+      shutdown(replicaDB);
+      remove(replicationServer);
+    }
+  }
+
+  @Test
</ins><span class="cx">   void testTrim() throws Exception
</span><span class="cx">   {
</span><span class="cx">     ReplicationServer replicationServer = null;
</span><span class="lines">@@ -94,7 +133,7 @@
</span><span class="cx">       replicationServer = configureReplicationServer(100, \
5000); </span><span class="cx">       replicaDB = newReplicaDB(replicationServer);
</span><span class="cx"> 
</span><del>-      CSN[] csns = newCSNs(1, 0, 5);
</del><ins>+      CSN[] csns = generateCSNs(1, 0, 5);
</ins><span class="cx"> 
</span><span class="cx">       replicaDB.add(new DeleteMsg(TEST_ROOT_DN, csns[0], \
&quot;uid&quot;)); </span><span class="cx">       replicaDB.add(new \
DeleteMsg(TEST_ROOT_DN, csns[1], &quot;uid&quot;)); </span><span class="lines">@@ \
-145,89 +184,13 @@ </span><span class="cx">     }
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  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 &lt; 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, 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 + &quot;build&quot;);
-    path = path + File.separator + &quot;unit-tests&quot; + File.separator + \
                &quot;JEReplicaDB&quot;;
-    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
-  {
-    DBCursor&lt;UpdateMsg&gt; cursor = replicaDB.generateCursorFrom(csns[0], \
                positionStrategy);
-    try
-    {
-      assertNull(cursor.getRecord(), &quot;Cursor should point to a null record \
                initially&quot;);
-
-      for (int i = positionStrategy == ON_MATCHING_KEY ? 0 : 1; i &lt; csns.length; \
                i++)
-      {
-        final String msg = &quot;i=&quot; + i + &quot;, csns[i]=&quot; + \
                csns[i].toStringUI();
-        final SoftAssertions softly = new SoftAssertions();
-        softly.assertThat(cursor.next()).as(msg).isTrue();
-        softly.assertThat(cursor.getRecord().getCSN()).as(msg).isEqualTo(csns[i]);
-        softly.assertAll();
-      }
-      final SoftAssertions softly = new SoftAssertions();
-      softly.assertThat(cursor.next()).isFalse();
-      softly.assertThat(cursor.getRecord()).isNull();
-      softly.assertAll();
-    }
-    finally
-    {
-      close(cursor);
-    }
-  }
-
</del><span class="cx">   /**
</span><span class="cx">    * Test the feature of clearing a JEReplicaDB used by a \
replication server. </span><span class="cx">    * The clear feature is used when a \
replication server receives a request to </span><span class="cx">    * reset the \
generationId of a given domain. </span><span class="cx">    */
</span><del>-  @Test(enabled=true)
-  void testClear() throws Exception
</del><ins>+  @Test
+  public void testClear() throws Exception
</ins><span class="cx">   {
</span><span class="cx">     ReplicationServer replicationServer = null;
</span><span class="cx">     JEReplicaDB replicaDB = null;
</span><span class="lines">@@ -237,7 +200,7 @@
</span><span class="cx">       replicationServer = configureReplicationServer(100, \
5000); </span><span class="cx">       replicaDB = newReplicaDB(replicationServer);
</span><span class="cx"> 
</span><del>-      CSN[] csns = newCSNs(1, 0, 3);
</del><ins>+      CSN[] csns = generateCSNs(1, 0, 3);
</ins><span class="cx"> 
</span><span class="cx">       // Add the changes and check they are here
</span><span class="cx">       replicaDB.add(new DeleteMsg(TEST_ROOT_DN, csns[0], \
&quot;uid&quot;)); </span><span class="lines">@@ -260,45 +223,6 @@
</span><span class="cx">     }
</span><span class="cx">   }
</span><span class="cx"> 
</span><del>-  @Test
-  public void testGenerateCursorFrom() throws Exception
-  {
-    ReplicationServer replicationServer = null;
-    JEReplicaDB replicaDB = null;
-    try
-    {
-      TestCaseUtils.startServer();
-      replicationServer = configureReplicationServer(100000, 10);
-      replicaDB = newReplicaDB(replicationServer);
-
-      final CSN[] csns = newCSNs(1, System.currentTimeMillis(), 5);
-      final ArrayList&lt;CSN&gt; csns2 = new \
                ArrayList&lt;CSN&gt;(Arrays.asList(csns));
-      csns2.remove(csns[3]);
-
-      for (CSN csn : csns2)
-      {
-        replicaDB.add(new DeleteMsg(TEST_ROOT_DN, csn, &quot;uid&quot;));
-      }
-
-      for (CSN csn : csns2)
-      {
-        assertNextCSN(replicaDB, csn, ON_MATCHING_KEY, csn);
-      }
-      assertNextCSN(replicaDB, csns[3], ON_MATCHING_KEY, csns[4]);
-
-      for (int i = 0; i &lt; csns2.size() - 1; i++)
-      {
-        assertNextCSN(replicaDB, csns2.get(i), AFTER_MATCHING_KEY, csns2.get(i + \
                1));
-      }
-      assertNotFound(replicaDB, csns[4], AFTER_MATCHING_KEY);
-    }
-    finally
-    {
-      shutdown(replicaDB);
-      remove(replicationServer);
-    }
-  }
-
</del><span class="cx">   private void assertNextCSN(JEReplicaDB replicaDB, final CSN \
startCSN, </span><span class="cx">       final PositionStrategy positionStrategy, \
final CSN expectedCSN) </span><span class="cx">       throws ChangelogException
</span><span class="lines">@@ -338,7 +262,7 @@
</span><span class="cx">    * Test the logic that manages counter records in the \
JEReplicaDB in order to </span><span class="cx">    * optimize the oldest and newest \
records in the replication changelog db. </span><span class="cx">    */
</span><del>-  @Test(enabled=true, groups = { &quot;opendj-256&quot; })
</del><ins>+  @Test(groups = { &quot;opendj-256&quot; })
</ins><span class="cx">   void testGetOldestNewestCSNs() throws Exception
</span><span class="cx">   {
</span><span class="cx">     // It's worth testing with 2 different setting for \
counterRecord </span><span class="lines">@@ -403,7 +327,7 @@
</span><span class="cx">       assertEquals(replicaDB.getNewestCSN(), csns[max], \
&quot;Wrong newest CSN&quot;); </span><span class="cx"> 
</span><span class="cx">       // Populate the db with 'max' msg
</span><del>-      for (int i=max+1; i&lt;=(2*max); i++)
</del><ins>+      for (int i=max+1; i&lt;=2 * max; i++)
</ins><span class="cx">       {
</span><span class="cx">         csns[i] = new CSN(now + i, mySeqnum, 1);
</span><span class="cx">         replicaDB.add(new DeleteMsg(TEST_ROOT_DN, csns[i], \
&quot;uid&quot;)); </span><span class="lines">@@ -413,7 +337,6 @@
</span><span class="cx">       assertEquals(replicaDB.getOldestCSN(), csns[1], \
&quot;Wrong oldest CSN&quot;); </span><span class="cx">       \
assertEquals(replicaDB.getNewestCSN(), csns[2 * max], &quot;Wrong newest CSN&quot;); \
</span><span class="cx">  </span><del>-      //
</del><span class="cx">       replicaDB.purgeUpTo(new CSN(Long.MAX_VALUE, 0, 0));
</span><span class="cx"> 
</span><span class="cx">       String testcase = &quot;AFTER PURGE (oldest, \
newest)=&quot;; </span><span class="lines">@@ -449,4 +372,80 @@
</span><span class="cx">     }
</span><span class="cx">   }
</span><span class="cx"> 
</span><ins>+  static CSN[] generateCSNs(int serverId, long timestamp, int number)
+  {
+    CSNGenerator gen = new CSNGenerator(serverId, timestamp);
+    CSN[] csns = new CSN[number];
+    for (int i = 0; i &lt; 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, 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 + &quot;build&quot;);
+    path = path + File.separator + &quot;unit-tests&quot; + File.separator + \
&quot;JEReplicaDB&quot;; +    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 +  {
+    DBCursor&lt;UpdateMsg&gt; cursor = replicaDB.generateCursorFrom(csns[0], \
positionStrategy); +    try
+    {
+      assertNull(cursor.getRecord(), &quot;Cursor should point to a null record \
initially&quot;); +
+      for (int i = positionStrategy == ON_MATCHING_KEY ? 0 : 1; i &lt; csns.length; \
i++) +      {
+        final String msg = &quot;i=&quot; + i + &quot;, csns[i]=&quot; + \
csns[i].toStringUI(); +        final SoftAssertions softly = new SoftAssertions();
+        softly.assertThat(cursor.next()).as(msg).isTrue();
+        softly.assertThat(cursor.getRecord().getCSN()).as(msg).isEqualTo(csns[i]);
+        softly.assertAll();
+      }
+      final SoftAssertions softly = new SoftAssertions();
+      softly.assertThat(cursor.next()).isFalse();
+      softly.assertThat(cursor.getRecord()).isNull();
+      softly.assertAll();
+    }
+    finally
+    {
+      close(cursor);
+    }
+  }
+
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>
<div id="footer">Copyright (c) by ForgeRock. All rights reserved.</div>

</body>
</html>



_______________________________________________
OpenDJ-dev mailing list
OpenDJ-dev@forgerock.org
https://lists.forgerock.org/mailman/listinfo/opendj-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic