Search in sources :

Example 6 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class NexusIndexerConsumer method processFile.

@Override
public void processFile(String path, boolean executeOnEntireRepo) throws Exception {
    if (executeOnEntireRepo) {
        processFile(path);
    } else {
        Path artifactFile = managedRepository.resolve(path);
        // specify in indexing task that this is not a repo scan request!
        ArtifactIndexingTask task = new ArtifactIndexingTask(repository, artifactFile, ArtifactIndexingTask.Action.ADD, repository.getIndexingContext(), false);
        // only update index we don't need to scan the full repo here
        task.setOnlyUpdate(true);
        try {
            log.debug("Queueing indexing task '{}' to add or update the artifact in the index.", task);
            scheduler.queueTask(task);
        } catch (TaskQueueException e) {
            throw new ConsumerException(e.getMessage(), e);
        }
    }
}
Also used : Path(java.nio.file.Path) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ConsumerException(org.apache.archiva.consumers.ConsumerException) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 7 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class NexusIndexerConsumer method completeScan.

@Override
public void completeScan() {
    ArtifactIndexingTask task = new ArtifactIndexingTask(repository, null, ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext());
    try {
        log.debug("Queueing indexing task '{}' to finish indexing.", task);
        scheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("Error queueing task: {}: {}", task, e.getMessage(), e);
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 8 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class RepositoryTaskJob method execute.

/**
 * Execute the discoverer and the indexer.
 *
 * @param context
 * @throws org.quartz.JobExecutionException
 */
@SuppressWarnings("unchecked")
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    setJobDataMap(dataMap);
    TaskQueue taskQueue = (TaskQueue) dataMap.get(DefaultRepositoryArchivaTaskScheduler.TASK_QUEUE);
    String repositoryId = (String) dataMap.get(DefaultRepositoryArchivaTaskScheduler.TASK_REPOSITORY);
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    try {
        taskQueue.put(task);
    } catch (TaskQueueException e) {
        throw new JobExecutionException(e);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) TaskQueue(org.apache.archiva.components.taskqueue.TaskQueue) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 9 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class AbstractRestService method doScanRepository.

protected Boolean doScanRepository(String repositoryId, boolean fullScan) {
    if (repositoryTaskScheduler.isProcessingRepositoryTask(repositoryId)) {
        log.info("scanning of repository with id {} already scheduled", repositoryId);
        return Boolean.FALSE;
    }
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    task.setScanAll(fullScan);
    try {
        repositoryTaskScheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("failed to schedule scanning of repo with id {}", repositoryId, e);
        return false;
    }
    return true;
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 10 with TaskQueueException

use of org.apache.archiva.components.taskqueue.TaskQueueException in project archiva by apache.

the class DefaultRepositoryArchivaTaskScheduler method queueInitialRepoScan.

// MRM-848: Pre-configured repository initially appear to be empty
private synchronized void queueInitialRepoScan(ManagedRepositoryConfiguration repoConfig) {
    String repoId = repoConfig.getId();
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repoId);
    if (!queuedRepos.contains(repoId)) {
        log.info("Repository [{}] is queued to be scanned as it hasn't been previously.", repoId);
        try {
            queuedRepos.add(repoConfig.getId());
            this.queueTask(task);
        } catch (TaskQueueException e) {
            log.error("Error occurred while queueing repository [{}] task : {}", e.getMessage(), repoId);
        }
    }
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Aggregations

TaskQueueException (org.apache.archiva.components.taskqueue.TaskQueueException)20 RepositoryTask (org.apache.archiva.scheduler.repository.model.RepositoryTask)15 ArtifactIndexingTask (org.apache.archiva.scheduler.indexing.ArtifactIndexingTask)10 ScanStatus (org.apache.archiva.admin.model.beans.ScanStatus)4 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Named (javax.inject.Named)2 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)2 RepositoryTaskAdministration (org.apache.archiva.admin.model.admin.RepositoryTaskAdministration)2 IndexingTask (org.apache.archiva.admin.model.beans.IndexingTask)2 MetadataScanTask (org.apache.archiva.admin.model.beans.MetadataScanTask)2 RepositoryTaskInfo (org.apache.archiva.admin.model.beans.RepositoryTaskInfo)2 TaskQueueExecutor (org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor)2 ConsumerException (org.apache.archiva.consumers.ConsumerException)2 RepositoryStatisticsManager (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager)2 RepositoryRegistry (org.apache.archiva.repository.RepositoryRegistry)2 IndexingArchivaTaskScheduler (org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler)2