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