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
This commit is contained in:
Andrew Hind
2011-08-19 10:10:46 +00:00
parent d093b6a8e4
commit 4427a22e03
8 changed files with 108 additions and 34 deletions

View File

@@ -15,6 +15,7 @@
<property name="qnameDAO" ref="qnameDAO"/> <property name="qnameDAO" ref="qnameDAO"/>
<property name="solrDAO" ref="solrDAO" /> <property name="solrDAO" ref="solrDAO" />
<property name="dictionaryDAO" ref="dictionaryDAO" /> <property name="dictionaryDAO" ref="dictionaryDAO" />
<property name="aclDAO" ref="aclDAO" />
<property name="enabled"> <property name="enabled">
<value>${search.solrTrackingSupport.enabled}</value> <value>${search.solrTrackingSupport.enabled}</value>
</property> </property>

View File

@@ -81,7 +81,10 @@ public class SolrQueryHTTPClient
{ {
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
httpClient = new HttpClient(connectionManager); 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")); httpClient.getState().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials("admin", "admin"));
} }

View File

@@ -75,4 +75,10 @@ public interface AccessControlListProperties
* @return the id * @return the id
*/ */
public Long getId(); public Long getId();
/**
* Get the acl change set
* @return - the id of the change set
*/
public Long getAclChangeSetId();
} }

View File

