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;
}
}
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;
}
}
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;
}
}
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;
}
}
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);
}
Aggregations