diff options
author | Maria Odea B. Ching <oching@apache.org> | 2010-11-25 11:20:47 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2010-11-25 11:20:47 +0000 |
commit | bc56d6353c98c3ff4ed51033ac9ec8a09351926a (patch) | |
tree | ff25b2856250af4da932c051a125124ae35c093e /archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src | |
parent | 0452f87c94754cd795fd526b0bcba8f1f1d937aa (diff) | |
download | archiva-bc56d6353c98c3ff4ed51033ac9ec8a09351926a.tar.gz archiva-bc56d6353c98c3ff4ed51033ac9ec8a09351926a.zip |
[MRM-1097]
o upgrade nexus indexer to 3.0.1 + added logger bean which is needed by NexusIndexer
o for deployments/proxied artifacts, create and close indexing context when indexing task is executed as compared to the original behavior where the indexing context is created
before it is queued (so as the indexing task queue builds up, more indexing contexts are being opened/created which might be causing the too many open files problem)
o updated unit tests with changes made
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1039004 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src')
2 files changed, 58 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java index 836fa6a8e..5e1f1ee9c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java @@ -99,6 +99,7 @@ public class NexusIndexerConsumer try { + log.info( "Creating indexing context for repo : " + repository.getId() ); context = ArtifactIndexingTask.createContext( repository ); } catch ( IOException e ) @@ -111,6 +112,21 @@ public class NexusIndexerConsumer } } + @Override + public void beginScan( ManagedRepositoryConfiguration repository, Date whenGathered, boolean executeOnEntireRepo ) + throws ConsumerException + { + if( executeOnEntireRepo ) + { + beginScan( repository, whenGathered ); + } + else + { + this.repository = repository; + managedRepository = new File( repository.getLocation() ); + } + } + public void processFile( String path ) throws ConsumerException { @@ -129,6 +145,33 @@ public class NexusIndexerConsumer } } + @Override + public void processFile( String path, boolean executeOnEntireRepo ) + throws Exception + { + if( executeOnEntireRepo ) + { + processFile( path ); + } + else + { + File artifactFile = new File( managedRepository, path ); + + // specify in indexing task that this is not a repo scan request! + ArtifactIndexingTask task = + new ArtifactIndexingTask( repository, artifactFile, ArtifactIndexingTask.Action.ADD, context, false ); + try + { + log.debug( "Queueing indexing task + '" + task + "' to add or update the artifact in the index." ); + scheduler.queueTask( task ); + } + catch ( TaskQueueException e ) + { + throw new ConsumerException( e.getMessage(), e ); + } + } + } + public void completeScan() { ArtifactIndexingTask task = @@ -145,6 +188,17 @@ public class NexusIndexerConsumer context = null; } + @Override + public void completeScan( boolean executeOnEntireRepo ) + { + if( executeOnEntireRepo ) + { + completeScan(); + } + + // else, do nothing as the context will be closed when indexing task is executed if not a repo scan request! + } + public List<String> getExcludes() { return Collections.emptyList(); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml index 542215ff2..8282c6cb2 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml @@ -8,4 +8,8 @@ <constructor-arg ref="archivaConfiguration"/> <constructor-arg ref="fileTypes"/> </bean> + + <bean id="logger" class="org.apache.maven.archiva.common.utils.Slf4JPlexusLogger"> + <constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg> + </bean> </beans>
\ No newline at end of file |