AVM DAO refactor - fix child entry name pattern match (+ missing test), also orphan reaper max limit

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16145 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-09-08 12:58:46 +00:00
parent efda84932f
commit efb73c6e4c
11 changed files with 1067 additions and 1010 deletions

View File

@@ -164,6 +164,11 @@
<parameter property="localname" jdbcType="VARCHAR" javaType="java.lang.String"/> <parameter property="localname" jdbcType="VARCHAR" javaType="java.lang.String"/>
</parameterMap> </parameterMap>
<parameterMap id="parameter_IdPatternMap" class="map">
<parameter property="id" jdbcType="BIGINT" javaType="java.lang.Long"/>
<parameter property="pattern" jdbcType="VARCHAR" javaType="java.lang.String"/>
</parameterMap>
<!-- --> <!-- -->
<!-- SQL Snippets --> <!-- SQL Snippets -->
@@ -788,6 +793,17 @@
parent_id = ? parent_id = ?
</select> </select>
<!-- Get AVMNodeChildEntries by parent node ID and name pattern -->
<select id="select_AVMNodeChildEntriesByParentAndNamePattern" parameterMap="parameter_IdPatternMap" resultMap="result_AVMChildEntry">
select
*
from
avm_child_entries
where
parent_id = ? and
name like ?
</select>
<!-- Get AVMNodeChildEntries by child node ID --> <!-- Get AVMNodeChildEntries by child node ID -->
<select id="select_AVMNodeChildEntriesByChild" parameterMap="parameter_IdMap" resultMap="result_AVMChildEntry"> <select id="select_AVMNodeChildEntriesByChild" parameterMap="parameter_IdMap" resultMap="result_AVMChildEntry">
select select

View File

@@ -1,14 +1,33 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* 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:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
public class AVMChildNamePatternMatchPerformanceTest extends AVMServiceTestBase public class AVMChildNamePatternMatchPerformanceTest extends AVMServiceTestBase

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2008 Alfresco Software Limited. * Copyright (C) 2005-2009 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -61,6 +61,7 @@ public class AVMTestSuite extends TestSuite
suite.addTestSuite(PurgeTestP.class); suite.addTestSuite(PurgeTestP.class);
suite.addTestSuite(SimultaneousLoadTest.class); suite.addTestSuite(SimultaneousLoadTest.class);
suite.addTestSuite(AVMDiffPerformanceTest.class); suite.addTestSuite(AVMDiffPerformanceTest.class);
suite.addTestSuite(AVMChildNamePatternMatchPerformanceTest.class);
return suite; return suite;
} }

View File

