Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

98317: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      98235: MNT-13497: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2)
         97915: MNT-13204: Long reindex times with nodes with Multiple Parents
            - Implement search.solrTrackingSupport.ignorePathsForSpecificAspects option to skip paths calculation for nodes with the defined aspects


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@98431 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tatyana Valkevych
2015-03-03 11:45:59 +00:00
parent 28eca9cea1
commit c753d6dee3
6 changed files with 152 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
search.solrTrackingSupport.enabled=true search.solrTrackingSupport.enabled=true
search.solrTrackingSupport.ignorePathsForSpecificTypes=false search.solrTrackingSupport.ignorePathsForSpecificTypes=false
search.solrTrackingSupport.ignorePathsForSpecificAspects=false
solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE
solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE

View File

@@ -29,6 +29,12 @@
<value>{http://www.alfresco.org/model/application/1.0}configurations</value> <value>{http://www.alfresco.org/model/application/1.0}configurations</value>
</list> </list>
</property> </property>
<property name="ignorePathsForSpecificAspects">
<value>${search.solrTrackingSupport.ignorePathsForSpecificAspects}</value>
</property>
<property name="aspectsForIgnoringPaths">
<list></list>
</property>
</bean> </bean>
<!-- Query Register Component --> <!-- Query Register Component -->

View File

@@ -1,5 +1,6 @@
search.solrTrackingSupport.enabled=true search.solrTrackingSupport.enabled=true
search.solrTrackingSupport.ignorePathsForSpecificTypes=false search.solrTrackingSupport.ignorePathsForSpecificTypes=false
search.solrTrackingSupport.ignorePathsForSpecificAspects=false
solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE
solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE

View File

@@ -1,5 +1,6 @@
search.solrTrackingSupport.enabled=true search.solrTrackingSupport.enabled=true
search.solrTrackingSupport.ignorePathsForSpecificTypes=false search.solrTrackingSupport.ignorePathsForSpecificTypes=false
search.solrTrackingSupport.ignorePathsForSpecificAspects=false
solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE
solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE

View File

@@ -1,5 +1,6 @@
search.solrTrackingSupport.enabled=true search.solrTrackingSupport.enabled=true
search.solrTrackingSupport.ignorePathsForSpecificTypes=false search.solrTrackingSupport.ignorePathsForSpecificTypes=false
search.solrTrackingSupport.ignorePathsForSpecificAspects=false
solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.fts.queryConsistency=TRANSACTIONAL_IF_POSSIBLE
solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE solr.query.cmis.queryConsistency=TRANSACTIONAL_IF_POSSIBLE

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2014 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -85,8 +85,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
private boolean enabled = true; private boolean enabled = true;
private boolean cacheAncestors =true; private boolean cacheAncestors =true;
private boolean ignorePathsForSpecificTypes = false; private boolean ignorePathsForSpecificTypes = false;
private boolean ignorePathsForSpecificAspects = false;
private Set<QName> typesForIgnoringPaths = new HashSet<QName>(); private Set<QName> typesForIgnoringPaths = new HashSet<QName>();
private Set<QName> aspectsForIgnoringPaths = new HashSet<QName>();
private List<String> typesForIgnoringPathsString; private List<String> typesForIgnoringPathsString;
private List<String> aspectsForIgnoringPathsString;
@Override @Override
@@ -106,16 +109,31 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
return ignorePathsForSpecificTypes; return ignorePathsForSpecificTypes;
} }
public boolean isIgnorePathsForSpecificAspects()
{
return ignorePathsForSpecificAspects;
}
public void setIgnorePathsForSpecificTypes(boolean ignorePersonAndConfigurationPaths) public void setIgnorePathsForSpecificTypes(boolean ignorePersonAndConfigurationPaths)
{ {
this.ignorePathsForSpecificTypes = ignorePersonAndConfigurationPaths; this.ignorePathsForSpecificTypes = ignorePersonAndConfigurationPaths;
} }
public void setIgnorePathsForSpecificAspects(boolean ignorePathsForSpecificAspects)
{
this.ignorePathsForSpecificAspects = ignorePathsForSpecificAspects;
}
public void setTypesForIgnoringPaths(List<String> typesForIgnoringPaths) public void setTypesForIgnoringPaths(List<String> typesForIgnoringPaths)
{ {
typesForIgnoringPathsString = typesForIgnoringPaths; typesForIgnoringPathsString = typesForIgnoringPaths;
} }
public void setAspectsForIgnoringPaths(List<String> aspectsForIgnoringPaths)
{
this.aspectsForIgnoringPathsString = aspectsForIgnoringPaths;
}
/** /**
* @param cacheAncestors the cacheAncestors to set * @param cacheAncestors the cacheAncestors to set
*/ */
@@ -174,6 +192,36 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
this.dictionaryDAO = dictionaryDAO; this.dictionaryDAO = dictionaryDAO;
} }
private interface DefinitionExistChecker
{
boolean isDefinitionExists(QName qName);
}
private void initIgnoringPathsByCriterion(List<String> initDataInString, Set<QName> dataForIgnoringPaths, DefinitionExistChecker dec)
{
if (null != initDataInString)
{
for (String qNameInString : initDataInString)
{
if ((null != qNameInString) && !qNameInString.isEmpty())
{
try
{
QName qname = QName.resolveToQName(namespaceService, qNameInString);
if (dec.isDefinitionExists(qname))
{
dataForIgnoringPaths.add(qname);
}
}
catch (InvalidQNameException e)
{
// Just ignore
}
}
}
}
}
/** /**
* Initialize * Initialize
*/ */
@@ -188,29 +236,24 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
PropertyCheck.mandatory(this, "dictionaryDAO", dictionaryDAO); PropertyCheck.mandatory(this, "dictionaryDAO", dictionaryDAO);
PropertyCheck.mandatory(this, "aclDAO", aclDAO); PropertyCheck.mandatory(this, "aclDAO", aclDAO);
PropertyCheck.mandatory(this, "namespaceService", namespaceService);
if ((null != typesForIgnoringPathsString) && (null != namespaceService)) initIgnoringPathsByCriterion(typesForIgnoringPathsString, typesForIgnoringPaths, new DefinitionExistChecker()
{ {
for (String typeQName : typesForIgnoringPathsString) @Override
public boolean isDefinitionExists(QName qName)
{ {
if ((null != typeQName) && !typeQName.isEmpty()) return (null != dictionaryService.getType(qName));
{
try
{
QName type = QName.resolveToQName(namespaceService, typeQName);
if (null != dictionaryService.getType(type))
{
this.typesForIgnoringPaths.add(type);
}
}
catch (InvalidQNameException e)
{
// Just ignore
}
}
} }
} });
initIgnoringPathsByCriterion(aspectsForIgnoringPathsString, aspectsForIgnoringPaths, new DefinitionExistChecker()
{
@Override
public boolean isDefinitionExists(QName qName)
{
return (null != dictionaryService.getAspect(qName));
}
});
} }
@Override @Override
@@ -766,22 +809,15 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
if(includeAspects || includePaths || includeParentAssociations) if(includeAspects || includePaths || includeParentAssociations)
{ {
aspects = new HashSet<QName>(); aspects = getNodeAspects(nodeId);
Set<QName> sourceAspects = nodeDAO.getNodeAspects(nodeId);
for(QName aspectQName : sourceAspects)
{
AspectDefinition aspect = dictionaryService.getAspect(aspectQName);
if(aspect != null)
{
aspects.add(aspectQName);
}
}
} }
nodeMetaData.setAspects(aspects); nodeMetaData.setAspects(aspects);
boolean ignoreLargeMetadata = ignorePathsForSpecificTypes && shouldTypeBeIgnored(getNodeType(nodeId)); boolean ignoreLargeMetadata = (ignorePathsForSpecificTypes && shouldBeIgnoredByType(getNodeType(nodeId))) ||
if (!ignoreLargeMetadata && ignorePathsForSpecificTypes) (ignorePathsForSpecificAspects && shouldBeIgnoredByAspect(nodeId, aspects));
if (!ignoreLargeMetadata && (ignorePathsForSpecificTypes || ignorePathsForSpecificAspects))
{ {
// check if parent should be ignored
final List<Long> parentIds = new LinkedList<Long>(); final List<Long> parentIds = new LinkedList<Long>();
nodeDAO.getParentAssocs(nodeId, null, null, true, new ChildAssocRefQueryCallback() nodeDAO.getParentAssocs(nodeId, null, null, true, new ChildAssocRefQueryCallback()
{ {
@@ -810,8 +846,19 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
} }
}); });
QName parentType = (!parentIds.isEmpty()) ? (getNodeType(parentIds.iterator().next())) : (null); if (!parentIds.isEmpty())
ignoreLargeMetadata = shouldTypeBeIgnored(parentType); {
Long parentId = parentIds.iterator().next();
if (ignorePathsForSpecificTypes)
{
QName parentType = getNodeType(parentId);
ignoreLargeMetadata = shouldBeIgnoredByType(parentType);
}
if (!ignoreLargeMetadata && ignorePathsForSpecificAspects)
{
ignoreLargeMetadata = shouldBeIgnoredByAspect(parentId);
}
}
} }
CategoryPaths categoryPaths = new CategoryPaths(new ArrayList<Pair<Path, QName>>(), new ArrayList<ChildAssociationRef>()); CategoryPaths categoryPaths = new CategoryPaths(new ArrayList<Pair<Path, QName>>(), new ArrayList<ChildAssociationRef>());
@@ -919,7 +966,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
if (ignorePathsForSpecificTypes) if (ignorePathsForSpecificTypes)
{ {
QName nodeType = nodeDAO.getNodeType(childNodePair.getFirst()); QName nodeType = nodeDAO.getNodeType(childNodePair.getFirst());
addCurrentChildAssoc = !shouldTypeBeIgnored(nodeType); addCurrentChildAssoc = !shouldBeIgnoredByType(nodeType);
}
if (!addCurrentChildAssoc && ignorePathsForSpecificAspects)
{
addCurrentChildAssoc = !shouldBeIgnoredByAspect(childNodePair.getFirst());
} }
if (addCurrentChildAssoc) if (addCurrentChildAssoc)
{ {
@@ -961,7 +1012,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
if (ignorePathsForSpecificTypes) if (ignorePathsForSpecificTypes)
{ {
QName nodeType = nodeDAO.getNodeType(childNodePair.getFirst()); QName nodeType = nodeDAO.getNodeType(childNodePair.getFirst());
addCurrentId = !shouldTypeBeIgnored(nodeType); addCurrentId = !shouldBeIgnoredByType(nodeType);
}
if (!addCurrentId)
{
addCurrentId = !shouldBeIgnoredByAspect(childNodePair.getFirst());
} }
if (addCurrentId) if (addCurrentId)
{ {
@@ -1051,7 +1106,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
return (null == type) ? (null) : (result); return (null == type) ? (null) : (result);
} }
private boolean shouldTypeBeIgnored(QName nodeType) private boolean shouldBeIgnoredByType(QName nodeType)
{ {
if (null != nodeType) if (null != nodeType)
{ {
@@ -1072,6 +1127,56 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
return false; return false;
} }
private Set<QName> getNodeAspects(Long nodeId)
{
Set<QName> aspects = new HashSet<QName>();
Set<QName> sourceAspects = nodeDAO.getNodeAspects(nodeId);
for(QName aspectQName : sourceAspects)
{
AspectDefinition aspect = dictionaryService.getAspect(aspectQName);
if(aspect != null)
{
aspects.add(aspectQName);
}
}
return aspects;
}
private boolean shouldBeIgnoredByAspect(Long nodeId)
{
return shouldBeIgnoredByAspect(nodeId, null);
}
private boolean shouldBeIgnoredByAspect(Long nodeId, Set<QName> aspects)
{
if (null == nodeId)
{
return false;
}
aspects = (aspects != null) ? aspects : getNodeAspects(nodeId);
if (!aspects.isEmpty())
{
for (QName aspectForIgnoringPaths : aspectsForIgnoringPaths)
{
if (aspects.contains(aspectForIgnoringPaths))
{
return true;
}
for (QName nodeAspect : aspects)
{
if (dictionaryService.isSubClass(nodeAspect, aspectForIgnoringPaths))
{
return true;
}
}
}
}
return false;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */