mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.1 to HEAD:
6556: AVM performance tweaks 6557: WCM-758. 6558: Fixes WCM-753. 6559: better handling of rename, copy and paste for form instance data and renditions. addresses WCM-752 and partially addresses WCM-559. 6560: Renamed JndiTest.java until we decide to keep it or not. 6561: Oops. 6562: probable fix WCM-669 6563: Build fix after the removal of flushing suport 6564: Fix for WCM-728 6566: Support for avm index clustering via tracking - WCM-762 6567: Test fix after flush changes 6568: Fixed AWC-1517: Can now create space based on existing top-level space 6569: misc IE fixes. 6570: Various changes to improve AVM import performance and submit performance. 6571: Session flushing is now deprecated and doesn't fail with an exception. 6572: Reduced the iteration count to stress nextResults calls a bit more 6573: WS query sessions put back into cache after more results have been fetched. 6574: AR-1347: RepositoryServiceSoapBindingStub.queryAssociated() returns nothing when direction=target 6575: Fixed AR-1680: XPath metadata extraction now handles Node, NodeList and String return values 6577: Fix for AWC-1518 (User Homes renaming issue, and unreported issue with client config overriding of users home location) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6745 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -38,7 +38,6 @@ import javax.jcr.nodetype.NoSuchNodeTypeException;
|
||||
import javax.jcr.version.VersionException;
|
||||
|
||||
import org.alfresco.jcr.session.SessionImpl;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
|
||||
|
||||
/**
|
||||
@@ -107,7 +106,6 @@ public abstract class ItemImpl implements Item
|
||||
*/
|
||||
public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException
|
||||
{
|
||||
AlfrescoTransactionSupport.flush();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -41,9 +41,9 @@ public class AVMCrawlTestP extends AVMServiceTestBase
|
||||
*/
|
||||
public void testCrawl()
|
||||
{
|
||||
int n = 4; // Number of Threads.
|
||||
int n = 8; // Number of Threads.
|
||||
int m = 2; // How many multiples of content to start with.
|
||||
long runTime = 3600000; // 1 Hour. .
|
||||
long runTime = 28800000; // 8 Hours. .
|
||||
fService.purgeStore("main");
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
|
@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
|
||||
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
@@ -1194,7 +1195,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
}
|
||||
}
|
||||
}
|
||||
values.put(qName, new PropertyValue(null, properties.get(qName)));
|
||||
DataTypeDefinition def = dictionaryService.getDataType(qName);
|
||||
if (def == null)
|
||||
{
|
||||
def = dictionaryService.getDataType(properties.get(qName).getClass());
|
||||
}
|
||||
values.put(qName, new PropertyValue(def.getName(), properties.get(qName)));
|
||||
}
|
||||
fAVMService.setNodeProperties(avmVersionPath.getSecond(), values);
|
||||
// Invoke policy behaviors.
|
||||
@@ -1287,7 +1293,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
|
||||
try
|
||||
{
|
||||
// Map<QName, Serializable> propsBefore = getProperties(nodeRef);
|
||||
fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(null, value));
|
||||
DataTypeDefinition def = dictionaryService.getDataType(qname);
|
||||
if (def == null)
|
||||
{
|
||||
def = dictionaryService.getDataType(value.getClass());
|
||||
}
|
||||
fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(def.getName(), value));
|
||||
// Map<QName, Serializable> propsAfter = getProperties(nodeRef);
|
||||
// Invoke policy behaviors.
|
||||
// invokeOnUpdateNode(nodeRef);
|
||||
|
@@ -639,7 +639,8 @@ public class AVMRepository
|
||||
throw new AVMNotFoundException("Path not found.");
|
||||
}
|
||||
srcDir = (DirectoryNode)sPath.getCurrentNode();
|
||||
srcNode = srcDir.lookupChild(sPath, srcName, false);
|
||||
Pair<AVMNode, Boolean> temp = srcDir.lookupChild(sPath, srcName, false);
|
||||
srcNode = (temp == null) ? null : temp.getFirst();
|
||||
if (srcNode == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Not found: " + srcName);
|
||||
@@ -665,7 +666,8 @@ public class AVMRepository
|
||||
throw new AVMNotFoundException("Path not found.");
|
||||
}
|
||||
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
|
||||
AVMNode child = dstDir.lookupChild(dPath, dstName, true);
|
||||
Pair<AVMNode, Boolean> temp = dstDir.lookupChild(dPath, dstName, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Node exists: " + dstName);
|
||||
|
@@ -254,13 +254,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
|
||||
props = new HashMap<QName, PropertyValue>();
|
||||
QName n1 = QName.createQName("silly.uri", "Prop1");
|
||||
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
|
||||
PropertyValue p1 = new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis()));
|
||||
props.put(n1, p1);
|
||||
QName n2 = QName.createQName("silly.uri", "Prop2");
|
||||
PropertyValue p2 = new PropertyValue(null, "A String Property.");
|
||||
PropertyValue p2 = new PropertyValue(DataTypeDefinition.TEXT, "A String Property.");
|
||||
props.put(n2, p2);
|
||||
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||
PropertyValue p3 = new PropertyValue(null, 42);
|
||||
PropertyValue p3 = new PropertyValue(DataTypeDefinition.INT, 42);
|
||||
props.put(n3, p3);
|
||||
fService.setNodeProperties("main:/a/b/c/bar", props);
|
||||
fService.createSnapshot("main", null, null);
|
||||
@@ -5187,11 +5187,11 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_TITLED);
|
||||
fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_AUDITABLE);
|
||||
Map<QName, PropertyValue> properties = new HashMap<QName, PropertyValue>();
|
||||
properties.put(ContentModel.PROP_ACCESSED, new PropertyValue(null, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_CREATED, new PropertyValue(null, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_MODIFIED, new PropertyValue(null, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_CREATOR, new PropertyValue(null, "Giles"));
|
||||
properties.put(ContentModel.PROP_MODIFIER, new PropertyValue(null, "Quentin"));
|
||||
properties.put(ContentModel.PROP_ACCESSED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_CREATED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_MODIFIED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
|
||||
properties.put(ContentModel.PROP_CREATOR, new PropertyValue(DataTypeDefinition.TEXT, "Giles"));
|
||||
properties.put(ContentModel.PROP_MODIFIER, new PropertyValue(DataTypeDefinition.TEXT, "Quentin"));
|
||||
fService.setNodeProperties("main:/a/b/c/foo", properties);
|
||||
fService.createSnapshot("main", null, null);
|
||||
|
||||
|
@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* A Repository contains a current root directory and a list of
|
||||
@@ -326,7 +327,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
@@ -368,7 +370,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + dstPath + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
@@ -411,7 +414,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
@@ -446,7 +450,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
@@ -483,7 +488,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + dstPath + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
@@ -1431,7 +1437,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Node not found: " + name);
|
||||
|
@@ -737,7 +737,15 @@ public class AVMSyncServiceImpl implements AVMSyncService
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// layer = fAVMService.forceCopy(layer.getPath());
|
||||
List<AVMDifference> diffs = compare(-1, layer.getPath(), -1, underlying.getPath(), null);
|
||||
if (diffs.size() == 0)
|
||||
{
|
||||
for (String name : layerListing.keySet())
|
||||
{
|
||||
fAVMRepository.flatten(layer.getPath(), name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Grab the listing
|
||||
Map<String, AVMNodeDescriptor> underListing =
|
||||
fAVMService.getDirectoryListing(underlying, true);
|
||||
|
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* The interface for Directory Nodes.
|
||||
@@ -54,7 +55,7 @@ public interface DirectoryNode extends AVMNode
|
||||
* @param name The name of the child to lookup.
|
||||
* @param includeDeleted Include deleted nodes or not.
|
||||
*/
|
||||
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted);
|
||||
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted);
|
||||
|
||||
/**
|
||||
* Lookup a child node using an AVMNodeDescriptor as context.
|
||||
|
@@ -35,6 +35,7 @@ import org.alfresco.service.cmr.avm.AVMException;
|
||||
import org.alfresco.service.cmr.avm.AVMExistsException;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* A layered directory node. A layered directory node points at
|
||||
@@ -507,7 +508,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
* @return The child or null if not found.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted)
|
||||
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted)
|
||||
{
|
||||
ChildKey key = new ChildKey(this, name);
|
||||
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
|
||||
@@ -517,7 +518,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return AVMNodeUnwrapper.Unwrap(entry.getChild());
|
||||
return new Pair<AVMNode, Boolean>(AVMNodeUnwrapper.Unwrap(entry.getChild()), true);
|
||||
}
|
||||
// Don't check our underlying directory if we are opaque.
|
||||
if (fOpacity)
|
||||
@@ -529,7 +530,11 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
if (lookup != null)
|
||||
{
|
||||
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
|
||||
AVMNode retVal = dir.lookupChild(lookup, name, includeDeleted);
|
||||
Pair<AVMNode, Boolean> retVal = dir.lookupChild(lookup, name, includeDeleted);
|
||||
if (retVal != null)
|
||||
{
|
||||
retVal.setSecond(false);
|
||||
}
|
||||
lPath.setFinalStore(lookup.getFinalStore());
|
||||
return retVal;
|
||||
}
|
||||
@@ -573,12 +578,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
if (lookup != null)
|
||||
{
|
||||
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
|
||||
AVMNode child = dir.lookupChild(lookup, name, includeDeleted);
|
||||
Pair<AVMNode, Boolean> child = dir.lookupChild(lookup, name, includeDeleted);
|
||||
if (child == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return child.getDescriptor(lookup);
|
||||
return child.getFirst().getDescriptor(lookup);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -613,7 +618,15 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
}
|
||||
else
|
||||
{
|
||||
child = lookupChild(lPath, name, false);
|
||||
Pair<AVMNode, Boolean> temp = lookupChild(lPath, name, false);
|
||||
if (temp == null)
|
||||
{
|
||||
child = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
child = temp.getFirst();
|
||||
}
|
||||
indirect = true;
|
||||
}
|
||||
if (child != null && (indirect || child.getStoreNew() == null || child.getAncestor() != null))
|
||||
@@ -893,7 +906,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
|
||||
throw new AVMBadArgumentException("Non primary layered directories cannot be linked.");
|
||||
}
|
||||
// Look for an existing child of that name.
|
||||
AVMNode existing = lookupChild(lPath, name, true);
|
||||
Pair<AVMNode, Boolean> temp = lookupChild(lPath, name, true);
|
||||
AVMNode existing = (temp == null) ? null : temp.getFirst();
|
||||
ChildKey key = new ChildKey(this, name);
|
||||
if (existing != null)
|
||||
{
|
||||
|
@@ -218,7 +218,7 @@ class Lookup implements Serializable
|
||||
* @param write Whether this is in the context of
|
||||
* a write operation.
|
||||
*/
|
||||
public void add(AVMNode node, String name, boolean write)
|
||||
public void add(AVMNode node, String name, boolean directlyContained, boolean write)
|
||||
{
|
||||
LookupComponent comp = new LookupComponent();
|
||||
comp.setName(name);
|
||||
@@ -226,7 +226,11 @@ class Lookup implements Serializable
|
||||
if (fPosition >= 0 && fDirectlyContained &&
|
||||
fComponents.get(fPosition).getNode().getType() == AVMNodeType.LAYERED_DIRECTORY)
|
||||
{
|
||||
fDirectlyContained = ((DirectoryNode)fComponents.get(fPosition).getNode()).directlyContains(node);
|
||||
// if (directlyContained != ((DirectoryNode)fComponents.get(fPosition).getNode()).directlyContains(node))
|
||||
// {
|
||||
// System.err.println("Bloody Murder!");
|
||||
// }
|
||||
fDirectlyContained = directlyContained;
|
||||
}
|
||||
if (!write)
|
||||
{
|
||||
|
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.repo.avm.util.SimplePath;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
@@ -104,14 +105,16 @@ public class LookupCache
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
|
||||
VersionRoot vRoot = AVMDAOs.Instance().fVersionRootDAO.getByVersionID(store, version);
|
||||
dir = vRoot.getRoot();
|
||||
// dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
|
||||
}
|
||||
if (dir == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Add an entry for the root.
|
||||
result.add(dir, "", write);
|
||||
result.add(dir, "", true, write);
|
||||
dir = (DirectoryNode)result.getCurrentNode();
|
||||
if (path.size() == 1 && path.get(0).equals(""))
|
||||
{
|
||||
@@ -122,28 +125,28 @@ public class LookupCache
|
||||
// before the end.
|
||||
for (int i = 0; i < path.size() - 1; i++)
|
||||
{
|
||||
AVMNode child = dir.lookupChild(result, path.get(i), includeDeleted);
|
||||
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(i), includeDeleted);
|
||||
if (child == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Every element that is not the last needs to be a directory.
|
||||
if (child.getType() != AVMNodeType.PLAIN_DIRECTORY &&
|
||||
child.getType() != AVMNodeType.LAYERED_DIRECTORY)
|
||||
if (child.getFirst().getType() != AVMNodeType.PLAIN_DIRECTORY &&
|
||||
child.getFirst().getType() != AVMNodeType.LAYERED_DIRECTORY)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
result.add(child, path.get(i), write);
|
||||
result.add(child.getFirst(), path.get(i), child.getSecond(), write);
|
||||
dir = (DirectoryNode)result.getCurrentNode();
|
||||
}
|
||||
// Now look up the last element.
|
||||
AVMNode child = dir.lookupChild(result, path.get(path.size() - 1),
|
||||
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(path.size() - 1),
|
||||
includeDeleted);
|
||||
if (child == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
result.add(child, path.get(path.size() - 1), write);
|
||||
result.add(child.getFirst(), path.get(path.size() - 1), child.getSecond(), write);
|
||||
fCache.put(key, result);
|
||||
return result;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
import org.alfresco.service.cmr.avm.AVMExistsException;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* A plain directory. No monkey tricks except for possiblyCopy.
|
||||
@@ -185,7 +186,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
* @return The child or null.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted)
|
||||
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted)
|
||||
{
|
||||
ChildKey key = new ChildKey(this, name);
|
||||
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
|
||||
@@ -196,7 +197,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
|
||||
}
|
||||
// We're doing the hand unrolling of the proxy because
|
||||
// Hibernate/CGLIB proxies are broken.
|
||||
return AVMNodeUnwrapper.Unwrap(entry.getChild());
|
||||
return new Pair<AVMNode, Boolean>(AVMNodeUnwrapper.Unwrap(entry.getChild()), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -51,7 +51,7 @@ public interface VersionRoot
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public long getId();
|
||||
public Long getId();
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
|
@@ -30,7 +30,7 @@ import java.io.Serializable;
|
||||
* Hold a single version root.
|
||||
* @author britt
|
||||
*/
|
||||
class VersionRootImpl implements VersionRoot, Serializable
|
||||
public class VersionRootImpl implements VersionRoot, Serializable
|
||||
{
|
||||
static final long serialVersionUID = 8826954538210455917L;
|
||||
|
||||
@@ -126,7 +126,7 @@ class VersionRootImpl implements VersionRoot, Serializable
|
||||
fCreator = creator;
|
||||
}
|
||||
|
||||
public long getId()
|
||||
public Long getId()
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
@@ -142,8 +142,8 @@
|
||||
</many-to-one>
|
||||
</class>
|
||||
<class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
|
||||
<!-- <cache usage="read-write"/> -->
|
||||
<id column="id" type="long">
|
||||
<cache usage="read-write"/>
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"></generator>
|
||||
</id>
|
||||
<natural-id>
|
||||
|
@@ -24,12 +24,16 @@
|
||||
package org.alfresco.repo.avm.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.avm.AVMNode;
|
||||
import org.alfresco.repo.avm.AVMStore;
|
||||
import org.alfresco.repo.avm.VersionRoot;
|
||||
import org.alfresco.repo.avm.VersionRootImpl;
|
||||
import org.alfresco.repo.avm.VersionRootDAO;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
|
||||
@@ -40,12 +44,15 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
class VersionRootDAOHibernate extends HibernateDaoSupport implements
|
||||
VersionRootDAO
|
||||
{
|
||||
private LinkedHashMap<Pair<Long, Integer>, Long> fCache;
|
||||
|
||||
/**
|
||||
* Do nothing constructor.
|
||||
*/
|
||||
public VersionRootDAOHibernate()
|
||||
{
|
||||
super();
|
||||
fCache = new LinkedHashMap<Pair<Long, Integer>, Long>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +135,37 @@ class VersionRootDAOHibernate extends HibernateDaoSupport implements
|
||||
* @param id The version id.
|
||||
* @return The VersionRoot or null if not found.
|
||||
*/
|
||||
public VersionRoot getByVersionID(AVMStore store, int id)
|
||||
public synchronized VersionRoot getByVersionID(AVMStore store, int id)
|
||||
{
|
||||
Long vID = fCache.get(new Pair<Long, Integer>(store.getId(), id));
|
||||
if (vID != null)
|
||||
{
|
||||
VersionRoot root = (VersionRoot)getSession().get(VersionRootImpl.class, vID);
|
||||
if (root != null)
|
||||
{
|
||||
return root;
|
||||
}
|
||||
fCache.remove(new Pair<Long, Integer>(store.getId(), id));
|
||||
}
|
||||
Query query = getSession().getNamedQuery("VersionRoot.VersionByID");
|
||||
query.setEntity("store", store);
|
||||
query.setInteger("version", id);
|
||||
return (VersionRoot)query.uniqueResult();
|
||||
VersionRoot root = (VersionRoot)query.uniqueResult();
|
||||
if (root != null)
|
||||
{
|
||||
vID = root.getId();
|
||||
if (vID != null)
|
||||
{
|
||||
if (fCache.size() >= 10)
|
||||
{
|
||||
Iterator<Pair<Long, Integer>> iter = fCache.keySet().iterator();
|
||||
iter.next();
|
||||
iter.remove();
|
||||
}
|
||||
fCache.put(new Pair<Long, Integer>(store.getId(), id), vID);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -264,7 +264,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
keys.add(lock.getWebProject());
|
||||
String digest = MD5.Digest(lock.getPath().getBytes());
|
||||
keys.add(digest);
|
||||
if (fAttributeService.getAttribute(keys) != null)
|
||||
if (fAttributeService.exists(keys))
|
||||
{
|
||||
throw new AVMExistsException("Lock Exists: " + keys);
|
||||
}
|
||||
@@ -316,8 +316,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
||||
keys.add(WEB_PROJECTS);
|
||||
keys.add(webProject);
|
||||
keys.add(pathKey);
|
||||
Attribute lockData = fAttributeService.getAttribute(keys);
|
||||
if (lockData == null)
|
||||
if (!fAttributeService.exists(keys))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ import java.util.Map;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ public class BulkLoader
|
||||
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
|
||||
for (int i = 0; i < fPropertyCount; i++)
|
||||
{
|
||||
props.put(QName.createQName("silly", "prop" + i), new PropertyValue(null, "I am property " + i));
|
||||
props.put(QName.createQName("silly", "prop" + i), new PropertyValue(DataTypeDefinition.TEXT, "I am property " + i));
|
||||
}
|
||||
File file = new File(fsPath);
|
||||
String name = file.getName();
|
||||
|
@@ -249,8 +249,48 @@ public class XPathMetadataExtracter extends AbstractMappingMetadataExtracter imp
|
||||
{
|
||||
String documentProperty = element.getKey();
|
||||
XPathExpression xpathExpression = element.getValue();
|
||||
// Get the value, assuming it is a nodeset
|
||||
Serializable value = null;
|
||||
try
|
||||
{
|
||||
value = getNodeSetValue(document, xpathExpression);
|
||||
}
|
||||
catch (XPathExpressionException e)
|
||||
{
|
||||
// That didn't work, so give it a try as a STRING
|
||||
value = getStringValue(document, xpathExpression);
|
||||
}
|
||||
// Put the value
|
||||
rawProperties.put(documentProperty, value);
|
||||
}
|
||||
// Done
|
||||
return rawProperties;
|
||||
}
|
||||
|
||||
private Serializable getStringValue(Document document, XPathExpression xpathExpression) throws XPathExpressionException
|
||||
{
|
||||
String value = (String) xpathExpression.evaluate(document, XPathConstants.STRING);
|
||||
// Done
|
||||
return value;
|
||||
}
|
||||
|
||||
private Serializable getNodeSetValue(Document document, XPathExpression xpathExpression) throws XPathExpressionException
|
||||
{
|
||||
// Execute it
|
||||
NodeList nodeList = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET);
|
||||
NodeList nodeList = null;
|
||||
try
|
||||
{
|
||||
nodeList = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET);
|
||||
}
|
||||
catch (XPathExpressionException e)
|
||||
{
|
||||
// Expression didn't evaluate to a nodelist
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Unable to evaluate expression and return a NODESET: " + xpathExpression);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
// Convert the value
|
||||
Serializable value = null;
|
||||
int nodeCount = nodeList.getLength();
|
||||
@@ -274,11 +314,8 @@ public class XPathMetadataExtracter extends AbstractMappingMetadataExtracter imp
|
||||
}
|
||||
value = stringValues;
|
||||
}
|
||||
// Put the value
|
||||
rawProperties.put(documentProperty, value);
|
||||
}
|
||||
// Done
|
||||
return rawProperties;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -600,6 +600,23 @@ public class FileFolderServiceImpl implements FileFolderService
|
||||
NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||
QName.createValidLocalName(newName));
|
||||
|
||||
QName targetParentType = nodeService.getType(targetParentRef);
|
||||
|
||||
// Fix AWC-1517
|
||||
QName assocTypeQname = null;
|
||||
if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
assocTypeQname = ContentModel.ASSOC_CONTAINS; // cm:folder -> cm:contains
|
||||
}
|
||||
else if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_CONTAINER))
|
||||
{
|
||||
assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidTypeException("Unexpected type (" + targetParentType + ") for target parent: " + targetParentRef);
|
||||
}
|
||||
|
||||
// move or copy
|
||||
NodeRef targetNodeRef = null;
|
||||
if (move)
|
||||
@@ -611,7 +628,7 @@ public class FileFolderServiceImpl implements FileFolderService
|
||||
ChildAssociationRef newAssocRef = nodeService.moveNode(
|
||||
sourceNodeRef,
|
||||
targetParentRef,
|
||||
assocRef.getTypeQName(),
|
||||
assocTypeQname,
|
||||
qname);
|
||||
targetNodeRef = newAssocRef.getChildRef();
|
||||
}
|
||||
@@ -629,7 +646,7 @@ public class FileFolderServiceImpl implements FileFolderService
|
||||
targetNodeRef = copyService.copy(
|
||||
sourceNodeRef,
|
||||
targetParentRef,
|
||||
assocRef.getTypeQName(),
|
||||
assocTypeQname,
|
||||
qname,
|
||||
true);
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
@@ -84,7 +85,8 @@ public class MLContentInterceptor implements MethodInterceptor
|
||||
NodeRef nodeRef = (NodeRef) args[0];
|
||||
|
||||
// Shortcut it if the node is not an empty translation
|
||||
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM) ||
|
||||
!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
return invocation.proceed();
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
@@ -251,7 +252,7 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
*/
|
||||
private NodeRef getPivotNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
if (!nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM) && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
return multilingualContentService.getPivotTranslation(nodeRef);
|
||||
}
|
||||
|
@@ -355,7 +355,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
verifyNodeExistence(bb_, true);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// check that the required properties are present and correct
|
||||
Map<QName, Serializable> bb_Properties = nodeService.getProperties(bb_);
|
||||
@@ -383,7 +383,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
verifyChildAssocExistence(childAssocBtoBB_, true);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// restore the node
|
||||
nodeService.restoreNode(b_, null, null, null);
|
||||
@@ -398,7 +398,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
nodeService.deleteNode(a);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// restore in reverse order
|
||||
nodeService.restoreNode(a_, null, null, null);
|
||||
@@ -414,7 +414,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
nodeService.deleteNode(b);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// restore in reverse order
|
||||
nodeService.restoreNode(b_, null, null, null);
|
||||
@@ -430,7 +430,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
nodeService.deleteNode(b);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// in restoring 'a' first, there will be some associations that won't be recreated
|
||||
nodeService.restoreNode(a_, null, null, null);
|
||||
@@ -486,7 +486,7 @@ public class ArchiveAndRestoreTest extends TestCase
|
||||
cumulatedArchiveTimeNs += (end - start);
|
||||
|
||||
// flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
//AlfrescoTransactionSupport.flush();
|
||||
|
||||
// now restore
|
||||
start = System.nanoTime();
|
||||
|
@@ -29,7 +29,6 @@ import java.lang.reflect.Method;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.BaseNodeServiceTest;
|
||||
import org.alfresco.repo.node.db.DbNodeServiceImpl;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.TransactionResourceInterceptor;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
@@ -53,7 +52,7 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
|
||||
{
|
||||
try
|
||||
{
|
||||
Class clazz = SessionSizeManagementTest.class;
|
||||
Class<SessionSizeManagementTest> clazz = SessionSizeManagementTest.class;
|
||||
createNodesMethod = clazz.getMethod(
|
||||
"createNodes",
|
||||
new Class[] {NodeService.class, Integer.TYPE, Boolean.TYPE});
|
||||
@@ -118,9 +117,6 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
|
||||
NodeService nodeService = getNodeService();
|
||||
createNodes(nodeService, LOAD_COUNT, false);
|
||||
// We can't check the session size as this is dependent on machine speed
|
||||
|
||||
// Now flush integrity to be sure things are not broken
|
||||
AlfrescoTransactionSupport.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +132,5 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
|
||||
}
|
||||
|
||||
createNodes(nodeService, LOAD_COUNT, true);
|
||||
|
||||
// Now flush integrity to be sure things are not broken
|
||||
AlfrescoTransactionSupport.flush();
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.alfresco.repo.node.index;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
|
||||
@@ -51,14 +52,12 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
this.lockServer = lockServer;
|
||||
}
|
||||
|
||||
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(
|
||||
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
{
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
@@ -72,76 +71,179 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
private void processStores()
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = avmService.getStores();
|
||||
LinkedHashMap<String, RecoveryMode> actions = new LinkedHashMap<String, RecoveryMode>();
|
||||
if (stores.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (recoveryMode)
|
||||
{
|
||||
case AUTO:
|
||||
case VALIDATE:
|
||||
int count = 0;
|
||||
int tracker = -1;
|
||||
logger.info("Checking indexes for AVM Stores");
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Checking indexes for AVM Stores: " + recoveryMode);
|
||||
}
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
if (isShuttingDown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
processStore(store.getName());
|
||||
actions.put(store.getName(), checkStore(store.getName()));
|
||||
count++;
|
||||
if (count * 10l / stores.size() > tracker)
|
||||
{
|
||||
tracker = (int) (count * 10l / stores.size());
|
||||
logger.info(" Stores "+(tracker*10)+"% complete");
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Store check " + (tracker * 10) + "% complete");
|
||||
}
|
||||
}
|
||||
logger.info("Finished checking indexes for AVM Stores");
|
||||
}
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Finished checking indexes for AVM Stores");
|
||||
}
|
||||
break;
|
||||
case FULL:
|
||||
case NONE:
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
if (isShuttingDown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
actions.put(store.getName(), checkStore(store.getName()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
private void processStore(String store)
|
||||
int full = 0;
|
||||
int auto = 0;
|
||||
int invalid = 0;
|
||||
for (String store : actions.keySet())
|
||||
{
|
||||
RecoveryMode mode = actions.get(store);
|
||||
switch (mode)
|
||||
{
|
||||
case AUTO:
|
||||
auto++;
|
||||
break;
|
||||
case FULL:
|
||||
full++;
|
||||
break;
|
||||
case VALIDATE:
|
||||
invalid++;
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if (recoveryMode != RecoveryMode.NONE)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Performing AVM index recovery for type: " + recoveryMode + " on store " + store);
|
||||
logger.debug("Invalid indexes: " + invalid);
|
||||
logger.debug("Indexes for full rebuild: " + full);
|
||||
logger.debug("Indexes for auto update: " + auto);
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
int tracker = -1;
|
||||
int total = full + auto;
|
||||
if (total > 0)
|
||||
{
|
||||
logger.info("Rebuilding indexes for " + total + " AVM Stores");
|
||||
for (String store : actions.keySet())
|
||||
{
|
||||
RecoveryMode mode = actions.get(store);
|
||||
if (isShuttingDown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((mode == RecoveryMode.FULL) || (mode == RecoveryMode.AUTO))
|
||||
{
|
||||
processStore(store, mode);
|
||||
count++;
|
||||
}
|
||||
if (count * 10l / total > tracker)
|
||||
{
|
||||
tracker = (int) (count * 10l / total);
|
||||
logger.info(" Reindex " + (tracker * 10) + "% complete");
|
||||
}
|
||||
}
|
||||
logger.info("Finished rebuilding indexes for AVM Stores");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private RecoveryMode checkStore(String store)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Checking AVM store for index recovery: " + recoveryMode + " on store " + store);
|
||||
}
|
||||
|
||||
// do we just ignore
|
||||
if (recoveryMode == RecoveryMode.NONE)
|
||||
{
|
||||
return;
|
||||
return RecoveryMode.NONE;
|
||||
}
|
||||
// check the level of cover required
|
||||
boolean fullRecoveryRequired = false;
|
||||
|
||||
// Nothing to do for unindexed stores
|
||||
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
|
||||
{
|
||||
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
logger.warn(" Index for avm store " + store + " is out of date");
|
||||
return recoveryMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RecoveryMode.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (recoveryMode == RecoveryMode.FULL) // no validate required
|
||||
{
|
||||
fullRecoveryRequired = true;
|
||||
return RecoveryMode.FULL;
|
||||
}
|
||||
else
|
||||
// validate first
|
||||
{
|
||||
if(avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
return;
|
||||
logger.warn(" Index for avm store " + store + " is out of date");
|
||||
return recoveryMode;
|
||||
}
|
||||
|
||||
int lastActualSnapshotId = avmService.getLatestSnapshotID(store);
|
||||
if (lastActualSnapshotId <= 0)
|
||||
{
|
||||
return;
|
||||
return RecoveryMode.NONE;
|
||||
}
|
||||
int lastIndexedSnapshotId = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store);
|
||||
if (lastActualSnapshotId != lastIndexedSnapshotId)
|
||||
{
|
||||
logger.warn(" Index for avm store " + store + " is out of date");
|
||||
// this store isn't up to date
|
||||
if (recoveryMode == RecoveryMode.VALIDATE)
|
||||
return recoveryMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the store is out of date - validation failed
|
||||
return recoveryMode.NONE;
|
||||
}
|
||||
else if (recoveryMode == RecoveryMode.AUTO)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processStore(String store, RecoveryMode mode)
|
||||
{
|
||||
fullRecoveryRequired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// put the server into read-only mode for the duration
|
||||
boolean allowWrite = !transactionService.isReadOnly();
|
||||
@@ -153,11 +255,8 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
transactionService.setAllowWrite(false);
|
||||
}
|
||||
|
||||
// do we need to perform a full recovery
|
||||
if (fullRecoveryRequired)
|
||||
{
|
||||
recoverStore(store);
|
||||
}
|
||||
recoverStore(store, mode);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -167,56 +266,97 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
|
||||
|
||||
}
|
||||
|
||||
private void recoverStore(String store)
|
||||
private void recoverStore(String store, RecoveryMode mode)
|
||||
{
|
||||
int tracker = -1;
|
||||
int latest = avmService.getLatestSnapshotID(store);
|
||||
if(latest <= 0)
|
||||
|
||||
if (mode == RecoveryMode.AUTO)
|
||||
{
|
||||
return;
|
||||
logger.info(" Auto recovering index for " + store);
|
||||
}
|
||||
else if (mode == RecoveryMode.FULL)
|
||||
{
|
||||
logger.info(" Rebuilding index for " + store);
|
||||
}
|
||||
logger.info("Recovery for "+store);
|
||||
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
|
||||
}
|
||||
|
||||
int latest = avmService.getLatestSnapshotID(store);
|
||||
if (latest <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean wasRecovered = false;
|
||||
|
||||
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) != IndexMode.UNINDEXED)
|
||||
{
|
||||
for (int i = 0; i <= latest; i++)
|
||||
{
|
||||
if (isShuttingDown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
recoverSnapShot(store, i);
|
||||
wasRecovered = recoverSnapShot(store, i, mode, wasRecovered);
|
||||
if (i * 10l / latest > tracker)
|
||||
{
|
||||
tracker = (int) (i * 10l / latest);
|
||||
logger.info(" Store "+store +" "+(tracker*10)+"% complete");
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Store " + store + " " + (tracker * 10) + "% complete");
|
||||
}
|
||||
}
|
||||
logger.info("Recovery for "+store+" done");
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Index updated for " + store);
|
||||
}
|
||||
}
|
||||
|
||||
private void recoverSnapShot(final String store, final int id)
|
||||
private boolean recoverSnapShot(final String store, final int id, final RecoveryMode mode, final boolean wasRecovered)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Reindexing avm store: " + store + " snapshot id " + id);
|
||||
}
|
||||
|
||||
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
|
||||
RetryingTransactionCallback<Boolean> reindexWork = new RetryingTransactionCallback<Boolean>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
public Boolean execute() throws Exception
|
||||
{
|
||||
if (wasRecovered)
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mode == RecoveryMode.AUTO)
|
||||
{
|
||||
if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id))
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
|
||||
return true;
|
||||
}
|
||||
// done
|
||||
return null;
|
||||
else
|
||||
{
|
||||
return wasRecovered;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
|
||||
// done
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.node.index;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Track and update when snapshots are created and indexed in a cluster
|
||||
*/
|
||||
public class AVMRemoteSnapshotTracker extends AbstractReindexComponent
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(AVMRemoteSnapshotTracker.class);
|
||||
|
||||
private AVMService avmService;
|
||||
|
||||
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
{
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reindexImpl()
|
||||
{
|
||||
processStores();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop throught the avm stores and compare the latest snapshot to that in the index.
|
||||
* Update the index if it has fallen behind.
|
||||
*
|
||||
*/
|
||||
private void processStores()
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = avmService.getStores();
|
||||
if (stores.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean upToDate;
|
||||
do
|
||||
{
|
||||
upToDate = true;
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
if (isShuttingDown())
|
||||
{
|
||||
break;
|
||||
}
|
||||
int current = avmService.getLatestSnapshotID(store.getName());
|
||||
int lastIndexed = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store.getName());
|
||||
|
||||
if (lastIndexed < current)
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Updating index for store "+store.getName()+" from snapshot "+lastIndexed+ " to "+current);
|
||||
}
|
||||
recoverSnapShot(store.getName(), lastIndexed, current);
|
||||
upToDate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!upToDate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the index update in one lump (not individual snapshots)
|
||||
*
|
||||
* @param store
|
||||
* @param lastIndexed
|
||||
* @param current
|
||||
*/
|
||||
private void recoverSnapShot(final String store, final int lastIndexed, final int current)
|
||||
{
|
||||
|
||||
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
if(lastIndexed == -1)
|
||||
{
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
|
||||
}
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, lastIndexed, current);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.node.index;
|
||||
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.node.db.NodeDaoService;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.search.Indexer;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.transaction.TransactionServiceImpl;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
|
||||
/**
|
||||
* Test that the index tracker catches up
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class AVMRemoteSnapshotTrackerTest extends BaseSpringTest
|
||||
{
|
||||
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
private AVMService avmService;
|
||||
|
||||
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
|
||||
private TransactionService transactionService;
|
||||
|
||||
private UserTransaction testTX;
|
||||
|
||||
private SearchService searchService;
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private FullTextSearchIndexer ftsIndexer;
|
||||
|
||||
private Indexer indexer;
|
||||
|
||||
private NodeDaoService nodeDaoService;
|
||||
|
||||
public AVMRemoteSnapshotTrackerTest()
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetUpInTransaction() throws Exception
|
||||
{
|
||||
super.onSetUpInTransaction();
|
||||
ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
|
||||
avmService = (AVMService) applicationContext.getBean("AVMService");
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor = (AVMSnapShotTriggeredIndexingMethodInterceptor) applicationContext.getBean("avmSnapShotTriggeredIndexingMethodInterceptor");
|
||||
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
||||
|
||||
searchService = serviceRegistry.getSearchService();
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
ftsIndexer = (FullTextSearchIndexer) applicationContext.getBean("LuceneFullTextSearchIndexer");
|
||||
indexer = (Indexer) applicationContext.getBean("indexerComponent");
|
||||
nodeDaoService = (NodeDaoService) applicationContext.getBean("nodeDaoService");
|
||||
|
||||
|
||||
testTX = transactionService.getUserTransaction();
|
||||
testTX.begin();
|
||||
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTearDownInTransaction() throws Exception
|
||||
{
|
||||
if (testTX.getStatus() == Status.STATUS_ACTIVE)
|
||||
{
|
||||
testTX.rollback();
|
||||
}
|
||||
try
|
||||
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
super.onTearDownInTransaction();
|
||||
}
|
||||
|
||||
public void testCatchUp()
|
||||
{
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
|
||||
|
||||
// initial state
|
||||
avmService.createStore("one");
|
||||
//assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
|
||||
avmService.createDirectory("one:/", "a");
|
||||
avmService.createSnapshot("one", null, null);
|
||||
|
||||
avmService.createStore("two");
|
||||
avmService.createDirectory("two:/", "a");
|
||||
|
||||
avmService.createStore("three");
|
||||
|
||||
// Check state
|
||||
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
|
||||
|
||||
// Disable the indexer and do updates
|
||||
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.setEnableIndexing(false);
|
||||
|
||||
// one unchanged
|
||||
|
||||
// two snap shot
|
||||
avmService.createSnapshot("two", null, null);
|
||||
|
||||
// three update and snapshot
|
||||
|
||||
avmService.createDirectory("three:/", "a");
|
||||
avmService.createSnapshot("three", null, null);
|
||||
|
||||
// four create
|
||||
|
||||
avmService.createStore("four");
|
||||
avmService.createDirectory("four:/", "a");
|
||||
avmService.createSnapshot("four", null, null);
|
||||
avmService.createDirectory("four:/", "b");
|
||||
avmService.createSnapshot("four", null, null);
|
||||
|
||||
//
|
||||
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
|
||||
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("four"));
|
||||
|
||||
avmSnapShotTriggeredIndexingMethodInterceptor.setEnableIndexing(true);
|
||||
|
||||
AVMRemoteSnapshotTracker tracker = new AVMRemoteSnapshotTracker();
|
||||
tracker.setAuthenticationComponent(authenticationComponent);
|
||||
tracker.setAvmService(avmService);
|
||||
tracker.setAvmSnapShotTriggeredIndexingMethodInterceptor(avmSnapShotTriggeredIndexingMethodInterceptor);
|
||||
tracker.setTransactionService((TransactionServiceImpl) transactionService);
|
||||
tracker.setFtsIndexer(ftsIndexer);
|
||||
tracker.setIndexer(indexer);
|
||||
tracker.setNodeDaoService(nodeDaoService);
|
||||
tracker.setNodeService(nodeService);
|
||||
tracker.setSearcher(searchService);
|
||||
|
||||
tracker.reindex();
|
||||
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
|
||||
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("four"));
|
||||
}
|
||||
|
||||
}
|
@@ -469,6 +469,7 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.flushPending();
|
||||
return avmIndexer.hasIndexBeenCreated(store);
|
||||
}
|
||||
return false;
|
||||
|
@@ -1545,16 +1545,30 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasIndexBeenCreated(String store)
|
||||
{
|
||||
IndexReader mainReader = null;
|
||||
return hasIndexBeenCreatedimpl(store, IndexChannel.MAIN) || hasIndexBeenCreatedimpl(store, IndexChannel.DELTA);
|
||||
}
|
||||
|
||||
public boolean hasIndexBeenCreatedimpl(String store, IndexChannel channel)
|
||||
{
|
||||
IndexReader reader = null;
|
||||
try
|
||||
{
|
||||
mainReader = getReader();
|
||||
if (channel == IndexChannel.DELTA)
|
||||
{
|
||||
flushPending();
|
||||
reader = getDeltaReader();
|
||||
}
|
||||
else
|
||||
{
|
||||
reader = getReader();
|
||||
}
|
||||
TermDocs termDocs = null;
|
||||
try
|
||||
{
|
||||
termDocs = mainReader.termDocs(new Term("ISROOT", "T"));
|
||||
termDocs = reader.termDocs(new Term("ISROOT", "T"));
|
||||
return termDocs.next();
|
||||
}
|
||||
finally
|
||||
@@ -1573,9 +1587,17 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mainReader != null)
|
||||
|
||||
if (reader != null)
|
||||
{
|
||||
mainReader.close();
|
||||
if (channel == IndexChannel.DELTA)
|
||||
{
|
||||
closeDeltaReader();
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
@@ -35,7 +35,6 @@ import java.util.Set;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.node.integrity.IntegrityChecker;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneIndexerAndSearcher;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -352,22 +351,13 @@ public abstract class AlfrescoTransactionSupport
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush in-transaction resources. A transaction must be active.
|
||||
* <p>
|
||||
* The flush may include:
|
||||
* <ul>
|
||||
* <li>{@link TransactionalDao#flush()}</li>
|
||||
* <li>{@link RuleService#executePendingRules()}</li>
|
||||
* <li>{@link IntegrityChecker#checkIntegrity()}</li>
|
||||
* </ul>
|
||||
* No-op
|
||||
*
|
||||
* @deprecated No longer does anything
|
||||
*/
|
||||
public static void flush()
|
||||
{
|
||||
// get transaction-local synchronization
|
||||
TransactionSynchronizationImpl synch = getSynchronization();
|
||||
// flush
|
||||
synch.flush();
|
||||
// No-op
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,15 +538,6 @@ public abstract class AlfrescoTransactionSupport
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the in-transaction flushing. Typically done during a transaction or
|
||||
* before commit.
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
throw new UnsupportedOperationException("Manual flush no longer supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AlfrescoTransactionSupport#SESSION_SYNCHRONIZATION_ORDER
|
||||
*/
|
||||
@@ -589,7 +570,7 @@ public abstract class AlfrescoTransactionSupport
|
||||
/**
|
||||
* Pre-commit cleanup.
|
||||
* <p>
|
||||
* Ensures that the session resources are {@link #flush() flushed}.
|
||||
* Ensures that the session transaction listeners are property executed.
|
||||
* The Lucene indexes are then prepared.
|
||||
*/
|
||||
@Override
|
||||
|
@@ -157,10 +157,6 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
||||
// register it
|
||||
AlfrescoTransactionSupport.bindListener(listener);
|
||||
|
||||
// test flush
|
||||
AlfrescoTransactionSupport.flush();
|
||||
assertTrue("flush not called on listener", strings.contains("flush"));
|
||||
|
||||
// test commit
|
||||
txn.commit();
|
||||
assertTrue("beforeCommit not called on listener", strings.contains("beforeCommit"));
|
||||
|
@@ -34,11 +34,7 @@ package org.alfresco.repo.transaction;
|
||||
public interface TransactionListener
|
||||
{
|
||||
/**
|
||||
* Allows the listener to flush any consuming resources. This mechanism is
|
||||
* used primarily during long-lived transactions to ensure that system resources
|
||||
* are not used up.
|
||||
* <p>
|
||||
* This method must not be used for implementing business logic.
|
||||
* @deprecated No longer supported
|
||||
*/
|
||||
void flush();
|
||||
|
||||
|
@@ -13,3 +13,4 @@ description=cm:description
|
||||
multi-value-text=test:multi-value-text
|
||||
multi-value-node=test:multi-value-node
|
||||
complex-node=test:complex-node
|
||||
element-name=test:element-name
|
||||
|
@@ -11,3 +11,4 @@ description=/projectDescription/comment/text()
|
||||
multi-value-text=/projectDescription/natures/nature/text()
|
||||
multi-value-node=/projectDescription/natures/nature
|
||||
complex-node=/projectDescription/natures
|
||||
element-name=name(/projectDescription)
|
Reference in New Issue
Block a user