Fix ALF-4291: PostgreSQL - AVM index/search

- don't need re-index snapshots backwards
- increase aync test delay

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22318 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2010-09-08 09:32:02 +00:00
parent 8c10779861
commit 8c74b0eacf
5 changed files with 82 additions and 53 deletions

View File

@@ -47,16 +47,18 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
public void test_CreateDelete() throws Exception public void test_CreateDelete() throws Exception
{ {
int threads= 4; int threads= 4;
int loops = 10; int loops = 10;
//int snapshotsPerLoop = 4; int snapshotsPerLoop = 4;
int snapshotsPerLoop = 1;
assertEquals(1, fService.getStoreVersions("main").size());
fService.createDirectory("main:/", "test"); fService.createDirectory("main:/", "test");
int startVersion = fService.createSnapshot("main", null, null).get("main"); int startVersion = fService.createSnapshot("main", null, null).get("main");
assertEquals(2, fService.getStoreVersions("main").size());
assertEquals(0, fService.getDirectoryListing(-1, "main:/test").size()); assertEquals(0, fService.getDirectoryListing(-1, "main:/test").size());
UserTransaction testTX = fTransactionService.getUserTransaction(); UserTransaction testTX = fTransactionService.getUserTransaction();
@@ -90,6 +92,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
} }
} }
System.out.println("Snapshot count: "+fService.getStoreVersions("main").size());
SortedMap<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/test"); SortedMap<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/test");
assertEquals(loops, listing.size()); assertEquals(loops, listing.size());
@@ -119,7 +123,6 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
testTX.commit(); testTX.commit();
// delete // delete
runner = null; runner = null;
@@ -143,6 +146,15 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
assertEquals(0, fService.getDirectoryListing(-1, "main:/test").size()); assertEquals(0, fService.getDirectoryListing(-1, "main:/test").size());
System.out.println("Snapshot count: "+fService.getStoreVersions("main").size());
/*
for(org.alfresco.service.cmr.avm.VersionDescriptor v : fService.getStoreVersions("main"))
{
System.out.println(v);
}
*/
testTX = fTransactionService.getUserTransaction(); testTX = fTransactionService.getUserTransaction();
testTX.begin(); testTX.begin();
@@ -160,13 +172,10 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
public void test_ALF_786() throws Exception public void test_ALF_786() throws Exception
{ {
//int threads= 4; int threads= 4;
int threads= 2;
int loops = 10; int loops = 10;
//int snapshotsPerLoop = 4; int snapshotsPerLoop = 4;
int snapshotsPerLoop = 1;
fService.createDirectory("main:/", "test"); fService.createDirectory("main:/", "test");
@@ -185,6 +194,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
testTX.commit(); testTX.commit();
// create
Thread runner = null; Thread runner = null;
for (int i = 0; i < threads; i++) for (int i = 0; i < threads; i++)
{ {
@@ -270,7 +281,7 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
results.close(); results.close();
testTX.commit(); testTX.commit();
// delete // delete
runner = null; runner = null;
for (int i = 0; i < threads; i++) for (int i = 0; i < threads; i++)
@@ -342,7 +353,7 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
testTX.commit(); testTX.commit();
//move // move
runner = null; runner = null;
for (int i = 0; i < threads; i++) for (int i = 0; i < threads; i++)
@@ -389,7 +400,6 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
testTX.commit(); testTX.commit();
testTX = fTransactionService.getUserTransaction(); testTX = fTransactionService.getUserTransaction();
testTX.begin(); testTX.begin();
StoreRef storeRef = AVMNodeConverter.ToStoreRef("main"); StoreRef storeRef = AVMNodeConverter.ToStoreRef("main");
SearchService searchService = fIndexerAndSearcher.getSearcher(AVMNodeConverter.ToStoreRef("main"), true); SearchService searchService = fIndexerAndSearcher.getSearcher(AVMNodeConverter.ToStoreRef("main"), true);
@@ -397,9 +407,9 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
assertEquals(0, results.length()); assertEquals(0, results.length());
results.close(); results.close();
testTX.commit(); testTX.commit();
Thread runner = null; Thread runner = null;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
runner = new Nester("Concurrent-" + i, runner, true, 10, Nester.Mode.CREATE, 10 ); runner = new Nester("Concurrent-" + i, runner, true, 10, Nester.Mode.CREATE, 10 );
@@ -407,7 +417,7 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
if (runner != null) if (runner != null)
{ {
runner.start(); runner.start();
try try
{ {
runner.join(); runner.join();
@@ -417,11 +427,12 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
e.printStackTrace(); e.printStackTrace();
} }
} }
testTX = fTransactionService.getUserTransaction(); testTX = fTransactionService.getUserTransaction();
testTX.begin(); testTX.begin();
// snap // snap
testTX.commit(); testTX.commit();
testTX = fTransactionService.getUserTransaction(); testTX = fTransactionService.getUserTransaction();
testTX.begin();; testTX.begin();;
SortedMap<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/test"); SortedMap<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, "main:/test");
@@ -456,7 +467,7 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
enum Mode {CREATE, UPDATE, DELETE, MOVE}; enum Mode {CREATE, UPDATE, DELETE, MOVE};
Thread waiter; Thread waiter;
int i; int i;
boolean multiThread; boolean multiThread;
@@ -477,7 +488,7 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
this.mode = mode; this.mode = mode;
this.loopCount = loopCount; this.loopCount = loopCount;
} }
public void run() public void run()
{ {
fAuthenticationComponent.setSystemUserAsCurrentUser(); fAuthenticationComponent.setSystemUserAsCurrentUser();
@@ -487,13 +498,16 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
} }
try try
{ {
System.out.println("Start " + this.getName()); //System.out.println("Start " + this.getName());
for(i = 0; i < loopCount; i++) for(i = 0; i < loopCount; i++)
{ {
RetryingTransactionCallback<Void> create = new RetryingTransactionCallback<Void>() RetryingTransactionCallback<Void> create = new RetryingTransactionCallback<Void>()
{ {
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
System.out.println("Create file: " + "main:/test/" + getName()+"-"+i);
fService.createFile("main:/test", getName()+"-"+i).close(); fService.createFile("main:/test", getName()+"-"+i).close();
return null; return null;
@@ -503,6 +517,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
{ {
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
System.out.println("Update file mime type: " + "main:/test/" + getName()+"-"+i);
fService.setMimeType("main:/test/"+getName()+"-"+i, "text/plain"); fService.setMimeType("main:/test/"+getName()+"-"+i, "text/plain");
return null; return null;
@@ -512,6 +528,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
{ {
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
System.out.println("Remove file: " + "main:/test/" + getName()+"-"+i);
fService.removeNode("main:/test/"+getName()+"-"+i); fService.removeNode("main:/test/"+getName()+"-"+i);
return null; return null;
@@ -521,6 +539,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
{ {
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
System.out.println("Rename file: " + "main:/test/" + getName()+"-"+i);
fService.rename("main:/test/", getName()+"-"+i, "main:/test/", "MOVED-"+getName()+"-"+i); fService.rename("main:/test/", getName()+"-"+i, "main:/test/", "MOVED-"+getName()+"-"+i);
return null; return null;
@@ -533,7 +553,6 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
{ {
case CREATE: case CREATE:
fRetryingTransactionHelper.doInTransaction(create); fRetryingTransactionHelper.doInTransaction(create);
System.out.println(getName()+i);
break; break;
case UPDATE: case UPDATE:
fRetryingTransactionHelper.doInTransaction(update); fRetryingTransactionHelper.doInTransaction(update);
@@ -553,6 +572,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
{ {
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
//System.out.println("Snap: main:/");
fService.createSnapshot("main", null, null); fService.createSnapshot("main", null, null);
return null; return null;
@@ -563,7 +584,8 @@ public class AVMServiceConcurrentTest extends AVMServiceTestBase
fRetryingTransactionHelper.doInTransaction(snap); fRetryingTransactionHelper.doInTransaction(snap);
} }
} }
System.out.println("End " + this.getName());
//System.out.println("End " + this.getName());
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -1,19 +1,19 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2010 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
* Alfresco is free software: you can redistribute it and/or modify * Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */ * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. */
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
@@ -39,7 +39,7 @@ public class AVMServiceIndexTest extends AVMServiceTestBase
private final static long REPEAT_INTERVAL_MSECS = 1000 * 60; private final static long REPEAT_INTERVAL_MSECS = 1000 * 60;
*/ */
private final static long SLEEP = 10000; private final static long SLEEP = 20000;
private final static long START_DELAY_MSECS = 2000; private final static long START_DELAY_MSECS = 2000;
private final static long REPEAT_INTERVAL_MSECS = 2000; private final static long REPEAT_INTERVAL_MSECS = 2000;

View File

@@ -78,14 +78,6 @@ public class AVMTestSuite extends TestSuite
suite.addTestSuite(AVMServiceIndexTest.class); suite.addTestSuite(AVMServiceIndexTest.class);
suite.addTestSuite(AVMServicePerfTest.class); suite.addTestSuite(AVMServicePerfTest.class);
//suite.addTestSuite(AVMCrawlTestP.class);
//suite.addTestSuite(AVMScaleTestP.class);
//suite.addTestSuite(AVMStressTestP.class);
//suite.addTestSuite(PurgeTestP.class); // see above
//suite.addTestSuite(SimultaneousLoadTest.class);
suite.addTestSuite(AVMDiffPerformanceTest.class); suite.addTestSuite(AVMDiffPerformanceTest.class);
suite.addTestSuite(AVMChildNamePatternMatchPerformanceTest.class); suite.addTestSuite(AVMChildNamePatternMatchPerformanceTest.class);
@@ -94,6 +86,11 @@ public class AVMTestSuite extends TestSuite
suite.addTestSuite(AVMServiceConcurrentTest.class); suite.addTestSuite(AVMServiceConcurrentTest.class);
//suite.addTestSuite(AVMCrawlTestP.class);
//suite.addTestSuite(AVMScaleTestP.class);
//suite.addTestSuite(AVMStressTestP.class);
//suite.addTestSuite(SimultaneousLoadTest.class);
/* /*
// note:to test remotely need running repo (otherwise effectively repeats AVMServiceLocalTest) // note:to test remotely need running repo (otherwise effectively repeats AVMServiceLocalTest)
suite.addTestSuite(AVMServiceRemoteSystemTest.class); suite.addTestSuite(AVMServiceRemoteSystemTest.class);

View File

@@ -156,7 +156,7 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("renameStore createIndex " + to, new Exception("Stack Trace")); logger.debug("renameStore createIndex " + to + "(0, " + after + ")", new Exception("Stack Trace"));
} }
avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS); avmIndexer.createIndex(to, IndexMode.SYNCHRONOUS);
avmIndexer.index(to, 0, after, getIndexMode(to)); avmIndexer.index(to, 0, after, getIndexMode(to));
@@ -274,11 +274,22 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
} }
int from = before != -1 ? before : last; int from = before != -1 ? before : last;
if (logger.isDebugEnabled())
if (from > after)
{ {
logger.debug("indexSnapshotImpl " + store, new Exception("Stack Trace")); if (logger.isTraceEnabled())
{
logger.trace("skip indexSnapshotImpl " + store + " (" + (before == -1 ? "-1, " : "") + from +", " + after +")", new Exception("Stack Trace"));
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("indexSnapshotImpl " + store + " (" + (before == -1 ? "-1, " : "") + from +", " + after +")", new Exception("Stack Trace"));
}
avmIndexer.index(store, from, after, getIndexMode(store));
} }
avmIndexer.index(store, from, after, getIndexMode(store));
} }
} }
} }

View File

@@ -59,7 +59,6 @@ import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.avm.AVMException; 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.VersionDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.avmsync.AVMSyncService; import org.alfresco.service.cmr.avmsync.AVMSyncService;
@@ -286,7 +285,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
{ {
s_logger.debug("new: ("+srcVersion+", "+dstVersion+") "+difference.getDestinationPath()); s_logger.debug("new: ("+srcVersion+", "+dstVersion+") "+difference.getDestinationPath());
} }
// AR-786 // ALF-786
reindex(difference.getDestinationPath(), dstDesc.isDirectory()); reindex(difference.getDestinationPath(), dstDesc.isDirectory());
if (dstDesc.isDirectory()) if (dstDesc.isDirectory())
{ {
@@ -310,7 +309,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
{ {
// We are back from the dead ...the node used to be deleted // We are back from the dead ...the node used to be deleted
// Treat as new // Treat as new
// AR-786 // ALF-786
if (s_logger.isDebugEnabled()) if (s_logger.isDebugEnabled())
{ {
s_logger.debug("back: ("+srcVersion+", "+dstVersion+") "+difference.getDestinationPath()); s_logger.debug("back: ("+srcVersion+", "+dstVersion+") "+difference.getDestinationPath());
@@ -420,7 +419,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
Map<String, AVMNodeDescriptor> children = avmService.getDirectoryListing(dir, false); Map<String, AVMNodeDescriptor> children = avmService.getDirectoryListing(dir, false);
for (AVMNodeDescriptor child : children.values()) for (AVMNodeDescriptor child : children.values())
{ {
// AR-786 // ALF-786
reindex(child.getPath(), child.isDirectory()); reindex(child.getPath(), child.isDirectory());
reindexAllAncestors(child.getPath()); reindexAllAncestors(child.getPath());
if (child.isDirectory()) if (child.isDirectory())