Search in sources :

Example 1 with CanWrite

use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.

the class StorageLayerTest method before.

@SuppressWarnings("deprecation")
@Before
public void before() {
    db = (GraphDatabaseAPI) createGraphDatabase();
    DependencyResolver resolver = db.getDependencyResolver();
    this.disk = resolver.resolveDependency(StorageEngine.class).storeReadLayer();
    this.state = new KernelStatement(null, null, disk.newStatement(), new Procedures(), new CanWrite(), LockTracer.NONE);
}
Also used : CanWrite(org.neo4j.kernel.impl.factory.CanWrite) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) Procedures(org.neo4j.kernel.impl.proc.Procedures) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Example 2 with CanWrite

use of org.neo4j.kernel.impl.factory.CanWrite 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 3 with CanWrite

use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.

the class KernelStatementTest method shouldReleaseStorageStatementWhenForceClosed.

@Test
public void shouldReleaseStorageStatementWhenForceClosed() throws Exception {
    // given
    StorageStatement storeStatement = mock(StorageStatement.class);
    KernelStatement statement = new KernelStatement(mock(KernelTransactionImplementation.class), null, storeStatement, new Procedures(), new CanWrite(), LockTracer.NONE);
    statement.acquire();
    // when
    statement.forceClose();
    // then
    verify(storeStatement).release();
}
Also used : CanWrite(org.neo4j.kernel.impl.factory.CanWrite) StorageStatement(org.neo4j.storageengine.api.StorageStatement) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Example 4 with CanWrite

use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.

the class KernelStatementTest method shouldThrowTerminateExceptionWhenTransactionTerminated.

@Test(expected = TransactionTerminatedException.class)
public void shouldThrowTerminateExceptionWhenTransactionTerminated() throws Exception {
    KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
    when(transaction.getReasonIfTerminated()).thenReturn(Optional.of(Status.Transaction.Terminated));
    when(transaction.securityContext()).thenReturn(AUTH_DISABLED);
    KernelStatement statement = new KernelStatement(transaction, null, mock(StorageStatement.class), null, new CanWrite(), LockTracer.NONE);
    statement.acquire();
    statement.readOperations().nodeExists(0);
}
Also used : CanWrite(org.neo4j.kernel.impl.factory.CanWrite) StorageStatement(org.neo4j.storageengine.api.StorageStatement) Test(org.junit.Test)

Example 5 with CanWrite

use of org.neo4j.kernel.impl.factory.CanWrite in project neo4j by neo4j.

the class KernelTransactionFactory method kernelTransactionWithInternals.

static Instances kernelTransactionWithInternals(SecurityContext securityContext) {
    TransactionHeaderInformation headerInformation = new TransactionHeaderInformation(-1, -1, new byte[0]);
    TransactionHeaderInformationFactory headerInformationFactory = mock(TransactionHeaderInformationFactory.class);
    when(headerInformationFactory.create()).thenReturn(headerInformation);
    StorageEngine storageEngine = mock(StorageEngine.class);
    StoreReadLayer storeReadLayer = mock(StoreReadLayer.class);
    StorageStatement storageStatement = mock(StorageStatement.class);
    when(storeReadLayer.newStatement()).thenReturn(storageStatement);
    when(storageEngine.storeReadLayer()).thenReturn(storeReadLayer);
    KernelTransactionImplementation transaction = new KernelTransactionImplementation(mock(StatementOperationContainer.class), mock(SchemaWriteGuard.class), new TransactionHooks(), mock(ConstraintIndexCreator.class), new Procedures(), headerInformationFactory, mock(TransactionRepresentationCommitProcess.class), mock(TransactionMonitor.class), mock(Supplier.class), mock(Pool.class), Clocks.systemClock(), NULL, LockTracer.NONE, PageCursorTracerSupplier.NULL, storageEngine, new CanWrite());
    StatementLocks statementLocks = new SimpleStatementLocks(new NoOpClient());
    transaction.initialize(0, 0, statementLocks, KernelTransaction.Type.implicit, securityContext, 0L);
    return new Instances(transaction, storageEngine, storeReadLayer, storageStatement);
}
Also used : StorageStatement(org.neo4j.storageengine.api.StorageStatement) TransactionHeaderInformation(org.neo4j.kernel.impl.api.TransactionHeaderInformation) StoreReadLayer(org.neo4j.storageengine.api.StoreReadLayer) TransactionHooks(org.neo4j.kernel.impl.api.TransactionHooks) Procedures(org.neo4j.kernel.impl.proc.Procedures) TransactionHeaderInformationFactory(org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory) StorageEngine(org.neo4j.storageengine.api.StorageEngine) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) CanWrite(org.neo4j.kernel.impl.factory.CanWrite) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) SchemaWriteGuard(org.neo4j.kernel.impl.api.SchemaWriteGuard) NoOpClient(org.neo4j.kernel.impl.locking.NoOpClient) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) TransactionRepresentationCommitProcess(org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks) PageCursorTracerSupplier(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier) Supplier(java.util.function.Supplier) Pool(org.neo4j.collection.pool.Pool) SimpleStatementLocks(org.neo4j.kernel.impl.locking.SimpleStatementLocks) TransactionMonitor(org.neo4j.kernel.impl.transaction.TransactionMonitor)

Aggregations

CanWrite (org.neo4j.kernel.impl.factory.CanWrite)5 Procedures (org.neo4j.kernel.impl.proc.Procedures)3 StorageStatement (org.neo4j.storageengine.api.StorageStatement)3 Test (org.junit.Test)2 StatementLocks (org.neo4j.kernel.impl.locking.StatementLocks)2 Supplier (java.util.function.Supplier)1 Before (org.junit.Before)1 Pool (org.neo4j.collection.pool.Pool)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1 PageCursorTracerSupplier (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier)1 AvailabilityGuard (org.neo4j.kernel.AvailabilityGuard)1 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)1 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)1 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)1 SchemaWriteGuard (org.neo4j.kernel.impl.api.SchemaWriteGuard)1 StatementOperationContainer (org.neo4j.kernel.impl.api.StatementOperationContainer)1 TransactionHeaderInformation (org.neo4j.kernel.impl.api.TransactionHeaderInformation)1 TransactionHooks (org.neo4j.kernel.impl.api.TransactionHooks)1 TransactionRepresentationCommitProcess (org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess)1 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)1