Search in sources :

Example 1 with StatementLocksFactory

use of org.neo4j.kernel.impl.locking.StatementLocksFactory in project neo4j by neo4j.

the class NeoStoreDataSourceRule method getDataSource.

public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, IdGeneratorFactory idGeneratorFactory, IdTypeConfigurationProvider idConfigurationProvider, PageCache pageCache, Config config, DatabaseHealth databaseHealth, LogService logService) {
    if (dataSource != null) {
        dataSource.stop();
        dataSource.shutdown();
    }
    StatementLocksFactory locksFactory = mock(StatementLocksFactory.class);
    StatementLocks statementLocks = mock(StatementLocks.class);
    Locks.Client locks = mock(Locks.Client.class);
    when(statementLocks.optimistic()).thenReturn(locks);
    when(statementLocks.pessimistic()).thenReturn(locks);
    when(locksFactory.newInstance()).thenReturn(statementLocks);
    JobScheduler jobScheduler = mock(JobScheduler.class, RETURNS_MOCKS);
    Monitors monitors = new Monitors();
    LabelScanStoreProvider labelScanStoreProvider = nativeLabelScanStoreProvider(storeDir, fs, pageCache, config, logService);
    SystemNanoClock clock = Clocks.nanoClock();
    dataSource = new NeoStoreDataSource(storeDir, config, idGeneratorFactory, IdReuseEligibility.ALWAYS, idConfigurationProvider, logService, mock(JobScheduler.class, RETURNS_MOCKS), mock(TokenNameLookup.class), dependencyResolverForNoIndexProvider(labelScanStoreProvider), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), locksFactory, mock(SchemaWriteGuard.class), mock(TransactionEventHandlers.class), IndexingService.NO_MONITOR, fs, mock(TransactionMonitor.class), databaseHealth, mock(PhysicalLogFile.Monitor.class), TransactionHeaderInformationFactory.DEFAULT, new StartupStatisticsProvider(), null, new CommunityCommitProcessFactory(), mock(InternalAutoIndexing.class), pageCache, new StandardConstraintSemantics(), monitors, new Tracers("null", NullLog.getInstance(), monitors, jobScheduler), mock(Procedures.class), IOLimiter.unlimited(), new AvailabilityGuard(clock, NullLog.getInstance()), clock, new CanWrite(), new StoreCopyCheckPointMutex());
    return dataSource;
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) Locks(org.neo4j.kernel.impl.locking.Locks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) StartupStatisticsProvider(org.neo4j.kernel.impl.core.StartupStatisticsProvider) CanWrite(org.neo4j.kernel.impl.factory.CanWrite) SystemNanoClock(org.neo4j.time.SystemNanoClock) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) Monitors(org.neo4j.kernel.monitoring.Monitors) StoreCopyCheckPointMutex(org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex) CommunityCommitProcessFactory(org.neo4j.kernel.impl.factory.CommunityCommitProcessFactory) StandardConstraintSemantics(org.neo4j.kernel.impl.constraints.StandardConstraintSemantics) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers)

Example 2 with StatementLocksFactory

use of org.neo4j.kernel.impl.locking.StatementLocksFactory in project neo4j by neo4j.

the class StatementLocksFactorySelector method select.

public StatementLocksFactory select() {
    StatementLocksFactory statementLocksFactory;
    String serviceName = StatementLocksFactory.class.getSimpleName();
    List<StatementLocksFactory> factories = serviceLoadFactories();
    if (factories.isEmpty()) {
        statementLocksFactory = new SimpleStatementLocksFactory();
        log.info("No services implementing " + serviceName + " found. " + "Using " + SimpleStatementLocksFactory.class.getSimpleName());
    } else if (factories.size() == 1) {
        statementLocksFactory = factories.get(0);
        log.info("Found single implementation of " + serviceName + ". Namely " + statementLocksFactory.getClass().getSimpleName());
    } else {
        throw new IllegalStateException("Found more than one implementation of " + serviceName + ": " + factories);
    }
    statementLocksFactory.initialize(locks, config);
    return statementLocksFactory;
}
Also used : SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory)

Example 3 with StatementLocksFactory

use of org.neo4j.kernel.impl.locking.StatementLocksFactory in project neo4j by neo4j.

the class KernelTransactionsTest method newKernelTransactions.

