From da28258f902906d5c65bcdc01bbad3d13f900340 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Thu, 19 Apr 2012 18:16:53 -0700 Subject: [PATCH] Option to set bdb cache size as an absolute number instead of a percentage (part of HER-1948) --- .../main/java/org/archive/bdb/BdbModule.java | 25 ++++++++++++------- .../restlet/profile-crawler-beans.cxml | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/commons/src/main/java/org/archive/bdb/BdbModule.java b/commons/src/main/java/org/archive/bdb/BdbModule.java index 47292d99..19c20f68 100644 --- a/commons/src/main/java/org/archive/bdb/BdbModule.java +++ b/commons/src/main/java/org/archive/bdb/BdbModule.java @@ -81,7 +81,6 @@ public class BdbModule implements Lifecycle, Checkpointable, Closeable, Disposab public BdbConfig config; } - /** * Configuration object for databases. Needed because * {@link DatabaseConfig} is not serializable. Also it prevents invalid @@ -103,22 +102,18 @@ public class BdbModule implements Lifecycle, Checkpointable, Closeable, Disposab public BdbConfig() { } - public boolean isAllowCreate() { return allowCreate; } - public void setAllowCreate(boolean allowCreate) { this.allowCreate = allowCreate; } - public boolean getSortedDuplicates() { return sortedDuplicates; } - public void setSortedDuplicates(boolean sortedDuplicates) { this.sortedDuplicates = sortedDuplicates; } @@ -132,17 +127,14 @@ public class BdbModule implements Lifecycle, Checkpointable, Closeable, Disposab return result; } - public boolean isTransactional() { return transactional; } - public void setTransactional(boolean transactional) { this.transactional = transactional; } - public void setDeferredWrite(boolean b) { this.deferredWrite = true; } @@ -163,6 +155,14 @@ public class BdbModule implements Lifecycle, Checkpointable, Closeable, Disposab public void setCachePercent(int cachePercent) { this.cachePercent = cachePercent; } + + int cacheSize = -1; + public int getCacheSize() { + return cacheSize; + } + public void setCacheSize(int cacheSize) { + this.cacheSize = cacheSize; + } boolean useSharedCache = true; public boolean getUseSharedCache() { @@ -255,9 +255,16 @@ public class BdbModule implements Lifecycle, Checkpointable, Closeable, Disposab EnvironmentConfig config = new EnvironmentConfig(); config.setAllowCreate(create); config.setLockTimeout(75, TimeUnit.MINUTES); // set to max - if(getCachePercent()>0) { + + if (getCacheSize() > 0) { + config.setCacheSize(getCacheSize()); + if (getCachePercent() > 0) { + LOGGER.warning("cachePercent and cacheSize are both set. Only cacheSize will be used."); + } + } else if (getCachePercent() > 0) { config.setCachePercent(getCachePercent()); } + config.setSharedCache(getUseSharedCache()); // we take the advice literally from... diff --git a/engine/src/main/resources/org/archive/crawler/restlet/profile-crawler-beans.cxml b/engine/src/main/resources/org/archive/crawler/restlet/profile-crawler-beans.cxml index a53b476b..d5366b7f 100644 --- a/engine/src/main/resources/org/archive/crawler/restlet/profile-crawler-beans.cxml +++ b/engine/src/main/resources/org/archive/crawler/restlet/profile-crawler-beans.cxml @@ -667,6 +667,7 @@ http://example.example/example class="org.archive.bdb.BdbModule"> +