archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1384116 - in /archiva/trunk: ./ archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/ archiva-modules/arc...
Date Wed, 12 Sep 2012 20:44:51 GMT
Author: olamy
Date: Wed Sep 12 20:44:51 2012
New Revision: 1384116

URL: http://svn.apache.org/viewvc?rev=1384116&view=rev
Log:
test last maven indexer version

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
    archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
    archiva/trunk/pom.xml

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
Wed Sep 12 20:44:51 2012
@@ -41,7 +41,6 @@ import org.apache.maven.index.context.In
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
 import org.apache.maven.index.expr.SourcedSearchExpression;
-import org.apache.maven.index.expr.StringSearchExpression;
 import org.apache.maven.index.expr.UserInputSearchExpression;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,7 +60,7 @@ import java.util.Set;
 /**
  * RepositorySearch implementation which uses the Nexus Indexer for searching.
  */
-@Service( "nexusSearch" )
+@Service ("nexusSearch")
 public class NexusRepositorySearch
     implements RepositorySearch
 {
@@ -160,9 +159,9 @@ public class NexusRepositorySearch
 
         if ( StringUtils.isNotBlank( searchFields.getArtifactId() ) )
         {
-            q.add(
-                indexer.constructQuery( MAVEN.ARTIFACT_ID, new UserInputSearchExpression(
searchFields.getArtifactId() ) ),
-                Occur.MUST );
+            q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID,
+                                           new UserInputSearchExpression( searchFields.getArtifactId()
) ),
+                   Occur.MUST );
         }
 
         if ( StringUtils.isNotBlank( searchFields.getVersion() ) )
@@ -173,15 +172,15 @@ public class NexusRepositorySearch
 
         if ( StringUtils.isNotBlank( searchFields.getPackaging() ) )
         {
-            q.add( indexer.constructQuery( MAVEN.PACKAGING, new UserInputSearchExpression(
searchFields.getPackaging() ) ),
-                   Occur.MUST );
+            q.add(
+                indexer.constructQuery( MAVEN.PACKAGING, new UserInputSearchExpression( searchFields.getPackaging()
) ),
+                Occur.MUST );
         }
 
         if ( StringUtils.isNotBlank( searchFields.getClassName() ) )
         {
-            q.add(
-                indexer.constructQuery( MAVEN.CLASSNAMES, new UserInputSearchExpression(
searchFields.getClassName() ) ),
-                Occur.MUST );
+            q.add( indexer.constructQuery( MAVEN.CLASSNAMES,
+                                           new UserInputSearchExpression( searchFields.getClassName()
) ), Occur.MUST );
         }
 
         if ( StringUtils.isNotBlank( searchFields.getBundleSymbolicName() ) )
@@ -193,9 +192,9 @@ public class NexusRepositorySearch
 
         if ( StringUtils.isNotBlank( searchFields.getBundleVersion() ) )
         {
-            q.add(
-                indexer.constructQuery( OSGI.VERSION, new UserInputSearchExpression( searchFields.getBundleVersion()
) ),
-                Occur.MUST );
+            q.add( indexer.constructQuery( OSGI.VERSION,
+                                           new UserInputSearchExpression( searchFields.getBundleVersion()
) ),
+                   Occur.MUST );
         }
 
         if ( StringUtils.isNotBlank( searchFields.getBundleExportPackage() ) )
@@ -241,9 +240,9 @@ public class NexusRepositorySearch
 
         if ( StringUtils.isNotBlank( searchFields.getClassifier() ) )
         {
-            q.add(
-                indexer.constructQuery( MAVEN.CLASSIFIER, new UserInputSearchExpression(
searchFields.getClassifier() ) ),
-                Occur.MUST );
+            q.add( indexer.constructQuery( MAVEN.CLASSIFIER,
+                                           new UserInputSearchExpression( searchFields.getClassifier()
) ),
+                   Occur.MUST );
         }
 
         if ( q.getClauses() == null || q.getClauses().length <= 0 )
