Search in sources :

Example 11 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImpl method monitorRunningAnalyses.

/**
 * {@inheritDoc}
 */
@Override
public Set<Future<AnalysisSubmission>> monitorRunningAnalyses() {
    synchronized (monitorRunningAnalysesLock) {
        logger.trace("Running monitorRunningAnalyses");
        List<AnalysisSubmission> analysisSubmissions = analysisSubmissionRepository.findByAnalysisState(AnalysisState.RUNNING);
        Set<Future<AnalysisSubmission>> submissions = Sets.newHashSet();
        for (AnalysisSubmission analysisSubmission : analysisSubmissions) {
            logger.trace("Checking state of " + analysisSubmission);
            try {
                GalaxyWorkflowStatus workflowStatus = analysisExecutionService.getWorkflowStatus(analysisSubmission);
                submissions.add(handleWorkflowStatus(workflowStatus, analysisSubmission));
            } catch (ExecutionManagerException | RuntimeException e) {
                logger.error("Error checking state for " + analysisSubmission, e);
                analysisSubmission.setAnalysisState(AnalysisState.ERROR);
                submissions.add(new AsyncResult<>(analysisSubmissionRepository.save(analysisSubmission)));
            }
        }
        return submissions;
    }
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)

Example 12 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImpl method cleanupAnalysisSubmissions.

/**
 * {@inheritDoc}
 */
@Override
public Set<Future<AnalysisSubmission>> cleanupAnalysisSubmissions() {
    synchronized (cleanupAnalysesResultsLock) {
        logger.trace("Running cleanupAnalysisSubmissions");
        List<AnalysisSubmission> analysisSubmissions = analysisSubmissionRepository.findByAnalysisState(AnalysisState.COMPLETED, AnalysisCleanedState.NOT_CLEANED);
        analysisSubmissions.addAll(analysisSubmissionRepository.findByAnalysisState(AnalysisState.ERROR, AnalysisCleanedState.NOT_CLEANED));
        Set<Future<AnalysisSubmission>> cleanedSubmissions = Sets.newHashSet();
        for (AnalysisSubmission submission : analysisSubmissions) {
            if (AnalysisCleanedState.NOT_CLEANED.equals(submission.getAnalysisCleanedState()) && cleanupCondition.shouldCleanupSubmission(submission)) {
                logger.trace("Attempting to clean up submission " + submission);
                try {
                    Future<AnalysisSubmission> cleanedSubmissionFuture = analysisExecutionService.cleanupSubmission(submission);
                    cleanedSubmissions.add(cleanedSubmissionFuture);
                } catch (ExecutionManagerException e) {
                    logger.error("Error cleaning submission " + submission, e);
                }
            }
        }
        return cleanedSubmissions;
    }
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)

Example 13 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImpl method prepareAnalyses.

/**
 * {@inheritDoc}
 */
@Override
public Set<Future<AnalysisSubmission>> prepareAnalyses() {
    synchronized (prepareAnalysesLock) {
        logger.trace("Running prepareAnalyses");
        List<AnalysisSubmission> analysisSubmissions = analysisSubmissionRepository.findByAnalysisState(AnalysisState.NEW);
        // Sort submissions by priority high to low
        analysisSubmissions.sort((a1, a2) -> {
            return a2.getPriority().compareTo(a1.getPriority());
        });
        Set<Future<AnalysisSubmission>> submissions = Sets.newHashSet();
        // check to see if execution service wants any more jobs
        int capacity = analysisExecutionService.getCapacity();
        if (capacity > 0) {
            if (capacity < analysisSubmissions.size()) {
                logger.debug("Attempting to submit more jobs than capacity, list will be trimmed: " + analysisSubmissions.size() + "=>" + capacity);
                // only submit up to capacity
                analysisSubmissions = analysisSubmissions.subList(0, capacity);
            }
            for (AnalysisSubmission analysisSubmission : analysisSubmissions) {
                logger.debug("Preparing " + analysisSubmission);
                try {
                    submissions.add(analysisExecutionService.prepareSubmission(analysisSubmission));
                } catch (ExecutionManagerException | IridaWorkflowNotFoundException | IOException e) {
                    logger.error("Error preparing submission " + analysisSubmission, e);
                }
            }
        } else {
            logger.trace("AnalysisExecutionService at max capacity.  No jobs updated.");
        }
        return submissions;
    }
}
Also used : IridaWorkflowNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) IOException(java.io.IOException) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)

