diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2007-03-15 22:18:27 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2007-03-15 22:18:27 +0000 |
commit | 9a9e104f22226a5d43fc51f48d51efa9f136afdd (patch) | |
tree | 7ac424217e2f80e65e9ce48aaa0068bc17c0eb5d /src/main/java/com/amazon/carbonado/repo/sleepycat | |
parent | a9c497ca3f29e7f48dfc3299e8237c753e4e54be (diff) |
IndexedRepository supports optional and throttled index repair.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/sleepycat')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java | 51 |
1 files changed, 51 insertions, 0 deletions
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 e332157..1f60bfd 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java @@ -86,6 +86,8 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { private File mDataHome;
private String mSingleFileName;
private boolean mIndexSupport = true;
+ private boolean mIndexRepairEnabled = true;
+ private double mIndexThrottle = 1.0;
private boolean mReadOnly;
private Long mCacheSize;
private double mLockTimeout = 0.5;
@@ -120,6 +122,8 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { IndexedRepositoryBuilder ixBuilder = new IndexedRepositoryBuilder();
ixBuilder.setWrappedRepository(this);
ixBuilder.setMaster(isMaster());
+ ixBuilder.setIndexRepairEnabled(mIndexRepairEnabled);
+ ixBuilder.setIndexRepairThrottle(mIndexThrottle);
return ixBuilder.build(rootRef);
} finally {
mIndexSupport = true;
@@ -339,6 +343,53 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { }
/**
+ * @see #setIndexRepairEnabled(boolean)
+ *
+ * @return true by default
+ */
+ public boolean isIndexRepairEnabled() {
+ return mIndexRepairEnabled;
+ }
+
+ /**
+ * By default, index repair is enabled. In this mode, the first time a
+ * Storable type is used, new indexes are populated and old indexes are
+ * removed. Until finished, access to the Storable is blocked.
+ *
+ * <p>When index repair is disabled, the Storable is immediately
+ * available. This does have consequences, however. The set of indexes
+ * available for queries is defined by the <i>intersection</i> of the old
+ * and new index sets. The set of indexes that are kept up-to-date is
+ * defined by the <i>union</i> of the old and new index sets.
+ *
+ * <p>While index repair is disabled, another process can safely repair the
+ * indexes in the background. When it is complete, index repair can be
+ * enabled for this repository too.
+ */
+ public void setIndexRepairEnabled(boolean enabled) {
+ mIndexRepairEnabled = enabled;
+ }
+
+ /**
+ * Returns the throttle parameter used when indexes are added, dropped or
+ * bulk repaired. By default this value is 1.0, or maximum speed.
+ */
+ public double getIndexRepairThrottle() {
+ return mIndexThrottle;
+ }
+
+ /**
+ * Sets the throttle parameter used when indexes are added, dropped or bulk
+ * repaired. By default this value is 1.0, or maximum speed.
+ *
+ * @param desiredSpeed 1.0 = perform work at full speed,
+ * 0.5 = perform work at half speed, 0.0 = fully suspend work
+ */
+ public void setIndexRepairThrottle(double desiredSpeed) {
+ mIndexThrottle = desiredSpeed;
+ }
+
+ /**
* Sets the repository to read-only mode. By default, repository is opened
* for reads and writes.
*/
|