@@ -22,7 +22,6 @@ package org.alfresco.repo.security.permissions;
* Basic implementation of access control list properties * Basic implementation of access control list properties
* *
* @author andyh * @author andyh
*
*/ */
public class SimpleAccessControlListProperties implements AccessControlListProperties public class SimpleAccessControlListProperties implements AccessControlListProperties
{ {
@@ -40,6 +39,8 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
private String aclId; private String aclId;
private Long aclChangeSetId;
// Default constructor // Default constructor
public SimpleAccessControlListProperties() public SimpleAccessControlListProperties()
{ {
@@ -88,6 +89,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set the acl id * Set the acl id
*
* @param aclId * @param aclId
*/ */
public void setAclId(String aclId) public void setAclId(String aclId)
@@ -97,6 +99,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set the acl type * Set the acl type
*
* @param aclType * @param aclType
*/ */
public void setAclType(ACLType aclType) public void setAclType(ACLType aclType)
@@ -106,6 +109,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set the acl version * Set the acl version
*
* @param aclVersion * @param aclVersion
*/ */
public void setAclVersion(Long aclVersion) public void setAclVersion(Long aclVersion)
@@ -115,6 +119,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set inheritance * Set inheritance
*
* @param inherits * @param inherits
*/ */
public void setInherits(boolean inherits) public void setInherits(boolean inherits)
@@ -124,6 +129,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set latest * Set latest
*
* @param latest * @param latest
*/ */
public void setLatest(boolean latest) public void setLatest(boolean latest)
@@ -133,6 +139,7 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set versioned * Set versioned
*
* @param versioned * @param versioned
*/ */
public void setVersioned(boolean versioned) public void setVersioned(boolean versioned)
@@ -147,10 +154,27 @@ public class SimpleAccessControlListProperties implements AccessControlListPrope
/** /**
* Set the id * Set the id
*
* @param id * @param id
*/ */
public void setId(Long id) public void setId(Long id)
{ {
this.id = 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;
}
} }

View File

@@ -30,13 +30,13 @@ public class AclReaders
{ {
private Long aclId; private Long aclId;
private Set<String> readers; private Set<String> readers;
private long aclChangeSetId;
@Override @Override
public String toString() public String toString()
{ {
return "AclReaders [aclId=" + aclId + ", readers=" + readers + "]"; return "AclReaders [aclId=" + aclId + ", readers=" + readers + ", aclChangeSetId=" + aclChangeSetId + "]";
} }
public Long getAclId() public Long getAclId()
{ {
return aclId; return aclId;
@@ -53,4 +53,13 @@ public class AclReaders
{ {
this.readers = aclReaders; this.readers = aclReaders;
} }
public long getAclChangeSetId()
{
return aclChangeSetId;
}
public void setAclChangeSetId(long aclChangeSetId)
{
this.aclChangeSetId = aclChangeSetId;
}
} }

View File

@@ -36,6 +36,7 @@ public class MetaDataResultsFilter
private boolean includeChildAssociations = true; private boolean includeChildAssociations = true;
private boolean includeNodeRef = true; private boolean includeNodeRef = true;
private boolean includeChildIds = true; private boolean includeChildIds = true;
private boolean includeTxnId = true;
public boolean getIncludeChildAssociations() public boolean getIncludeChildAssociations()
{ {
@@ -117,5 +118,12 @@ public class MetaDataResultsFilter
{ {
this.includeChildIds = includeChildIds; this.includeChildIds = includeChildIds;
} }
public boolean getIncludeTxnId()
{
return includeTxnId;
}
public void setIncludeTxnId(boolean includeTxnId)
{
this.includeTxnId = includeTxnId;
}
} }

View File

@@ -49,6 +49,7 @@ public class NodeMetaData
private List<ChildAssociationRef> parentAssocs; private List<ChildAssociationRef> parentAssocs;
private Long parentAssocsCrc; private Long parentAssocsCrc;
private List<Long> childIds; private List<Long> childIds;
private Long txnId;
public String getOwner() public String getOwner()
{ {
@@ -148,4 +149,13 @@ public class NodeMetaData
{ {
this.childIds = childIds; this.childIds = childIds;
} }
public Long getTxnId()
{
return txnId;
}
public void setTxnId(Long txnId)
{
this.txnId = txnId;
}
} }

View File

@@ -42,6 +42,7 @@ import org.alfresco.repo.domain.CrcHelper;
import org.alfresco.repo.domain.node.Node; import org.alfresco.repo.domain.node.Node;
import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback; 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.qname.QNameDAO;
import org.alfresco.repo.domain.solr.SOLRDAO; import org.alfresco.repo.domain.solr.SOLRDAO;
import org.alfresco.repo.solr.AlfrescoModelDiff.TYPE; import org.alfresco.repo.solr.AlfrescoModelDiff.TYPE;
@@ -76,6 +77,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
private SOLRDAO solrDAO; private SOLRDAO solrDAO;
private DictionaryDAO dictionaryDAO; private DictionaryDAO dictionaryDAO;
private PermissionService permissionService; private PermissionService permissionService;
private AclDAO aclDAO;
private OwnableService ownableService; private OwnableService ownableService;
private TenantService tenantService; private TenantService tenantService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
@@ -129,7 +131,10 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
} }
public void setAclDAO(AclDAO aclDAO)
{
this.aclDAO = aclDAO;
}
public void setDictionaryDAO(DictionaryDAO dictionaryDAO) public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
{ {
@@ -149,6 +154,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
PropertyCheck.mandatory(this, "tenantService", tenantService); PropertyCheck.mandatory(this, "tenantService", tenantService);
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);
} }
@Override @Override
@@ -195,6 +201,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
AclReaders readers = new AclReaders(); AclReaders readers = new AclReaders();
readers.setAclId(aclId); readers.setAclId(aclId);
readers.setReaders(readersSet); readers.setReaders(readersSet);
readers.setAclChangeSetId(aclDAO.getAccessControlList(aclId).getProperties().getAclChangeSetId());
aclsReaders.add(readers); aclsReaders.add(readers);
} }
@@ -472,6 +479,7 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations()); boolean includeChildAssociations = (resultFilter == null ? true : resultFilter.getIncludeChildAssociations());
boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner()); boolean includeOwner = (resultFilter == null ? true : resultFilter.getIncludeOwner());
boolean includeChildIds = (resultFilter == null ? true : resultFilter.getIncludeChildIds()); boolean includeChildIds = (resultFilter == null ? true : resultFilter.getIncludeChildIds());
boolean includeTxnId = (resultFilter == null ? true : resultFilter.getIncludeTxnId());
List<Long> nodeIds = preCacheNodes(nodeMetaDataParameters); List<Long> nodeIds = preCacheNodes(nodeMetaDataParameters);
@@ -492,6 +500,11 @@ public class SOLRTrackingComponentImpl implements SOLRTrackingComponent
Pair<Long, NodeRef> pair = nodeDAO.getNodePair(nodeId); Pair<Long, NodeRef> pair = nodeDAO.getNodePair(nodeId);
nodeMetaData.setAclId(nodeDAO.getNodeAclId(nodeId)); nodeMetaData.setAclId(nodeDAO.getNodeAclId(nodeId));
if(includeTxnId)
{
nodeMetaData.setTxnId(nodeDAO.getNodeRefStatus(pair.getSecond()).getDbTxnId());
}
if(includeType) if(includeType)
{ {
QName nodeType = nodeDAO.getNodeType(nodeId); QName nodeType = nodeDAO.getNodeType(nodeId);