Example 14 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImpl method executeAnalyses.

/**
 * {@inheritDoc}
 */
@Override
public Set<Future<AnalysisSubmission>> executeAnalyses() {
    synchronized (executeAnalysesLock) {
        logger.trace("Running executeAnalyses");
        List<AnalysisSubmission> analysisSubmissions = analysisSubmissionRepository.findByAnalysisState(AnalysisState.PREPARED);
        Set<Future<AnalysisSubmission>> submissions = Sets.newHashSet();
        for (AnalysisSubmission analysisSubmission : analysisSubmissions) {
            logger.debug("Executing " + analysisSubmission);
            try {
                submissions.add(analysisExecutionService.executeAnalysis(analysisSubmission));
            } catch (ExecutionManagerException | IridaWorkflowException e) {
                logger.error("Error executing submission " + analysisSubmission, e);
            }
        }
        return submissions;
    }
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) IridaWorkflowException(ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowException)

Example 15 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyAsync method transferAnalysisResults.

/**
 * Downloads and saves the results of an {@link AnalysisSubmission} that was
 * previously submitted from an execution manager.
 *
 * @param submittedAnalysis
 *            An {@link AnalysisSubmission} that was previously submitted.
 * @return A {@link Future} with an {@link AnalysisSubmission} object
 *         containing information about the particular analysis.
 * @throws ExecutionManagerException
 *             If there was an issue with the execution manager.
 * @throws IridaWorkflowNotFoundException
 *             If the workflow for this submission could not be found in
 *             IRIDA.
 * @throws IOException
 *             If there was an error loading the analysis results from an
 *             execution manager.
 * @throws IridaWorkflowAnalysisTypeException
 *             If there was an issue building an {@link Analysis} object.
 */
@Transactional
public Future<AnalysisSubmission> transferAnalysisResults(AnalysisSubmission submittedAnalysis) throws ExecutionManagerException, IOException, IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException {
    checkNotNull(submittedAnalysis, "submittedAnalysis is null");
    checkNotNull(submittedAnalysis.getRemoteAnalysisId(), "remoteAnalysisId is null");
    if (!analysisSubmissionService.exists(submittedAnalysis.getId())) {
        throw new EntityNotFoundException("Could not find analysis submission for " + submittedAnalysis);
    }
    logger.debug("Getting results for " + submittedAnalysis);
    Analysis analysisResults = workspaceService.getAnalysisResults(submittedAnalysis);
    logger.trace("Saving results for " + submittedAnalysis);
    Analysis savedAnalysis = analysisService.create(analysisResults);
    // if samples should be updated, set to TRANSFERRED.  Otherwise just complete.
    if (submittedAnalysis.getUpdateSamples()) {
        submittedAnalysis.setAnalysisState(AnalysisState.TRANSFERRED);
    } else {
        submittedAnalysis.setAnalysisState(AnalysisState.COMPLETED);
    }
    try {
        submittedAnalysis.setAnalysis(savedAnalysis);
    } catch (AnalysisAlreadySetException e) {
        throw new ExecutionManagerException("Analysis already set", e);
    }
    AnalysisSubmission completedSubmission = analysisSubmissionService.update(submittedAnalysis);
    return new AsyncResult<>(completedSubmission);
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisAlreadySetException(ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)15 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)8 Future (java.util.concurrent.Future)5 IOException (java.io.IOException)3 Test (org.junit.Test)3 IridaWorkflowException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowException)2 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)2 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)2 Tool (com.github.jmchilton.blend4j.galaxy.beans.Tool)2 List (java.util.List)2 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)2 AnalysisAlreadySetException (ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException)1 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)1 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)1 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)1 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)1 IridaToolParameter (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter)1 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)1 GalaxyHistoriesService (ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyHistoriesService)1