use of org.neo4j.unsafe.impl.batchimport.input.csv.DataFactory in project neo4j by neo4j.
the class ImportPanicIT method shouldExitAndThrowExceptionOnPanic.
/**
* There was this problem where some steps and in particular parallel CSV input parsing that
* paniced would hang the import entirely.
*/
@Test
public void shouldExitAndThrowExceptionOnPanic() throws Exception {
// GIVEN
BatchImporter importer = new ParallelBatchImporter(directory.absolutePath(), fs, Configuration.DEFAULT, NullLogService.getInstance(), ExecutionMonitors.invisible(), AdditionalInitialIds.EMPTY, Config.empty(), StandardV3_0.RECORD_FORMATS);
Iterable<DataFactory<InputNode>> nodeData = nodeData(data(NO_NODE_DECORATOR, fileAsCharReadable(nodeCsvFileWithBrokenEntries())));
Input brokenCsvInput = new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData(), defaultFormatRelationshipFileHeader(), IdType.ACTUAL, csvConfigurationWithLowBufferSize(), new BadCollector(new NullOutputStream(), 0, 0), Runtime.getRuntime().availableProcessors());
// WHEN
try {
importer.doImport(brokenCsvInput);
fail("Should have failed properly");
} catch (InputException e) {
// THEN
assertTrue(e.getCause() instanceof DataAfterQuoteException);
// and we managed to shut down properly
}
}
Aggregations