diff options
author | Edwin L. Punzalan <epunzalan@apache.org> | 2006-10-25 06:17:38 +0000 |
---|---|---|
committer | Edwin L. Punzalan <epunzalan@apache.org> | 2006-10-25 06:17:38 +0000 |
commit | 15fe0128dd35bc08124b4ee76d59b360ad6541cb (patch) | |
tree | 5e608ba536254c62d6db7fbae1e58bdf49ef46da /archiva-core | |
parent | c15a3f3ec59e823f0fbe86f9ed7510d0ad03dcd5 (diff) | |
download | archiva-15fe0128dd35bc08124b4ee76d59b360ad6541cb.tar.gz archiva-15fe0128dd35bc08124b4ee76d59b360ad6541cb.zip |
PR: MRM-139
Enabled task scheduler policy for queueing: wait, and skip.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@467569 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-core')
4 files changed, 57 insertions, 14 deletions
diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/DefaultRepositoryTaskScheduler.java b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/DefaultRepositoryTaskScheduler.java index 4724fedc6..21e5e7531 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/DefaultRepositoryTaskScheduler.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/DefaultRepositoryTaskScheduler.java @@ -27,6 +27,7 @@ import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; import org.apache.maven.archiva.indexer.RepositoryIndexException; import org.apache.maven.archiva.scheduler.executors.IndexerTaskExecutor; import org.apache.maven.archiva.scheduler.task.IndexerTask; +import org.apache.maven.archiva.scheduler.task.RepositoryTask; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; @@ -143,6 +144,7 @@ public class DefaultRepositoryTaskScheduler JobDataMap dataMap = new JobDataMap(); dataMap.put( RepositoryTaskJob.TASK_QUEUE, indexerQueue ); + dataMap.put( RepositoryTaskJob.TASK_QUEUE_POLICY, RepositoryTask.QUEUE_POLICY_SKIP ); jobDetail.setJobDataMap( dataMap ); return jobDetail; diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/RepositoryTaskJob.java b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/RepositoryTaskJob.java index 6b859a526..169e58a92 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/RepositoryTaskJob.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/RepositoryTaskJob.java @@ -17,6 +17,7 @@ package org.apache.maven.archiva.scheduler; */ import org.apache.maven.archiva.scheduler.task.IndexerTask; +import org.apache.maven.archiva.scheduler.task.RepositoryTask; import org.codehaus.plexus.scheduler.AbstractJob; import org.codehaus.plexus.taskqueue.TaskQueue; import org.codehaus.plexus.taskqueue.TaskQueueException; @@ -34,12 +35,13 @@ public class RepositoryTaskJob static final String TASK_QUEUE = "TASK_QUEUE"; + static final String TASK_QUEUE_POLICY = "TASK_QUEUE_POLICY"; + /** * Execute the discoverer and the indexer. * * @param context * @throws org.quartz.JobExecutionException - * */ public void execute( JobExecutionContext context ) throws JobExecutionException @@ -48,18 +50,32 @@ public class RepositoryTaskJob setJobDataMap( dataMap ); TaskQueue indexerQueue = (TaskQueue) dataMap.get( TASK_QUEUE ); + String queuePolicy = dataMap.get( TASK_QUEUE_POLICY ).toString(); - IndexerTask task = new IndexerTask(); + RepositoryTask task = new IndexerTask(); task.setJobName( context.getJobDetail().getName() ); try { - indexerQueue.put( task ); + if ( indexerQueue.getQueueSnapshot().size() == 0 ) + { + indexerQueue.put( task ); + } + else + { + if ( RepositoryTask.QUEUE_POLICY_WAIT.equals( queuePolicy ) ) + { + indexerQueue.put( task ); + } + else if ( RepositoryTask.QUEUE_POLICY_SKIP.equals( queuePolicy ) ) + { + //do not queue anymore, policy is to skip + } + } } catch ( TaskQueueException e ) { throw new JobExecutionException( e ); } } - } diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java index ec653e112..32ad62cf1 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java @@ -16,18 +16,18 @@ package org.apache.maven.archiva.scheduler.task; * limitations under the License. */ -import org.codehaus.plexus.taskqueue.Task; - /** * Task for discovering changes in the repository and updating the index accordingly. * * @author <a href="mailto:brett@apache.org">Brett Porter</a> */ public class IndexerTask - implements Task + implements RepositoryTask { private String jobName; + private String policy; + public long getMaxExecutionTime() { return 0; @@ -38,8 +38,20 @@ public class IndexerTask return jobName; } + public String getQueuePolicy() + { + return policy; + } + + public void setQueuePolicy( String policy ) + { + this.policy = policy; + } + public void setJobName( String jobName ) { this.jobName = jobName; } + + } diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/RepositoryTask.java b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/RepositoryTask.java index fc92f690b..2c9252ce6 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/RepositoryTask.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/RepositoryTask.java @@ -16,7 +16,6 @@ package org.apache.maven.archiva.scheduler.task; * limitations under the License. */ -import org.apache.maven.archiva.scheduler.TaskExecutionException; import org.codehaus.plexus.taskqueue.Task; /** @@ -27,15 +26,29 @@ import org.codehaus.plexus.taskqueue.Task; public interface RepositoryTask extends Task { + String QUEUE_POLICY_WAIT = "wait"; + + String QUEUE_POLICY_SKIP = "skip"; + + /** + * Gets the queue policy for this task. + * + * @return Queue policy for this task + */ + String getQueuePolicy(); + /** - * Execute the task. + * Sets the queue policy for this task. + * + * @param policy */ - void execute() - throws TaskExecutionException; + void setQueuePolicy( String policy ); /** - * Execute the task now if needed because the target doesn't exist. + * Sets the job name to represent a group of similar / identical job tasks. Can be used to check the + * task queue for similar / identical job tasks. */ - void executeNowIfNeeded() - throws TaskExecutionException; + void setJobName( String jobName ); + + String getJobName(); } |