Adjusted AVMCrawlTestPP to be more stringent now that we have retryin

transactions.
History is noww correctly maintained for cases of deletes followed by renames
or creates.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4587 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-12-12 21:09:07 +00:00
parent 24a00b201f
commit 7f8c678bd5
5 changed files with 85 additions and 29 deletions

View File

@@ -35,8 +35,8 @@ public class AVMCrawlTestP extends AVMServiceTestBase
*/ */
public void testCrawl() public void testCrawl()
{ {
int n = 8; // Number of Threads. int n = 4; // Number of Threads.
int m = 32; // How many multiples of content to start with. int m = 16; // How many multiples of content to start with.
long runTime = 3600000; // 6 hours. long runTime = 3600000; // 6 hours.
fService.purgeAVMStore("main"); fService.purgeAVMStore("main");
BulkLoader loader = new BulkLoader(); BulkLoader loader = new BulkLoader();

View File

@@ -31,9 +31,7 @@ import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.ContentIOException;
import org.hibernate.HibernateException;
import org.springframework.dao.ConcurrencyFailureException;
/** /**
@@ -230,22 +228,14 @@ class AVMCrawler implements Runnable
{ {
return; return;
} }
if (e instanceof ContentIOException)
{
return;
}
if (e instanceof AlfrescoRuntimeException) if (e instanceof AlfrescoRuntimeException)
{ {
return; return;
} }
if (e instanceof ConcurrencyFailureException)
{
return;
}
if (e instanceof HibernateException)
{
return;
}
if (e instanceof InvalidNodeRefException)
{
return;
}
throw new AVMException("Failure", e); throw new AVMException("Failure", e);
} }
} }

View File

@@ -596,11 +596,12 @@ public class AVMRepository
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode(); DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
AVMNode dstNode = dstDir.lookupChild(dPath, dstName, false); AVMNode child = dstDir.lookupChild(dPath, dstName, true);
if (dstNode != null) if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Node exists: " + dstName); throw new AVMExistsException("Node exists: " + dstName);
} }
AVMNode dstNode = null;
// We've passed the check, so we can go ahead and do the rename. // We've passed the check, so we can go ahead and do the rename.
if (srcNode.getType() == AVMNodeType.PLAIN_DIRECTORY) if (srcNode.getType() == AVMNodeType.PLAIN_DIRECTORY)
{ {
@@ -682,9 +683,16 @@ public class AVMRepository
srcDir.removeChild(sPath, srcName); srcDir.removeChild(sPath, srcName);
srcDir.updateModTime(); srcDir.updateModTime();
dstNode.setVersionID(dstRepo.getNextVersionID()); dstNode.setVersionID(dstRepo.getNextVersionID());
if (child != null)
{
dstNode.setAncestor(child);
}
dstDir.putChild(dstName, dstNode); dstDir.putChild(dstName, dstNode);
dstDir.updateModTime(); dstDir.updateModTime();
dstNode.setAncestor(srcNode); if (child == null)
{
dstNode.setAncestor(srcNode);
}
} }
finally finally
{ {

View File

@@ -71,6 +71,39 @@ import org.alfresco.util.Pair;
*/ */
public class AVMServiceTest extends AVMServiceTestBase public class AVMServiceTest extends AVMServiceTestBase
{ {
/**
* Test relinking of nodes to history.
*/
public void testHistoryRelink()
{
try
{
setupBasicTree();
fService.createAVMStore("branch");
fService.createBranch(-1, "main:/a", "branch:/", "a");
fService.removeNode("branch:/a/b/c/foo");
List<AVMDifference> diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
assertEquals(1, diffs.size());
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
fService.createFile("branch:/a/b/c", "foo").close();
diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
assertEquals(1, diffs.size());
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
fSyncService.update(diffs, null, false, false, false, false, null, null);
fService.removeNode("branch:/a/b/c/bar");
fService.createFile("branch:/a/b/c", "pismo").close();
fService.rename("branch:/a/b/c", "pismo", "branch:/a/b/c", "bar");
diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
assertEquals(1, diffs.size());
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
/** /**
* Test renaming a store. * Test renaming a store.
*/ */
@@ -775,13 +808,13 @@ public class AVMServiceTest extends AVMServiceTestBase
{ {
// Do nothing. // Do nothing.
} }
// Get synced again by doing an override conflict. // Get synced again by doing an override older.
System.out.println(recursiveList("main", -1, true)); System.out.println(recursiveList("main", -1, true));
diffs.clear(); diffs.clear();
diffs.add(new AVMDifference(-1, "main:/a/monkey", diffs.add(new AVMDifference(-1, "main:/a/monkey",
-1, "main:/abranch/monkey", -1, "main:/abranch/monkey",
AVMDifference.NEWER)); AVMDifference.NEWER));
fSyncService.update(diffs, null, false, false, true, false, null, null); fSyncService.update(diffs, null, false, false, false, true, null, null);
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size()); assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
fService.createSnapshot("main", null, null); fService.createSnapshot("main", null, null);
System.out.println(recursiveList("main", -1, true)); System.out.println(recursiveList("main", -1, true));
@@ -859,13 +892,13 @@ public class AVMServiceTest extends AVMServiceTestBase
{ {
// Do nothing. // Do nothing.
} }
// Get synced again by doing an override conflict. // Get synced again by doing an override older.
System.out.println(recursiveList("main", -1, true)); System.out.println(recursiveList("main", -1, true));
diffs.clear(); diffs.clear();
diffs.add(new AVMDifference(-1, "main:/a/monkey", diffs.add(new AVMDifference(-1, "main:/a/monkey",
-1, "main:/layer/monkey", -1, "main:/layer/monkey",
AVMDifference.NEWER)); AVMDifference.NEWER));
fSyncService.update(diffs, null, false, false, true, false, null, null); fSyncService.update(diffs, null, false, false, false, true, null, null);
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size()); assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
fService.createSnapshot("main", null, null); fService.createSnapshot("main", null, null);
System.out.println(recursiveList("main", -1, true)); System.out.println(recursiveList("main", -1, true));

View File

@@ -214,7 +214,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, false) != null) AVMNode child = dir.lookupChild(lPath, name, true);
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -232,6 +233,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
newDir = new PlainDirectoryNodeImpl(this); newDir = new PlainDirectoryNodeImpl(this);
} }
newDir.setVersionID(getNextVersionID()); newDir.setVersionID(getNextVersionID());
if (child != null)
{
newDir.setAncestor(child);
}
dir.putChild(name, newDir); dir.putChild(name, newDir);
dir.updateModTime(); dir.updateModTime();
} }
@@ -251,7 +256,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, false) != null) AVMNode child = dir.lookupChild(lPath, name, true);
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -270,6 +276,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
// Otherwise we issue a brand new layer id. // Otherwise we issue a brand new layer id.
newDir.setLayerID(fAVMRepository.issueLayerID()); newDir.setLayerID(fAVMRepository.issueLayerID());
} }
if (child != null)
{
newDir.setAncestor(child);
}
dir.putChild(name, newDir); dir.putChild(name, newDir);
dir.updateModTime(); dir.updateModTime();
newDir.setVersionID(getNextVersionID()); newDir.setVersionID(getNextVersionID());
@@ -289,7 +299,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, false) != null) AVMNode child = dir.lookupChild(lPath, name, true);
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -297,6 +308,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
file.setVersionID(getNextVersionID()); file.setVersionID(getNextVersionID());
dir.putChild(name, file); dir.putChild(name, file);
dir.updateModTime(); dir.updateModTime();
if (child != null)
{
file.setAncestor(child);
}
file.setContentData(new ContentData(null, file.setContentData(new ContentData(null,
RawServices.Instance().getMimetypeService().guessMimetype(name), RawServices.Instance().getMimetypeService().guessMimetype(name),
-1, -1,
@@ -319,7 +334,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, false) != null) AVMNode child = dir.lookupChild(lPath, name, true);
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
@@ -327,6 +343,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
file.setVersionID(getNextVersionID()); file.setVersionID(getNextVersionID());
dir.putChild(name, file); dir.putChild(name, file);
dir.updateModTime(); dir.updateModTime();
if (child != null)
{
file.setAncestor(child);
}
file.setContentData(new ContentData(null, file.setContentData(new ContentData(null,
RawServices.Instance().getMimetypeService().guessMimetype(name), RawServices.Instance().getMimetypeService().guessMimetype(name),
-1, -1,
@@ -349,13 +369,18 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path not found."); throw new AVMNotFoundException("Path not found.");
} }
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode(); DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
if (dir.lookupChild(lPath, name, false) != null) AVMNode child = dir.lookupChild(lPath, name, true);
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{ {
throw new AVMExistsException("Child exists: " + name); throw new AVMExistsException("Child exists: " + name);
} }
// TODO Reexamine decision to not check validity of srcPath. // TODO Reexamine decision to not check validity of srcPath.
LayeredFileNodeImpl newFile = LayeredFileNodeImpl newFile =
new LayeredFileNodeImpl(srcPath, this); new LayeredFileNodeImpl(srcPath, this);
if (child != null)
{
newFile.setAncestor(child);
}
dir.putChild(name, newFile); dir.putChild(name, newFile);
dir.updateModTime(); dir.updateModTime();
newFile.setVersionID(getNextVersionID()); newFile.setVersionID(getNextVersionID());