Search in sources :

Example 11 with Configuration

use of org.neo4j.internal.batchimport.Configuration in project neo4j by neo4j.

the class ReadEntityIdsStepUsingTokenIndexTest method shouldSeeRecentUpdatesRightInFrontOfExternalUpdatesPoint.

@Test
void shouldSeeRecentUpdatesRightInFrontOfExternalUpdatesPoint() throws Exception {
    // given
    long entityCount = 1_000 + random.nextInt(100);
    BitSet expectedEntityIds = new BitSet();
    BitSet seenEntityIds = new BitSet();
    try (var indexAccessor = indexAccessor()) {
        populateTokenIndex(indexAccessor, expectedEntityIds, entityCount);
        Configuration configuration = withBatchSize(DEFAULT, 100);
        Stage stage = new Stage("Test", null, configuration, 0) {

            {
                add(new ReadEntityIdsStep(control(), configuration, cursorContext -> new TokenIndexScanIdIterator(indexAccessor.newTokenReader(), new int[] { TOKEN_ID }, CursorContext.NULL), NULL, new ControlledUpdatesCheck(indexAccessor, expectedEntityIds), new AtomicBoolean(true)));
                add(new CollectEntityIdsStep(control(), configuration, seenEntityIds));
            }
        };
        // when
        stage.execute().awaitCompletion();
        // then
        assertThat(seenEntityIds).isEqualTo(expectedEntityIds);
    }
}
Also used : RandomExtension(org.neo4j.test.extension.RandomExtension) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Stage(org.neo4j.internal.batchimport.staging.Stage) Config(org.neo4j.configuration.Config) NULL(org.neo4j.io.pagecache.tracing.PageCacheTracer.NULL) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) GraphDatabaseSettings.preallocate_logical_logs(org.neo4j.configuration.GraphDatabaseSettings.preallocate_logical_logs) Configuration.withBatchSize(org.neo4j.internal.batchimport.Configuration.withBatchSize) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) BatchSender(org.neo4j.internal.batchimport.staging.BatchSender) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Inject(org.neo4j.test.extension.Inject) RandomRule(org.neo4j.test.rule.RandomRule) StageControl(org.neo4j.internal.batchimport.staging.StageControl) PageCache(org.neo4j.io.pagecache.PageCache) EMPTY_LONG_ARRAY(org.neo4j.collection.PrimitiveLongCollections.EMPTY_LONG_ARRAY) PageCacheExtension(org.neo4j.test.extension.pagecache.PageCacheExtension) Configuration(org.neo4j.internal.batchimport.Configuration) ExternalUpdatesCheck(org.neo4j.kernel.impl.api.index.StoreScan.ExternalUpdatesCheck) TestDirectory(org.neo4j.test.rule.TestDirectory) IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) TokenIndexAccessor(org.neo4j.kernel.impl.index.schema.TokenIndexAccessor) Neo4jLayoutExtension(org.neo4j.test.extension.Neo4jLayoutExtension) IndexFiles(org.neo4j.kernel.impl.index.schema.IndexFiles) Test(org.junit.jupiter.api.Test) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) ProcessorStep(org.neo4j.internal.batchimport.staging.ProcessorStep) DatabaseIndexContext(org.neo4j.kernel.impl.index.schema.DatabaseIndexContext) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) EntityType(org.neo4j.common.EntityType) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) AnyTokenSchemaDescriptor(org.neo4j.internal.schema.AnyTokenSchemaDescriptor) BitSet(java.util.BitSet) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) GraphDatabaseSettings.neo4j_home(org.neo4j.configuration.GraphDatabaseSettings.neo4j_home) DEFAULT(org.neo4j.internal.batchimport.Configuration.DEFAULT) ONLINE(org.neo4j.kernel.impl.api.index.IndexUpdateMode.ONLINE) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Configuration(org.neo4j.internal.batchimport.Configuration) BitSet(java.util.BitSet) Stage(org.neo4j.internal.batchimport.staging.Stage) Test(org.junit.jupiter.api.Test)

Example 12 with Configuration

use of org.neo4j.internal.batchimport.Configuration in project neo4j by neo4j.

the class CoarseBoundedProgressExecutionMonitorTest method progressOnMultipleExecutions.

