opends/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDB.java
@@ -93,7 +93,6 @@ private final AtomicLong lastGeneratedChangeNumber; private DbMonitorProvider dbMonitor = new DbMonitorProvider(); private final AtomicBoolean shutdown = new AtomicBoolean(false); private volatile boolean trimDone = false; /** * A dedicated thread loops trim(). * <p> @@ -252,15 +251,15 @@ notifyAll(); } synchronized (this) { /* Can we just do a thread.join() ? */ while (!trimDone) if (trimmingThread != null) { try { try { wait(); } catch (InterruptedException e) { /* do nothing */ } trimmingThread.join(); } catch (InterruptedException ignored) { // Nothing can be done about it, just proceed } } @@ -283,12 +282,16 @@ synchronized (this) { try if (!shutdown.get()) { wait(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); try { wait(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } } @@ -302,35 +305,6 @@ } break; } try { trim(shutdown); synchronized (this) { try { wait(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } catch (Exception end) { logError(ERR_EXCEPTION_CHANGELOG_TRIM_FLUSH .get(stackTraceToSingleLineString(end))); if (replicationServer != null) { replicationServer.shutdown(); } break; } } synchronized (this) { trimDone = true; notifyAll(); } } opends/src/server/org/opends/server/replication/server/changelog/je/JEChangelogDB.java
@@ -678,6 +678,18 @@ @Override public ChangeNumberIndexDB getChangeNumberIndexDB() { return getChangeNumberIndexDB(true); } /** * Returns the {@link ChangeNumberIndexDB} object. * * @param startTrimmingThread * whether the trimming thread should be started * @return the {@link ChangeNumberIndexDB} object */ ChangeNumberIndexDB getChangeNumberIndexDB(boolean startTrimmingThread) { synchronized (cnIndexDBLock) { if (cnIndexDB == null) @@ -685,7 +697,10 @@ try { cnIndexDB = new JEChangeNumberIndexDB(replicationServer, this.dbEnv); cnIndexDB.startTrimmingThread(); if (startTrimmingThread) { cnIndexDB.startTrimmingThread(); } } catch (Exception e) { opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/changelog/je/JEChangeNumberIndexDBTest.java
@@ -26,9 +26,6 @@ */ package org.opends.server.replication.server.changelog.je; import java.io.File; import java.io.IOException; import org.opends.server.TestCaseUtils; import org.opends.server.replication.ReplicationTestCase; import org.opends.server.replication.common.CSN; @@ -74,7 +71,7 @@ try { replicationServer = newReplicationServer(); cnIndexDB = newCNIndexDB(replicationServer); cnIndexDB = getCNIndexDBNoTrimming(replicationServer); cnIndexDB.setPurgeDelay(0); // Prepare data to be stored in the db @@ -122,8 +119,6 @@ } finally { if (cnIndexDB != null) cnIndexDB.shutdown(); remove(replicationServer); } } @@ -141,27 +136,15 @@ assertEquals(record.getPreviousCookie(), cookie); } private JEChangeNumberIndexDB newCNIndexDB(ReplicationServer rs) throws Exception private JEChangeNumberIndexDB getCNIndexDBNoTrimming(ReplicationServer rs) throws ChangelogException { final File testRoot = createCleanDir(); final ReplicationDbEnv dbEnv = new ReplicationDbEnv(testRoot.getPath(), rs); final JEChangeNumberIndexDB cnIndexDB = new JEChangeNumberIndexDB(rs, dbEnv); final JEChangelogDB changelogDB = (JEChangelogDB) rs.getChangelogDB(); final JEChangeNumberIndexDB cnIndexDB = (JEChangeNumberIndexDB) changelogDB.getChangeNumberIndexDB(false); assertTrue(cnIndexDB.isEmpty()); return cnIndexDB; } 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 + "JEChangeNumberIndexDB"; final File testRoot = new File(path); TestCaseUtils.deleteDirectory(testRoot); testRoot.mkdirs(); return testRoot; } /** * This test makes basic operations of a JEChangeNumberIndexDB and explicitly * calls the clear() method instead of waiting for the periodic trim to clear @@ -181,7 +164,7 @@ try { replicationServer = newReplicationServer(); cnIndexDB = newCNIndexDB(replicationServer); cnIndexDB = getCNIndexDBNoTrimming(replicationServer); cnIndexDB.setPurgeDelay(0); // Prepare data to be stored in the db @@ -229,8 +212,6 @@ } finally { if (cnIndexDB != null) cnIndexDB.shutdown(); remove(replicationServer); } }