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

Jean-Noel Rouvignac
05.14.2013 cf44474b926f6da103b7a4376fb446d7722ca939
OPENDJ-1174 Transfer responsibility for populating the ChangeNumberIndexDB to ChangelogDB

Code review: Matthew Swift



Fixing failing unit tests, removed the following stack trace which makes test and code fail.

[testng] Failed Test: org.opends.server.replication.plugin.HistoricalCsnOrderingTest#buildAndPublishMissingChangesSeveralEntriesTest
[testng] Failure Cause: com.sleepycat.je.ThreadInterruptedException: (JE 5.0.97) Environment must be closed, caused by: com.sleepycat.je.ThreadInterruptedException: Environment invalid because of previous exception: (JE 5.0.97) <https://builds.forgerock.org/job/OpenDJ%20-%20trunk%20-%20postcommit/ws/build/unit-tests/package-instance/HistoricalCsnOrdering> Thread interrupted prior to logging the commit THREAD_INTERRUPTED: InterruptedException may cause incorrect internal state, unable to continue. Environment is invalid and must be closed.
[testng] com.sleepycat.je.ThreadInterruptedException.wrapSelf(ThreadInterruptedException.java:99)
[testng] com.sleepycat.je.dbi.EnvironmentImpl.checkIfInvalid(EnvironmentImpl.java:1594)
[testng] com.sleepycat.je.Database.checkEnv(Database.java:2154)
[testng] com.sleepycat.je.Database.getDatabaseName(Database.java:1939)
[testng] org.opends.server.replication.server.changelog.je.ReplicationDbEnv.closeDB(ReplicationDbEnv.java:457)
[testng] org.opends.server.replication.server.changelog.je.ReplicationDbEnv.shutdown(ReplicationDbEnv.java:435)
[testng] org.opends.server.replication.server.changelog.je.JEChangelogDB.shutdownDB(JEChangelogDB.java:409)
[testng] org.opends.server.replication.server.ReplicationServer.shutdown(ReplicationServer.java:702)
[testng] org.opends.server.replication.server.ReplicationServer.remove(ReplicationServer.java:1028)
[testng] org.opends.server.replication.plugin.HistoricalCsnOrderingTest.buildAndPublishMissingChangesSeveralEntriesTest(HistoricalCsnOrderingTest.java:308)



DirectoryThread.java:
In initiateShutdown(), removed the call to Thread.interrupt() added in r9911.

ChangeNumberIndexer.java:
Overrode initiateShutdown() to stop this thread on shutdown: used notify() to wake up the thread if it was waiting.
In run(), checked whether shutdown has been initiated for this thread before calling wait(): this protects against missed notifications.

JEReplicaDB.java:
In run(), removed call to Thread.currentThread().interrupt().
3 files modified
24 ■■■■ changed files
opends/src/server/org/opends/server/api/DirectoryThread.java 1 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java 5 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/DirectoryThread.java
@@ -416,7 +416,6 @@
  public void initiateShutdown()
  {
    setThreadStateIfNotShuttingDown(ThreadState.SHUTTING_DOWN);
    interrupt();
  }
  /**
opends/src/server/org/opends/server/replication/server/changelog/je/ChangeNumberIndexer.java
@@ -347,6 +347,17 @@
  /** {@inheritDoc} */
  @Override
  public void initiateShutdown()
  {
    super.initiateShutdown();
    synchronized (this)
    {
      notify();
    }
  }
  /** {@inheritDoc} */
  @Override
  public void run()
  {
    try
@@ -380,6 +391,10 @@
          {
            synchronized (this)
            {
              if (isShutdownInitiated())
              {
                continue;
              }
              wait();
            }
            // advance cursor, success/failure will be checked later
@@ -400,7 +415,8 @@
            synchronized (this)
            {
              // double check to protect against a missed call to notify()
              if (!canMoveForwardMediumConsistencyPoint(baseDN))
              if (!isShutdownInitiated()
                  && !canMoveForwardMediumConsistencyPoint(baseDN))
              {
                wait();
                // loop to check if changes older than the medium consistency
opends/src/server/org/opends/server/replication/server/changelog/je/JEReplicaDB.java
@@ -363,7 +363,10 @@
              }
              catch (InterruptedException e)
              {
                Thread.currentThread().interrupt();
                // Do not reset the interrupt flag here,
                // because otherwise JE will barf next time flush() is called:
                // JE 5.0.97 refuses to persist changes to the DB when invoked
                // from a Thread with the interrupt flag set to true.
              }
            }
          }