@ParameterizedTest
@ValueSource(ints = { 1, 10, 123 })
void progressOnMultipleExecutions(int batchSize) {
    Configuration config = config(batchSize);
    ProgressExecutionMonitor progressExecutionMonitor = new ProgressExecutionMonitor(batchSize, config);
    long total = progressExecutionMonitor.total();
    for (int i = 0; i < 4; i++) {
        progressExecutionMonitor.start(execution(0, config));
        progressExecutionMonitor.check(execution(total / 4, config));
    }
    progressExecutionMonitor.done(true, 0, "Completed");
    assertEquals(total, progressExecutionMonitor.getProgress(), "Each item should be completed");
}
Also used : Configuration(org.neo4j.internal.batchimport.Configuration) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with Configuration

use of org.neo4j.internal.batchimport.Configuration in project neo4j by neo4j.

the class CoarseBoundedProgressExecutionMonitorTest method shouldReportProgressOnSingleExecution.

@ParameterizedTest
@ValueSource(ints = { 1, 10, 123 })
void shouldReportProgressOnSingleExecution(int batchSize) {
    // GIVEN
    Configuration config = config(batchSize);
    ProgressExecutionMonitor progressExecutionMonitor = new ProgressExecutionMonitor(batchSize, config(batchSize));
    // WHEN
    long total = monitorSingleStageExecution(progressExecutionMonitor, config);
    // THEN
    assertEquals(total, progressExecutionMonitor.getProgress());
}
Also used : Configuration(org.neo4j.internal.batchimport.Configuration) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with Configuration

use of org.neo4j.internal.batchimport.Configuration in project neo4j by neo4j.

the class DynamicProcessorAssignerTest method shouldAssignProcessorsToSlowestStep.

@Test
void shouldAssignProcessorsToSlowestStep() {
    // GIVEN
    Configuration config = config(10, 5);
    DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);
    ControlledStep<?> slowStep = stepWithStats("slow", 0, Keys.avg_processing_time, 10L, Keys.done_batches, 10L);
    ControlledStep<?> fastStep = stepWithStats("fast", 0, Keys.avg_processing_time, 2L, Keys.done_batches, 10L);
    StageExecution execution = executionOf(config, slowStep, fastStep);
    assigner.start(execution);
    // WHEN
    assigner.check(execution);
    // THEN
    assertEquals(4, slowStep.processors(0));
    assertEquals(1, fastStep.processors(0));
}
Also used : Configuration(org.neo4j.internal.batchimport.Configuration) Test(org.junit.jupiter.api.Test)

Example 15 with Configuration

use of org.neo4j.internal.batchimport.Configuration in project neo4j by neo4j.

the class DynamicProcessorAssignerTest method shouldNotMoveProcessorFromFastStepSoThatItBecomesBottleneck.

@Test
void shouldNotMoveProcessorFromFastStepSoThatItBecomesBottleneck() {
    // GIVEN
    Configuration config = config(10, 4);
    DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);
    ControlledStep<?> slowStep = stepWithStats("slow", 1, Keys.avg_processing_time, 10L, Keys.done_batches, 10L);
    ControlledStep<?> fastStep = stepWithStats("fast", 0, Keys.avg_processing_time, 7L, Keys.done_batches, 10L).setProcessors(3);
    StageExecution execution = executionOf(config, slowStep, fastStep);
    assigner.start(execution);
    // WHEN checking
    assigner.check(execution);
    // THEN
    assertEquals(3, fastStep.processors(0));
    assertEquals(1, slowStep.processors(0));
}
Also used : Configuration(org.neo4j.internal.batchimport.Configuration) Test(org.junit.jupiter.api.Test)

Aggregations

Configuration (org.neo4j.internal.batchimport.Configuration)17 Test (org.junit.jupiter.api.Test)11 CursorContext (org.neo4j.io.pagecache.context.CursorContext)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 BitSet (java.util.BitSet)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 EMPTY_LONG_ARRAY (org.neo4j.collection.PrimitiveLongCollections.EMPTY_LONG_ARRAY)1 EntityType (org.neo4j.common.EntityType)1 Config (org.neo4j.configuration.Config)1 DEFAULT_DATABASE_NAME (org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME)1 GraphDatabaseSettings.neo4j_home (org.neo4j.configuration.GraphDatabaseSettings.neo4j_home)1 GraphDatabaseSettings.preallocate_logical_logs (org.neo4j.configuration.GraphDatabaseSettings.preallocate_logical_logs)1 Extractors (org.neo4j.csv.reader.Extractors)1 RecoveryCleanupWorkCollector.immediate (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate)1