@@ -244,8 +244,7 @@ class AVMNodeDAOIbatis extends HibernateDaoSupport implements AVMNodeDAO
*/ */
public List<AVMNode> getOrphans(int batchSize) public List<AVMNode> getOrphans(int batchSize)
{ {
// TODO - limit to batch size List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodeOrphans(batchSize);
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodeOrphans();
if (nodeEntities == null) if (nodeEntities == null)
{ {

View File

@@ -65,9 +65,7 @@ class ChildEntryDAOIbatis implements ChildEntryDAO
*/ */
public List<ChildEntry> getByParent(DirectoryNode parent, String childNamePattern) public List<ChildEntry> getByParent(DirectoryNode parent, String childNamePattern)
{ {
// TODO - add option for childNamePattern List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByParent(parent.getId(), childNamePattern);
List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByParent(parent.getId());
List<ChildEntry> result = new ArrayList<ChildEntry>(childEntryEntities.size()); List<ChildEntry> result = new ArrayList<ChildEntry>(childEntryEntities.size());
for (AVMChildEntryEntity childEntryEntity : childEntryEntities) for (AVMChildEntryEntity childEntryEntity : childEntryEntities)

View File

@@ -65,7 +65,7 @@ public interface AVMNodeDAO
public List<Long> getLayeredNodesNewInStoreIDs(long storeId); public List<Long> getLayeredNodesNewInStoreIDs(long storeId);
public List<AVMNodeEntity> getNodeOrphans(); public List<AVMNodeEntity> getNodeOrphans(int maxSize);
public void updateNodesClearNewInStore(long storeId); public void updateNodesClearNewInStore(long storeId);

View File

@@ -48,9 +48,9 @@ public interface AVMNodeLinksDAO
public void createChildEntry(long parentNodeId, String name, long childNodeId); public void createChildEntry(long parentNodeId, String name, long childNodeId);
/** /**
* Get all the children of a given parent * Get all the children of a given parent (with optional child name pattern)
*/ */
public List<AVMChildEntryEntity> getChildEntriesByParent(long parentNodeId); public List<AVMChildEntryEntity> getChildEntriesByParent(long parentNodeId, String childNamePattern);
/** /**
* Get all the ChildEntries corresponding to the given child * Get all the ChildEntries corresponding to the given child

View File

@@ -266,9 +266,9 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<AVMNodeEntity> getNodeOrphans() public List<AVMNodeEntity> getNodeOrphans(int maxSize)
{ {
return getNodeEntityOrphans(); return getNodeEntityOrphans(maxSize);
} }
/** /**
@@ -399,7 +399,7 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
protected abstract List<AVMNodeEntity> getNodeEntitiesNewInStore(long storeId); protected abstract List<AVMNodeEntity> getNodeEntitiesNewInStore(long storeId);
protected abstract List<AVMNodeEntity> getLayeredNodeEntitiesNewInStore(long storeId); protected abstract List<AVMNodeEntity> getLayeredNodeEntitiesNewInStore(long storeId);
protected abstract List<Long> getLayeredNodeEntityIdsNewInStore(long storeId); protected abstract List<Long> getLayeredNodeEntityIdsNewInStore(long storeId);
protected abstract List<AVMNodeEntity> getNodeEntityOrphans(); protected abstract List<AVMNodeEntity> getNodeEntityOrphans(int maxSize);
protected abstract List<AVMNodeEntity> getAllLayeredDirectoryNodeEntities(); protected abstract List<AVMNodeEntity> getAllLayeredDirectoryNodeEntities();
protected abstract List<AVMNodeEntity> getAllLayeredFileNodeEntities(); protected abstract List<AVMNodeEntity> getAllLayeredFileNodeEntities();
protected abstract List<Long> getAVMNodeEntityIdsByAclId(long aclId); protected abstract List<Long> getAVMNodeEntityIdsByAclId(long aclId);

View File

@@ -33,6 +33,7 @@ import org.alfresco.repo.cache.lookup.EntityLookupCache;
import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO; import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.alfresco.util.SearchLanguageConversion;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
/** /**
@@ -143,9 +144,20 @@ public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public List<AVMChildEntryEntity> getChildEntriesByParent(long parentNodeId) public List<AVMChildEntryEntity> getChildEntriesByParent(long parentNodeId, String childNamePattern)
{ {
List<AVMChildEntryEntity> result = getChildEntryEntitiesByParent(parentNodeId); List<AVMChildEntryEntity> result = null;
if ((childNamePattern == null) || (childNamePattern.length() == 0))
{
result = getChildEntryEntitiesByParent(parentNodeId);
}
else
{
String pattern = SearchLanguageConversion.convert(SearchLanguageConversion.DEF_LUCENE, SearchLanguageConversion.DEF_SQL_LIKE, childNamePattern);
result = getChildEntryEntitiesByParent(parentNodeId, pattern);
}
if (result == null) if (result == null)
{ {
result = new ArrayList<AVMChildEntryEntity>(0); result = new ArrayList<AVMChildEntryEntity>(0);
@@ -214,7 +226,7 @@ public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO
*/ */
public void deleteChildEntriesByParent(long parentNodeId) public void deleteChildEntriesByParent(long parentNodeId)
{ {
List<AVMChildEntryEntity> ceEntities = getChildEntriesByParent(parentNodeId); List<AVMChildEntryEntity> ceEntities = getChildEntriesByParent(parentNodeId, null);
if (ceEntities.size() == 0) if (ceEntities.size() == 0)
{ {
return; return;
@@ -353,6 +365,7 @@ public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO
} }
protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByParent(long parentNodeId); protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByParent(long parentNodeId);
protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByParent(long parentNodeId, String childNamePattern);
protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId); protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId);
protected abstract AVMChildEntryEntity getChildEntryEntity(long parentNodeId, String name); protected abstract AVMChildEntryEntity getChildEntryEntity(long parentNodeId, String name);

View File

@@ -166,9 +166,9 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List<AVMNodeEntity> getNodeEntityOrphans() protected List<AVMNodeEntity> getNodeEntityOrphans(int maxSize)
{ {
return (List<AVMNodeEntity>) template.queryForList(SELECT_AVM_NODES_ORPHANS); return (List<AVMNodeEntity>) template.queryForList(SELECT_AVM_NODES_ORPHANS, 0, maxSize);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@@ -46,6 +46,7 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl
private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME ="alfresco.avm.select_AVMChildEntryByParentAndName"; // parent + name private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_NAME ="alfresco.avm.select_AVMChildEntryByParentAndName"; // parent + name
private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD ="alfresco.avm.select_AVMChildEntryByParentAndChild"; // parent + child private static final String SELECT_AVM_NODE_CHILD_ENTRY_BY_PARENT_AND_CHILD ="alfresco.avm.select_AVMChildEntryByParentAndChild"; // parent + child
private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT ="alfresco.avm.select_AVMNodeChildEntriesByParent"; // parent private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT ="alfresco.avm.select_AVMNodeChildEntriesByParent"; // parent
private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN ="alfresco.avm.select_AVMNodeChildEntriesByParentAndNamePattern"; // parent + name pattern
private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD ="alfresco.avm.select_AVMNodeChildEntriesByChild"; // child private static final String SELECT_AVM_NODE_CHILD_ENTRIES_BY_CHILD ="alfresco.avm.select_AVMNodeChildEntriesByChild"; // child
private static final String INSERT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.insert_AVMChildEntry"; // parent + name + child private static final String INSERT_AVM_NODE_CHILD_ENTRY ="alfresco.avm.insert_AVMChildEntry"; // parent + name + child
@@ -103,6 +104,16 @@ public class AVMNodeLinksDAOImpl extends AbstractAVMNodeLinksDAOImpl
return (List<AVMChildEntryEntity>) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params); return (List<AVMChildEntryEntity>) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT, params);
} }
@SuppressWarnings("unchecked")
@Override
protected List<AVMChildEntryEntity> getChildEntryEntitiesByParent(long parentNodeId, String childNamePattern)
{
Map<String, Object> params = new HashMap<String, Object>(1);
params.put("id", parentNodeId);
params.put("pattern", childNamePattern);
return (List<AVMChildEntryEntity>) template.queryForList(SELECT_AVM_NODE_CHILD_ENTRIES_BY_PARENT_AND_NAME_PATTERN, params);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId) protected List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId)