mirror of
https://github.com/apache/archiva.git
synced 2025-02-08 02:59:43 +00:00
Adding type for repository group config
This commit is contained in:
parent
6c0afa8b8f
commit
c2bbd80b1b
@ -47,6 +47,15 @@ public class RepositoryGroupConfiguration
|
|||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The repository type. Currently only MAVEN type
|
||||||
|
* is known.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String type = "MAVEN";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path of the merged index.
|
* The path of the merged index.
|
||||||
*/
|
*/
|
||||||
@ -211,4 +220,12 @@ public String getName() {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,6 +731,7 @@ private RepositoryGroupConfiguration readRepositoryGroupConfiguration(String pre
|
|||||||
value.setId(id);
|
value.setId(id);
|
||||||
|
|
||||||
value.setName(registry.getString(prefix + "name"));
|
value.setName(registry.getString(prefix + "name"));
|
||||||
|
value.setType(registry.getString(prefix + "type"));
|
||||||
|
|
||||||
//String mergedIndexPath = registry.getString( prefix + "mergedIndexPath", value.getMergedIndexPath() );
|
//String mergedIndexPath = registry.getString( prefix + "mergedIndexPath", value.getMergedIndexPath() );
|
||||||
|
|
||||||
|
@ -422,6 +422,9 @@ private void writeRepositoryGroupConfiguration(String prefix, RepositoryGroupCon
|
|||||||
if (value.getName() != null) {
|
if (value.getName() != null) {
|
||||||
registry.setString(prefix + "name", value.getName());
|
registry.setString(prefix + "name", value.getName());
|
||||||
}
|
}
|
||||||
|
if (value.getType() != null) {
|
||||||
|
registry.setString(prefix + "type", value.getType());
|
||||||
|
}
|
||||||
if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer")
|
if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer")
|
||||||
) {
|
) {
|
||||||
String mergedIndexPath = "mergedIndexPath";
|
String mergedIndexPath = "mergedIndexPath";
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.index.context.IndexingContext;
|
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public interface IndexMerger
|
|||||||
* @return a temporary directory with a merge index (directory marked deleteOnExit)
|
* @return a temporary directory with a merge index (directory marked deleteOnExit)
|
||||||
* @throws IndexMergerException
|
* @throws IndexMergerException
|
||||||
*/
|
*/
|
||||||
IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
ArchivaIndexingContext buildMergedIndex(IndexMergerRequest indexMergerRequest )
|
||||||
throws IndexMergerException;
|
throws IndexMergerException;
|
||||||
|
|
||||||
void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
|
void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
|
@ -19,7 +19,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.admin.model.beans.RepositoryGroup;
|
|
||||||
|
import org.apache.archiva.repository.RepositoryGroup;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ public interface MergedRemoteIndexesScheduler
|
|||||||
* remote indexes
|
* remote indexes
|
||||||
* @param repositoryGroup
|
* @param repositoryGroup
|
||||||
*/
|
*/
|
||||||
void schedule( RepositoryGroup repositoryGroup, Path directory );
|
void schedule(RepositoryGroup repositoryGroup, Path directory );
|
||||||
|
|
||||||
void unschedule( RepositoryGroup repositoryGroup );
|
void unschedule( RepositoryGroup repositoryGroup );
|
||||||
|
|
@ -19,7 +19,8 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.admin.model.beans.RepositoryGroup;
|
import org.apache.archiva.repository.ManagedRepository;
|
||||||
|
import org.apache.archiva.repository.RepositoryGroup;
|
||||||
import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler;
|
import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -35,6 +36,7 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
@ -57,25 +59,26 @@ public class DefaultMergedRemoteIndexesScheduler
|
|||||||
private Map<String, ScheduledFuture> scheduledFutureMap = new ConcurrentHashMap<>();
|
private Map<String, ScheduledFuture> scheduledFutureMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void schedule( RepositoryGroup repositoryGroup, Path directory )
|
public void schedule(RepositoryGroup repositoryGroup, Path directory )
|
||||||
{
|
{
|
||||||
if ( StringUtils.isEmpty( repositoryGroup.getCronExpression() ) )
|
if ( StringUtils.isEmpty( repositoryGroup.getSchedulingDefinition() ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CronTrigger cronTrigger = new CronTrigger( repositoryGroup.getCronExpression() );
|
CronTrigger cronTrigger = new CronTrigger( repositoryGroup.getSchedulingDefinition() );
|
||||||
|
|
||||||
List<String> repositories = repositoryGroup.getRepositories();
|
List<ManagedRepository> repositories = repositoryGroup.getRepositories();
|
||||||
|
|
||||||
IndexMergerRequest indexMergerRequest =
|
IndexMergerRequest indexMergerRequest =
|
||||||
new IndexMergerRequest( repositories, true, repositoryGroup.getId(), repositoryGroup.getMergedIndexPath(),
|
new IndexMergerRequest( repositories.stream().map(r -> r.getId()).collect(Collectors.toList()), true, repositoryGroup.getId(),
|
||||||
repositoryGroup.getMergedIndexTtl() ).mergedIndexDirectory( directory );
|
repositoryGroup.getMergedIndexPath().getFilePath().toString(),
|
||||||
|
repositoryGroup.getMergedIndexTTL() ).mergedIndexDirectory( directory );
|
||||||
|
|
||||||
MergedRemoteIndexesTaskRequest taskRequest =
|
MergedRemoteIndexesTaskRequest taskRequest =
|
||||||
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||||
|
|
||||||
logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(),
|
logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(),
|
||||||
repositoryGroup.getCronExpression() );
|
repositoryGroup.getSchedulingDefinition() );
|
||||||
|
|
||||||
ScheduledFuture scheduledFuture =
|
ScheduledFuture scheduledFuture =
|
||||||
taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger );
|
taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger );
|
@ -19,7 +19,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.index.context.IndexingContext;
|
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public MergedRemoteIndexesTaskResult execute()
|
|||||||
{
|
{
|
||||||
IndexMerger indexMerger = mergedRemoteIndexesTaskRequest.getIndexMerger();
|
IndexMerger indexMerger = mergedRemoteIndexesTaskRequest.getIndexMerger();
|
||||||
|
|
||||||
IndexingContext indexingContext =
|
ArchivaIndexingContext indexingContext =
|
||||||
indexMerger.buildMergedIndex( mergedRemoteIndexesTaskRequest.getIndexMergerRequest() );
|
indexMerger.buildMergedIndex( mergedRemoteIndexesTaskRequest.getIndexMergerRequest() );
|
||||||
|
|
||||||
return new MergedRemoteIndexesTaskResult( indexingContext );
|
return new MergedRemoteIndexesTaskResult( indexingContext );
|
@ -19,7 +19,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.index.context.IndexingContext;
|
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
@ -27,19 +27,19 @@
|
|||||||
*/
|
*/
|
||||||
public class MergedRemoteIndexesTaskResult
|
public class MergedRemoteIndexesTaskResult
|
||||||
{
|
{
|
||||||
private IndexingContext indexingContext;
|
private ArchivaIndexingContext indexingContext;
|
||||||
|
|
||||||
public MergedRemoteIndexesTaskResult( IndexingContext indexingContext )
|
public MergedRemoteIndexesTaskResult( ArchivaIndexingContext indexingContext )
|
||||||
{
|
{
|
||||||
this.indexingContext = indexingContext;
|
this.indexingContext = indexingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexingContext getIndexingContext()
|
public ArchivaIndexingContext getIndexingContext()
|
||||||
{
|
{
|
||||||
return indexingContext;
|
return indexingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexingContext( IndexingContext indexingContext )
|
public void setIndexingContext( ArchivaIndexingContext indexingContext )
|
||||||
{
|
{
|
||||||
this.indexingContext = indexingContext;
|
this.indexingContext = indexingContext;
|
||||||
}
|
}
|
@ -19,7 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.common.utils.FileUtils;
|
import org.apache.archiva.common.utils.FileUtils;
|
||||||
|
import org.apache.archiva.indexer.ArchivaIndexingContext;
|
||||||
import org.apache.archiva.indexer.UnsupportedBaseContextException;
|
import org.apache.archiva.indexer.UnsupportedBaseContextException;
|
||||||
|
import org.apache.archiva.indexer.maven.MavenIndexContext;
|
||||||
import org.apache.archiva.indexer.merger.IndexMerger;
|
import org.apache.archiva.indexer.merger.IndexMerger;
|
||||||
import org.apache.archiva.indexer.merger.IndexMergerException;
|
import org.apache.archiva.indexer.merger.IndexMergerException;
|
||||||
import org.apache.archiva.indexer.merger.IndexMergerRequest;
|
import org.apache.archiva.indexer.merger.IndexMergerRequest;
|
||||||
@ -86,7 +88,7 @@ public DefaultIndexMerger( Indexer indexer, IndexPacker indexPacker, List<IndexC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
public ArchivaIndexingContext buildMergedIndex(IndexMergerRequest indexMergerRequest )
|
||||||
throws IndexMergerException
|
throws IndexMergerException
|
||||||
{
|
{
|
||||||
String groupId = indexMergerRequest.getGroupId();
|
String groupId = indexMergerRequest.getGroupId();
|
||||||
@ -146,7 +148,7 @@ public IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest )
|
|||||||
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() );
|
||||||
return mergedCtx;
|
return new MavenIndexContext(repositoryRegistry.getRepositoryGroup(groupId), mergedCtx);
|
||||||
}
|
}
|
||||||
catch ( IOException e)
|
catch ( IOException e)
|
||||||
{
|
{
|
Loading…
x
Reference in New Issue
Block a user