use of org.neo4j.unsafe.impl.batchimport.staging.ExecutionMonitor in project neo4j by neo4j.
the class ParallelBatchImporterTest method shouldImportCsvData.
@Test
public void shouldImportCsvData() throws Exception {
// GIVEN
ExecutionMonitor processorAssigner = eagerRandomSaturation(config.maxNumberOfProcessors());
final BatchImporter inserter = new ParallelBatchImporter(directory.graphDbDir(), fileSystemRule.get(), config, NullLogService.getInstance(), processorAssigner, EMPTY, Config.empty(), getFormat());
boolean successful = false;
IdGroupDistribution groups = new IdGroupDistribution(NODE_COUNT, 5, random.random());
long nodeRandomSeed = random.nextLong(), relationshipRandomSeed = random.nextLong();
try {
// WHEN
inserter.doImport(Inputs.input(nodes(nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups), relationships(relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups), idMapper, idGenerator, /*insanely high bad tolerance, but it will actually never be that many*/
silentBadCollector(RELATIONSHIP_COUNT)));
// THEN
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(directory.graphDbDir()).newGraphDatabase();
try (Transaction tx = db.beginTx()) {
inputIdGenerator.reset();
verifyData(NODE_COUNT, RELATIONSHIP_COUNT, db, groups, nodeRandomSeed, relationshipRandomSeed);
tx.success();
} finally {
db.shutdown();
}
assertConsistent(directory.graphDbDir());
successful = true;
} finally {
if (!successful) {
File failureFile = directory.file("input");
try (PrintStream out = new PrintStream(failureFile)) {
out.println("Seed used in this failing run: " + random.seed());
out.println(inputIdGenerator);
inputIdGenerator.reset();
for (InputNode node : nodes(nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups)) {
out.println(node);
}
for (InputRelationship relationship : relationships(relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups)) {
out.println(relationship);
}
out.println();
out.println("Processor assignments");
out.println(processorAssigner.toString());
}
System.err.println("Additional debug information stored in " + failureFile);
}
}
}
Aggregations