ozeigermann 2004/02/25 05:10:19
Modified: src/share/org/apache/slide/util TxLRUObjectCache.java
ByteSizeLimitedObjectCache.java
src/share/org/apache/slide/store ExtendedStore.java
Log:
Added two new cache modes:
- off: disables all caching (*slow*)
- isolation-shadow: allows the cache to shadow the isolation of the
underlying store
Revision Changes Path
1.4 +12 -9
jakarta-slide/src/share/org/apache/slide/util/TxLRUObjectCache.java
Index: TxLRUObjectCache.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/util/TxLRUObjectCache.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TxLRUObjectCache.java 20 Feb 2004 11:13:23 -0000 1.3
+++ TxLRUObjectCache.java 25 Feb 2004 13:10:19 -0000 1.4
@@ -66,6 +66,8 @@
protected Logger logger;
protected String logChannel;
protected final boolean loggingEnabled;
+
+ protected boolean noGlobalCachingInsideTx;
/**
* Creates a new object cache. If global caching is disabled, the cache
@@ -76,8 +78,9 @@
* global cache shall be used
* @param name the name used to construct logging category / channel
* @param logger Slide logger to be used for logging
+ * @param noGlobalCachingInsideTx indicates global caches are enabled, but
shall not be used inside transactions
*/
- public TxLRUObjectCache(int globalCacheSize, String name, Logger logger) {
+ public TxLRUObjectCache(int globalCacheSize, String name, Logger logger,
boolean noGlobalCachingInsideTx) {
if (globalCacheSize != -1) {
globalCache = new LRUMap(globalCacheSize);
}
@@ -86,6 +89,7 @@
this.name = name;
this.logger = logger;
+ this.noGlobalCachingInsideTx = noGlobalCachingInsideTx;
logChannel = "TxLRUObjectCache";
if (name != null) {
@@ -96,10 +100,6 @@
loggingEnabled = logger.isEnabled(logChannel, Logger.DEBUG);
}
- public TxLRUObjectCache(int globalCacheSize) {
- this(globalCacheSize, null, null);
- }
-
public synchronized void clear() {
if (globalCache != null) globalCache.clear();
txChangeCaches.clear();
@@ -125,6 +125,9 @@
}
if (globalCache == null) return null;
+
+ // if global cache is disabled inside transactions, do not use it
+ if (noGlobalCachingInsideTx && txId != null) return null;
// as fall back return value from global cache (if present)
Object global = globalCache.get(key);
1.3 +8 -6
jakarta-slide/src/share/org/apache/slide/util/ByteSizeLimitedObjectCache.java
Index: ByteSizeLimitedObjectCache.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/util/ByteSizeLimitedObjectCache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ByteSizeLimitedObjectCache.java 11 Feb 2004 11:30:20 -0000 1.2
+++ ByteSizeLimitedObjectCache.java 25 Feb 2004 13:10:19 -0000 1.3
@@ -73,6 +73,7 @@
* @param maxByteSizePerEntry maximum size of a single cache entry in bytes
* @param name the name used to construct logging category / channel
* @param logger Slide logger to be used for logging
+ * @param noGlobalCachingInsideTx indicates global caches are enabled, but
shall not be used inside transactions
*/
public ByteSizeLimitedObjectCache(
int globalCacheSize,
@@ -81,8 +82,9 @@
long txByteSize,
long maxByteSizePerEntry,
String name,
- Logger logger) {
- super(globalCacheSize, name, logger);
+ Logger logger,
+ boolean noGlobalCachingInsideTx) {
+ super(globalCacheSize, name, logger, noGlobalCachingInsideTx);
globalCache = new SizeCountingLRUMap(globalCacheSize, globalByteSize,
maxByteSizePerEntry);
this.globalByteSize = globalByteSize;
this.txCacheSize = txCacheSize;
1.6 +37 -19
jakarta-slide/src/share/org/apache/slide/store/ExtendedStore.java
Index: ExtendedStore.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/store/ExtendedStore.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ExtendedStore.java 20 Feb 2004 11:13:23 -0000 1.5
+++ ExtendedStore.java 25 Feb 2004 13:10:19 -0000 1.6
@@ -63,8 +63,6 @@
public class ExtendedStore extends AbstractStore {
private static final String LOG_CHANNEL = ExtendedStore.class.getName();
- // just for debugging
- private static final boolean globalCacheOff = false;
protected static final int DEFAULT_OBJECT_GLOBAL_CACHE_SIZE = 10000;
protected static final String GLOBAL_OBJECT_CACHE_SIZE_PARAMETER =
"object-cache-size";
@@ -102,7 +100,8 @@
protected static final String CACHE_MODE_PARAMETER = "cache-mode";
protected static final String CACHE_MODE_FULL = "full";
protected static final String CACHE_MODE_LOCAL = "cluster";
- protected static final String CACHE_MODE_FULL_NO_TX = "isolation-shadow";
+ protected static final String CACHE_MODE_NO_GLOBAL_IN_TX = "isolation-shadow";
+ protected static final String CACHE_MODE_OFF = "off";
protected static final String DEFAULT_CACHE_MODE = CACHE_MODE_FULL;
// there might be at least one active transaction branch per thread
@@ -115,6 +114,8 @@
protected TxCacheWrapper descriptorsCache;
protected TxCacheWrapper descriptorCache;
+ protected boolean globalCacheOff;
+
public void setParameters(Hashtable parameters)
throws ServiceParameterErrorException, ServiceParameterMissingException {
super.setParameters(parameters);
@@ -286,17 +287,31 @@
cacheModeString = cacheModeString.trim();
boolean noGlobalCache;
+ boolean noGlobalCacheInTx;
if (cacheModeString.equals(CACHE_MODE_FULL)) {
noGlobalCache = false;
+ globalCacheOff = false;
+ noGlobalCacheInTx = false;
getLogger().log("Enabling full caching causing low isolation",
LOG_CHANNEL, Logger.INFO);
} else if (cacheModeString.equals(CACHE_MODE_LOCAL)) {
noGlobalCache = true;
+ globalCacheOff = false;
+ noGlobalCacheInTx = false;
getLogger().log("Disabling global cache to shadow store isolation and
allow for clustering", LOG_CHANNEL, Logger.INFO);
- } else if (cacheModeString.equals(CACHE_MODE_FULL_NO_TX)) {
+ } else if (cacheModeString.equals(CACHE_MODE_NO_GLOBAL_IN_TX)) {
+ globalCacheOff = false;
+ noGlobalCache = false;
+ noGlobalCacheInTx = true;
+ getLogger().log("Disabling global cache inside transactions to shadow
store isolation", LOG_CHANNEL, Logger.INFO);
+ } else if (cacheModeString.equals(CACHE_MODE_OFF)) {
+ globalCacheOff = true;
noGlobalCache = true;
- getLogger().log("Cache mode isolation shadow not yet implemented! Using
cluster mode instead...", LOG_CHANNEL, Logger.WARNING);
+ noGlobalCacheInTx = true;
+ getLogger().log("Disabling cache completely", LOG_CHANNEL, Logger.INFO);
} else {
noGlobalCache = false;
+ globalCacheOff = false;
+ noGlobalCacheInTx = false;
getLogger().log("Unknown cache mode "+cacheModeString+" Using full mode
instead...", LOG_CHANNEL, Logger.WARNING);
}
@@ -321,7 +336,8 @@
contentCacheBytes,
txContentCacheSize,
txContentCacheBytes,
- maxByteSizePerEntry);
+ maxByteSizePerEntry,
+ noGlobalCacheInTx);
}
//
@@ -937,13 +953,14 @@
long contentCacheBytes,
int txContentCacheSize,
long txContentCacheBytes,
- long maxByteSizePerEntry) {
+ long maxByteSizePerEntry,
+ boolean noGlobalCacheInTx) {
try {
- objectsCache = new TxCacheWrapper(globalObjectCacheSize, "object");
- permissionsCache = new TxCacheWrapper(globalPermissionCacheSize,
"permission");
- locksCache = new TxCacheWrapper(globalLockCacheSize, "lock");
- descriptorsCache = new TxCacheWrapper(globalDescrtiptorsCacheSize,
"descriptors");
- descriptorCache = new TxCacheWrapper(globalDescrtiptorCacheSize,
"descriptor");
+ objectsCache = new TxCacheWrapper(globalObjectCacheSize, "object",
noGlobalCacheInTx);
+ permissionsCache = new TxCacheWrapper(globalPermissionCacheSize,
"permission", noGlobalCacheInTx);
+ locksCache = new TxCacheWrapper(globalLockCacheSize, "lock",
noGlobalCacheInTx);
+ descriptorsCache = new TxCacheWrapper(globalDescrtiptorsCacheSize,
"descriptors", noGlobalCacheInTx);
+ descriptorCache = new TxCacheWrapper(globalDescrtiptorCacheSize,
"descriptor", noGlobalCacheInTx);
if (contentCachingEnabled) {
contentCache =
@@ -955,7 +972,8 @@
txContentCacheBytes,
maxByteSizePerEntry,
getName() + ".content",
- getLogger()));
+ getLogger(),
+ noGlobalCacheInTx));
} else {
contentCache = null;
}
@@ -992,8 +1010,8 @@
this.txCache = txCache;
}
- public TxCacheWrapper(int globalCacheSize, String name) {
- this(new TxLRUObjectCache(globalCacheSize, getName() + "." + name,
getLogger()));
+ public TxCacheWrapper(int globalCacheSize, String name, boolean
noGlobalCacheInTx) {
+ this(new TxLRUObjectCache(globalCacheSize, getName() + "." + name,
getLogger(), noGlobalCacheInTx));
}
public Object get(Object key) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]