mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -164,6 +164,11 @@
|
||||
<parameter property="localname" jdbcType="VARCHAR" javaType="java.lang.String"/>
|
||||
</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 -->
|
||||
@@ -788,6 +793,17 @@
|
||||
parent_id = ?
|
||||
</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 -->
|
||||
<select id="select_AVMNodeChildEntriesByChild" parameterMap="parameter_IdMap" resultMap="result_AVMChildEntry">
|
||||
select
|
||||
|
@@ -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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
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;
|
||||
|
||||
public class AVMChildNamePatternMatchPerformanceTest extends AVMServiceTestBase
|
||||
|
@@ -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
|
||||
* 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(SimultaneousLoadTest.class);
|
||||
suite.addTestSuite(AVMDiffPerformanceTest.class);
|
||||
suite.addTestSuite(AVMChildNamePatternMatchPerformanceTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
@@ -244,8 +244,7 @@ class AVMNodeDAOIbatis extends HibernateDaoSupport implements AVMNodeDAO
|
||||
*/
|
||||
public List<AVMNode> getOrphans(int batchSize)
|
||||
{
|
||||
// TODO - limit to batch size
|
||||
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodeOrphans();
|
||||
List<AVMNodeEntity> nodeEntities = AVMDAOs.Instance().newAVMNodeDAO.getNodeOrphans(batchSize);
|
||||
|
||||
if (nodeEntities == null)
|
||||
{
|
||||
|
@@ -65,9 +65,7 @@ class ChildEntryDAOIbatis implements ChildEntryDAO
|
||||
*/
|
||||
public List<ChildEntry> getByParent(DirectoryNode parent, String childNamePattern)
|
||||
{
|
||||
// TODO - add option for childNamePattern
|
||||
|
||||
List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByParent(parent.getId());
|
||||
List<AVMChildEntryEntity> childEntryEntities = AVMDAOs.Instance().newAVMNodeLinksDAO.getChildEntriesByParent(parent.getId(), childNamePattern);
|
||||
|
||||
List<ChildEntry> result = new ArrayList<ChildEntry>(childEntryEntities.size());
|
||||
for (AVMChildEntryEntity childEntryEntity : childEntryEntities)
|
||||
|
@@ -65,7 +65,7 @@ public interface AVMNodeDAO
|
||||
|
||||
public List<Long> getLayeredNodesNewInStoreIDs(long storeId);
|
||||
|
||||
public List<AVMNodeEntity> getNodeOrphans();
|
||||
public List<AVMNodeEntity> getNodeOrphans(int maxSize);
|
||||
|
||||
public void updateNodesClearNewInStore(long storeId);
|
||||
|
||||
|
@@ -48,9 +48,9 @@ public interface AVMNodeLinksDAO
|
||||
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
|
||||
|
@@ -266,9 +266,9 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
|
||||
/**
|
||||
* {@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> getLayeredNodeEntitiesNewInStore(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> getAllLayeredFileNodeEntities();
|
||||
protected abstract List<Long> getAVMNodeEntityIdsByAclId(long aclId);
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.repo.cache.lookup.EntityLookupCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAO;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.SearchLanguageConversion;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
@@ -143,9 +144,20 @@ public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO
|
||||
/**
|
||||
* {@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)
|
||||
{
|
||||
result = new ArrayList<AVMChildEntryEntity>(0);
|
||||
@@ -214,7 +226,7 @@ public abstract class AbstractAVMNodeLinksDAOImpl implements AVMNodeLinksDAO
|
||||
*/
|
||||
public void deleteChildEntriesByParent(long parentNodeId)
|
||||
{
|
||||
List<AVMChildEntryEntity> ceEntities = getChildEntriesByParent(parentNodeId);
|
||||
List<AVMChildEntryEntity> ceEntities = getChildEntriesByParent(parentNodeId, null);
|
||||
if (ceEntities.size() == 0)
|
||||
{
|
||||
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, String childNamePattern);
|
||||
protected abstract List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId);
|
||||
|
||||
protected abstract AVMChildEntryEntity getChildEntryEntity(long parentNodeId, String name);
|
||||
|
@@ -166,9 +166,9 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@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")
|
||||
|
@@ -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_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_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 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);
|
||||
}
|
||||
|
||||
@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")
|
||||
@Override
|
||||
protected List<AVMChildEntryEntity> getChildEntryEntitiesByChild(long childNodeId)
|
||||
|
Reference in New Issue
Block a user