summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java43
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java4
2 files changed, 42 insertions, 5 deletions
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<Txn> extends AbstractRepository<Txn>
private final BDBRepositoryBuilder.DatabaseHook mDatabaseHook;
private final Map<Class<?>, Integer> mDatabasePageSizes;
+ final boolean mRunCheckpointer;
+ final boolean mRunDeadlockDetector;
+
final File mDataHome;
final File mEnvHome;
final String mSingleFileName;
@@ -149,6 +152,8 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
mExTransformer = exTransformer;
mTxnMgr = new BDBTransactionManager<Txn>(mExTransformer, this);
+ mRunCheckpointer = !builder.getReadOnly() && builder.getRunCheckpointer();
+ mRunDeadlockDetector = builder.getRunDeadlockDetector();
mStorableCodecFactory = builder.getStorableCodecFactory();
mPreShutdownHook = builder.getPreShutdownHook();
mPostShutdownHook = builder.getShutdownHook();
@@ -548,14 +553,46 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
* @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.
+ *
+ * @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.
* @param builder containing additonal background task properties.
*/
void start(long checkpointInterval, long deadlockDetectorInterval,
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<Txn> extends AbstractRepository<Txn>
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.
*
* <p>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.
*
* <p>Checkpoint threshold is only used by Carbonado's built-in
* checkpointer, and is ignored when using BDB-JE.