Alfresco -> Alfresco deployment is smarter.

- The source store is implicitly snapshotted before deployment begins.
- The destination (remote) store is implicitly snapshotted before deployment begins
  and again when the deployment is finished.
- This means that comparison of GUIDs on directories can be used to short circuit
  the tree comparison.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5636 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2007-05-07 23:50:28 +00:00
parent c55d48a3e7
commit 072d642d65
3 changed files with 30 additions and 11 deletions

View File

@@ -143,35 +143,36 @@ public class AVMServiceTest extends AVMServiceTestBase
{
DeploymentService depService = (DeploymentService)fContext.getBean("DeploymentService");
setupBasicTree();
TestDeploymentCallback callback = new TestDeploymentCallback();
// TestDeploymentCallback callback = new TestDeploymentCallback();
fService.createStore("target");
DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
DeploymentReport report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, null);
System.out.println(report);
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getGuid(),
fService.lookup(-1, "target:/a/b/c/foo").getGuid());
assertEquals(fService.lookup(-1, "main:/a/b/c/bar").getGuid(),
fService.lookup(-1, "target:/a/b/c/bar").getGuid());
fService.createFile("main:/a/b", "biz").close();
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, true, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, true, null);
System.out.println(report);
System.out.println(recursiveList("target", -1, true));
assertNull(fService.lookup(-1, "target:/a/b/biz"));
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, null);
System.out.println(report);
assertEquals(fService.lookup(-1, "main:/a/b/biz").getGuid(),
fService.lookup(-1, "target:/a/b/biz").getGuid());
fService.removeNode("main:/a/b/c/foo");
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, true, false, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, true, false, null);
System.out.println(report);
assertNotNull(fService.lookup(-1, "target:/a/b/c/foo"));
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, null);
System.out.println(report);
assertNull(fService.lookup(-1, "target:/a/b/c/foo"));
fService.removeNode("main:/a/b/c/bar");
fService.createDirectory("main:/a/b/c", "bar");
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, null);
System.out.println(report);
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", true, false, false, callback);
report = depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target:/a", false, false, false, null);
depService.deployDifference(-1, "main:/a", "localhost", 50500, "admin", "admin", "target2:/wiggly/diggly", true, false, false, null);
System.out.println(report);
}
catch (Exception e)

View File

@@ -112,6 +112,11 @@ public class DeploymentServiceImpl implements DeploymentService
dstPath);
callback.eventOccurred(event);
}
if (version < 0)
{
String storeName = srcPath.substring(0, srcPath.indexOf(":"));
version = fAVMService.createSnapshot(storeName, null, null);
}
// Get the root of the deployment from this server.
AVMNodeDescriptor srcRoot = fAVMService.lookup(version, srcPath);
if (srcRoot == null)
@@ -143,6 +148,7 @@ public class DeploymentServiceImpl implements DeploymentService
}
}
snapshot = remote.createSnapshot(storePath[0], "PreDeploy", "Pre Deployment Snapshot");
}
// Get the root of the deployment on the destination server.
AVMNodeDescriptor dstRoot = remote.lookup(-1, dstPath);
@@ -163,6 +169,7 @@ public class DeploymentServiceImpl implements DeploymentService
return report;
}
copyDirectory(version, srcRoot, dstParent, remote);
remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot.");
if (callback != null)
{
event = new DeploymentEvent(DeploymentEvent.Type.END,
@@ -180,6 +187,7 @@ public class DeploymentServiceImpl implements DeploymentService
try
{
deployDirectoryPush(version, srcRoot, dstRoot, remote, dontDelete, dontDo, report, callback);
remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot.");
if (callback != null)
{
DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.END,
@@ -197,7 +205,7 @@ public class DeploymentServiceImpl implements DeploymentService
{
AVMSyncService syncService = getSyncService(hostName, port);
List<AVMDifference> diffs = syncService.compare(snapshot, dstPath, -1, dstPath, null);
syncService.update(diffs, null, false, false, true, true, "Abortd Deployment", "Aborted Deployment");
syncService.update(diffs, null, false, false, true, true, "Aborted Deployment", "Aborted Deployment");
}
}
catch (Exception ee)
@@ -227,6 +235,14 @@ public class DeploymentServiceImpl implements DeploymentService
DeploymentReport report,
DeploymentCallback callback)
{
if (src.getGuid().equals(dst.getGuid()))
{
return;
}
if (!dontDo && !dontDelete)
{
copyMetadata(version, src, dst, remote);
}
// Get the listing for the source.
SortedMap<String, AVMNodeDescriptor> srcList = fAVMService.getDirectoryListing(src);
// Get the listing for the destination.