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