From 4427a22e039f7cbb8f5cb427742559c8bcee17ad Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Fri, 19 Aug 2011 10:10:46 +0000 Subject: [PATCH] ALF-9860: RSOLR 034: Incremental Index Fix - generic fix, supprot to request purge, index and reindex for tx, node, acl-tx and acl (partly to make broken indexes) - expose index fix via JMX - migrate logging in the SOLR project to slf4j to fit the SOLR logging pattern (config to come) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29904 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../Search/common-search-context.xml | 1 + .../search/impl/solr/SolrQueryHTTPClient.java | 5 +- .../AccessControlListProperties.java | 6 ++ .../SimpleAccessControlListProperties.java | 78 ++++++++++++------- .../org/alfresco/repo/solr/AclReaders.java | 15 +++- .../repo/solr/MetaDataResultsFilter.java | 10 ++- .../org/alfresco/repo/solr/NodeMetaData.java | 10 +++ .../repo/solr/SOLRTrackingComponentImpl.java | 17 +++- 8 files changed, 108 insertions(+), 34 deletions(-) diff --git a/config/alfresco/subsystems/Search/common-search-context.xml b/config/alfresco/subsystems/Search/common-search-context.xml index ccc37205c1..438de57e45 100644 --- a/config/alfresco/subsystems/Search/common-search-context.xml +++ b/config/alfresco/subsystems/Search/common-search-context.xml @@ -15,6 +15,7 @@ + ${search.solrTrackingSupport.enabled} diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java index c18eaa987c..1c5b9f6f85 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java @@ -81,7 +81,10 @@ public class SolrQueryHTTPClient { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); httpClient = new HttpClient(connectionManager); - httpClient.getParams().setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true); + HttpClientParams params = httpClient.getParams(); + params.setBooleanParameter("http.tcp.nodelay", true); + params.setBooleanParameter("http.connection.stalecheck", false); + params.setBooleanParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true); httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin")); } diff --git a/source/java/org/alfresco/repo/security/permissions/AccessControlListProperties.java b/source/java/org/alfresco/repo/security/permissions/AccessControlListProperties.java index 98a7aab6b2..8e716645b8 100644 --- a/source/java/org/alfresco/repo/security/permissions/AccessControlListProperties.java +++ b/source/java/org/alfresco/repo/security/permissions/AccessControlListProperties.java @@ -75,4 +75,10 @@ public interface AccessControlListProperties * @return the id */ public Long getId(); + + /** + * Get the acl change set + * @return - the id of the change set + */ + public Long getAclChangeSetId(); } diff --git a/source/java/org/alfresco/repo/security/permissions/SimpleAccessControlListProperties.java b/source/java/org/alfresco/repo/security/permissions/SimpleAccessControlListProperties.java index 8667dc47f3..cccb43d51d 100644 --- a/source/java/org/alfresco/repo/security/permissions/SimpleAccessControlListProperties.java +++ b/source/java/org/alfresco/repo/security/permissions/SimpleAccessControlListProperties.java @@ -22,29 +22,30 @@ package org.alfresco.repo.security.permissions; * Basic implementation of access control list properties * * @author andyh - * */ public class SimpleAccessControlListProperties implements AccessControlListProperties { private Long id; - + private ACLType aclType; - + private Long aclVersion; - + private Boolean inherits; - + private Boolean latest; - + private Boolean versioned; - + private String aclId; - + + private Long aclChangeSetId; + // Default constructor public SimpleAccessControlListProperties() { } - + public SimpleAccessControlListProperties(AccessControlListProperties props) { this.id = props.getId(); @@ -55,102 +56,125 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope this.versioned = props.isVersioned(); this.aclId = props.getAclId(); } - + public String getAclId() { - return aclId; + return aclId; } - + public ACLType getAclType() { - return aclType; + return aclType; } - + public Long getAclVersion() { - return aclVersion; + return aclVersion; } - + public Boolean getInherits() { return inherits; } - + public Boolean isLatest() { return latest; } - + public Boolean isVersioned() { - return versioned; + return versioned; } - + /** * Set the acl id + * * @param aclId */ public void setAclId(String aclId) { this.aclId = aclId; } - + /** * Set the acl type + * * @param aclType */ public void setAclType(ACLType aclType) { this.aclType = aclType; } - + /** * Set the acl version + * * @param aclVersion */ public void setAclVersion(Long aclVersion) { this.aclVersion = aclVersion; } - + /** * Set inheritance + * * @param inherits */ public void setInherits(boolean inherits) { this.inherits = inherits; } - + /** * Set latest + * * @param latest */ public void setLatest(boolean latest) { this.latest = latest; } - + /** * Set versioned + * * @param versioned */ public void setVersioned(boolean versioned) { this.versioned = versioned; } - + public Long getId() { return id; } - + /** * Set the id + * * @param id */ public void setId(Long id) { this.id = id; } + + /* + * (non-Javadoc) + * @see org.alfresco.repo.security.permissions.AccessControlListProperties#getChangeSetId() + */ + @Override + public Long getAclChangeSetId() + { + return aclChangeSetId; + } + + public void setAclChangeSetId(Long aclChangeSetId) + { + this.aclChangeSetId = aclChangeSetId; + } + } diff --git a/source/java/org/alfresco/repo/solr/AclReaders.java b/source/java/org/alfresco/repo/solr/AclReaders.java index 697716d1a5..41bd96c15f 100644 --- a/source/java/org/alfresco/repo/solr/AclReaders.java +++ b/source/java/org/alfresco/repo/solr/AclReaders.java @@ -30,13 +30,13 @@ public class AclReaders { private Long aclId; private Set readers; - + private long aclChangeSetId; + @Override public String toString() { - return "AclReaders [aclId=" + aclId + ", readers=" + readers + "]"; + return "AclReaders [aclId=" + aclId + ", readers=" + readers + ", aclChangeSetId=" + aclChangeSetId + "]"; } - public Long getAclId() { return aclId; @@ -53,4 +53,13 @@ public class AclReaders { this.readers = aclReaders; } + public long getAclChangeSetId() + { + return aclChangeSetId; + } + public void setAclChangeSetId(long aclChangeSetId) + { + this.aclChangeSetId = aclChangeSetId; + } + } diff --git a/source/java/org/alfresco/repo/solr/MetaDataResultsFilter.java b/source/java/org/alfresco/repo/solr/MetaDataResultsFilter.java index 079341ff88..fea4775ebe 100644 --- a/source/java/org/alfresco/repo/solr/MetaDataResultsFilter.java +++ b/source/java/org/alfresco/repo/solr/MetaDataResultsFilter.java @@ -36,6 +36,7 @@ public class MetaDataResultsFilter private boolean includeChildAssociations = true; private boolean includeNodeRef = true; private boolean includeChildIds = true; + private boolean includeTxnId = true; public boolean getIncludeChildAssociations() { @@ -117,5 +118,12 @@ public class MetaDataResultsFilter { this.includeChildIds = includeChildIds; } - + public boolean getIncludeTxnId() + { + return includeTxnId; + } + public void setIncludeTxnId(boolean includeTxnId) + { + this.includeTxnId = includeTxnId; + } } diff --git a/source/java/org/alfresco/repo/solr/NodeMetaData.java b/source/java/org/alfresco/repo/solr/NodeMetaData.java index 4e873f2bef..c9d61017ae 100644 --- a/source/java/org/alfresco/repo/solr/NodeMetaData.java +++ b/source/java/org/alfresco/repo/solr/NodeMetaData.java @@ -49,6 +49,7 @@ public class NodeMetaData private List parentAssocs; private Long parentAssocsCrc; private List childIds; + private Long txnId; public String getOwner() { @@ -147,5 +148,14 @@ public class NodeMetaData public void setChildIds(List childIds) { this.childIds = childIds; + } + public Long getTxnId() + { + return txnId; + } + public void setTxnId(Long txnId) + { + this.txnId = txnId; } + } diff --git a/source/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java b/source/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java index d95de094c5..c6070492d2 100644 --- a/source/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java +++ b/source/java/org/alfresco/repo/solr/SOLRTrackingComponentImpl.java @@ -42,6 +42,7 @@ import org.alfresco.repo.domain.CrcHelper; import org.alfresco.repo.domain.node.Node; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback; +import org.alfresco.repo.domain.permissions.AclDAO; import org.alfresco.repo.domain.qname.QNameDAO; import org.alfresco.repo.domain.solr.SOLRDAO; import org.alfresco.repo.solr.AlfrescoModelDiff.TYPE; @@ -76,6 +77,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent private SOLRDAO solrDAO; private DictionaryDAO dictionaryDAO; private PermissionService permissionService; + private AclDAO aclDAO; private OwnableService ownableService; private TenantService tenantService; private DictionaryService dictionaryService; @@ -128,9 +130,12 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent { this.dictionaryService = dictionaryService; } + + public void setAclDAO(AclDAO aclDAO) + { + this.aclDAO = aclDAO; + } - - public void setDictionaryDAO(DictionaryDAO dictionaryDAO) { this.dictionaryDAO = dictionaryDAO; @@ -149,6 +154,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent PropertyCheck.mandatory(this, "tenantService", tenantService); PropertyCheck.mandatory(this, "dictionaryService", dictionaryService); PropertyCheck.mandatory(this, "dictionaryDAO", dictionaryDAO); + PropertyCheck.mandatory(this, "aclDAO", aclDAO); } @Override @@ -195,6 +201,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent AclReaders readers = new AclReaders(); readers.setAclId(aclId); readers.setReaders(readersSet); + readers.setAclChangeSetId(aclDAO.getAccessControlList(aclId).getProperties().getAclChangeSetId()); aclsReaders.add(readers); } @@ -472,6 +479,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations()); boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner()); boolean includeChildIds = (resultFilter == null ? true : resultFilter.getIncludeChildIds()); + boolean includeTxnId = (resultFilter == null ? true : resultFilter.getIncludeTxnId()); List nodeIds = preCacheNodes(nodeMetaDataParameters); @@ -492,6 +500,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent Pair pair = nodeDAO.getNodePair(nodeId); nodeMetaData.setAclId(nodeDAO.getNodeAclId(nodeId)); + if(includeTxnId) + { + nodeMetaData.setTxnId(nodeDAO.getNodeRefStatus(pair.getSecond()).getDbTxnId()); + } + if(includeType) { QName nodeType = nodeDAO.getNodeType(nodeId);