mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.1 to HEAD
6944: More hibernate session cache taming. 6945: Times for commits are close to linear in the number of items submitted. 6946: Missing break statement. (Courtesy of Jan). 6948: Fixed session cache eviction problem triggered by resetLayer(). 6956: Wrapped AVMService and AttributeService in TransactionResourceInterceptor. Reverted log4j.properties git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7368 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -57,6 +57,7 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
||||
public void save(AVMNode node)
|
||||
{
|
||||
getSession().save(node);
|
||||
SessionCacheChecker.instance.check();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,6 +67,7 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
||||
public void delete(AVMNode node)
|
||||
{
|
||||
getSession().delete(node);
|
||||
SessionCacheChecker.instance.check();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +76,7 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
||||
*/
|
||||
public AVMNode getByID(long id)
|
||||
{
|
||||
SessionCacheChecker.instance.check();
|
||||
return AVMNodeUnwrapper.Unwrap((AVMNode)getSession().get(AVMNodeImpl.class, id));
|
||||
}
|
||||
|
||||
@@ -215,6 +218,5 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements
|
||||
*/
|
||||
public void evict(AVMNode node)
|
||||
{
|
||||
getSession().evict(node);
|
||||
}
|
||||
}
|
||||
|
@@ -66,6 +66,7 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
*/
|
||||
public ChildEntry get(ChildKey key)
|
||||
{
|
||||
SessionCacheChecker.instance.check();
|
||||
return (ChildEntry)getSession().get(ChildEntryImpl.class, key);
|
||||
}
|
||||
|
||||
@@ -96,6 +97,7 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
"and ce.child = :child");
|
||||
query.setEntity("parent", parent);
|
||||
query.setEntity("child", child);
|
||||
SessionCacheChecker.instance.check();
|
||||
return (ChildEntry)query.uniqueResult();
|
||||
}
|
||||
|
||||
@@ -148,6 +150,5 @@ class ChildEntryDAOHibernate extends HibernateDaoSupport implements
|
||||
*/
|
||||
public void evict(ChildEntry entry)
|
||||
{
|
||||
getSession().evict(entry);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.alfresco.repo.avm.hibernate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.engine.EntityKey;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
/**
|
||||
* @author britt
|
||||
*/
|
||||
public class SessionCacheChecker extends HibernateDaoSupport
|
||||
{
|
||||
public static SessionCacheChecker instance = null;
|
||||
|
||||
private static Log fgLogger = LogFactory.getLog(SessionCacheChecker.class);
|
||||
|
||||
private int fCount = 0;
|
||||
|
||||
public SessionCacheChecker()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void check()
|
||||
{
|
||||
if (!fgLogger.isDebugEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fCount % 1000 == 0)
|
||||
{
|
||||
Map<String, Integer> types = new HashMap<String, Integer>();
|
||||
Set<EntityKey> keys = (Set<EntityKey>)getSession().getStatistics().getEntityKeys();
|
||||
if (keys.size() > 200)
|
||||
{
|
||||
for (EntityKey key : keys)
|
||||
{
|
||||
String name = key.getEntityName();
|
||||
if (!types.containsKey(name))
|
||||
{
|
||||
types.put(name, 0);
|
||||
}
|
||||
types.put(name, types.get(name) + 1);
|
||||
}
|
||||
fgLogger.debug(types);
|
||||
// for (Object it : Thread.currentThread().getStackTrace())
|
||||
// {
|
||||
// fgLogger.debug(it);
|
||||
// }
|
||||
// fCount = 0;
|
||||
}
|
||||
}
|
||||
fCount++;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user