Merged V3.2 to HEAD:

16653 : MERGED V3.1 To V3.2
        16351: ETHREEOH-2812 deployment batch file update
        16352: ETHREEOH-2772 ASR deployment wrong on first deployment
    16655 : MERGE 3.1 TO 3.2
        16303 - ETHREEOH-2758 FSR Deployment of stale files.
    16685  :ETHREEOH-2370 - Unable to set a number of threads in the Deployment

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16965 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2009-10-15 13:38:20 +00:00
parent f4563a2482
commit 330a50d85c
4 changed files with 94 additions and 65 deletions

View File

@@ -27,10 +27,10 @@
<value>deploymentAsyncAction</value> <value>deploymentAsyncAction</value>
</property> </property>
<property name="corePoolSize"> <property name="corePoolSize">
<value>2</value> <value>${deployment.service.corePoolSize}</value>
</property> </property>
<property name="maximumPoolSize"> <property name="maximumPoolSize">
<value>3</value> <value>${deployment.service.maximumPoolSize}</value>
</property> </property>
</bean> </bean>

View File

@@ -72,7 +72,7 @@
<!-- how many files to send in parallel --> <!-- how many files to send in parallel -->
<property name="numberOfSendingThreads"> <property name="numberOfSendingThreads">
<value>5</value> <value>${deployment.service.numberOfSendingThreads}</value>
</property> </property>
<!-- Which adapters are provided to communicate with remote File System Receivers --> <!-- Which adapters are provided to communicate with remote File System Receivers -->

View File

@@ -387,4 +387,10 @@ subsystems.test.beanProp=inst1,inst2,inst3
subsystems.test.beanProp.value.inst2.boolProperty=true subsystems.test.beanProp.value.inst2.boolProperty=true
subsystems.test.beanProp.value.inst3.anotherStringProperty=Global Instance Default subsystems.test.beanProp.value.inst3.anotherStringProperty=Global Instance Default
subsystems.test.simpleProp2=true subsystems.test.simpleProp2=true
subsystems.test.simpleProp3=Global Default3 subsystems.test.simpleProp3=Global Default3
# Deployment Service
deployment.service.numberOfSendingThreads=5
deployment.service.corePoolSize=2
deployment.service.maximumPoolSize=3

View File

@@ -318,47 +318,6 @@ public class DeploymentServiceImpl implements DeploymentService
throw new AVMWrongTypeException("Not a directory: " + srcPath); 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<Integer> copyContents = new RetryingTransactionCallback<Integer>()
{
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<Integer, String>(version, srcPath),
dstPath);
processEvent(event, callbacks);
}
return;
}
/** /**
* The destination directory exists - check is actually a directory * The destination directory exists - check is actually a directory
*/ */
@@ -459,6 +418,19 @@ public class DeploymentServiceImpl implements DeploymentService
SortedMap<String, AVMNodeDescriptor> srcList = fAVMService.getDirectoryListing(src); SortedMap<String, AVMNodeDescriptor> srcList = fAVMService.getDirectoryListing(src);
// Get the listing for the destination. // Get the listing for the destination.
SortedMap<String, AVMNodeDescriptor> dstList = remote.getDirectoryListing(dst); SortedMap<String, AVMNodeDescriptor> dstList = remote.getDirectoryListing(dst);
// Strip out stale nodes.
for (Map.Entry<String, AVMNodeDescriptor> entry : srcList.entrySet())
{
String name = entry.getKey();
AVMNodeDescriptor srcNode = entry.getValue();
if(isStale(srcNode))
{
srcList.remove(name);
}
}
for (Map.Entry<String, AVMNodeDescriptor> entry : srcList.entrySet()) for (Map.Entry<String, AVMNodeDescriptor> entry : srcList.entrySet())
{ {
String name = entry.getKey(); String name = entry.getKey();
@@ -466,6 +438,12 @@ public class DeploymentServiceImpl implements DeploymentService
AVMNodeDescriptor dstNode = dstList.get(name); AVMNodeDescriptor dstNode = dstList.get(name);
if (!excluded(matcher, srcNode.getPath(), dstNode != null ? dstNode.getPath() : null)) 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); 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)) 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 it's a file, copy it over and move on.
if (child.isFile()) if (child.isFile())
@@ -1178,7 +1163,8 @@ public class DeploymentServiceImpl implements DeploymentService
Object[] objs = { srcPath, target, version, adapterName, hostName, port, e }; Object[] objs = { srcPath, target, version, adapterName, hostName, port, e };
throw new AVMException(f.format(objs), e); throw new AVMException(f.format(objs), e);
} }
} }
private class ComparatorFileDescriptorCaseSensitive implements Comparator<FileDescriptor> private class ComparatorFileDescriptorCaseSensitive implements Comparator<FileDescriptor>
{ {
@@ -1252,6 +1238,22 @@ public class DeploymentServiceImpl implements DeploymentService
if (srcIter.hasNext()) if (srcIter.hasNext())
{ {
src = srcIter.next(); 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) if (dst == null)
@@ -1273,12 +1275,7 @@ public class DeploymentServiceImpl implements DeploymentService
{ {
String newDstPath = extendPath(dstPath, dst.getName()); String newDstPath = extendPath(dstPath, dst.getName());
if (!excluded(matcher, null, newDstPath)) if (!excluded(matcher, null, newDstPath))
{ {
// service.delete(ticket, newDstPath);
// eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.DELETED,
// new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
// newDstPath));
sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED,
new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())), new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
newDstPath), ticket)); newDstPath), ticket));
@@ -1311,13 +1308,19 @@ public class DeploymentServiceImpl implements DeploymentService
} }
if (diff == 0) 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())) if (src.getGuid().equals(dst.getGUID()))
{ {
src = null; src = null;
dst = null; dst = null;
continue; continue;
} }
/**
* src and dst are different and src is a file
*/
if (src.isFile()) if (src.isFile())
{ {
// this is an update to a file // this is an update to a file
@@ -1334,7 +1337,10 @@ public class DeploymentServiceImpl implements DeploymentService
dst = null; dst = null;
continue; continue;
} }
// Source is a directory.
/**
* src and dst are different and src is a directory
*/
if (dst.getType() == FileType.DIR) if (dst.getType() == FileType.DIR)
{ {
String extendedPath = extendPath(dstPath, dst.getName()); String extendedPath = extendPath(dstPath, dst.getName());
@@ -1364,17 +1370,13 @@ public class DeploymentServiceImpl implements DeploymentService
dst = null; dst = null;
continue; 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()); String newDstPath = extendPath(dstPath, dst.getName());
// service.delete(ticket, newDstPath);
//
// eventQueue.add(new DeploymentEvent(DeploymentEvent.Type.DELETED,
// new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
// newDstPath));
//
sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED, sendQueue.add(new DeploymentWork(new DeploymentEvent(DeploymentEvent.Type.DELETED,
new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())), new Pair<Integer, String>(version, extendPath(srcPath, dst.getName())),
newDstPath), ticket)); 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;
}
} }