Search in sources :

Example 1 with JobSchedulerAdapter

use of org.neo4j.test.scheduler.JobSchedulerAdapter in project neo4j by neo4j.

the class BlockBasedIndexPopulatorTest method shouldScheduleMergeOnJobSchedulerWithCorrectGroup.

@Test
void shouldScheduleMergeOnJobSchedulerWithCorrectGroup() throws IndexEntryConflictException, IOException {
    // given
    BlockBasedIndexPopulator<GenericKey, NativeIndexValue> populator = instantiatePopulator(NO_MONITOR);
    boolean closed = false;
    try {
        populator.add(batchOfUpdates(), NULL);
        // when
        MutableBoolean called = new MutableBoolean();
        JobScheduler trackingJobScheduler = new JobSchedulerAdapter() {

            @Override
            public <T> JobHandle<T> schedule(Group group, JobMonitoringParams jobMonitoringParams, Callable<T> job) {
                called.setTrue();
                assertThat(group).isSameAs(Group.INDEX_POPULATION_WORK);
                return jobScheduler.schedule(group, jobMonitoringParams, job);
            }
        };
        populator.scanCompleted(nullInstance, wrapScheduler(trackingJobScheduler), NULL);
        assertTrue(called.booleanValue());
        populator.close(true, NULL);
        closed = true;
    } finally {
        if (!closed) {
            populator.close(true, NULL);
        }
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) Group(org.neo4j.scheduler.Group) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) JobSchedulerAdapter(org.neo4j.test.scheduler.JobSchedulerAdapter) JobMonitoringParams(org.neo4j.scheduler.JobMonitoringParams) Callable(java.util.concurrent.Callable) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Callable (java.util.concurrent.Callable)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Group (org.neo4j.scheduler.Group)1 JobMonitoringParams (org.neo4j.scheduler.JobMonitoringParams)1 JobScheduler (org.neo4j.scheduler.JobScheduler)1 JobSchedulerAdapter (org.neo4j.test.scheduler.JobSchedulerAdapter)1