Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java (original) +++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/packer/DefaultIndexPacker.java Mon Aug 13 12:09:13 2012 @@ -38,6 +38,7 @@ import org.apache.lucene.document.Field; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.IndexInput; @@ -109,108 +110,97 @@ public class DefaultIndexPacker final IndexingContext context = request.getContext(); - context.lock(); - try { - try + // Note that for incremental indexes to work properly, a valid index.properties file + // must be present + info = readIndexProperties( request ); + + if ( request.isCreateIncrementalChunks() ) { - // Note that for incremental indexes to work properly, a valid index.properties file - // must be present - info = readIndexProperties( request ); + List<Integer> chunk = incrementalHandler.getIncrementalUpdates( request, info ); - if ( request.isCreateIncrementalChunks() ) + if ( chunk == null ) { - List<Integer> chunk = incrementalHandler.getIncrementalUpdates( request, info ); + getLogger().debug( "Problem with Chunks, forcing regeneration of whole index" ); + incrementalHandler.initializeProperties( info ); + } + else if ( chunk.isEmpty() ) + { + getLogger().debug( "No incremental changes, not writing new incremental chunk" ); + } + else + { + File file = + new File( request.getTargetDir(), // + IndexingContext.INDEX_FILE_PREFIX + "." + + info.getProperty( IndexingContext.INDEX_CHUNK_COUNTER ) + ".gz" ); - if ( chunk == null ) - { - getLogger().debug( "Problem with Chunks, forcing regeneration of whole index" ); - incrementalHandler.initializeProperties( info ); - } - else if ( chunk.isEmpty() ) - { - getLogger().debug( "No incremental changes, not writing new incremental chunk" ); - } - else + writeIndexData( request.getContext(), // + chunk, file ); + + if ( request.isCreateChecksumFiles() ) { - File file = - new File( request.getTargetDir(), // - IndexingContext.INDEX_FILE_PREFIX + "." - + info.getProperty( IndexingContext.INDEX_CHUNK_COUNTER ) + ".gz" ); - - writeIndexData( request.getContext(), // - chunk, file ); - - if ( request.isCreateChecksumFiles() ) - { - FileUtils.fileWrite( - new File( file.getParentFile(), file.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( file ) ); - - FileUtils.fileWrite( - new File( file.getParentFile(), file.getName() + ".md5" ).getAbsolutePath(), - DigesterUtils.getMd5Digest( file ) ); - } + FileUtils.fileWrite( + new File( file.getParentFile(), file.getName() + ".sha1" ).getAbsolutePath(), + DigesterUtils.getSha1Digest( file ) ); + + FileUtils.fileWrite( + new File( file.getParentFile(), file.getName() + ".md5" ).getAbsolutePath(), + DigesterUtils.getMd5Digest( file ) ); } } } - catch ( IOException e ) - { - getLogger().info( "Unable to read properties file, will force index regeneration" ); - info = new Properties(); - incrementalHandler.initializeProperties( info ); - } - - Date timestamp = request.getContext().getTimestamp(); + } + catch ( IOException e ) + { + getLogger().info( "Unable to read properties file, will force index regeneration" ); + info = new Properties(); + incrementalHandler.initializeProperties( info ); + } - if ( timestamp == null ) - { - timestamp = new Date( 0 ); // never updated - } + Date timestamp = request.getContext().getTimestamp(); - if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_LEGACY ) ) - { - info.setProperty( IndexingContext.INDEX_LEGACY_TIMESTAMP, format( timestamp ) ); + if ( timestamp == null ) + { + timestamp = new Date( 0 ); // never updated + } - writeIndexArchive( request.getContext(), legacyFile ); + if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_LEGACY ) ) + { + info.setProperty( IndexingContext.INDEX_LEGACY_TIMESTAMP, format( timestamp ) ); - if ( request.isCreateChecksumFiles() ) - { - FileUtils.fileWrite( - new File( legacyFile.getParentFile(), legacyFile.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( legacyFile ) ); - - FileUtils.fileWrite( - new File( legacyFile.getParentFile(), legacyFile.getName() + ".md5" ).getAbsolutePath(), - DigesterUtils.getMd5Digest( legacyFile ) ); - } - } + writeIndexArchive( request.getContext(), legacyFile ); - if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_V1 ) ) + if ( request.isCreateChecksumFiles() ) { - info.setProperty( IndexingContext.INDEX_TIMESTAMP, format( timestamp ) ); - - writeIndexData( request.getContext(), null, v1File ); + FileUtils.fileWrite( + new File( legacyFile.getParentFile(), legacyFile.getName() + ".sha1" ).getAbsolutePath(), + DigesterUtils.getSha1Digest( legacyFile ) ); - if ( request.isCreateChecksumFiles() ) - { - FileUtils.fileWrite( - new File( v1File.getParentFile(), v1File.getName() + ".sha1" ).getAbsolutePath(), - DigesterUtils.getSha1Digest( v1File ) ); - - FileUtils.fileWrite( - new File( v1File.getParentFile(), v1File.getName() + ".md5" ).getAbsolutePath(), - DigesterUtils.getMd5Digest( v1File ) ); - } + FileUtils.fileWrite( + new File( legacyFile.getParentFile(), legacyFile.getName() + ".md5" ).getAbsolutePath(), + DigesterUtils.getMd5Digest( legacyFile ) ); } - - writeIndexProperties( request, info ); } - finally + + if ( request.getFormats().contains( IndexPackingRequest.IndexFormat.FORMAT_V1 ) ) { - context.unlock(); + info.setProperty( IndexingContext.INDEX_TIMESTAMP, format( timestamp ) ); + + writeIndexData( request.getContext(), null, v1File ); + + if ( request.isCreateChecksumFiles() ) + { + FileUtils.fileWrite( new File( v1File.getParentFile(), v1File.getName() + ".sha1" ).getAbsolutePath(), + DigesterUtils.getSha1Digest( v1File ) ); + + FileUtils.fileWrite( new File( v1File.getParentFile(), v1File.getName() + ".md5" ).getAbsolutePath(), + DigesterUtils.getMd5Digest( v1File ) ); + } } + + writeIndexProperties( request, info ); } private Properties readIndexProperties( IndexPackingRequest request ) @@ -290,7 +280,15 @@ public class DefaultIndexPacker IndexUtils.updateTimestamp( context.getIndexDirectory(), context.getTimestamp() ); IndexUtils.updateTimestamp( fdir, context.getTimestamp() ); - copyLegacyDocuments( context.getIndexReader(), fdir, context ); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + copyLegacyDocuments( indexSearcher.getIndexReader(), fdir, context ); + } + finally + { + context.releaseIndexSearcher( indexSearcher ); + } packDirectory( fdir, os ); } finally
Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java (original) +++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexDataWriter.java Mon Aug 13 12:09:13 2012 @@ -35,6 +35,7 @@ import org.apache.lucene.document.Docume import org.apache.lucene.document.Field; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.IndexSearcher; import org.apache.maven.index.ArtifactInfo; import org.apache.maven.index.context.DefaultIndexingContext; import org.apache.maven.index.context.IndexingContext; @@ -85,7 +86,16 @@ public class IndexDataWriter { writeHeader( context ); - int n = writeDocuments( context.getIndexReader(), docIndexes ); + int n = 0; + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + try + { + n = writeDocuments( indexSearcher.getIndexReader(), docIndexes ); + } + finally + { + context.releaseIndexSearcher( indexSearcher ); + } writeGroupFields(); Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractIndexCreatorHelper.java Mon Aug 13 12:09:13 2012 @@ -70,8 +70,6 @@ public class AbstractIndexCreatorHelper FULL_CREATORS.add( mavenPlugin ); FULL_CREATORS.add( mavenArchetype ); FULL_CREATORS.add( jar ); - - DefaultIndexingContext.BLOCKING_COMMIT = true; } protected void deleteDirectory( File dir ) Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/AbstractRepoNexusIndexerTest.java Mon Aug 13 12:09:13 2012 @@ -519,7 +519,7 @@ public abstract class AbstractRepoNexusI public void testPackaging() throws Exception { - IndexReader reader = context.getIndexReader(); + IndexReader reader = context.acquireIndexSearcher().getIndexReader(); for ( int i = 0; i < reader.maxDoc(); i++ ) { Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseTest.java Mon Aug 13 12:09:13 2012 @@ -41,9 +41,6 @@ public class ConcurrentUseTest protected void prepareNexusIndexer( NexusIndexer nexusIndexer ) throws Exception { - // This IS concurrent test, so here, unlike all other UTs, we DO want to have async commits - DefaultIndexingContext.BLOCKING_COMMIT = false; - context = nexusIndexer.addIndexingContext( "test-default", "test", repo, indexDir, null, null, DEFAULT_CREATORS ); Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/ConcurrentUseWithMergedContextTest.java Mon Aug 13 12:09:13 2012 @@ -47,9 +47,6 @@ public class ConcurrentUseWithMergedCont protected void prepareNexusIndexer( NexusIndexer nexusIndexer ) throws Exception { - // This IS concurrent test, so here, unlike all other UTs, we DO want to have async commits - DefaultIndexingContext.BLOCKING_COMMIT = false; - context1 = nexusIndexer.addIndexingContext( "test-default-member1", "test1", repo, indexDir1, null, null, DEFAULT_CREATORS ); Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/FSDirectoryDeleteTest.java Mon Aug 13 12:09:13 2012 @@ -21,6 +21,7 @@ package org.apache.maven.index; import java.io.File; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.maven.index.context.IndexingContext; @@ -84,9 +85,14 @@ public class FSDirectoryDeleteTest public void testIndexAndDelete() throws Exception { - context.getIndexReader().maxDoc(); - - otherContext.getIndexReader().maxDoc(); + final IndexSearcher indexSearcher = context.acquireIndexSearcher(); + final IndexSearcher otherIndexSearcher = otherContext.acquireIndexSearcher(); + + indexSearcher.getIndexReader().maxDoc(); + otherIndexSearcher.getIndexReader().maxDoc(); + + context.releaseIndexSearcher( indexSearcher ); + otherContext.releaseIndexSearcher( otherIndexSearcher ); context.replace( otherIndexDir ); Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Index20081108RegressionTest.java Mon Aug 13 12:09:13 2012 @@ -68,7 +68,7 @@ public class Index20081108RegressionTest public void testExtension() throws Exception { - assertEquals( 31, context.getIndexReader().numDocs() ); + assertEquals( 31, context.getSize() ); { Query q = nexusIndexer.constructQuery( MAVEN.GROUP_ID, "qdox", SearchType.SCORED ); Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/Nexus737NexusIndexerTest.java Mon Aug 13 12:09:13 2012 @@ -44,7 +44,7 @@ public class Nexus737NexusIndexerTest public void testValidateUINFOs() throws Exception { - IndexReader reader = context.getIndexReader(); + IndexReader reader = context.acquireIndexSearcher().getIndexReader(); int foundCount = 0; Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/IndexDataTest.java URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/IndexDataTest.java?rev=1372380&r1=1372379&r2=1372380&view=diff ============================================================================== --- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/IndexDataTest.java (original) +++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/IndexDataTest.java Mon Aug 13 12:09:13 2012 @@ -115,7 +115,7 @@ public class IndexDataTest public void testData() throws Exception { - IndexReader r1 = context.getIndexReader(); + IndexReader r1 = context.acquireIndexSearcher().getIndexReader(); Map<String, ArtifactInfo> r1map = readIndex( r1 );