diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml index 50692671b4..17cae555db 100644 --- a/config/alfresco/action-services-context.xml +++ b/config/alfresco/action-services-context.xml @@ -27,10 +27,10 @@ deploymentAsyncAction - 2 + ${deployment.service.corePoolSize} - 3 + ${deployment.service.maximumPoolSize} diff --git a/config/alfresco/deployment-service-context.xml b/config/alfresco/deployment-service-context.xml index 128190fbb0..22a2edad0c 100644 --- a/config/alfresco/deployment-service-context.xml +++ b/config/alfresco/deployment-service-context.xml @@ -72,7 +72,7 @@ - 5 + ${deployment.service.numberOfSendingThreads} diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index ffafeab5b7..4e2f41a4bd 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -387,4 +387,10 @@ subsystems.test.beanProp=inst1,inst2,inst3 subsystems.test.beanProp.value.inst2.boolProperty=true subsystems.test.beanProp.value.inst3.anotherStringProperty=Global Instance Default subsystems.test.simpleProp2=true -subsystems.test.simpleProp3=Global Default3 \ No newline at end of file +subsystems.test.simpleProp3=Global Default3 + +# Deployment Service +deployment.service.numberOfSendingThreads=5 +deployment.service.corePoolSize=2 +deployment.service.maximumPoolSize=3 + diff --git a/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java b/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java index 0d5c1f74ff..60422d1f06 100644 --- a/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java +++ b/source/java/org/alfresco/repo/deploy/DeploymentServiceImpl.java @@ -318,47 +318,6 @@ public class DeploymentServiceImpl implements DeploymentService throw new AVMWrongTypeException("Not a directory: " + srcPath); } - // Get the root of the deployment on the destination server. - if (createdRoot) - { - /** - * This is the first deployment - */ - if (dontDo) - { - fgLogger.debug("dont do specified returning"); - return; - } - - /** - * Copy the new directory - */ - fgLogger.debug("start copying to remote"); - final AVMNodeDescriptor dstParentNode = dstRoot; - RetryingTransactionCallback copyContents = new RetryingTransactionCallback() - { - public Integer execute() throws Throwable - { - copyDirectory(srcVersion, srcRoot, dstParentNode, remote, matcher, callbacks); - return new Integer(0); - } - }; - trn.setMaxRetries(1); - version = trn.doInTransaction(copyContents, false, true).intValue(); - - fgLogger.debug("finished copying, snapshot remote"); - remote.createSnapshot(storePath[0], "Deployment", "Post Deployment Snapshot."); - if (callbacks != null) - { - DeploymentEvent event = new DeploymentEvent(DeploymentEvent.Type.END, - new Pair(version, srcPath), - dstPath); - processEvent(event, callbacks); - - } - return; - } - /** * The destination directory exists - check is actually a directory */ @@ -459,6 +418,19 @@ public class DeploymentServiceImpl implements DeploymentService SortedMap srcList = fAVMService.getDirectoryListing(src); // Get the listing for the destination. SortedMap dstList = remote.getDirectoryListing(dst); + + // Strip out stale nodes. + for (Map.Entry entry : srcList.entrySet()) + { + String name = entry.getKey(); + AVMNodeDescriptor srcNode = entry.getValue(); + + if(isStale(srcNode)) + { + srcList.remove(name); + } + } + for (Map.Entry entry : srcList.entrySet()) { String name = entry.getKey(); @@ -466,6 +438,12 @@ public class DeploymentServiceImpl implements DeploymentService AVMNodeDescriptor dstNode = dstList.get(name); if (!excluded(matcher, srcNode.getPath(), dstNode != null ? dstNode.getPath() : null)) { + if(isStale(srcNode)) + { + fgLogger.debug("stale file not added" + srcNode); + continue; + } + deploySinglePush(version, srcNode, dst, dstNode, remote, matcher, dontDelete, dontDo, callbacks); } } @@ -661,7 +639,14 @@ public class DeploymentServiceImpl implements DeploymentService { if (!excluded(matcher, child.getPath(), null)) { - + /** + * Temporary work around for staleness. + */ + if(isStale(child)) + { + fgLogger.debug("stale file ignored" + child); + continue; + } // If it's a file, copy it over and move on. if (child.isFile()) @@ -1178,7 +1163,8 @@ public class DeploymentServiceImpl implements DeploymentService Object[] objs = { srcPath, target, version, adapterName, hostName, port, e }; throw new AVMException(f.format(objs), e); } - } + } + private class ComparatorFileDescriptorCaseSensitive implements Comparator { @@ -1252,6 +1238,22 @@ public class DeploymentServiceImpl implements DeploymentService if (srcIter.hasNext()) { src = srcIter.next(); + + /** + * Temporary check for stale assets + * + * Correct fix would be to remove stale files from the snapshot. + * Code becomes obsolete once stale files are not part of the snapshot. + */ + if(isStale(src)) + { + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug("Stale content found" + src); + } + src = null; + continue; + } } } if (dst == null) @@ -1273,12 +1275,7 @@ public class DeploymentServiceImpl implements DeploymentService { String newDstPath = extendPath(dstPath, dst.getName()); if (!excluded(matcher, null, newDstPath)) - { -// service.delete(ticket, newDstPath); -// eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.DELETED, -// new Pair(version, extendPath(srcPath, dst.getName())), -// newDstPath)); - + { sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, new Pair(version, extendPath(srcPath, dst.getName())), newDstPath), ticket)); @@ -1311,13 +1308,19 @@ public class DeploymentServiceImpl implements DeploymentService } if (diff == 0) { - // src and dst have same file name + /** + * src and dst have same file name and GUID - nothing to do + */ if (src.getGuid().equals(dst.getGUID())) - { + { src = null; dst = null; continue; } + + /** + * src and dst are different and src is a file + */ if (src.isFile()) { // this is an update to a file @@ -1334,7 +1337,10 @@ public class DeploymentServiceImpl implements DeploymentService dst = null; continue; } - // Source is a directory. + + /** + * src and dst are different and src is a directory + */ if (dst.getType() == FileType.DIR) { String extendedPath = extendPath(dstPath, dst.getName()); @@ -1364,17 +1370,13 @@ public class DeploymentServiceImpl implements DeploymentService dst = null; continue; } - // diff > 0 - // Destination is missing in source, delete it. + + /** + * diff > 0 + * Destination is missing in source, delete it. + */ String newDstPath = extendPath(dstPath, dst.getName()); - // service.delete(ticket, newDstPath); -// -// eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.DELETED, -// new Pair(version, extendPath(srcPath, dst.getName())), -// newDstPath)); - - // sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, new Pair(version, extendPath(srcPath, dst.getName())), newDstPath), ticket)); @@ -1850,4 +1852,25 @@ public class DeploymentServiceImpl implements DeploymentService } } } + + private boolean isStale(AVMNodeDescriptor avmRef) + { + // note: currently specific to WCM use-cases, eg. ETHREEOH-2758 + if ((avmRef.isLayeredDirectory() && avmRef.isPrimary()) || avmRef.isLayeredFile()) + { + AVMNodeDescriptor parentNode = avmRef; + + while((parentNode.isLayeredDirectory() && parentNode.isPrimary()) || parentNode.isLayeredFile()) + { + AVMNodeDescriptor childNode = fAVMService.lookup(avmRef.getIndirectionVersion(), avmRef.getIndirection()); + if(childNode == null) + { + // The child node is missing + return true; + } + parentNode = childNode; + } + } + return false; + } }