Merged V3.2 to HEAD

15151: IndexCheckServiceImplTest - build/test fix (ent-only)
    15152: Formatting-only
    15360: Fix for ETHREEOH-2567: Index check includes nodes in the unindexed version store - these should be excluded
    15630: Merged V3.1 to V3.2
        14424: Fix build/test - indexing of version store(s) is disabled
        14438: Fix index check (related to ETHREEOH-1832 - disable indexing of version2Store)
        14526: ETHREEOH-1759 - fix getVersion (affects IBM JVM => WebSphere)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16592 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-09-29 13:56:58 +00:00
parent aa4ad8b826
commit 4a7df596da
4 changed files with 137 additions and 6 deletions

View File

@@ -43,6 +43,15 @@
<property name="nodeDaoService"> <property name="nodeDaoService">
<ref bean="nodeDaoService" /> <ref bean="nodeDaoService" />
</property> </property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="storesToIgnore">
<list>
<value>${version.store.version2Store}</value>
<value>${version.store.deprecated.lightWeightVersionStore}</value>
</list>
</property>
</bean> </bean>
<!-- index recovery and validation --> <!-- index recovery and validation -->

View File

@@ -147,6 +147,7 @@
<property name="storesToIgnore"> <property name="storesToIgnore">
<list> <list>
<value>${version.store.version2Store}</value> <value>${version.store.version2Store}</value>
<!-- <value>${version.store.deprecated.lightWeightVersionStore}</value> -->
</list> </list>
</property> </property>
</bean> </bean>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 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
@@ -26,6 +26,7 @@ package org.alfresco.repo.node.index;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
@@ -43,6 +44,7 @@ import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer; import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListenerAdapter; import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.TransactionServiceImpl;
@@ -94,6 +96,9 @@ public abstract class AbstractReindexComponent implements IndexRecovery
/** the component that holds the reindex worker threads */ /** the component that holds the reindex worker threads */
private ThreadPoolExecutor threadPoolExecutor; private ThreadPoolExecutor threadPoolExecutor;
private TenantService tenantService;
private List<String> storesToIgnore = new ArrayList<String>(0);
private volatile boolean shutdown; private volatile boolean shutdown;
private final WriteLock indexerWriteLock; private final WriteLock indexerWriteLock;
@@ -204,6 +209,21 @@ public abstract class AbstractReindexComponent implements IndexRecovery
this.threadPoolExecutor = threadPoolExecutor; this.threadPoolExecutor = threadPoolExecutor;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setStoresToIgnore(List<String> storesToIgnore)
{
this.storesToIgnore = storesToIgnore;
}
public List<String> getStoresToIgnore()
{
return this.storesToIgnore;
}
/** /**
* Determines if calls to {@link #reindexImpl()} should be wrapped in a transaction or not. * Determines if calls to {@link #reindexImpl()} should be wrapped in a transaction or not.
* The default is <b>true</b>. * The default is <b>true</b>.
@@ -321,6 +341,23 @@ public abstract class AbstractReindexComponent implements IndexRecovery
storeRefsIterator.remove(); storeRefsIterator.remove();
} }
} }
List<String> storesToIgnore = getStoresToIgnore();
if (storesToIgnore != null)
{
storeRefsIterator = storeRefs.iterator();
while (storeRefsIterator.hasNext())
{
// Remove stores to ignore
StoreRef storeRef = storeRefsIterator.next();
if (storesToIgnore.contains(storeRef.toString()))
{
storeRefsIterator.remove();
}
}
}
// Change the ordering to favour the most common stores // Change the ordering to favour the most common stores
if (storeRefs.contains(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE)) if (storeRefs.contains(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE))
{ {
@@ -385,7 +422,41 @@ public abstract class AbstractReindexComponent implements IndexRecovery
{ {
// If none of the stores have the transaction, then that might be because it consists of 0 modifications // If none of the stores have the transaction, then that might be because it consists of 0 modifications
int updateCount = nodeDaoService.getTxnUpdateCount(txnId); int updateCount = nodeDaoService.getTxnUpdateCount(txnId);
if (updateCount > 0)
/* Alternative (r15360)
// exclude updates in the version store
if(updateCount > 0)
{
// the updates could all be in the version stores ...
List<NodeRef> changes = nodeDaoService.getTxnChanges(txnId);
for(NodeRef change : changes)
{
StoreRef changeStore = change.getStoreRef();
if(changeStore.getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
{
if(changeStore.getIdentifier().equals("lightWeightVersionStore"))
{
Status nodeStatus = nodeService.getNodeStatus(change);
if(!nodeStatus.isDeleted())
{
updateCount--;
}
}
if(changeStore.getIdentifier().equals("version2Store"))
{
Status nodeStatus = nodeService.getNodeStatus(change);
if(!nodeStatus.isDeleted())
{
updateCount--;
}
}
}
}
}
*/
if ((updateCount > 0) && (! allUpdatedNodesCanBeIgnored(txnId)))
{ {
// There were updates, but there is no sign in the indexes // There were updates, but there is no sign in the indexes
result = InIndex.NO; result = InIndex.NO;
@@ -472,6 +543,47 @@ public abstract class AbstractReindexComponent implements IndexRecovery
} }
} }
protected boolean allUpdatedNodesCanBeIgnored(Long txnId)
{
boolean allUpdatedNodesCanBeIgnored = false;
List<String> storesToIgnore = getStoresToIgnore();
if ((storesToIgnore != null) && (storesToIgnore.size() > 0) && (txnId != null))
{
List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId);
allUpdatedNodesCanBeIgnored = true;
for (NodeRef nodeRef : nodeRefs)
{
if (nodeRef != null)
{
Status nodeStatus = nodeService.getNodeStatus(nodeRef);
if (nodeStatus == null)
{
// it's not there any more
continue;
}
if (! nodeStatus.isDeleted())
{
// updated node (ie. not deleted)
StoreRef storeRef = nodeRef.getStoreRef();
if (tenantService != null)
{
storeRef = tenantService.getBaseName(nodeRef.getStoreRef());
}
if (! storesToIgnore.contains(storeRef.toString()))
{
allUpdatedNodesCanBeIgnored = false;
break;
}
}
}
}
}
return allUpdatedNodesCanBeIgnored;
}
private boolean haveNodesBeenRemovedFromIndex(final StoreRef storeRef, final Transaction txn) private boolean haveNodesBeenRemovedFromIndex(final StoreRef storeRef, final Transaction txn)
{ {
final Long txnId = txn.getId(); final Long txnId = txn.getId();

View File

@@ -667,7 +667,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
} }
// TODO consolidate with VersionUtil.convertFrozenToOriginalProps // TODO consolidate with VersionUtil.convertFrozenToOriginalProps
nodeProperties.remove(ContentModel.PROP_DESCRIPTION);
for (QName key : nodeProperties.keySet()) for (QName key : nodeProperties.keySet())
{ {
Serializable value = nodeProperties.get(key); Serializable value = nodeProperties.get(key);
@@ -694,12 +694,21 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
versionProperties.put(VersionBaseModel.PROP_VERSION_NUMBER, (Integer)value); versionProperties.put(VersionBaseModel.PROP_VERSION_NUMBER, (Integer)value);
} }
else else
{
if (keyName.equals(Version.PROP_DESCRIPTION) ||
keyName.equals(VersionBaseModel.PROP_VERSION_LABEL) ||
keyName.equals(VersionBaseModel.PROP_VERSION_NUMBER))
{
// ignore reserved localname (including cm:description, cm:versionLabel)
}
else
{ {
// all other properties // all other properties
versionProperties.put(keyName, value); versionProperties.put(keyName, value);
} }
} }
} }
}
// Create and return the version object // Create and return the version object
NodeRef newNodeRef = new NodeRef(new StoreRef(Version2Model.STORE_PROTOCOL, Version2Model.STORE_ID), versionRef.getId()); NodeRef newNodeRef = new NodeRef(new StoreRef(Version2Model.STORE_PROTOCOL, Version2Model.STORE_ID), versionRef.getId());