Search in sources :

Example 11 with Neo4jJobScheduler

use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.

the class SharedDiscoveryServiceIT method createDiscoveryJob.

private Callable<Void> createDiscoveryJob(MemberId member, DiscoveryServiceFactory disoveryServiceFactory, Set<MemberId> expectedTargetSet) throws ExecutionException, InterruptedException {
    Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
    jobScheduler.init();
    CoreTopologyService topologyService = disoveryServiceFactory.coreTopologyService(config(), member, jobScheduler, logProvider, userLogProvider);
    return sharedClientStarter(topologyService, expectedTargetSet);
}
Also used : Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler)

Example 12 with Neo4jJobScheduler

use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.

the class RecordStorageEngineRule method get.

private RecordStorageEngine get(FileSystemAbstraction fs, PageCache pageCache, SchemaIndexProvider schemaIndexProvider, DatabaseHealth databaseHealth, File storeDirectory, Function<BatchTransactionApplierFacade, BatchTransactionApplierFacade> transactionApplierTransformer) {
    if (!fs.fileExists(storeDirectory) && !fs.mkdir(storeDirectory)) {
        throw new IllegalStateException();
    }
    IdGeneratorFactory idGeneratorFactory = new EphemeralIdGenerator.Factory();
    LabelScanStoreProvider labelScanStoreProvider = nativeLabelScanStoreProvider(storeDirectory, fs, pageCache);
    LegacyIndexProviderLookup legacyIndexProviderLookup = mock(LegacyIndexProviderLookup.class);
    when(legacyIndexProviderLookup.all()).thenReturn(Iterables.empty());
    IndexConfigStore indexConfigStore = new IndexConfigStore(storeDirectory, fs);
    JobScheduler scheduler = life.add(new Neo4jJobScheduler());
    Config config = Config.defaults();
    Supplier<KernelTransactionsSnapshot> txSnapshotSupplier = () -> new KernelTransactionsSnapshot(Collections.emptySet(), 0);
    return life.add(new ExtendedRecordStorageEngine(storeDirectory, config, idGeneratorFactory, IdReuseEligibility.ALWAYS, new CommunityIdTypeConfigurationProvider(), pageCache, fs, NullLogProvider.getInstance(), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), () -> {
    }, new StandardConstraintSemantics(), scheduler, mock(TokenNameLookup.class), new ReentrantLockService(), schemaIndexProvider, IndexingService.NO_MONITOR, databaseHealth, labelScanStoreProvider, legacyIndexProviderLookup, indexConfigStore, new SynchronizedArrayIdOrderingQueue(20), txSnapshotSupplier, transactionApplierTransformer));
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) NeoStoreDataSourceRule.nativeLabelScanStoreProvider(org.neo4j.test.rule.NeoStoreDataSourceRule.nativeLabelScanStoreProvider) LegacyIndexProviderLookup(org.neo4j.kernel.impl.api.LegacyIndexProviderLookup) Config(org.neo4j.kernel.configuration.Config) IndexConfigStore(org.neo4j.kernel.impl.index.IndexConfigStore) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) IdGeneratorFactory(org.neo4j.kernel.impl.store.id.IdGeneratorFactory) KernelTransactionsSnapshot(org.neo4j.kernel.impl.api.KernelTransactionsSnapshot) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) SynchronizedArrayIdOrderingQueue(org.neo4j.kernel.impl.util.SynchronizedArrayIdOrderingQueue) ReentrantLockService(org.neo4j.kernel.impl.locking.ReentrantLockService) StandardConstraintSemantics(org.neo4j.kernel.impl.constraints.StandardConstraintSemantics)

Example 13 with Neo4jJobScheduler

use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.

the class IndexingServiceTest method newIndexingServiceWithMockedDependencies.

