Search in sources :

Example 1 with TaskExecutionPanicException

use of org.neo4j.unsafe.impl.batchimport.executor.TaskExecutionPanicException in project neo4j by neo4j.

the class ParallelInputEntityDeserializerTest method shouldTreatExternalCloseAsPanic.

// Timeout is so that if this bug strikes again it will only cause this test to run for a limited time
// before failing. Normally this test is really quick
@Test(timeout = 10_000)
public void shouldTreatExternalCloseAsPanic() throws Exception {
    // GIVEN enough data to fill up queues
    int entities = 500;
    Data<InputNode> data = testData(entities);
    Configuration config = new Configuration.Overridden(COMMAS) {

        @Override
        public int bufferSize() {
            return 100;
        }
    };
    IdType idType = ACTUAL;
    Collector badCollector = mock(Collector.class);
    Groups groups = new Groups();
    // WHEN closing before having consumed all results
    DeserializerFactory<InputNode> deserializerFactory = defaultNodeDeserializer(groups, config, idType, badCollector);
    try (ParallelInputEntityDeserializer<InputNode> deserializer = new ParallelInputEntityDeserializer<>(data, defaultFormatNodeFileHeader(), config, idType, 3, 3, deserializerFactory, Validators.<InputNode>emptyValidator(), InputNode.class)) {
        deserializer.hasNext();
        deserializer.receivePanic(new RuntimeException());
        // processed items so that it wants to go ahead and offer its result.
        for (int i = 0; i < 100 && deserializer.hasNext(); i++) {
            deserializer.next();
        }
    } catch (TaskExecutionPanicException e) {
    // THEN it should be able to exit (this exception comes as a side effect)
    }
}
Also used : InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) Groups(org.neo4j.unsafe.impl.batchimport.input.Groups) Collector(org.neo4j.unsafe.impl.batchimport.input.Collector) TaskExecutionPanicException(org.neo4j.unsafe.impl.batchimport.executor.TaskExecutionPanicException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 TaskExecutionPanicException (org.neo4j.unsafe.impl.batchimport.executor.TaskExecutionPanicException)1 Collector (org.neo4j.unsafe.impl.batchimport.input.Collector)1 Groups (org.neo4j.unsafe.impl.batchimport.input.Groups)1 InputNode (org.neo4j.unsafe.impl.batchimport.input.InputNode)1