Search in sources :

Example 1 with FileProcessorErrorQCEntry

use of ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry 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)

Example 2 with FileProcessorErrorQCEntry

use of ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry in project irida by phac-nml.

the class SequencingObjectServiceImplIT method testCreateCorruptSequenceFileInSample.

@Test
@WithMockUser(username = "fbristow", roles = "SEQUENCER")
public void testCreateCorruptSequenceFileInSample() throws IOException, InterruptedException {
    Sample s = sampleService.read(1L);
    SequenceFile sf = new SequenceFile();
    Path sequenceFile = Files.createTempFile("TEMPORARY-SEQUENCE-FILE", ".gz");
    OutputStream gzOut = Files.newOutputStream(sequenceFile);
    gzOut.write("not a file".getBytes());
    gzOut.close();
    sf.setFile(sequenceFile);
    SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
    objectService.createSequencingObjectInSample(so, s);
    // Wait 5 seconds. file processing should have failed by then.
    Thread.sleep(5000);
    Sample readSample = sampleService.read(s.getId());
    List<QCEntry> qcEntries = sampleService.getQCEntriesForSample(readSample);
    assertFalse("should be a qc entry", qcEntries.isEmpty());
    QCEntry qc = qcEntries.iterator().next();
    assertTrue("should be a FileProcessorErrorQCEntry", qc instanceof FileProcessorErrorQCEntry);
}
Also used : Path(java.nio.file.Path) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) GZIPOutputStream(java.util.zip.GZIPOutputStream) OutputStream(java.io.OutputStream) CoverageQCEntry(ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) QCEntry(ca.corefacility.bioinformatics.irida.model.sample.QCEntry) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

FileProcessorErrorQCEntry (ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry)2 FileProcessorTimeoutException (ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException)1 CoverageQCEntry (ca.corefacility.bioinformatics.irida.model.sample.CoverageQCEntry)1 QCEntry (ca.corefacility.bioinformatics.irida.model.sample.QCEntry)1 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)1 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)1 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)1 FileProcessor (ca.corefacility.bioinformatics.irida.processing.FileProcessor)1 FileProcessorException (ca.corefacility.bioinformatics.irida.processing.FileProcessorException)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 Test (org.junit.Test)1 WithMockUser (org.springframework.security.test.context.support.WithMockUser)1