Search in sources :

Example 1 with FileProcessor

use of ca.corefacility.bioinformatics.irida.processing.FileProcessor in project irida by phac-nml.

the class DefaultFileProcessingChain method launchChain.

/**
 * {@inheritDoc}
 */
@Override
public List<Exception> launchChain(Long sequencingObjectId) throws FileProcessorTimeoutException {
    List<Exception> ignoredExceptions = new ArrayList<>();
    Integer waiting = 0;
    // file has been persisted in the database.
    while (!sequencingObjectRepository.exists(sequencingObjectId)) {
        if (waiting > timeout) {
            throw new FileProcessorTimeoutException("Waiting for longer than " + sleepDuration * timeout + "ms, bailing out.");
        }
        waiting++;
        try {
            Thread.sleep(sleepDuration);
        } catch (InterruptedException e) {
        }
    }
    for (FileProcessor fileProcessor : fileProcessors) {
        try {
            if (fileProcessor.shouldProcessFile(sequencingObjectId)) {
                SequencingObject settledSequencingObject = getSettledSequencingObject(sequencingObjectId);
                fileProcessor.process(settledSequencingObject);
            }
        } catch (FileProcessorException e) {
            SequencingObject sequencingObject = sequencingObjectRepository.findOne(sequencingObjectId);
            qcRepository.save(new FileProcessorErrorQCEntry(sequencingObject));
            // execution (show the error, but proceed).
            if (fileProcessor.modifiesFile() || fastFail) {
                throw e;
            } else {
                ignoredExceptions.add(e);
                logger.error("File processor [" + fileProcessor.getClass() + "] failed to process [" + sequencingObjectId + "], but proceeding with the remaining processors because the " + "file would not be modified by the processor. Stack trace follows.", e);
            }
        }
    }
    return ignoredExceptions;
}
Also used : FileProcessorTimeoutException(ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException) FileProcessor(ca.corefacility.bioinformatics.irida.processing.FileProcessor) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) ArrayList(java.util.ArrayList) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) FileProcessorTimeoutException(ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException)

Aggregations

FileProcessorTimeoutException (ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException)1 FileProcessorErrorQCEntry (ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry)1 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)1 FileProcessor (ca.corefacility.bioinformatics.irida.processing.FileProcessor)1 FileProcessorException (ca.corefacility.bioinformatics.irida.processing.FileProcessorException)1 ArrayList (java.util.ArrayList)1