From 529eda22e6cbd93685a2d3260cdcdc8d3f14a56e Mon Sep 17 00:00:00 2001 From: Tobias Holgers Date: Mon, 18 May 2009 17:59:14 +0000 Subject: Support backwards compatiblity with older CarbonadoSleepycat packages. --- .../carbonado/repo/sleepycat/BDBRepository.java | 43 ++++++++++++++++++++-- .../repo/sleepycat/BDBRepositoryBuilder.java | 4 +- 2 files changed, 42 insertions(+), 5 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java index 1391c40..6fbc4f5 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java @@ -109,6 +109,9 @@ abstract class BDBRepository extends AbstractRepository private final BDBRepositoryBuilder.DatabaseHook mDatabaseHook; private final Map, Integer> mDatabasePageSizes; + final boolean mRunCheckpointer; + final boolean mRunDeadlockDetector; + final File mDataHome; final File mEnvHome; final String mSingleFileName; @@ -149,6 +152,8 @@ abstract class BDBRepository extends AbstractRepository mExTransformer = exTransformer; mTxnMgr = new BDBTransactionManager(mExTransformer, this); + mRunCheckpointer = !builder.getReadOnly() && builder.getRunCheckpointer(); + mRunDeadlockDetector = builder.getRunDeadlockDetector(); mStorableCodecFactory = builder.getStorableCodecFactory(); mPreShutdownHook = builder.getPreShutdownHook(); mPostShutdownHook = builder.getShutdownHook(); @@ -539,6 +544,39 @@ abstract class BDBRepository extends AbstractRepository } } + /** + * Start background tasks and enable auto shutdown. + * + * @param checkpointInterval how often to run checkpoints, in milliseconds, + * or zero if never. Ignored if repository is read only or builder has + * checkpoints disabled. + * @param deadlockDetectorInterval how often to run deadlock detector, in + * milliseconds, or zero if never. Ignored if builder has deadlock detector + * disabled. + * + * @deprecated Overloaded for backwards compatiblity with older + * CarbonadoSleepycat packages + */ + void start(long checkpointInterval, long deadlockDetectorInterval) { + getLog().info("Opened repository \"" + getName() + '"'); + + if (mRunCheckpointer && checkpointInterval > 0) { + mCheckpointer = new Checkpointer(this, checkpointInterval, 1024, 5); + mCheckpointer.start(); + } else { + mCheckpointer = null; + } + + if (mRunDeadlockDetector && deadlockDetectorInterval > 0) { + mDeadlockDetector = new DeadlockDetector(this, deadlockDetectorInterval); + mDeadlockDetector.start(); + } else { + mDeadlockDetector = null; + } + + setAutoShutdownEnabled(true); + } + /** * Start background tasks and enable auto shutdown. * @@ -554,8 +592,7 @@ abstract class BDBRepository extends AbstractRepository BDBRepositoryBuilder builder) { getLog().info("Opened repository \"" + getName() + '"'); - if (!builder.getReadOnly() && builder.getRunCheckpointer() - && checkpointInterval > 0) { + if (mRunCheckpointer && checkpointInterval > 0) { mCheckpointer = new Checkpointer(this, checkpointInterval, builder.getCheckpointThresholdKB(), builder.getCheckpointThresholdMinutes()); @@ -564,7 +601,7 @@ abstract class BDBRepository extends AbstractRepository mCheckpointer = null; } - if (builder.getRunDeadlockDetector() && deadlockDetectorInterval > 0) { + if (mRunDeadlockDetector && deadlockDetectorInterval > 0) { mDeadlockDetector = new DeadlockDetector(this, deadlockDetectorInterval); mDeadlockDetector.start(); } else { diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java index f3ea993..59a5d22 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java @@ -680,7 +680,7 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { /** * Set the size threshold to run checkpoints. This setting is ignored if - * the checkpointer is not configured to run. + * the checkpointer is not configured to run. Default value is 1024 KB. * *

Checkpoint threshold is only used by Carbonado's built-in * checkpointer, and is ignored when using BDB-JE. @@ -700,7 +700,7 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { /** * Set the time threshold to run checkpoints. This setting is ignored if - * the checkpointer is not configured to run. + * the checkpointer is not configured to run. Default value is 5 minutes. * *

Checkpoint threshold is only used by Carbonado's built-in * checkpointer, and is ignored when using BDB-JE. -- cgit v1.2.3