diff options
author | Olivier Lamy <olamy@apache.org> | 2013-12-17 07:29:31 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-12-17 07:29:31 +0000 |
commit | 1e1f7cdacd0118a5fb9a707871c7b7100b7f09d2 (patch) | |
tree | 1f1750f62f31b10b5cd1cb0b9ed96eeed848c823 | |
parent | 3ac4f6e6624968f11d6293ac17244e1275ab1305 (diff) | |
download | archiva-1e1f7cdacd0118a5fb9a707871c7b7100b7f09d2.tar.gz archiva-1e1f7cdacd0118a5fb9a707871c7b7100b7f09d2.zip |
[MRM-1746] build merged index for groups with a cron schedule
fix issues
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1551475 13f79535-47bb-0310-9956-ffa450edef68
5 files changed, 24 insertions, 20 deletions
diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java index 480529b44..776253d99 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java @@ -22,6 +22,7 @@ package org.apache.archiva.indexer.merger; import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.TaskScheduler; @@ -52,24 +53,19 @@ public class DefaultMergedRemoteIndexesScheduler private TaskScheduler taskScheduler; @Inject - private RepositoryGroupAdmin repositoryGroupAdmin; - - @Inject private IndexMerger indexMerger; private Map<String, ScheduledFuture> scheduledFutureMap = new ConcurrentHashMap<String, ScheduledFuture>(); @Override - public void schedule( RepositoryGroup repositoryGroup ) + public void schedule( RepositoryGroup repositoryGroup, File directory ) { - if ( repositoryGroup.getCronExpression() == null ) + if ( StringUtils.isEmpty( repositoryGroup.getCronExpression() ) ) { return; } CronTrigger cronTrigger = new CronTrigger( repositoryGroup.getCronExpression() ); - File directory = repositoryGroupAdmin.getMergedIndexDirectory( repositoryGroup.getId() ); - List<String> repositories = repositoryGroup.getRepositories(); IndexMergerRequest indexMergerRequest = @@ -79,6 +75,9 @@ public class DefaultMergedRemoteIndexesScheduler MergedRemoteIndexesTaskRequest taskRequest = new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger ); + logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(), + repositoryGroup.getCronExpression() ); + ScheduledFuture scheduledFuture = taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger ); scheduledFutureMap.put( repositoryGroup.getId(), scheduledFuture ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RepositoryGroup.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RepositoryGroup.java index 2064cc026..8a116e158 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RepositoryGroup.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RepositoryGroup.java @@ -176,7 +176,7 @@ public class RepositoryGroup this.cronExpression = cronExpression; } - public RepositoryGroup mergedIndexCronExpression( String mergedIndexCronExpression ) + public RepositoryGroup cronExpression( String mergedIndexCronExpression ) { this.cronExpression = mergedIndexCronExpression; return this; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java index e35c74c06..abc3caae5 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java @@ -84,7 +84,7 @@ public class DefaultRepositoryGroupAdmin { for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() ) { - mergedRemoteIndexesScheduler.schedule( repositoryGroup ); + mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) ); } } catch ( RepositoryAdminException e ) @@ -112,7 +112,8 @@ public class DefaultRepositoryGroupAdmin repositoriesGroups.add( new RepositoryGroup( repositoryGroupConfiguration.getId(), new ArrayList<String>( repositoryGroupConfiguration.getRepositories() ) ).mergedIndexPath( repositoryGroupConfiguration.getMergedIndexPath() ).mergedIndexTtl( - repositoryGroupConfiguration.getMergedIndexTtl() ) ); + repositoryGroupConfiguration.getMergedIndexTtl() ).cronExpression( + repositoryGroupConfiguration.getCronExpression() ) ); } return repositoriesGroups; @@ -148,7 +149,7 @@ public class DefaultRepositoryGroupAdmin configuration.addRepositoryGroup( repositoryGroupConfiguration ); saveConfiguration( configuration ); triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.ADD_REPO_GROUP, auditInformation ); - mergedRemoteIndexesScheduler.schedule( repositoryGroup ); + mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) ); return Boolean.TRUE; } @@ -202,7 +203,7 @@ public class DefaultRepositoryGroupAdmin triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation ); } mergedRemoteIndexesScheduler.unschedule( repositoryGroup ); - mergedRemoteIndexesScheduler.schedule( repositoryGroup ); + mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) ); return Boolean.TRUE; } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java index ae96cfe64..b799861c2 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java @@ -21,6 +21,8 @@ package org.apache.archiva.scheduler; import org.apache.archiva.admin.model.beans.RepositoryGroup; +import java.io.File; + /** * @author Olivier Lamy * @since 2.0.0 @@ -33,7 +35,7 @@ public interface MergedRemoteIndexesScheduler * remote indexes * @param repositoryGroup */ - void schedule( RepositoryGroup repositoryGroup ); + void schedule( RepositoryGroup repositoryGroup, File directory ); void unschedule( RepositoryGroup repositoryGroup ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java index 1b5759101..afabd6676 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java @@ -33,7 +33,7 @@ import java.util.List; /** * @author Olivier Lamy */ -@Service( "repositoryGroupService#rest" ) +@Service("repositoryGroupService#rest") public class DefaultRepositoryGroupService extends AbstractRestService implements RepositoryGroupService @@ -52,8 +52,8 @@ public class DefaultRepositoryGroupService for ( org.apache.archiva.admin.model.beans.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() ) { repositoriesGroups.add( new RepositoryGroup( repoGroup.getId(), new ArrayList<String>( - repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ) - .mergedIndexTtl( repoGroup.getMergedIndexTtl() ) ); + repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl( + repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ) ); } return repositoriesGroups; } @@ -83,8 +83,9 @@ public class DefaultRepositoryGroupService { return repositoryGroupAdmin.addRepositoryGroup( new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<String>( - repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ) - .mergedIndexTtl( repoGroup.getMergedIndexTtl() ), getAuditInformation() ); + repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl( + repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ), + getAuditInformation() ); } catch ( RepositoryAdminException e ) { @@ -99,8 +100,9 @@ public class DefaultRepositoryGroupService { return repositoryGroupAdmin.updateRepositoryGroup( new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<String>( - repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ) - .mergedIndexTtl( repoGroup.getMergedIndexTtl() ), getAuditInformation() ); + repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl( + repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ), + getAuditInformation() ); } catch ( RepositoryAdminException e ) { |