summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
authorTobias Holgers <tholgers@users.sourceforge.net>2009-05-15 23:52:35 +0000
committerTobias Holgers <tholgers@users.sourceforge.net>2009-05-15 23:52:35 +0000
commit6806b3a6fff3f236ae41ab741618b3ad51a64783 (patch)
tree1a5726e40db94a8257f12dba1a6086399986ad54 /src/main/java/com/amazon/carbonado/repo
parent4a0115c24f7eb72405ecdc2c2d4cc25af429e5e1 (diff)
Added methods for configuring checkpointThresholdKB, checkpointThresholdMinutes, and checksumEnabled.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java35
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java72
2 files changed, 82 insertions, 25 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 01e3668..1391c40 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
@@ -109,9 +109,6 @@ 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;
@@ -152,8 +149,6 @@ 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();
@@ -545,22 +540,31 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
}
/**
+ * Start background tasks and enable auto shutdown.
+ *
* @param checkpointInterval how often to run checkpoints, in milliseconds,
- * or zero if never. Ignored if builder has checkpoints disabled.
+ * 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.
+ * 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) {
+ void start(long checkpointInterval, long deadlockDetectorInterval,
+ BDBRepositoryBuilder builder) {
getLog().info("Opened repository \"" + getName() + '"');
- if (mRunCheckpointer && checkpointInterval > 0) {
- mCheckpointer = new Checkpointer(this, checkpointInterval);
+ if (!builder.getReadOnly() && builder.getRunCheckpointer()
+ && checkpointInterval > 0) {
+ mCheckpointer = new Checkpointer(this, checkpointInterval,
+ builder.getCheckpointThresholdKB(),
+ builder.getCheckpointThresholdMinutes());
mCheckpointer.start();
} else {
mCheckpointer = null;
}
- if (mRunDeadlockDetector && deadlockDetectorInterval > 0) {
+ if (builder.getRunDeadlockDetector() && deadlockDetectorInterval > 0) {
mDeadlockDetector = new DeadlockDetector(this, deadlockDetectorInterval);
mDeadlockDetector.start();
} else {
@@ -663,15 +667,6 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
*
* @param repository outer class
* @param sleepInterval milliseconds to sleep before running checkpoint
- */
- Checkpointer(BDBRepository repository, long sleepInterval) {
- this(repository, sleepInterval, 1024, 5);
- }
-
- /**
- *
- * @param repository outer class
- * @param sleepInterval milliseconds to sleep before running checkpoint
* @param kBytes run checkpoint if at least this many kilobytes in log
* @param minutes run checkpoint if at least this many minutes passed
* since last checkpoint
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 9301f28..f3ea993 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
@@ -104,7 +104,10 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
private boolean mRunFullRecovery;
private boolean mRunCheckpointer = true;
private int mCheckpointInterval = DEFAULT_CHECKPOINT_INTERVAL;
+ private int mCheckpointThresholdKB = 1024;
+ private int mCheckpointThresholdMinutes = 5;
private boolean mRunDeadlockDetector = true;
+ private Boolean mChecksumEnabled;
private Object mInitialEnvConfig = null;
private Object mInitialDBConfig = null;
private StorableCodecFactory mStorableCodecFactory = new GenericStorableCodecFactory();
@@ -439,8 +442,8 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
}
/**
- * Set the percent of JVM heap used by the repository cache. Actual
- * BDB implementation will select a suitable default if this is not
+ * Set the percent of JVM heap used by the repository cache. Actual
+ * BDB implementation will select a suitable default if this is not
* set. This is overridden by setting an explicit cacheSize.
*/
public void setCachePercent(int cachePercent) {
@@ -448,8 +451,8 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
}
/**
- * Set the percent of JVM heap used by the repository cache. Actual
- * BDB implementation will select a suitable default if this is not
+ * Set the percent of JVM heap used by the repository cache. Actual
+ * BDB implementation will select a suitable default if this is not
* set. This is overridden by setting an explicit cacheSize.
*
* @param cachePercent percent of JVM heap to use, or null for default
@@ -459,7 +462,7 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
}
/**
- * Returns the percent of JVM heap used by the repository cache, or
+ * Returns the percent of JVM heap used by the repository cache, or
* null if default should be selected.
*/
public Integer getCachePercent() {
@@ -676,6 +679,48 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
}
/**
+ * Set the size threshold to run checkpoints. This setting is ignored if
+ * the checkpointer is not configured to run.
+ *
+ * <p>Checkpoint threshold is only used by Carbonado's built-in
+ * checkpointer, and is ignored when using BDB-JE.
+ *
+ * @param thresholdKB run checkpoint if at least this many kilobytes in log
+ */
+ public void setCheckpointThresholdKB(int thresholdKB) {
+ mCheckpointThresholdKB = thresholdKB;
+ }
+
+ /**
+ * @return run checkpoint if at least this many kilobytes in log
+ */
+ public int getCheckpointThresholdKB() {
+ return mCheckpointThresholdKB;
+ }
+
+ /**
+ * Set the time threshold to run checkpoints. This setting is ignored if
+ * the checkpointer is not configured to run.
+ *
+ * <p>Checkpoint threshold is only used by Carbonado's built-in
+ * checkpointer, and is ignored when using BDB-JE.
+ *
+ * @param thresholdMinutes run checkpoint if at least this many minutes
+ * passed since last checkpoint
+ */
+ public void setCheckpointThresholdMinutes(int thresholdMinutes) {
+ mCheckpointThresholdMinutes = thresholdMinutes;
+ }
+
+ /**
+ * @return run checkpoint if at least this many minutes passed since last
+ * checkpoint
+ */
+ public int getCheckpointThresholdMinutes() {
+ return mCheckpointThresholdMinutes;
+ }
+
+ /**
* Disable automatic deadlock detection of database if another thread is
* responsible for that.
*/
@@ -691,6 +736,23 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
}
/**
+ * When true, enable checksum verification of pages read into the cache
+ * from the backing filestore. By default checksum is enabled for BDB-JE,
+ * and disabled for BDB-C.
+ */
+ public void setChecksumEnabled(Boolean checksumEnabled) {
+ mChecksumEnabled = checksumEnabled;
+ }
+
+ /**
+ * Returns true if checksum verification is enabled. Returns null if the
+ * BDB default is used.
+ */
+ public Boolean getChecksumEnabled() {
+ return mChecksumEnabled;
+ }
+
+ /**
* Optionally set the BDB specific environment configuration to
* use. The builder will verify that needed configuration values are set.
*/