Option to set bdb cache size as an absolute number instead of a percentage (part of HER-1948)

This commit is contained in:
Noah Levitt
2012-04-19 18:16:53 -07:00
parent 4a64c6ba59
commit da28258f90
2 changed files with 17 additions and 9 deletions
@@ -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...
@@ -667,6 +667,7 @@ http://example.example/example
class="org.archive.bdb.BdbModule">
<!-- <property name="dir" value="state" /> -->
<!-- <property name="cachePercent" value="60" /> -->
<!-- <property name="cacheSize" value="104857600" /> -->
<!-- <property name="useSharedCache" value="true" /> -->
<!-- <property name="expectedConcurrency" value="25" /> -->
</bean>