mirror of https://github.com/apache/archiva.git
add a nex flag to indicate the merged index is temporary
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551477 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5830c882e
commit
009686ad2d
|
@ -20,11 +20,15 @@ package org.apache.archiva.indexer.merger;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
|
import org.apache.archiva.admin.model.beans.RepositoryGroup;
|
||||||
|
import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
|
||||||
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||||
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
|
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
|
||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.time.StopWatch;
|
import org.apache.commons.lang.time.StopWatch;
|
||||||
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;
|
||||||
|
@ -54,9 +58,6 @@ public class DefaultIndexMerger
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
|
||||||
|
|
||||||
private MavenIndexerUtils mavenIndexerUtils;
|
private MavenIndexerUtils mavenIndexerUtils;
|
||||||
|
|
||||||
private NexusIndexer indexer;
|
private NexusIndexer indexer;
|
||||||
|
@ -120,8 +121,12 @@ public class DefaultIndexMerger
|
||||||
IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
|
IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
|
||||||
indexPacker.packIndex( request );
|
indexPacker.packIndex( request );
|
||||||
}
|
}
|
||||||
temporaryGroupIndexes.add( new TemporaryGroupIndex( mergedIndexDirectory, tempRepoId, groupId,
|
|
||||||
indexMergerRequest.getMergedIndexTtl() ) );
|
if ( indexMergerRequest.isTemporary() )
|
||||||
|
{
|
||||||
|
temporaryGroupIndexes.add( new TemporaryGroupIndex( mergedIndexDirectory, tempRepoId, groupId,
|
||||||
|
indexMergerRequest.getMergedIndexTtl() ) );
|
||||||
|
}
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
log.info( "merged index for repos {} in {} s", indexMergerRequest.getRepositoriesIds(),
|
log.info( "merged index for repos {} in {} s", indexMergerRequest.getRepositoriesIds(),
|
||||||
stopWatch.getTime() );
|
stopWatch.getTime() );
|
||||||
|
|
|
@ -47,6 +47,8 @@ public class IndexMergerRequest
|
||||||
|
|
||||||
private File mergedIndexDirectory;
|
private File mergedIndexDirectory;
|
||||||
|
|
||||||
|
private boolean temporary;
|
||||||
|
|
||||||
public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId )
|
public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId )
|
||||||
{
|
{
|
||||||
this.repositoriesIds = repositoriesIds;
|
this.repositoriesIds = repositoriesIds;
|
||||||
|
@ -133,6 +135,22 @@ public class IndexMergerRequest
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTemporary()
|
||||||
|
{
|
||||||
|
return temporary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemporary( boolean temporary )
|
||||||
|
{
|
||||||
|
this.temporary = temporary;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IndexMergerRequest temporary( boolean temporary )
|
||||||
|
{
|
||||||
|
this.temporary = temporary;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
|
@ -143,7 +161,8 @@ public class IndexMergerRequest
|
||||||
sb.append( ", groupId='" ).append( groupId ).append( '\'' );
|
sb.append( ", groupId='" ).append( groupId ).append( '\'' );
|
||||||
sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
|
sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
|
||||||
sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl );
|
sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl );
|
||||||
sb.append( ", mergedIndexDirectory='" ).append( mergedIndexDirectory ).append( '\'' );
|
sb.append( ", mergedIndexDirectory=" ).append( mergedIndexDirectory );
|
||||||
|
sb.append( ", temporary=" ).append( temporary );
|
||||||
sb.append( '}' );
|
sb.append( '}' );
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1314,7 +1314,8 @@ public class ArchivaDavResourceFactory
|
||||||
|
|
||||||
IndexMergerRequest indexMergerRequest = new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
|
IndexMergerRequest indexMergerRequest = new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
|
||||||
repositoryGroupConfiguration.getMergedIndexPath(),
|
repositoryGroupConfiguration.getMergedIndexPath(),
|
||||||
repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile );
|
repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile )
|
||||||
|
.temporary( true );
|
||||||
|
|
||||||
MergedRemoteIndexesTaskRequest taskRequest =
|
MergedRemoteIndexesTaskRequest taskRequest =
|
||||||
new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger);
|
new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger);
|
||||||
|
|
Loading…
Reference in New Issue