From 9a9e104f22226a5d43fc51f48d51efa9f136afdd Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 15 Mar 2007 22:18:27 +0000 Subject: IndexedRepository supports optional and throttled index repair. --- .../repo/sleepycat/BDBRepositoryBuilder.java | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/main/java/com/amazon/carbonado/repo/sleepycat') 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; @@ -338,6 +342,53 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder { return mIndexSupport; } + /** + * @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. + * + *

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 intersection of the old + * and new index sets. The set of indexes that are kept up-to-date is + * defined by the union of the old and new index sets. + * + *

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. -- cgit v1.2.3