Search in sources :

Example 11 with TaskQueueException

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

the class DefaultRepositoriesService method removeScanningTaskFromQueue.

@Override
public ActionStatus removeScanningTaskFromQueue(String repositoryId) {
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    try {
        return new ActionStatus(repositoryTaskScheduler.unQueueTask(task));
    } catch (TaskQueueException e) {
        log.error("failed to unschedule scanning of repo with id {}", repositoryId, e);
        return ActionStatus.FAIL;
    }
}
Also used : RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException) ActionStatus(org.apache.archiva.rest.api.model.ActionStatus)

Example 12 with TaskQueueException

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

the class DefaultManagedRepositoryAdmin method scanRepository.

public Boolean scanRepository(String repositoryId, boolean fullScan) {
    if (getRepositoryTaskScheduler().isProcessingRepositoryTask(repositoryId)) {
        log.info("scanning of repository with id {} already scheduled", repositoryId);
    }
    RepositoryTask task = new RepositoryTask();
    task.setRepositoryId(repositoryId);
    task.setScanAll(fullScan);
    try {
        getRepositoryTaskScheduler().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 13 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method cancelScanTasks.

@Override
public List<RepositoryTaskInfo> cancelScanTasks(String repositoryId) throws RepositoryAdminException {
    try {
        ArrayList<RepositoryTaskInfo> resultList = new ArrayList<>();
        List<RepositoryTask> removeTasks = scanningTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepositoryId())).collect(Collectors.toList());
        scanningTaskExecutor.getQueue().removeAll(removeTasks);
        RepositoryTask currentTask = scanningTaskExecutor.getCurrentTask();
        if (currentTask != null && repositoryId.equals(currentTask.getRepositoryId())) {
            scanningTaskExecutor.cancelTask(currentTask);
            resultList.add(getMetadataScanTaskInfo(currentTask));
        }
        resultList.addAll(removeTasks.stream().map(task -> getMetadataScanTaskInfo(task)).collect(Collectors.toList()));
        return resultList;
    } catch (TaskQueueException e) {
        throw RepositoryAdminException.ofKey("repository.task.dequeue_failed", repositoryId);
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueExecutor(org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor) Logger(org.slf4j.Logger) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryArchivaTaskScheduler(org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) LoggerFactory(org.slf4j.LoggerFactory) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) IndexingTask(org.apache.archiva.admin.model.beans.IndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RepositoryTaskAdministration(org.apache.archiva.admin.model.admin.RepositoryTaskAdministration) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException) List(java.util.List) MetadataScanTask(org.apache.archiva.admin.model.beans.MetadataScanTask) Service(org.springframework.stereotype.Service) Named(javax.inject.Named) RepositoryStatisticsManager(org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager) IndexingArchivaTaskScheduler(org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) ArrayList(java.util.ArrayList) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 14 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method scheduleIndexFullScan.

@Override
public void scheduleIndexFullScan(String repositoryId) throws RepositoryAdminException {
    if (StringUtils.isEmpty(repositoryId)) {
        throw RepositoryAdminException.ofKey("repository.id.invalid", "");
    }
    try {
        org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository(repositoryId);
        if (repository == null) {
            throw RepositoryAdminException.ofKey("repository.not_found", repositoryId);
        }
        ArtifactIndexingTask task = new ArtifactIndexingTask(repository, null, ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext());
        task.setExecuteOnEntireRepo(true);
        task.setOnlyUpdate(false);
        indexingArchivaTaskScheduler.queueTask(task);
    } catch (TaskQueueException e) {
        log.error("Could not queue the task: {}", e.getMessage(), e);
        throw RepositoryAdminException.ofKey("repository.scan.task_queue_error", e, e.getMessage());
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException)

Example 15 with TaskQueueException

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

the class DefaultRepositoryTaskAdministration method cancelIndexTasks.

@Override
public List<RepositoryTaskInfo> cancelIndexTasks(String repositoryId) throws RepositoryAdminException {
    try {
        ArrayList<RepositoryTaskInfo> resultList = new ArrayList<>();
        List<ArtifactIndexingTask> removeTasks = indexingTaskExecutor.getQueue().getQueueSnapshot().stream().filter(task -> repositoryId.equals(task.getRepository().getId())).collect(Collectors.toList());
        indexingTaskExecutor.getQueue().removeAll(removeTasks);
        ArtifactIndexingTask currentTask = indexingTaskExecutor.getCurrentTask();
        if (currentTask != null && repositoryId.equals(currentTask.getRepository().getId())) {
            indexingTaskExecutor.cancelTask(currentTask);
            resultList.add(getIndexingTaskInfo(currentTask));
        }
        resultList.addAll(removeTasks.stream().map(task -> getIndexingTaskInfo(task)).collect(Collectors.toList()));
        return resultList;
    } catch (TaskQueueException e) {
        throw RepositoryAdminException.ofKey("repository.task.dequeue_failed", repositoryId);
    }
}
Also used : ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) TaskQueueExecutor(org.apache.archiva.components.taskqueue.execution.TaskQueueExecutor) Logger(org.slf4j.Logger) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RepositoryArchivaTaskScheduler(org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) LoggerFactory(org.slf4j.LoggerFactory) RepositoryTask(org.apache.archiva.scheduler.repository.model.RepositoryTask) IndexingTask(org.apache.archiva.admin.model.beans.IndexingTask) ScanStatus(org.apache.archiva.admin.model.beans.ScanStatus) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RepositoryTaskAdministration(org.apache.archiva.admin.model.admin.RepositoryTaskAdministration) TaskQueueException(org.apache.archiva.components.taskqueue.TaskQueueException) List(java.util.List) MetadataScanTask(org.apache.archiva.admin.model.beans.MetadataScanTask) Service(org.springframework.stereotype.Service) Named(javax.inject.Named) RepositoryStatisticsManager(org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager) IndexingArchivaTaskScheduler(org.apache.archiva.scheduler.indexing.IndexingArchivaTaskScheduler) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) RepositoryTaskInfo(org.apache.archiva.admin.model.beans.RepositoryTaskInfo) ArrayList(java.util.ArrayList) 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