Author: nfilotto
Date: 2010-09-09 12:41:35 -0400 (Thu, 09 Sep 2010)
New Revision: 3100
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
Log:
EXOJCR-942: Applied the following changes
CacheableLockManagerImpl: we evict the root node instead of stopping the cache in the
method stop() since the cache could be shared
JBossCacheWorkspaceStorageCache: The method getSize() has been reviewed
ExoJBossCacheFactory: Only a part of the default EvictionRegionConfig was used to defined
the EvictionRegionConfig of the new created Region, which caused a memory leak since the
evictionActionPolicyClassName was not set
ParentNodeEvictionActionPolicy: Javadoc updated to indicate that the region id has been
added to the path
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-09-09
13:24:12 UTC (rev 3099)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-09-09
16:41:35 UTC (rev 3100)
@@ -817,8 +817,8 @@
lockRemover.halt();
lockRemover.interrupt();
sessionLockManagers.clear();
-
- PrivilegedCacheHelper.stop(cache);
+ // The cache cannot be stopped since it cans be shared so we evict the root node
instead
+ cache.evict(lockRoot);
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-09
13:24:12 UTC (rev 3099)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-09
16:41:35 UTC (rev 3100)
@@ -132,6 +132,8 @@
protected final Fqn<String> childPropsList;
+ protected final Fqn<String> rootFqn;
+
/**
* Node order comparator for getChildNodes().
*/
@@ -306,7 +308,7 @@
LOG.info("Using BufferedJBossCache compatible with Expiration
algorithm.");
}
- Fqn<String> rootFqn = Fqn.fromElements(wsConfig.getUniqueName());
+ this.rootFqn = Fqn.fromElements(wsConfig.getUniqueName());
parentCache = ExoJBossCacheFactory.getUniqueInstance(CacheType.JCR_CACHE, rootFqn,
parentCache);
// if expiration is used, set appropriate factory with with timeout set via
configuration (or default one 15minutes)
@@ -726,10 +728,26 @@
public long getSize()
{
// Total number of JBC nodes in the cache - the total amount of resident nodes
- return cache.getNumberOfNodes() - 5 * cache.getRoot().getChildrenNames().size();
+ return numNodes(cache.getNode(rootFqn)) - 6;
}
/**
+ * Evaluates the total amount of sub-nodes that the given node contains
+ */
+ private static long numNodes(Node<Serializable, Object> n)
+ {
+ long count = 1;// for n
+ if (n != null)
+ {
+ for (Node<Serializable, Object> child : n.getChildren())
+ {
+ count += numNodes(child);
+ }
+ }
+ return count;
+ }
+
+ /**
* {@inheritDoc}
*/
public boolean isEnabled()
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java 2010-09-09
13:24:12 UTC (rev 3099)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/ParentNodeEvictionActionPolicy.java 2010-09-09
16:41:35 UTC (rev 3100)
@@ -73,8 +73,8 @@
if (parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_NODES)
|| parentFqn.get(1).equals(JBossCacheWorkspaceStorageCache.CHILD_PROPS))
{
- // The expected data structure is of type
$CHILD_NODES/${node-id}/${sub-node-name} or
- // $CHILD_PROPS/${node-id}/${sub-property-name}
+ // The expected data structure is of type
${ws-id}/$CHILD_NODES/${node-id}/${sub-node-name} or
+ // ${ws-id}/$CHILD_PROPS/${node-id}/${sub-property-name}
// We use the method getChildrenNamesDirect to avoid going through
// the intercepter chain (EXOJCR-460)
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-09-09
13:24:12 UTC (rev 3099)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-09-09
16:41:35 UTC (rev 3100)
@@ -221,11 +221,10 @@
EvictionConfig ec = cfg.getEvictionConfig();
// Create the region and set the config
Region region = cache.getRegion(fqn, true);
- if (ec != null && ec.getDefaultEvictionRegionConfig() != null
- && ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() !=
null)
+ if (ec != null && ec.getDefaultEvictionRegionConfig() != null)
{
- EvictionRegionConfig erc =
- new EvictionRegionConfig(fqn,
ec.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig());
+ EvictionRegionConfig erc = new EvictionRegionConfig(fqn);
+ erc.setDefaults(ec.getDefaultEvictionRegionConfig());
region.setEvictionRegionConfig(erc);
}
}