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;
}
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;
}
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;
}
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());
}
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));
}
Aggregations