mirror of https://github.com/apache/archiva.git
[MRM-1693] exposing index downloaded from remote repositories
pack index. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1398259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac5d5d5f47
commit
b0b8c3c08a
|
@ -36,6 +36,7 @@ import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.index.NexusIndexer;
|
import org.apache.maven.index.NexusIndexer;
|
||||||
import org.apache.maven.index.context.IndexingContext;
|
import org.apache.maven.index.context.IndexingContext;
|
||||||
import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
|
import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
|
||||||
|
import org.apache.maven.index.packer.IndexPacker;
|
||||||
import org.apache.maven.index.updater.IndexUpdater;
|
import org.apache.maven.index.updater.IndexUpdater;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -56,7 +57,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 1.4-M1
|
* @since 1.4-M1
|
||||||
*/
|
*/
|
||||||
@Service( "downloadRemoteIndexScheduler#default" )
|
@Service ("downloadRemoteIndexScheduler#default")
|
||||||
public class DefaultDownloadRemoteIndexScheduler
|
public class DefaultDownloadRemoteIndexScheduler
|
||||||
implements ConfigurationListener, DownloadRemoteIndexScheduler
|
implements ConfigurationListener, DownloadRemoteIndexScheduler
|
||||||
{
|
{
|
||||||
|
@ -64,7 +65,7 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named( value = "taskScheduler#indexDownloadRemote" )
|
@Named (value = "taskScheduler#indexDownloadRemote")
|
||||||
private TaskScheduler taskScheduler;
|
private TaskScheduler taskScheduler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -92,6 +93,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||||
|
|
||||||
private IndexUpdater indexUpdater;
|
private IndexUpdater indexUpdater;
|
||||||
|
|
||||||
|
private IndexPacker indexPacker;
|
||||||
|
|
||||||
// store ids about currently running remote download : updated in DownloadRemoteIndexTask
|
// store ids about currently running remote download : updated in DownloadRemoteIndexTask
|
||||||
private List<String> runningRemoteDownloadIds = new CopyOnWriteArrayList<String>();
|
private List<String> runningRemoteDownloadIds = new CopyOnWriteArrayList<String>();
|
||||||
|
|
||||||
|
@ -107,6 +110,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||||
|
|
||||||
indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );
|
indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );
|
||||||
|
|
||||||
|
this.indexPacker = plexusSisuBridge.lookup( IndexPacker.class );
|
||||||
|
|
||||||
for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
|
for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
|
||||||
{
|
{
|
||||||
String contextKey = "remote-" + remoteRepository.getId();
|
String contextKey = "remote-" + remoteRepository.getId();
|
||||||
|
@ -176,7 +181,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
||||||
DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest =
|
DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest =
|
||||||
new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy(
|
new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy(
|
||||||
networkProxy ).setFullDownload( fullDownload ).setWagonFactory(
|
networkProxy ).setFullDownload( fullDownload ).setWagonFactory(
|
||||||
wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater( indexUpdater );
|
wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater(
|
||||||
|
indexUpdater ).setIndexPacker( this.indexPacker );
|
||||||
|
|
||||||
if ( now )
|
if ( now )
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.apache.archiva.proxy.common.WagonFactoryException;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.time.StopWatch;
|
import org.apache.commons.lang.time.StopWatch;
|
||||||
import org.apache.maven.index.context.IndexingContext;
|
import org.apache.maven.index.context.IndexingContext;
|
||||||
|
import org.apache.maven.index.packer.IndexPacker;
|
||||||
|
import org.apache.maven.index.packer.IndexPackingRequest;
|
||||||
import org.apache.maven.index.updater.IndexUpdateRequest;
|
import org.apache.maven.index.updater.IndexUpdateRequest;
|
||||||
import org.apache.maven.index.updater.IndexUpdater;
|
import org.apache.maven.index.updater.IndexUpdater;
|
||||||
import org.apache.maven.index.updater.ResourceFetcher;
|
import org.apache.maven.index.updater.ResourceFetcher;
|
||||||
|
@ -78,6 +80,8 @@ public class DownloadRemoteIndexTask
|
||||||
|
|
||||||
private IndexUpdater indexUpdater;
|
private IndexUpdater indexUpdater;
|
||||||
|
|
||||||
|
private IndexPacker indexPacker;
|
||||||
|
|
||||||
public DownloadRemoteIndexTask( DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest,
|
public DownloadRemoteIndexTask( DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest,
|
||||||
List<String> runningRemoteDownloadIds )
|
List<String> runningRemoteDownloadIds )
|
||||||
{
|
{
|
||||||
|
@ -88,6 +92,7 @@ public class DownloadRemoteIndexTask
|
||||||
this.runningRemoteDownloadIds = runningRemoteDownloadIds;
|
this.runningRemoteDownloadIds = runningRemoteDownloadIds;
|
||||||
this.indexUpdater = downloadRemoteIndexTaskRequest.getIndexUpdater();
|
this.indexUpdater = downloadRemoteIndexTaskRequest.getIndexUpdater();
|
||||||
this.remoteRepositoryAdmin = downloadRemoteIndexTaskRequest.getRemoteRepositoryAdmin();
|
this.remoteRepositoryAdmin = downloadRemoteIndexTaskRequest.getRemoteRepositoryAdmin();
|
||||||
|
this.indexPacker = downloadRemoteIndexTaskRequest.getIndexPacker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
|
@ -170,6 +175,13 @@ public class DownloadRemoteIndexTask
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
log.info( "time to download remote repository index for repository {}: {} s", this.remoteRepository.getId(),
|
log.info( "time to download remote repository index for repository {}: {} s", this.remoteRepository.getId(),
|
||||||
( stopWatch.getTime() / 1000 ) );
|
( stopWatch.getTime() / 1000 ) );
|
||||||
|
|
||||||
|
// index packing optionnal ??
|
||||||
|
IndexPackingRequest indexPackingRequest =
|
||||||
|
new IndexPackingRequest( indexingContext, indexingContext.getIndexDirectoryFile() );
|
||||||
|
indexPacker.packIndex( indexPackingRequest );
|
||||||
|
indexingContext.updateTimestamp( true );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( MalformedURLException e )
|
catch ( MalformedURLException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.beans.RemoteRepository;
|
||||||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||||
import org.apache.archiva.proxy.common.WagonFactory;
|
import org.apache.archiva.proxy.common.WagonFactory;
|
||||||
import org.apache.maven.index.NexusIndexer;
|
import org.apache.maven.index.NexusIndexer;
|
||||||
|
import org.apache.maven.index.packer.IndexPacker;
|
||||||
import org.apache.maven.index.updater.IndexUpdater;
|
import org.apache.maven.index.updater.IndexUpdater;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +44,8 @@ public class DownloadRemoteIndexTaskRequest
|
||||||
|
|
||||||
private IndexUpdater indexUpdater;
|
private IndexUpdater indexUpdater;
|
||||||
|
|
||||||
|
private IndexPacker indexPacker;
|
||||||
|
|
||||||
public DownloadRemoteIndexTaskRequest()
|
public DownloadRemoteIndexTaskRequest()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
|
@ -114,4 +117,15 @@ public class DownloadRemoteIndexTaskRequest
|
||||||
this.remoteRepositoryAdmin = remoteRepositoryAdmin;
|
this.remoteRepositoryAdmin = remoteRepositoryAdmin;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IndexPacker getIndexPacker()
|
||||||
|
{
|
||||||
|
return indexPacker;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadRemoteIndexTaskRequest setIndexPacker( IndexPacker indexPacker )
|
||||||
|
{
|
||||||
|
this.indexPacker = indexPacker;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue