Search in sources :

Example 1 with FileProcessingChain

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

the class DefaultFileProcessingChainTest method testFastFailProcessorChain.

@Test(expected = FileProcessorException.class)
public void testFastFailProcessorChain() throws FileProcessorTimeoutException {
    FileProcessingChain fileProcessingChain = new DefaultFileProcessingChain(objectRepository, qcRepository, new FailingFileProcessor());
    when(objectRepository.exists(objectId)).thenReturn(true);
    fileProcessingChain.setFastFail(true);
    fileProcessingChain.launchChain(1L);
    fail("should not proceed when encountering exception and fastFail is enabled.");
}
Also used : DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) FileProcessingChain(ca.corefacility.bioinformatics.irida.processing.FileProcessingChain) DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) Test(org.junit.Test)

Example 2 with FileProcessingChain

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

the class DefaultFileProcessingChain method getSettledSequencingObject.

/**
 * Checks the {@link SequenceFile}s for the given {@link SequencingObject}
 * to see if it's files are in the place they should be. Since there's lots
 * of saves going on during the {@link FileProcessingChain} the transaction
 * might not be complete in the time the file is first read.
 *
 * @param sequencingObjectId
 *            the id of the {@link SequencingObject} to check
 * @return the settled {@link SequencingObject}
 * @throws FileProcessorTimeoutException
 *             if the files don't settle in the configured timeout
 */
private SequencingObject getSettledSequencingObject(Long sequencingObjectId) throws FileProcessorTimeoutException {
    boolean filesNotSettled = true;
    Integer waiting = 0;
    SequencingObject sequencingObject;
    do {
        if (waiting > timeout) {
            throw new FileProcessorTimeoutException("Waiting for longer than " + sleepDuration * timeout + "ms, bailing out.  File id " + sequencingObjectId);
        }
        waiting++;
        try {
            Thread.sleep(sleepDuration);
        } catch (InterruptedException e) {
        }
        sequencingObject = sequencingObjectRepository.findOne(sequencingObjectId);
        Set<SequenceFile> files = sequencingObject.getFiles();
        filesNotSettled = files.stream().anyMatch(f -> {
            return !Files.exists(f.getFile());
        });
    } while (filesNotSettled);
    return sequencingObject;
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Files(java.nio.file.Files) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) SequencingObjectRepository(ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequencingObjectRepository) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) QCEntryRepository(ca.corefacility.bioinformatics.irida.repositories.sample.QCEntryRepository) ArrayList(java.util.ArrayList) FileProcessor(ca.corefacility.bioinformatics.irida.processing.FileProcessor) FileProcessorErrorQCEntry(ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry) List(java.util.List) FileProcessorTimeoutException(ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException) FileProcessingChain(ca.corefacility.bioinformatics.irida.processing.FileProcessingChain) FileProcessorTimeoutException(ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)

Example 3 with FileProcessingChain

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

the class SequencingObjectServiceTest method setUp.

@Before
public void setUp() {
    repository = mock(SequencingObjectRepository.class);
    sequenceFileRepository = mock(SequenceFileRepository.class);
    ssoRepository = mock(SampleSequencingObjectJoinRepository.class);
    executor = mock(TaskExecutor.class);
    fileProcessingChain = mock(FileProcessingChain.class);
    concatenationRepository = mock(SequenceConcatenationRepository.class);
    service = new SequencingObjectServiceImpl(repository, sequenceFileRepository, ssoRepository, concatenationRepository, executor, fileProcessingChain, validator);
}
Also used : TaskExecutor(org.springframework.core.task.TaskExecutor) SequenceConcatenationRepository(ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequenceConcatenationRepository) SequencingObjectRepository(ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequencingObjectRepository) SequenceFileRepository(ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequenceFileRepository) SequencingObjectServiceImpl(ca.corefacility.bioinformatics.irida.service.impl.SequencingObjectServiceImpl) SampleSequencingObjectJoinRepository(ca.corefacility.bioinformatics.irida.repositories.joins.sample.SampleSequencingObjectJoinRepository) FileProcessingChain(ca.corefacility.bioinformatics.irida.processing.FileProcessingChain) Before(org.junit.Before)

Example 4 with FileProcessingChain

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

the class DefaultFileProcessingChainTest method testFailWithContinueChain.

@Test
public void testFailWithContinueChain() throws FileProcessorTimeoutException {
    FileProcessingChain fileProcessingChain = new DefaultFileProcessingChain(objectRepository, qcRepository, new FailingFileProcessor());
    when(objectRepository.exists(objectId)).thenReturn(true);
    List<Exception> exceptions = fileProcessingChain.launchChain(1L);
    // exceptions should be ignored in this test
    assertEquals("exactly one exception should have been ignored.", 1, exceptions.size());
    assertTrue("ignored exception should be of type FileProcessorException.", exceptions.iterator().next() instanceof FileProcessorException);
}
Also used : FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) FileProcessorTimeoutException(ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException) FileProcessingChain(ca.corefacility.bioinformatics.irida.processing.FileProcessingChain) DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) Test(org.junit.Test)

Example 5 with FileProcessingChain

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

the class DefaultFileProcessingChainTest method testExceedsTimeout.

@Test(expected = FileProcessorTimeoutException.class)
public void testExceedsTimeout() throws FileProcessorTimeoutException {
    FileProcessingChain fileProcessingChain = new DefaultFileProcessingChain(objectRepository, qcRepository);
    fileProcessingChain.setTimeout(1);
    fileProcessingChain.setSleepDuration(0);
    fileProcessingChain.launchChain(objectId);
}
Also used : DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) FileProcessingChain(ca.corefacility.bioinformatics.irida.processing.FileProcessingChain) DefaultFileProcessingChain(ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain) Test(org.junit.Test)

Aggregations

FileProcessingChain (ca.corefacility.bioinformatics.irida.processing.FileProcessingChain)8 DefaultFileProcessingChain (ca.corefacility.bioinformatics.irida.processing.impl.DefaultFileProcessingChain)6 Test (org.junit.Test)6 FileProcessorException (ca.corefacility.bioinformatics.irida.processing.FileProcessorException)3 FileProcessorTimeoutException (ca.corefacility.bioinformatics.irida.exceptions.FileProcessorTimeoutException)2 SequencingObjectRepository (ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequencingObjectRepository)2 FileProcessorErrorQCEntry (ca.corefacility.bioinformatics.irida.model.sample.FileProcessorErrorQCEntry)1 QCEntry (ca.corefacility.bioinformatics.irida.model.sample.QCEntry)1 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)1 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)1 FileProcessor (ca.corefacility.bioinformatics.irida.processing.FileProcessor)1 SampleSequencingObjectJoinRepository (ca.corefacility.bioinformatics.irida.repositories.joins.sample.SampleSequencingObjectJoinRepository)1 QCEntryRepository (ca.corefacility.bioinformatics.irida.repositories.sample.QCEntryRepository)1 SequenceConcatenationRepository (ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequenceConcatenationRepository)1 SequenceFileRepository (ca.corefacility.bioinformatics.irida.repositories.sequencefile.SequenceFileRepository)1 SequencingObjectServiceImpl (ca.corefacility.bioinformatics.irida.service.impl.SequencingObjectServiceImpl)1 Files (java.nio.file.Files)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1