private IndexingService newIndexingServiceWithMockedDependencies(IndexPopulator populator, IndexAccessor accessor, DataUpdates data, IndexingService.Monitor monitor, IndexRule... rules) throws IOException {
    when(indexProvider.getInitialState(anyLong(), any(NewIndexDescriptor.class))).thenReturn(ONLINE);
    when(indexProvider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
    when(indexProvider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
    data.getsProcessedByStoreScanFrom(storeView);
    when(indexProvider.getOnlineAccessor(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(accessor);
    when(indexProvider.snapshotMetaFiles()).thenReturn(Iterators.emptyIterator());
    when(indexProvider.storeMigrationParticipant(any(FileSystemAbstraction.class), any(PageCache.class), any(LabelScanStoreProvider.class))).thenReturn(StoreMigrationParticipant.NOT_PARTICIPATING);
    when(nameLookup.labelGetName(anyInt())).thenAnswer(new NameLookupAnswer("label"));
    when(nameLookup.propertyKeyGetName(anyInt())).thenAnswer(new NameLookupAnswer("property"));
    Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.multi_threaded_schema_index_population_enabled.name(), "false"));
    return life.add(IndexingServiceFactory.createIndexingService(config, life.add(new Neo4jJobScheduler()), new DefaultSchemaIndexProviderMap(indexProvider), storeView, nameLookup, loop(iterator(rules)), logProvider, monitor, DO_NOTHING_CALLBACK));
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Config(org.neo4j.kernel.configuration.Config) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) PageCache(org.neo4j.io.pagecache.PageCache)

Example 14 with Neo4jJobScheduler

use of org.neo4j.kernel.impl.util.Neo4jJobScheduler in project neo4j by neo4j.

the class IndexSamplingJobTrackerTest method shouldAcceptNewJobWhenRunningJobFinishes.

@Test(timeout = 5_000)
public void shouldAcceptNewJobWhenRunningJobFinishes() throws Throwable {
    // Given
    when(config.jobLimit()).thenReturn(1);
    JobScheduler jobScheduler = new Neo4jJobScheduler();
    jobScheduler.init();
    final IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(config, jobScheduler);
    final DoubleLatch latch = new DoubleLatch();
    final AtomicBoolean lastJobExecuted = new AtomicBoolean();
    jobTracker.scheduleSamplingJob(new IndexSamplingJob() {

        @Override
        public long indexId() {
            return indexId11;
        }

        @Override
        public void run() {
            latch.waitForAllToStart();
        }
    });
    // When
    Executors.newSingleThreadExecutor().execute(() -> {
        jobTracker.waitUntilCanExecuteMoreSamplingJobs();
        jobTracker.scheduleSamplingJob(new IndexSamplingJob() {

            @Override
            public long indexId() {
                return indexId22;
            }

            @Override
            public void run() {
                lastJobExecuted.set(true);
                latch.finish();
            }
        });
    });
    assertFalse(jobTracker.canExecuteMoreSamplingJobs());
    latch.startAndWaitForAllToStart();
    latch.waitForAllToFinish();
    // Then
    assertTrue(lastJobExecuted.get());
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DoubleLatch(org.neo4j.test.DoubleLatch) Test(org.junit.Test)

Aggregations

Neo4jJobScheduler (org.neo4j.kernel.impl.util.Neo4jJobScheduler)14 Test (org.junit.Test)8 Config (org.neo4j.kernel.configuration.Config)6 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)6 CountDownLatch (java.util.concurrent.CountDownLatch)3 DoubleLatch (org.neo4j.test.DoubleLatch)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)2 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)2 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)2 File (java.io.File)1 Semaphore (java.util.concurrent.Semaphore)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ChannelException (org.jboss.netty.channel.ChannelException)1 CoreTopologyService (org.neo4j.causalclustering.discovery.CoreTopologyService)1 HazelcastDiscoveryServiceFactory (org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory)1 MemberId (org.neo4j.causalclustering.identity.MemberId)1 ClusterClientModule (org.neo4j.cluster.client.ClusterClientModule)1 NotElectableElectionCredentialsProvider (org.neo4j.cluster.protocol.election.NotElectableElectionCredentialsProvider)1 GraphDatabaseFactoryState (org.neo4j.graphdb.factory.GraphDatabaseFactoryState)1