@@ -437,6 +436,7 @@ public class NexusRepositorySearch
         throws RepositorySearchException
     {
         List<IndexingContext> indexContexts = getIndexingContexts( selectedRepos );
+
         if ( indexContexts == null || indexContexts.isEmpty() )
         {
             return Collections.emptyList();
@@ -455,8 +455,10 @@ public class NexusRepositorySearch
         {
             throw new RepositorySearchException( e.getMessage(), e );
         }
+
     }
 
+
     protected List<? extends IndexCreator> getAllIndexCreators()
     {
         return mavenIndexerUtils.getAllIndexCreators();

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java
Wed Sep 12 20:44:51 2012
@@ -211,7 +211,7 @@ public abstract class AbstractNexusRepos
         }
         // force flushing
         context.getIndexWriter().commit();
-        context.getIndexWriter().close( true );
+        //context.getIndexWriter().close( true );
         // wait for io flush ....
         //Thread.sleep( 2000 );
         context.setSearchable( true );

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java
Wed Sep 12 20:44:51 2012
@@ -127,7 +127,7 @@ public class NexusRepositorySearchTest
         archivaConfigControl.verify();
 
         assertNotNull( results );
-        assertEquals( "total hints not 1", 1, results.getTotalHits() );
+        assertEquals( "total hints not 3", 3, results.getTotalHits() );
 
         //TODO: search for class & package names
     }
@@ -194,7 +194,7 @@ public class NexusRepositorySearchTest
         archivaConfigControl.verify();
 
         assertNotNull( results );
-        assertEquals( 1, results.getTotalHits() );
+        assertEquals( 2, results.getTotalHits() );
 
         SearchResultHit hit = results.getHits().get( 0 );
         assertEquals( "org.apache.archiva", hit.getGroupId() );

Modified: archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml Wed
Sep 12 20:44:51 2012
@@ -136,6 +136,11 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>slf4j-impl</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-http-lightweight</artifactId>
       <scope>provided</scope>

Modified: archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
(original)
+++ archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
Wed Sep 12 20:44:51 2012
@@ -25,6 +25,9 @@ import org.apache.archiva.admin.model.be
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.archiva.redback.components.taskqueue.Task;
+import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutionException;
+import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
@@ -34,14 +37,10 @@ import org.apache.maven.index.FlatSearch
 import org.apache.maven.index.FlatSearchResponse;
 import org.apache.maven.index.MAVEN;
 import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.artifact.IllegalArtifactCoordinateException;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.expr.SourcedSearchExpression;
 import org.apache.maven.index.packer.IndexPacker;
 import org.apache.maven.index.packer.IndexPackingRequest;
-import org.apache.archiva.redback.components.taskqueue.Task;
-import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutionException;
-import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -50,14 +49,13 @@ import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import java.io.File;
 import java.io.IOException;
-import java.util.Arrays;
 
 /**
  * ArchivaIndexingTaskExecutor Executes all indexing tasks. Adding, updating and removing
artifacts from the index are
  * all performed by this executor. Add and update artifact in index tasks are added in the
indexing task queue by the
  * NexusIndexerConsumer while remove artifact from index tasks are added by the LuceneCleanupRemoveIndexedConsumer.
  */
-@Service( "taskExecutor#indexing" )
+@Service ("taskExecutor#indexing")
 public class ArchivaIndexingTaskExecutor
     implements TaskExecutor
 {
@@ -92,6 +90,14 @@ public class ArchivaIndexingTaskExecutor
 
     }
 
