From dacd1dc403149c6322edbb4d2402ef121bde6f2b Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 30 Mar 2012 17:09:27 +0200 Subject: Cache RemoteMaps if they are not related to a transaction --- .../c2kernel/persistency/ClusterStorageManager.java | 19 ++++++++++++++++++- .../com/c2kernel/persistency/TransactionManager.java | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'source/com') diff --git a/source/com/c2kernel/persistency/ClusterStorageManager.java b/source/com/c2kernel/persistency/ClusterStorageManager.java index b4515e0..756ac4d 100644 --- a/source/com/c2kernel/persistency/ClusterStorageManager.java +++ b/source/com/c2kernel/persistency/ClusterStorageManager.java @@ -8,8 +8,10 @@ import java.util.StringTokenizer; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.entity.agent.JobList; import com.c2kernel.entity.proxy.EntityProxyManager; import com.c2kernel.entity.proxy.ProxyMessage; +import com.c2kernel.events.History; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; @@ -163,7 +165,7 @@ public class ClusterStorageManager { /** Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache */ public C2KLocalObject get(Integer sysKeyIntObj, String path) throws ClusterStorageException, ObjectNotFoundException { - C2KLocalObject result; + C2KLocalObject result = null; // check cache first SoftCache sysKeyMemCache = null; if (memoryCache.containsKey(sysKeyIntObj)) { @@ -189,6 +191,21 @@ public class ClusterStorageManager { return data; } } + + // deal out top level remote maps + if (path.indexOf('/') == -1) { + if (path.equals(ClusterStorage.HISTORY)) + result = new History(sysKeyIntObj, null); + if (path.equals(ClusterStorage.JOB)) + result = new JobList(sysKeyIntObj, null); + if (result!=null) { + synchronized(sysKeyMemCache) { + sysKeyMemCache.put(path, result); + } + return result; + } + + } // else try each reader in turn until we find it ArrayList readers = findStorages(ClusterStorage.getClusterType(path), false); diff --git a/source/com/c2kernel/persistency/TransactionManager.java b/source/com/c2kernel/persistency/TransactionManager.java index 6f930b7..d2679a8 100644 --- a/source/com/c2kernel/persistency/TransactionManager.java +++ b/source/com/c2kernel/persistency/TransactionManager.java @@ -53,11 +53,11 @@ public class TransactionManager { ObjectNotFoundException { if (path.startsWith("/") && path.length() > 1) path = path.substring(1); - // deal out top level remote maps + // deal out top level remote maps, if transactions aren't needed if (path.indexOf('/') == -1) { - if (path.equals(ClusterStorage.HISTORY)) + if (path.equals(ClusterStorage.HISTORY) && locker != null) return new History(sysKey, locker); - if (path.equals(ClusterStorage.JOB)) + if (path.equals(ClusterStorage.JOB) && locker != null) return new JobList(sysKey, locker); } -- cgit v1.2.3