aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-scheduler
diff options
context:
space:
mode:
authorolivier lamy <olamy@apache.org>2017-08-19 21:37:35 +1000
committerolivier lamy <olamy@apache.org>2017-08-19 21:37:35 +1000
commit7a2710ec0a566f44a1f135b71176addfdd7047e7 (patch)
tree48886c9c6e6d66035093df4c6bbb866b83253ead /archiva-modules/archiva-scheduler
parentf93a787e74f048fd4fe393819c09d898da63b4f4 (diff)
parent88385088993b8121099f48371ce9e00689ccb547 (diff)
downloadarchiva-7a2710ec0a566f44a1f135b71176addfdd7047e7.tar.gz
archiva-7a2710ec0a566f44a1f135b71176addfdd7047e7.zip
Merge branch 'feature/jcr_oak'
Diffstat (limited to 'archiva-modules/archiva-scheduler')
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml1
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java70
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java8
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java32
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultIndexUpdateSideEffect.java47
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java27
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java123
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java8
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfebin0 -> 299 bytes
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfsbin0 -> 1053 bytes
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.sibin0 -> 364 bytes
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/segments_2bin0 -> 136 bytes
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/write.lock0
13 files changed, 141 insertions, 175 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
index 5aca8e1ad..2f2c6244e 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml
@@ -44,6 +44,7 @@
<dependency>
<groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId>
+ <classifier>shaded-lucene</classifier>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
index 1509bef12..69ec1ec44 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java
@@ -23,13 +23,9 @@ package org.apache.archiva.scheduler.indexing;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ManagedRepository;
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.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
import org.apache.maven.index.FlatSearchRequest;
@@ -40,11 +36,12 @@ 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.maven.index_shaded.lucene.search.BooleanClause;
+import org.apache.maven.index_shaded.lucene.search.BooleanQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
@@ -54,37 +51,24 @@ import java.io.IOException;
* 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
{
private Logger log = LoggerFactory.getLogger( ArchivaIndexingTaskExecutor.class );
+ @Inject
private IndexPacker indexPacker;
- private ArtifactContextProducer artifactContextProducer;
-
@Inject
- private PlexusSisuBridge plexusSisuBridge;
+ private ArtifactContextProducer artifactContextProducer;
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
+ @Inject
private NexusIndexer nexusIndexer;
- @PostConstruct
- public void initialize()
- throws PlexusSisuBridgeException
- {
- log.info( "Initialized {}", this.getClass().getName() );
-
- artifactContextProducer = plexusSisuBridge.lookup( ArtifactContextProducer.class );
-
- indexPacker = plexusSisuBridge.lookup( IndexPacker.class, "default" );
-
- nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
-
- }
/**
* depending on current {@link Task} you have.
@@ -128,9 +112,10 @@ public class ArchivaIndexingTaskExecutor
{
try
{
- log.debug( "Creating indexing context on resource: {}", ( indexingTask.getResourceFile() == null
- ? "none"
- : indexingTask.getResourceFile().getPath() ) );
+ log.debug( "Creating indexing context on resource: {}", //
+ ( indexingTask.getResourceFile() == null
+ ? "none"
+ : indexingTask.getResourceFile().getPath() ) );
context = managedRepositoryAdmin.createIndexContext( repository );
}
catch ( RepositoryAdminException e )
@@ -162,9 +147,9 @@ public class ArchivaIndexingTaskExecutor
// TODO make that configurable?
if ( artifactFile.getPath().endsWith( ".pom" ) )
{
- ac.getArtifactInfo().fextension = "pom";
- ac.getArtifactInfo().packaging = "pom";
- ac.getArtifactInfo().classifier = "pom";
+ ac.getArtifactInfo().setFileExtension( "pom" );
+ ac.getArtifactInfo().setPackaging( "pom" );
+ ac.getArtifactInfo().setClassifier( "pom" );
}
if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
{
@@ -174,20 +159,20 @@ public class ArchivaIndexingTaskExecutor
BooleanQuery q = new BooleanQuery();
q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
- ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
+ ac.getArtifactInfo().getGroupId() ) ), BooleanClause.Occur.MUST );
q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
- ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
+ ac.getArtifactInfo().getArtifactId() ) ), BooleanClause.Occur.MUST );
q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
- ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
- if ( ac.getArtifactInfo().classifier != null )
+ ac.getArtifactInfo().getVersion() ) ), BooleanClause.Occur.MUST );
+ if ( ac.getArtifactInfo().getClassifier() != null )
{
q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
- ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
+ ac.getArtifactInfo().getClassifier() ) ), BooleanClause.Occur.MUST );
}
- if ( ac.getArtifactInfo().packaging != null )
+ if ( ac.getArtifactInfo().getPackaging() != null )
{
q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
- ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
+ ac.getArtifactInfo().getPackaging() ) ), BooleanClause.Occur.MUST );
}
FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
@@ -248,7 +233,11 @@ public class ArchivaIndexingTaskExecutor
if ( !repository.isSkipPackedIndexCreation() )
{
- IndexPackingRequest request = new IndexPackingRequest( context, context.getIndexDirectoryFile() );
+ IndexPackingRequest request = new IndexPackingRequest( context, //
+ context.acquireIndexSearcher().getIndexReader(),
+ //
+ context.getIndexDirectoryFile() );
+
indexPacker.packIndex( request );
context.updateTimestamp( true );
@@ -272,13 +261,4 @@ public class ArchivaIndexingTaskExecutor
this.indexPacker = indexPacker;
}
- public PlexusSisuBridge getPlexusSisuBridge()
- {
- return plexusSisuBridge;
- }
-
- public void setPlexusSisuBridge( PlexusSisuBridge plexusSisuBridge )
- {
- this.plexusSisuBridge = plexusSisuBridge;
- }
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
index 0029bc096..2da5ab779 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.java
@@ -20,8 +20,8 @@ package org.apache.archiva.scheduler.indexing;
*/
import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.maven.index.context.IndexingContext;
import org.apache.archiva.redback.components.taskqueue.Task;
+import org.apache.maven.index.context.IndexingContext;
import java.io.File;
@@ -80,7 +80,13 @@ public class ArtifactIndexingTask
public void setExecuteOnEntireRepo( boolean executeOnEntireRepo )
{
+ this.executeOnEntireRepo( executeOnEntireRepo );
+ }
+
+ public ArtifactIndexingTask executeOnEntireRepo( boolean executeOnEntireRepo )
+ {
this.executeOnEntireRepo = executeOnEntireRepo;
+ return this;
}
@Override
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
index 42a6b72a6..b1f39558b 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java
@@ -25,8 +25,6 @@ import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.common.ArchivaException;
-import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ConfigurationEvent;
@@ -57,7 +55,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
* @author Olivier Lamy
* @since 1.4-M1
*/
-@Service ("downloadRemoteIndexScheduler#default")
+@Service( "downloadRemoteIndexScheduler#default" )
public class DefaultDownloadRemoteIndexScheduler
implements ConfigurationListener, DownloadRemoteIndexScheduler
{
@@ -65,7 +63,7 @@ public class DefaultDownloadRemoteIndexScheduler
private Logger log = LoggerFactory.getLogger( getClass() );
@Inject
- @Named (value = "taskScheduler#indexDownloadRemote")
+ @Named( value = "taskScheduler#indexDownloadRemote" )
private TaskScheduler taskScheduler;
@Inject
@@ -84,15 +82,12 @@ public class DefaultDownloadRemoteIndexScheduler
private NetworkProxyAdmin networkProxyAdmin;
@Inject
- private PlexusSisuBridge plexusSisuBridge;
-
- @Inject
- private MavenIndexerUtils mavenIndexerUtils;
-
private NexusIndexer nexusIndexer;
+ @Inject
private IndexUpdater indexUpdater;
+ @Inject
private IndexPacker indexPacker;
// store ids about currently running remote download : updated in DownloadRemoteIndexTask
@@ -106,12 +101,6 @@ public class DefaultDownloadRemoteIndexScheduler
archivaConfiguration.addListener( this );
// TODO add indexContexts even if null
- nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
-
- indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );
-
- this.indexPacker = plexusSisuBridge.lookup( IndexPacker.class );
-
for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
{
String contextKey = "remote-" + remoteRepository.getId();
@@ -180,11 +169,14 @@ public class DefaultDownloadRemoteIndexScheduler
}
}
- DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest =
- new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy(
- networkProxy ).setFullDownload( fullDownload ).setWagonFactory(
- wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater(
- indexUpdater ).setIndexPacker( this.indexPacker );
+ DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() //
+ .setRemoteRepository( remoteRepository ) //
+ .setNetworkProxy( networkProxy ) //
+ .setFullDownload( fullDownload ) //
+ .setWagonFactory( wagonFactory ) //
+ .setRemoteRepositoryAdmin( remoteRepositoryAdmin ) //
+ .setIndexUpdater( indexUpdater ) //
+ .setIndexPacker( this.indexPacker );
if ( now )
{
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultIndexUpdateSideEffect.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultIndexUpdateSideEffect.java
new file mode 100644
index 000000000..0dcadd9d7
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultIndexUpdateSideEffect.java
@@ -0,0 +1,47 @@
+package org.apache.archiva.scheduler.indexing;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.index.context.IndexingContext;
+import org.apache.maven.index_shaded.lucene.store.Directory;
+import org.apache.maven.index.updater.IndexUpdateSideEffect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Not doing much but required at least one implementation
+ *
+ * @since 3.0.0
+ */
+@Service
+public class DefaultIndexUpdateSideEffect
+ implements IndexUpdateSideEffect
+{
+ private static final Logger LOGGER = LoggerFactory.getLogger( DefaultIndexUpdateSideEffect.class );
+
+ @Override
+ public void updateIndex( Directory directory, IndexingContext indexingContext, boolean b )
+ {
+ LOGGER.info( "updating index: {} with directory: {}", //
+ indexingContext.getId(), //
+ directory.toString() );
+ }
+}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
index f8fd42a24..436e7bb0b 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java
@@ -196,32 +196,7 @@ public class DownloadRemoteIndexTask
indexingContext.updateTimestamp( true );
}
- catch ( MalformedURLException e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( WagonFactoryException e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( ConnectionException e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( AuthenticationException e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( IOException e )
- {
- log.error( e.getMessage(), e );
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( RepositoryAdminException e )
+ catch ( Exception e )
{
log.error( e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e );
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
index 1f07c52ac..14bf7fc50 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutorTest.java
@@ -22,21 +22,24 @@ package org.apache.archiva.scheduler.indexing;
import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.ManagedRepository;
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.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.TopDocs;
import org.apache.maven.index.ArtifactInfo;
import org.apache.maven.index.FlatSearchRequest;
import org.apache.maven.index.FlatSearchResponse;
import org.apache.maven.index.MAVEN;
import org.apache.maven.index.NexusIndexer;
+import org.apache.maven.index.context.IndexCreator;
import org.apache.maven.index.context.IndexingContext;
import org.apache.maven.index.expr.SourcedSearchExpression;
import org.apache.maven.index.expr.StringSearchExpression;
+import org.apache.maven.index_shaded.lucene.search.BooleanClause;
+import org.apache.maven.index_shaded.lucene.search.BooleanQuery;
+import org.apache.maven.index_shaded.lucene.search.IndexSearcher;
+import org.apache.maven.index_shaded.lucene.search.TopDocs;
+import org.apache.maven.index.updater.DefaultIndexUpdater;
+import org.apache.maven.index.updater.IndexUpdateRequest;
+import org.apache.maven.index.updater.IndexUpdater;
+import org.assertj.core.api.Assertions;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -44,18 +47,10 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.util.List;
import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
/**
* ArchivaIndexingTaskExecutorTest
@@ -70,16 +65,17 @@ public class ArchivaIndexingTaskExecutorTest
private ManagedRepository repositoryConfig;
+ @Inject
private NexusIndexer indexer;
@Inject
- PlexusSisuBridge plexusSisuBridge;
+ List<IndexCreator> indexCreators;
@Inject
- MavenIndexerUtils mavenIndexerUtils;
+ ManagedRepositoryAdmin managedRepositoryAdmin;
@Inject
- ManagedRepositoryAdmin managedRepositoryAdmin;
+ private IndexUpdater indexUpdater;
@Before
@Override
@@ -98,8 +94,6 @@ public class ArchivaIndexingTaskExecutorTest
repositoryConfig.setSnapshots( false );
repositoryConfig.setReleases( true );
- indexer = plexusSisuBridge.lookup( NexusIndexer.class );
-
managedRepositoryAdmin.createIndexContext( repositoryConfig );
}
@@ -147,19 +141,19 @@ public class ArchivaIndexingTaskExecutorTest
BooleanQuery q = new BooleanQuery();
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
q.add(
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
if ( !indexer.getIndexingContexts().containsKey( repositoryConfig.getId() ) )
{
- IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), repositoryConfig.getId(),
- new File( repositoryConfig.getLocation() ),
- new File( repositoryConfig.getLocation(),
- ".indexer" ), null, null,
- mavenIndexerUtils.getAllIndexCreators()
- );
+ IndexingContext context = indexer.addIndexingContext( repositoryConfig.getId(), //
+ repositoryConfig.getId(), //
+ new File( repositoryConfig.getLocation() ), //
+ new File( repositoryConfig.getLocation(), ".indexer" )
+ //
+ , null, null, indexCreators );
context.setSearchable( true );
}
@@ -173,9 +167,9 @@ public class ArchivaIndexingTaskExecutorTest
Set<ArtifactInfo> results = response.getResults();
ArtifactInfo artifactInfo = results.iterator().next();
- assertEquals( "org.apache.archiva", artifactInfo.groupId );
- assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
- assertEquals( "test-repo", artifactInfo.repository );
+ assertEquals( "org.apache.archiva", artifactInfo.getGroupId() );
+ assertEquals( "archiva-index-methods-jar-test", artifactInfo.getArtifactId() );
+ assertEquals( "test-repo", artifactInfo.getRepository() );
}
@@ -195,10 +189,10 @@ public class ArchivaIndexingTaskExecutorTest
BooleanQuery q = new BooleanQuery();
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
q.add(
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
IndexingContext ctx = indexer.getIndexingContexts().get( repositoryConfig.getId() );
@@ -231,7 +225,7 @@ public class ArchivaIndexingTaskExecutorTest
BooleanQuery q = new BooleanQuery();
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( "org.apache.archiva" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
//q.add(
// indexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
// Occur.SHOULD );
@@ -258,10 +252,10 @@ public class ArchivaIndexingTaskExecutorTest
q = new BooleanQuery();
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( "org.apache.archiva" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
q.add( indexer.constructQuery( MAVEN.ARTIFACT_ID,
- new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ), Occur.SHOULD
- );
+ new SourcedSearchExpression( "archiva-index-methods-jar-test" ) ),
+ BooleanClause.Occur.SHOULD );
assertTrue( new File( repositoryConfig.getLocation(), ".indexer" ).exists() );
assertFalse( new File( repositoryConfig.getLocation(), ".index" ).exists() );
@@ -315,20 +309,26 @@ public class ArchivaIndexingTaskExecutorTest
assertTrue( indexerDirectory.exists() );
// test packed index file creation
- assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.zip" ).exists() );
- assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.properties" ).exists() );
- assertTrue( new File( indexerDirectory, "nexus-maven-repository-index.gz" ).exists() );
+ //no more zip
+ //Assertions.assertThat(new File( indexerDirectory, "nexus-maven-repository-index.zip" )).exists();
+ Assertions.assertThat( new File( indexerDirectory, "nexus-maven-repository-index.properties" ) ).exists();
+ Assertions.assertThat( new File( indexerDirectory, "nexus-maven-repository-index.gz" ) ).exists();
// unpack .zip index
File destDir = new File( repositoryConfig.getLocation(), ".indexer/tmp" );
- unzipIndex( indexerDirectory.getPath(), destDir.getPath() );
+ //unzipIndex( indexerDirectory.getPath(), destDir.getPath() );
+
+ DefaultIndexUpdater.FileFetcher fetcher = new DefaultIndexUpdater.FileFetcher( indexerDirectory );
+ IndexUpdateRequest updateRequest = new IndexUpdateRequest( getIndexingContext(), fetcher );
+ //updateRequest.setLocalIndexCacheDir( indexerDirectory );
+ indexUpdater.fetchAndUpdateIndex( updateRequest );
BooleanQuery q = new BooleanQuery();
q.add( indexer.constructQuery( MAVEN.GROUP_ID, new StringSearchExpression( "org.apache.archiva" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
q.add(
indexer.constructQuery( MAVEN.ARTIFACT_ID, new StringSearchExpression( "archiva-index-methods-jar-test" ) ),
- Occur.SHOULD );
+ BooleanClause.Occur.SHOULD );
FlatSearchRequest request = new FlatSearchRequest( q, getIndexingContext() );
FlatSearchResponse response = indexer.searchFlat( request );
@@ -336,42 +336,11 @@ public class ArchivaIndexingTaskExecutorTest
Set<ArtifactInfo> results = response.getResults();
ArtifactInfo artifactInfo = results.iterator().next();
- assertEquals( "org.apache.archiva", artifactInfo.groupId );
- assertEquals( "archiva-index-methods-jar-test", artifactInfo.artifactId );
- assertEquals( "test-repo", artifactInfo.repository );
+ assertEquals( "org.apache.archiva", artifactInfo.getGroupId() );
+ assertEquals( "archiva-index-methods-jar-test", artifactInfo.getArtifactId() );
+ assertEquals( "test-repo", artifactInfo.getRepository() );
assertEquals( 1, response.getTotalHits() );
}
- private void unzipIndex( String indexDir, String destDir )
- throws IOException
- {
- final int buff = 2048;
-
- Files.createDirectories( Paths.get( destDir ) );
-
- try (InputStream fin = Files.newInputStream( Paths.get( indexDir, "nexus-maven-repository-index.zip" ) ))
- {
- ZipInputStream in = new ZipInputStream( new BufferedInputStream( fin ) );
- ZipEntry entry;
-
- while ( ( entry = in.getNextEntry() ) != null )
- {
- int count;
- byte data[] = new byte[buff];
- try (OutputStream fout = Files.newOutputStream( Paths.get( destDir, entry.getName() ) ))
- {
- try (BufferedOutputStream out = new BufferedOutputStream( fout, buff ))
- {
-
- while ( ( count = in.read( data, 0, buff ) ) != -1 )
- {
- out.write( data, 0, count );
- }
- }
- }
- }
-
- }
- }
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java
index 7e95b4f26..ef0dd86ed 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java
@@ -20,16 +20,15 @@ package org.apache.archiva.scheduler.indexing;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.utils.FileUtil;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
import org.apache.maven.index.FlatSearchRequest;
import org.apache.maven.index.FlatSearchResponse;
import org.apache.maven.index.MAVEN;
import org.apache.maven.index.NexusIndexer;
import org.apache.maven.index.expr.StringSearchExpression;
+import org.apache.maven.index_shaded.lucene.search.BooleanClause;
+import org.apache.maven.index_shaded.lucene.search.BooleanQuery;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
@@ -75,8 +74,6 @@ public class DownloadRemoteIndexTaskTest
DefaultDownloadRemoteIndexScheduler downloadRemoteIndexScheduler;
@Inject
- PlexusSisuBridge plexusSisuBridge;
-
NexusIndexer nexusIndexer;
@Before
@@ -90,7 +87,6 @@ public class DownloadRemoteIndexTaskTest
this.server.start();
this.port = serverConnector.getLocalPort();
log.info( "start server on port {}", this.port );
- nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
}
protected void createContext( Server server, File repositoryDirectory )
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfe b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfe
new file mode 100644
index 000000000..4ece53663
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfe
Binary files differ
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfs b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfs
new file mode 100644
index 000000000..a66fea159
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.cfs
Binary files differ
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.si b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.si
new file mode 100644
index 000000000..84e9c5aaf
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/_0.si
Binary files differ
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/segments_2 b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/segments_2
new file mode 100644
index 000000000..3d64213c6
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/segments_2
Binary files differ
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/write.lock b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/write.lock
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/repositories/default-repository/.indexer/write.lock