Temporary fix for the chicken and egg problem when making changes to the configuration database.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3f583684 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3f583684 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3f583684 Branch: refs/heads/ui-restyle Commit: 3f583684c6ddcf7efb66adada63957f8ca06cfdc Parents: a3babdd Author: Hugo Trippaers <[email protected]> Authored: Thu Oct 3 12:33:10 2013 +0200 Committer: Hugo Trippaers <[email protected]> Committed: Thu Oct 3 12:36:34 2013 +0200 ---------------------------------------------------------------------- .../cache/manager/StorageCacheReplacementAlgorithmLRU.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3f583684/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java ---------------------------------------------------------------------- diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java index fc96a0d..ed1fc1a 100644 --- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java +++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java @@ -60,7 +60,10 @@ public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacem @PostConstruct public void initialize() { - unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30); + /* Avoid using configDao at this time, we can't be sure that the database is already upgraded + * and there might be fatal errors when using a dao. + */ + //unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30); } public void setUnusedTimeInterval(Integer interval) { @@ -69,6 +72,9 @@ public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacem @Override public DataObject chooseOneToBeReplaced(DataStore store) { + if (unusedTimeInterval == null) { + unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30); + } Calendar cal = Calendar.getInstance(); cal.setTime(DateUtil.now()); cal.add(Calendar.DAY_OF_MONTH, -unusedTimeInterval.intValue());
