mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Various changes to keep Hibernate session caches from growing without bound.
Deleting AVM locks is considerably faster which makes large submits faster. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6935 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
@@ -41,13 +41,13 @@ public interface AttributeDAO
|
||||
* @param attr The attribute to save.
|
||||
*/
|
||||
public void save(Attribute attr);
|
||||
|
||||
|
||||
/**
|
||||
* Delete an attribute (recursively).
|
||||
* @param attr The attribute to delete.
|
||||
*/
|
||||
public void delete(Attribute attr);
|
||||
|
||||
|
||||
/**
|
||||
* Find all attributes that match a given path and AttrQuery.
|
||||
* @param map The map within which to query.
|
||||
@@ -55,11 +55,17 @@ public interface AttributeDAO
|
||||
* @return A List of key, attribute value pairs.
|
||||
*/
|
||||
public List<Pair<String,Attribute>> find(MapAttribute map, AttrQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* Delete entries from a map that match the given query.
|
||||
* @param map
|
||||
* @param query
|
||||
*/
|
||||
public void delete(MapAttribute map, AttrQuery query);
|
||||
|
||||
/**
|
||||
* Evict an Attribute from the session cache.
|
||||
* @param attr
|
||||
*/
|
||||
public void evict(Attribute attr);
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
@@ -44,30 +44,30 @@ import org.alfresco.util.Pair;
|
||||
public class AttributeServiceImpl implements AttributeService
|
||||
{
|
||||
private GlobalAttributeEntryDAO fGlobalAttributeEntryDAO;
|
||||
|
||||
|
||||
private AttributeDAO fAttributeDAO;
|
||||
|
||||
|
||||
private AttributeConverter fAttributeConverter;
|
||||
|
||||
|
||||
public AttributeServiceImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void setGlobalAttributeEntryDao(GlobalAttributeEntryDAO dao)
|
||||
{
|
||||
fGlobalAttributeEntryDAO = dao;
|
||||
}
|
||||
|
||||
|
||||
public void setAttributeDao(AttributeDAO dao)
|
||||
{
|
||||
fAttributeDAO = dao;
|
||||
}
|
||||
|
||||
|
||||
public void setAttributeConverter(AttributeConverter converter)
|
||||
{
|
||||
fAttributeConverter = converter;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.attributes.AttributeService#getAttribute(java.lang.String)
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ public class AttributeServiceImpl implements AttributeService
|
||||
int off = 0;
|
||||
while (off < path.length())
|
||||
{
|
||||
while (off < path.length() && path.charAt(off) == '/')
|
||||
while (off < path.length() && path.charAt(off) == '/')
|
||||
{
|
||||
off++;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class AttributeServiceImpl implements AttributeService
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.attributes.AttributeService#query(java.lang.String, org.alfresco.service.cmr.attributes.AttrQuery)
|
||||
*/
|
||||
@@ -192,7 +192,9 @@ public class AttributeServiceImpl implements AttributeService
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return fAttributeConverter.toValue(found);
|
||||
Attribute converted = fAttributeConverter.toValue(found);
|
||||
fAttributeDAO.evict(found);
|
||||
return converted;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -251,7 +253,9 @@ public class AttributeServiceImpl implements AttributeService
|
||||
{
|
||||
throw new AVMWrongTypeException("Not a Map: " + keys);
|
||||
}
|
||||
found.put(name, fAttributeConverter.toPersistent(value));
|
||||
Attribute converted = fAttributeConverter.toPersistent(value);
|
||||
found.put(name, converted);
|
||||
fAttributeDAO.evict(converted);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -278,11 +282,11 @@ public class AttributeServiceImpl implements AttributeService
|
||||
}
|
||||
List<Pair<String, Attribute>> rawResult =
|
||||
fAttributeDAO.find((MapAttribute)found, query);
|
||||
List<Pair<String, Attribute>> result =
|
||||
List<Pair<String, Attribute>> result =
|
||||
new ArrayList<Pair<String, Attribute>>();
|
||||
for (Pair<String, Attribute> raw : rawResult)
|
||||
{
|
||||
result.add(new Pair<String, Attribute>(raw.getFirst(),
|
||||
result.add(new Pair<String, Attribute>(raw.getFirst(),
|
||||
fAttributeConverter.toValue(raw.getSecond())));
|
||||
}
|
||||
return result;
|
||||
@@ -313,7 +317,7 @@ public class AttributeServiceImpl implements AttributeService
|
||||
}
|
||||
found.remove(name);
|
||||
}
|
||||
|
||||
|
||||
private Attribute getAttributeFromPath(List<String> keys)
|
||||
{
|
||||
GlobalAttributeEntry entry = fGlobalAttributeEntryDAO.get(keys.get(0));
|
||||
@@ -480,7 +484,9 @@ public class AttributeServiceImpl implements AttributeService
|
||||
{
|
||||
throw new AVMWrongTypeException("Attribute Not List: " + keys);
|
||||
}
|
||||
Attribute converted = fAttributeConverter.toPersistent(value);
|
||||
found.set(index, fAttributeConverter.toPersistent(value));
|
||||
fAttributeDAO.evict(converted);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -15,11 +15,11 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
|
||||
@@ -43,6 +43,8 @@ import org.alfresco.repo.attributes.Attribute.Type;
|
||||
import org.alfresco.service.cmr.attributes.AttrQuery;
|
||||
import org.alfresco.service.cmr.attributes.AttrQueryHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
@@ -53,24 +55,26 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
AttributeDAO
|
||||
{
|
||||
private static Log fgLogger = LogFactory.getLog(AttributeDAOHibernate.class);
|
||||
|
||||
private MapEntryDAO fMapEntryDAO;
|
||||
|
||||
|
||||
private ListEntryDAO fListEntryDAO;
|
||||
|
||||
|
||||
public AttributeDAOHibernate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void setMapEntryDao(MapEntryDAO dao)
|
||||
{
|
||||
fMapEntryDAO = dao;
|
||||
}
|
||||
|
||||
|
||||
public void setListEntryDao(ListEntryDAO dao)
|
||||
{
|
||||
fListEntryDAO = dao;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeDAO#delete(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
@@ -83,6 +87,7 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
for (MapEntry entry : mapEntries)
|
||||
{
|
||||
Attribute subAttr = entry.getAttribute();
|
||||
getSession().evict(entry);
|
||||
fMapEntryDAO.delete(entry);
|
||||
delete(subAttr);
|
||||
}
|
||||
@@ -94,10 +99,16 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
for (ListEntry entry : listEntries)
|
||||
{
|
||||
Attribute subAttr = entry.getAttribute();
|
||||
getSession().evict(entry);
|
||||
fListEntryDAO.delete(entry);
|
||||
delete(subAttr);
|
||||
}
|
||||
}
|
||||
if (fgLogger.isDebugEnabled())
|
||||
{
|
||||
fgLogger.debug("Entities: " + getSession().getStatistics().getEntityCount());
|
||||
}
|
||||
getSession().evict(attr);
|
||||
getSession().delete(attr);
|
||||
}
|
||||
|
||||
@@ -144,4 +155,26 @@ public class AttributeDAOHibernate extends HibernateDaoSupport implements
|
||||
{
|
||||
getSession().save(attr);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.attributes.AttributeDAO#evict(org.alfresco.repo.attributes.Attribute)
|
||||
*/
|
||||
public void evict(Attribute attr)
|
||||
{
|
||||
if (attr.getType() == Attribute.Type.MAP)
|
||||
{
|
||||
for (Attribute child : attr.values())
|
||||
{
|
||||
evict(child);
|
||||
}
|
||||
}
|
||||
if (attr.getType() == Attribute.Type.LIST)
|
||||
{
|
||||
for (Attribute child : attr)
|
||||
{
|
||||
evict(child);
|
||||
}
|
||||
}
|
||||
getSession().evict(attr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user