private static KernelTransactions newKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, boolean testKernelTransactions) throws Throwable {
    LifeSupport life = new LifeSupport();
    life.start();
    TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
    when(transactionIdStore.getLastCommittedTransaction()).thenReturn(new TransactionId(0, 0, 0));
    Tracers tracers = new Tracers("null", NullLog.getInstance(), new Monitors(), mock(JobScheduler.class));
    StatementLocksFactory statementLocksFactory = new SimpleStatementLocksFactory(locks);
    StatementOperationContainer statementOperationsContianer = new StatementOperationContainer(null, null);
    KernelTransactions transactions;
    if (testKernelTransactions) {
        transactions = createTestTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperationsContianer, clock, availabilityGuard);
    } else {
        transactions = createTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperationsContianer, clock, availabilityGuard);
    }
    transactions.start();
    return transactions;
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) Monitors(org.neo4j.kernel.monitoring.Monitors) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) TransactionId(org.neo4j.kernel.impl.store.TransactionId) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers)

Example 4 with StatementLocksFactory

use of org.neo4j.kernel.impl.locking.StatementLocksFactory in project neo4j by neo4j.

the class StatementLocksFactorySelectorTest method loadSimpleStatementLocksFactoryWhenNoServices.

@Test
public void loadSimpleStatementLocksFactoryWhenNoServices() {
    Locks locks = mock(Locks.class);
    Locks.Client locksClient = mock(Client.class);
    when(locks.newClient()).thenReturn(locksClient);
    StatementLocksFactorySelector loader = newLoader(locks);
    StatementLocksFactory factory = loader.select();
    StatementLocks statementLocks = factory.newInstance();
    assertThat(factory, instanceOf(SimpleStatementLocksFactory.class));
    assertThat(statementLocks, instanceOf(SimpleStatementLocks.class));
    assertSame(locksClient, statementLocks.optimistic());
    assertSame(locksClient, statementLocks.pessimistic());
}
Also used : SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) Client(org.neo4j.kernel.impl.locking.Locks.Client) SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) Locks(org.neo4j.kernel.impl.locking.Locks) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) Test(org.junit.Test)

Example 5 with StatementLocksFactory

use of org.neo4j.kernel.impl.locking.StatementLocksFactory in project neo4j by neo4j.

the class StatementLocksFactorySelectorTest method loadSingleAvailableFactory.

@Test
public void loadSingleAvailableFactory() {
    Locks locks = mock(Locks.class);
    StatementLocksFactory factory = mock(StatementLocksFactory.class);
    StatementLocksFactorySelector loader = newLoader(locks, factory);
    StatementLocksFactory loadedFactory = loader.select();
    assertSame(factory, loadedFactory);
    verify(factory).initialize(same(locks), any(Config.class));
}
Also used : SimpleStatementLocksFactory(org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory) StatementLocksFactory(org.neo4j.kernel.impl.locking.StatementLocksFactory) Config(org.neo4j.kernel.configuration.Config) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) Locks(org.neo4j.kernel.impl.locking.Locks) Test(org.junit.Test)

Aggregations

StatementLocksFactory (org.neo4j.kernel.impl.locking.StatementLocksFactory)5 SimpleStatementLocksFactory (org.neo4j.kernel.impl.locking.SimpleStatementLocksFactory)4 Locks (org.neo4j.kernel.impl.locking.Locks)3 StatementLocks (org.neo4j.kernel.impl.locking.StatementLocks)3 Test (org.junit.Test)2 SimpleStatementLocks (org.neo4j.kernel.impl.locking.SimpleStatementLocks)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 Monitors (org.neo4j.kernel.monitoring.Monitors)2 Tracers (org.neo4j.kernel.monitoring.tracing.Tracers)2 AvailabilityGuard (org.neo4j.kernel.AvailabilityGuard)1 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)1 Config (org.neo4j.kernel.configuration.Config)1 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)1 StandardConstraintSemantics (org.neo4j.kernel.impl.constraints.StandardConstraintSemantics)1 StartupStatisticsProvider (org.neo4j.kernel.impl.core.StartupStatisticsProvider)1 CanWrite (org.neo4j.kernel.impl.factory.CanWrite)1 CommunityCommitProcessFactory (org.neo4j.kernel.impl.factory.CommunityCommitProcessFactory)1 Client (org.neo4j.kernel.impl.locking.Locks.Client)1 TransactionId (org.neo4j.kernel.impl.store.TransactionId)1 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)1