diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml
index 5cdc9ddc91..2eed041490 100644
--- a/config/alfresco/avm-services-context.xml
+++ b/config/alfresco/avm-services-context.xml
@@ -146,14 +146,8 @@
-
- 50
-
-
-
-
-
-
+
+
@@ -290,6 +284,9 @@
+
+
+
diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml
index 180340b0c2..1f8f04b81e 100644
--- a/config/alfresco/cache-context.xml
+++ b/config/alfresco/cache-context.xml
@@ -244,7 +244,36 @@
10
-
+
+
+
+
+
+
+
+
+
+
+ org.alfresco.repo.avm.lookupSharedCache
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.alfresco.repo.avm.lookupTransactionalCache
+
+
+ 50
+
+
diff --git a/config/alfresco/file-servers.xml b/config/alfresco/file-servers.xml
index 94d80de702..1966844b43 100644
--- a/config/alfresco/file-servers.xml
+++ b/config/alfresco/file-servers.xml
@@ -2,7 +2,7 @@
-
+
Alfresco CIFS Server
diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml
index eef4296cf1..27efcd4982 100644
--- a/config/alfresco/public-services-context.xml
+++ b/config/alfresco/public-services-context.xml
@@ -795,9 +795,6 @@
-
-
-
diff --git a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java b/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
index 33860c3567..e99217ff7d 100644
--- a/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
+++ b/source/java/org/alfresco/repo/avm/AVMExpiredContentProcessor.java
@@ -48,6 +48,7 @@ import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
+import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -86,6 +87,7 @@ public class AVMExpiredContentProcessor
protected Map>> expiredContent;
protected AVMService avmService;
protected AVMSyncService avmSyncService;
+ protected AVMService avmLockingAwareService;
protected NodeService nodeService;
protected WorkflowService workflowService;
protected PersonService personService;
@@ -157,6 +159,11 @@ public class AVMExpiredContentProcessor
{
this.searchService = searchService;
}
+
+ public void setAvmLockingAwareService(AVMService avmLockingAwareService)
+ {
+ this.avmLockingAwareService = avmLockingAwareService;
+ }
/**
* Executes the expired content processor.
@@ -305,7 +312,7 @@ public class AVMExpiredContentProcessor
if (logger.isDebugEnabled())
logger.debug("Examining expiration date for '" + nodePath + "': " +
- expirationDateProp.getStringValue());
+ expirationDateProp);
if (expirationDateProp != null)
{
@@ -465,10 +472,10 @@ public class AVMExpiredContentProcessor
String path = workflowStoreName + ":/" + JNDIConstants.DIR_DEFAULT_WWW +
"/" + JNDIConstants.DIR_DEFAULT_APPBASE;
// DNS name mangle the property name - can only contain value DNS characters!
- String dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(userStore, packageName);
+ String dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(stagingStore, packageName);
this.avmService.setStoreProperty(workflowStoreName, QName.createQName(null, dnsProp),
new PropertyValue(DataTypeDefinition.TEXT, path));
-
+
// the main workflow store depends on the main user store (dist=1)
String prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + userStore;
this.avmService.setStoreProperty(workflowStoreName, QName.createQName(null, prop_key),
@@ -560,11 +567,10 @@ public class AVMExpiredContentProcessor
String pathInWorkflowStore = workflowStoreName + ":" + relPath;
// call forceCopy to make sure the path appears modified in the workflow
- // sandbox, if the item is already modified or deleted this call has no
- // effect.
- this.avmService.forceCopy(pathInWorkflowStore);
+ // sandbox, if the item is already modified or deleted this call has no effect.
+ this.avmLockingAwareService.forceCopy(pathInWorkflowStore);
}
-
+
// convert package to workflow package
AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath);
NodeRef packageNodeRef = workflowService.createPackage(
diff --git a/source/java/org/alfresco/repo/avm/AVMLookupCacheListener.java b/source/java/org/alfresco/repo/avm/AVMLookupCacheListener.java
deleted file mode 100644
index 8b1aa5f4ef..0000000000
--- a/source/java/org/alfresco/repo/avm/AVMLookupCacheListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- */
-package org.alfresco.repo.avm;
-
-import org.alfresco.repo.transaction.TransactionListenerAdapter;
-
-/**
- * This is the listener that cleans up the lookup cache on transaction
- * rollback.
- * @author britt
- */
-public class AVMLookupCacheListener extends TransactionListenerAdapter
-{
- /**
- * The lookup cache.
- */
- private LookupCache fLookupCache;
-
- /**
- * A default constructor.
- */
- public AVMLookupCacheListener()
- {
- }
-
- /**
- * Set the Lookup Cache.
- * @param lookupCache
- */
- public void setLookupCache(LookupCache lookupCache)
- {
- fLookupCache = lookupCache;
- }
-
- /* (non-Javadoc)
- * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterRollback()
- */
- @Override
- public void afterRollback()
- {
- fLookupCache.onRollback();
- }
-
- /* (non-Javadoc)
- * @see org.alfresco.repo.transaction.TransactionListenerAdapter#afterCommit()
- */
- @Override
- public void afterCommit()
- {
- fLookupCache.onCommit();
- }
-}
diff --git a/source/java/org/alfresco/repo/avm/AVMRepository.java b/source/java/org/alfresco/repo/avm/AVMRepository.java
index 5e89be0eab..b51e183dae 100644
--- a/source/java/org/alfresco/repo/avm/AVMRepository.java
+++ b/source/java/org/alfresco/repo/avm/AVMRepository.java
@@ -633,7 +633,6 @@ public class AVMRepository
{
throw new AVMNotFoundException("Store not found.");
}
- fLookupCache.onDelete(pathParts[0]);
sPath = srcRepo.lookupDirectory(-1, pathParts[1], true);
if (sPath == null)
{
@@ -645,6 +644,7 @@ public class AVMRepository
{
throw new AVMNotFoundException("Not found: " + srcName);
}
+ fLookupCache.onDelete(pathParts[0]);
}
finally
{
@@ -659,7 +659,6 @@ public class AVMRepository
{
throw new AVMNotFoundException("Store not found.");
}
- fLookupCache.onWrite(pathParts[0]);
Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true);
if (dPath == null)
{
@@ -761,6 +760,7 @@ public class AVMRepository
{
dstNode.setAncestor(srcNode);
}
+ fLookupCache.onWrite(pathParts[0]);
}
finally
{
@@ -808,10 +808,10 @@ public class AVMRepository
{
throw new AVMNotFoundException("Store not found.");
}
- fLookupCache.onSnapshot(storeName);
Map result = store.createSnapshot(tag, description, new HashMap());
for (Map.Entry entry : result.entrySet())
{
+ fLookupCache.onSnapshot(entry.getKey());
fCreateVersionTxnListener.versionCreated(entry.getKey(), entry.getValue());
}
return result;
@@ -1639,18 +1639,33 @@ public class AVMRepository
*/
public Lookup lookupDirectory(int version, String path)
{
- fLookupCount.set(fLookupCount.get() + 1);
- if (fLookupCount.get() > 50)
+ Integer count = fLookupCount.get();
+ try
{
- throw new AVMCycleException("Cycle in lookup.");
+ if (count == null)
+ {
+ fLookupCount.set(1);
+ }
+ fLookupCount.set(fLookupCount.get() + 1);
+ if (fLookupCount.get() > 50)
+ {
+ throw new AVMCycleException("Cycle in lookup.");
+ }
+ String [] pathParts = SplitPath(path);
+ AVMStore store = getAVMStoreByName(pathParts[0]);
+ if (store == null)
+ {
+ return null;
+ }
+ return store.lookupDirectory(version, pathParts[1], false);
}
- String [] pathParts = SplitPath(path);
- AVMStore store = getAVMStoreByName(pathParts[0]);
- if (store == null)
+ finally
{
- return null;
+ if (count == null)
+ {
+ fLookupCount.set(null);
+ }
}
- return store.lookupDirectory(version, pathParts[1], false);
}
/**
diff --git a/source/java/org/alfresco/repo/avm/AVMScaleTestP.java b/source/java/org/alfresco/repo/avm/AVMScaleTestP.java
index 3dfb0a2035..ea0cf9ec6b 100644
--- a/source/java/org/alfresco/repo/avm/AVMScaleTestP.java
+++ b/source/java/org/alfresco/repo/avm/AVMScaleTestP.java
@@ -36,12 +36,12 @@ public class AVMScaleTestP extends AVMServiceTestBase
{
public void testScaling()
{
- int n = 4; // The number of BulkLoads to do.
+ int n = 250; // The number of BulkLoads to do.
int futzCount = 10; // The number of post snapshot modifications to make after each load.
String load = "/Users/britt/hibernate-3.1"; // The tree of stuff to load.
BulkLoader loader = new BulkLoader();
loader.setAvmService(fService);
- loader.setPropertyCount(5);
+ loader.setPropertyCount(50);
BulkReader reader = new BulkReader();
reader.setAvmService(fService);
long lastTime = System.currentTimeMillis();
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
index d2d6046457..a67ab64d15 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
@@ -36,8 +36,6 @@ import java.util.SortedMap;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.domain.PropertyValue;
-import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
-import org.alfresco.repo.transaction.TransactionListener;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMExistsException;
@@ -72,8 +70,6 @@ public class AVMServiceImpl implements AVMService
*/
private AVMRepository fAVMRepository;
- private TransactionListener fTransactionListener;
-
/**
* Basic constructor for the service.
*/
@@ -90,15 +86,6 @@ public class AVMServiceImpl implements AVMService
fAVMRepository = avmRepository;
}
- /**
- * Set the transaction listener.
- * @param transactionListener
- */
- public void setTransactionListener(TransactionListener transactionListener)
- {
- fTransactionListener = transactionListener;
- }
-
/**
* Get an InputStream from a file.
* @param version The version to look under.
@@ -139,7 +126,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.getOutputStream(path);
}
@@ -169,7 +155,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.createContentWriter(path);
}
@@ -361,7 +346,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.createFile(path, name);
}
@@ -378,7 +362,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
// Save the contents to temp space.
File temp;
try
@@ -419,7 +402,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createDirectory(path, name);
}
@@ -436,7 +418,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createLayeredFile(srcPath, parent, name);
}
@@ -453,7 +434,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createLayeredDirectory(srcPath, parent, name);
}
@@ -485,7 +465,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.createBranch(version, srcPath, dstPath, name);
}
@@ -501,7 +480,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.remove(parent, name);
}
@@ -520,7 +498,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Cannot remove root node: " + path);
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.remove(basePath[0], basePath[1]);
}
@@ -539,7 +516,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.rename(srcParent, srcName, dstParent, dstName);
}
@@ -554,7 +530,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.uncover(dirPath, name);
}
@@ -570,7 +545,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.flatten(dirPath, name);
}
@@ -616,7 +590,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Store is null.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.createSnapshot(store, tag, description);
}
@@ -861,7 +834,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.retargetLayeredDirectory(path, target);
}
@@ -875,7 +847,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Path is null.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.makePrimary(path);
}
@@ -967,7 +938,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setOpacity(path, opacity);
}
@@ -1018,7 +988,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setNodeProperty(path, name, value);
}
@@ -1033,7 +1002,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setNodeProperties(path, properties);
}
@@ -1091,7 +1059,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteNodeProperty(path, name);
}
@@ -1105,7 +1072,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteNodeProperties(path);
}
@@ -1208,7 +1174,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Invalid null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.deleteStoreProperty(store, name);
}
@@ -1250,7 +1215,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.getContentDataForWrite(path);
}
@@ -1268,7 +1232,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setContentData(path, data);
}
@@ -1283,7 +1246,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal null argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setMetaDataFrom(path, from);
}
@@ -1300,7 +1262,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.addAspect(path, aspectName);
}
@@ -1342,7 +1303,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.removeAspect(path, aspectName);
}
@@ -1374,7 +1334,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.link(parentPath, name, toLink);
}
@@ -1388,7 +1347,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Null Path.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
return fAVMRepository.forceCopy(path);
}
@@ -1427,7 +1385,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal name.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
AVMNodeDescriptor srcDesc = lookup(srcVersion, srcPath);
recursiveCopy(srcVersion, srcDesc, dstPath, name);
}
@@ -1508,7 +1465,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Cannot revert store root: " + path);
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.revert(baseName[0], baseName[1], toRevertTo);
}
@@ -1521,7 +1477,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setGuid(path, guid);
}
@@ -1534,7 +1489,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setEncoding(path, encoding);
}
@@ -1547,7 +1501,6 @@ public class AVMServiceImpl implements AVMService
{
throw new AVMBadArgumentException("Illegal Null Argument.");
}
- AlfrescoTransactionSupport.bindListener(fTransactionListener);
fAVMRepository.setMimeType(path, mimeType);
}
}
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
index ffd2ae9c40..f788bb9fbb 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
@@ -347,136 +347,6 @@ public class AVMServiceTest extends AVMServiceTestBase
}
- /**
- * Test async indexing.
- * @throws Exception
- */
- public void testAsyncIndex() throws Exception
- {
- // Make sure the slate is clean ...
- UserTransaction tx = fTransactionService.getUserTransaction();
- tx.begin();
- if(fService.getStore("avmAsynchronousTest") != null)
- {
- assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
- fService.purgeStore("avmAsynchronousTest");
- assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
- assertFalse(fIndexingInterceptor.hasIndexBeenCreated("bananaStoreWoof"));
- }
- else
- {
- assertFalse(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
- }
- StoreRef storeRef = AVMNodeConverter.ToStoreRef("avmAsynchronousTest");
- Indexer indexer = fIndexerAndSearcher.getIndexer(storeRef);
- if(indexer instanceof AVMLuceneIndexer)
- {
- AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer)indexer;
- avmIndexer.deleteIndex("avmAsynchronousTest", IndexMode.SYNCHRONOUS);
- }
- tx.commit();
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("bananaStoreWoof"));
- assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- tx.commit();
-
- // TODO: Suspend and resume indexing in case we are really unlucky and hit an index before we expect it.
-
- SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
- ResultSet results;
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(0, results.length());
- results.close();
-
- fService.createStore("avmAsynchronousTest");
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- tx.commit();
-
- fService.createSnapshot("avmAsynchronousTest", null, null);
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- tx.commit();
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(1, results.length());
- results.close();
-
- fService.createDirectory("avmAsynchronousTest:/", "a");
- fService.createDirectory("avmAsynchronousTest:/a", "b");
- fService.createDirectory("avmAsynchronousTest:/a/b", "c");
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
- tx.commit();
-
- fService.createSnapshot("avmAsynchronousTest", null, null);
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
- assertFalse(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
- assertEquals(IndexMode.ASYNCHRONOUS, fIndexingInterceptor.getIndexMode("avmAsynchronousTest"));
- assertEquals(IndexMode.SYNCHRONOUS, fIndexingInterceptor.getIndexMode("main"));
- assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 0));
- assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 1));
- assertFalse(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 2));
- tx.commit();
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(1, results.length());
- results.close();
-
- Thread.sleep(180000);
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(4, results.length());
- results.close();
-
-
- tx = fTransactionService.getUserTransaction();
- tx.begin();
- assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
- assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
- assertTrue(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
- tx.commit();
-
- fService.purgeStore("avmAsynchronousTest");
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(0, results.length());
- results.close();
-
- fService.createStore("avmAsynchronousTest");
- fService.createSnapshot("avmAsynchronousTest", null, null);
- fService.createDirectory("avmAsynchronousTest:/", "a");
- fService.createDirectory("avmAsynchronousTest:/a", "b");
- fService.createDirectory("avmAsynchronousTest:/a/b", "c");
- fService.createSnapshot("avmAsynchronousTest", null, null);
- fService.purgeStore("avmAsynchronousTest");
- fService.createStore("avmAsynchronousTest");
- fService.createSnapshot("avmAsynchronousTest", null, null);
- fService.createDirectory("avmAsynchronousTest:/", "a");
- fService.createDirectory("avmAsynchronousTest:/a", "b");
- fService.createDirectory("avmAsynchronousTest:/a/b", "c");
- fService.createSnapshot("avmAsynchronousTest", null, null);
-
- Thread.sleep(180000);
-
- results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
- assertEquals(4, results.length());
- results.close();
- }
public void testForceCopyDeleted()
{
@@ -537,8 +407,16 @@ public class AVMServiceTest extends AVMServiceTestBase
fService.createBranch(1, "layer:/root", "branch:/", "branch");
fService.createSnapshot("branch", null, null);
fService.getFileOutputStream("main:/a/b/c/foo").close();
+ System.out.println("main 1");
+ System.out.println(recursiveList("main", 1, true));
+ System.out.println("branch 1");
+ System.out.println(recursiveList("branch", 1, true));
assertEquals(fService.lookup(1, "main:/a/b/c/foo").getId(), fService.lookup(1,
"branch:/branch/layer/b/c/foo").getId());
+ System.out.println("main -1");
+ System.out.println(recursiveList("main", -1, true));
+ System.out.println("branch -1");
+ System.out.println(recursiveList("branch", -1, true));
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getId(), fService.lookup(-1,
"branch:/branch/layer/b/c/foo").getId());
}
@@ -5641,4 +5519,135 @@ public class AVMServiceTest extends AVMServiceTestBase
fail();
}
}
+
+ /**
+ * Test async indexing.
+ * @throws Exception
+ */
+ public void testAsyncIndex() throws Exception
+ {
+ // Make sure the slate is clean ...
+ UserTransaction tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ if(fService.getStore("avmAsynchronousTest") != null)
+ {
+ assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
+ fService.purgeStore("avmAsynchronousTest");
+ assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
+ assertFalse(fIndexingInterceptor.hasIndexBeenCreated("bananaStoreWoof"));
+ }
+ else
+ {
+ assertFalse(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
+ }
+ StoreRef storeRef = AVMNodeConverter.ToStoreRef("avmAsynchronousTest");
+ Indexer indexer = fIndexerAndSearcher.getIndexer(storeRef);
+ if(indexer instanceof AVMLuceneIndexer)
+ {
+ AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer)indexer;
+ avmIndexer.deleteIndex("avmAsynchronousTest", IndexMode.SYNCHRONOUS);
+ }
+ tx.commit();
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("bananaStoreWoof"));
+ assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ tx.commit();
+
+ // TODO: Suspend and resume indexing in case we are really unlucky and hit an index before we expect it.
+
+ SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
+ ResultSet results;
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(0, results.length());
+ results.close();
+
+ fService.createStore("avmAsynchronousTest");
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ tx.commit();
+
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ tx.commit();
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(1, results.length());
+ results.close();
+
+ fService.createDirectory("avmAsynchronousTest:/", "a");
+ fService.createDirectory("avmAsynchronousTest:/a", "b");
+ fService.createDirectory("avmAsynchronousTest:/a/b", "c");
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
+ tx.commit();
+
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
+ assertFalse(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
+ assertEquals(IndexMode.ASYNCHRONOUS, fIndexingInterceptor.getIndexMode("avmAsynchronousTest"));
+ assertEquals(IndexMode.SYNCHRONOUS, fIndexingInterceptor.getIndexMode("main"));
+ assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 0));
+ assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 1));
+ assertFalse(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 2));
+ tx.commit();
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(1, results.length());
+ results.close();
+
+ Thread.sleep(180000);
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(4, results.length());
+ results.close();
+
+
+ tx = fTransactionService.getUserTransaction();
+ tx.begin();
+ assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
+ assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
+ assertTrue(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
+ tx.commit();
+
+ fService.purgeStore("avmAsynchronousTest");
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(0, results.length());
+ results.close();
+
+ fService.createStore("avmAsynchronousTest");
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+ fService.createDirectory("avmAsynchronousTest:/", "a");
+ fService.createDirectory("avmAsynchronousTest:/a", "b");
+ fService.createDirectory("avmAsynchronousTest:/a/b", "c");
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+ fService.purgeStore("avmAsynchronousTest");
+ fService.createStore("avmAsynchronousTest");
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+ fService.createDirectory("avmAsynchronousTest:/", "a");
+ fService.createDirectory("avmAsynchronousTest:/a", "b");
+ fService.createDirectory("avmAsynchronousTest:/a/b", "c");
+ fService.createSnapshot("avmAsynchronousTest", null, null);
+
+ Thread.sleep(180000);
+
+ results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
+ assertEquals(4, results.length());
+ results.close();
+ }
}
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
index 6449c72d35..e5c9512296 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTestBase.java
@@ -24,7 +24,6 @@
package org.alfresco.repo.avm;
import java.io.IOException;
-import java.io.PrintStream;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -39,9 +38,7 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
-import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentWriter;
-import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
@@ -225,6 +222,7 @@ public class AVMServiceTestBase extends TestCase
Map listing = fService.getDirectoryListing(version, path, true);
for (String name : listing.keySet())
{
+ System.err.println(name);
builder.append(recursiveList(basename + name, version, indent + 2, followLinks));
}
}
diff --git a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
index ee0dca4b43..e6ab1900b6 100644
--- a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
@@ -214,11 +214,20 @@ public class AVMStoreImpl implements AVMStore, Serializable
{
continue;
}
+ fAVMRepository.forceCopy(entry.getPath());
+ // TODO This leaves the behavior of LayeredFiles not quite
+ // right.
+ /*
String parentName[] = AVMNodeConverter.SplitBase(entry.getPath());
parentName[0] = parentName[0].substring(parentName[0].indexOf(':') + 1);
lookup = lookupDirectory(-1, parentName[0], true);
DirectoryNode parent = (DirectoryNode)lookup.getCurrentNode();
AVMNode child = parent.lookupChild(lookup, parentName[1], false);
+ // TODO For debugging.
+ if (child == null)
+ {
+ System.err.println("Yoiks!");
+ }
// TODO This is funky. Need to look carefully to see that this call
// does exactly what's needed.
lookup.add(child, parentName[1], false);
@@ -232,6 +241,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
newChild = ((LayeredFileNode)child).copyLiterally(lookup);
}
parent.putChild(parentName[1], newChild);
+ */
}
// Clear out the new nodes.
List newInRep = AVMDAOs.Instance().fAVMNodeDAO.getNewInStore(this);
diff --git a/source/java/org/alfresco/repo/avm/Lookup.java b/source/java/org/alfresco/repo/avm/Lookup.java
index 9a50a3b9c5..e7320f55d0 100644
--- a/source/java/org/alfresco/repo/avm/Lookup.java
+++ b/source/java/org/alfresco/repo/avm/Lookup.java
@@ -23,6 +23,7 @@
package org.alfresco.repo.avm;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -34,8 +35,10 @@ import org.alfresco.util.Pair;
* from the root directory of a repository.
* @author britt
*/
-class Lookup
+class Lookup implements Serializable
{
+ private static final long serialVersionUID = -2844833688622561L;
+
/**
* Is this lookup valid?
*/
diff --git a/source/java/org/alfresco/repo/avm/LookupCache.java b/source/java/org/alfresco/repo/avm/LookupCache.java
index b966e14cc6..bca5443827 100644
--- a/source/java/org/alfresco/repo/avm/LookupCache.java
+++ b/source/java/org/alfresco/repo/avm/LookupCache.java
@@ -3,14 +3,11 @@
*/
package org.alfresco.repo.avm;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.ArrayList;
+import java.util.List;
import org.alfresco.repo.avm.util.SimplePath;
+import org.alfresco.repo.cache.SimpleCache;
import org.apache.log4j.Logger;
/**
@@ -21,42 +18,10 @@ public class LookupCache
{
private static Logger fgLogger = Logger.getLogger(LookupCache.class);
-
- /**
- * Per transaction lookup results to be added to the cache on successful
- * commit.
- */
- private ThreadLocal