+    /**
+     * depending on current {@link Action} you have.
+     * If {@link org.apache.archiva.scheduler.indexing.ArtifactIndexingTask.Action.FINISH}
&& isExecuteOnEntireRepo:
+     * repository will be scanned.
+     *
+     * @param task
+     * @throws TaskExecutionException
+     */
     public void executeTask( Task task )
         throws TaskExecutionException
     {
@@ -108,9 +114,8 @@ public class ArchivaIndexingTaskExecutor
                 long start = System.currentTimeMillis();
                 nexusIndexer.scan( context, null, indexingTask.isOnlyUpdate() );
                 long end = System.currentTimeMillis();
-                log.info( "indexed maven repository: {}, onlyUpdate: {}, time {} ms",
-                          Arrays.asList( repository.getId(), indexingTask.isOnlyUpdate(),
( end - start ) ).toArray(
-                              new Object[3] ) );
+                log.info( "indexed maven repository: {}, onlyUpdate: {}, time {} ms", repository.getId(),
+                          indexingTask.isOnlyUpdate(), ( end - start ) );
             }
             catch ( IOException e )
             {
@@ -126,7 +131,9 @@ public class ArchivaIndexingTaskExecutor
             {
                 try
                 {
-                    log.debug( "Creating indexing context on resource: {}", indexingTask.getResourceFile().getPath()
);
+                    log.debug( "Creating indexing context on resource: {}", ( indexingTask.getResourceFile()
== null
+                        ? "none"
+                        : indexingTask.getResourceFile().getPath() ) );
                     context = managedRepositoryAdmin.createIndexContext( repository );
                 }
                 catch ( RepositoryAdminException e )
@@ -144,6 +151,11 @@ public class ArchivaIndexingTaskExecutor
             try
             {
                 File artifactFile = indexingTask.getResourceFile();
+                if ( artifactFile == null )
+                {
+                    log.debug( "no artifact pass in indexing task so skip it" );
+                    return;
+                }
                 ArtifactContext ac = artifactContextProducer.getArtifactContext( context,
artifactFile );
 
                 if ( ac != null )
@@ -187,6 +199,7 @@ public class ArchivaIndexingTaskExecutor
                         }
 
                         context.updateTimestamp();
+                        context.commit();
 
                         // close the context if not a repo scan request
                         if ( !indexingTask.isExecuteOnEntireRepo() )
@@ -210,11 +223,6 @@ public class ArchivaIndexingTaskExecutor
                 throw new TaskExecutionException( "Error occurred while executing indexing
task '" + indexingTask + "'",
                                                   e );
             }
-            catch ( IllegalArtifactCoordinateException e )
-            {
-                log.error( "Error occurred while getting artifact context: " + e.getMessage()
);
-                throw new TaskExecutionException( "Error occurred while getting artifact
context.", e );
-            }
         }
 
     }

Modified: archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
Wed Sep 12 20:44:51 2012
@@ -24,7 +24,7 @@ import org.apache.archiva.admin.model.be
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.commons.io.FileUtils;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.IndexSearcher;
@@ -48,19 +48,17 @@ import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 
 /**
  * ArchivaIndexingTaskExecutorTest
  */
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml"
} )
+@RunWith (ArchivaSpringJUnit4ClassRunner.class)
+@ContextConfiguration (locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml"
})
 public class ArchivaIndexingTaskExecutorTest
     extends TestCase
 {
@@ -196,10 +194,13 @@ public class ArchivaIndexingTaskExecutor
             indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test"
) ),
             Occur.SHOULD );
 
-        IndexSearcher searcher = indexer.getIndexingContexts().get( repositoryConfig.getId()
).getIndexSearcher();
+        IndexingContext ctx = indexer.getIndexingContexts().get( repositoryConfig.getId()
);
+
+        IndexSearcher searcher = ctx.acquireIndexSearcher();
         TopDocs topDocs = searcher.search( q, null, 10 );
 
-        searcher.close();
+        //searcher.close();
+        ctx.releaseIndexSearcher( searcher );
 
         assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
         assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() );
@@ -282,7 +283,7 @@ public class ArchivaIndexingTaskExecutor
 
         indexingExecutor.executeTask( task );
 
-        task = new ArtifactIndexingTask( repositoryConfig, artifactFile, ArtifactIndexingTask.Action.FINISH,
+        task = new ArtifactIndexingTask( repositoryConfig, null, ArtifactIndexingTask.Action.FINISH,
                                          getIndexingContext() );
 
         task.setExecuteOnEntireRepo( false );
@@ -316,7 +317,7 @@ public class ArchivaIndexingTaskExecutor
     }
 
     private void unzipIndex( String indexDir, String destDir )
-        throws FileNotFoundException, IOException
+        throws IOException
     {
         final int buff = 2048;
 

Modified: archiva/trunk/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/pom.xml?rev=1384116&r1=1384115&r2=1384116&view=diff
==============================================================================
--- archiva/trunk/pom.xml (original)
+++ archiva/trunk/pom.xml Wed Sep 12 20:44:51 2012
@@ -65,7 +65,7 @@
     <aether.version>1.13.1</aether.version>
 
     <maven-model-converter.version>2.1</maven-model-converter.version>
-    <maven.indexer.version>4.1.3</maven.indexer.version>
+    <maven.indexer.version>5.0.0-SNAPSHOT</maven.indexer.version>
     <wagon.version>2.2</wagon.version>
     <redback.version>2.0-SNAPSHOT</redback.version>
     <redback.cache.version>2.0-SNAPSHOT</redback.cache.version>



Mime
View raw message