Search in sources :

Example 21 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class StorageLayerTest method readOps.

protected ReadOperations readOps() {
    DependencyResolver dependencyResolver = db.getDependencyResolver();
    Statement statement = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class).get();
    return statement.readOperations();
}
Also used : Statement(org.neo4j.kernel.api.Statement) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 22 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class DependencyResolverSupplierTest method shouldReturnTheDependencyResolveFromTheRegisteredDatasource.

@Test
public void shouldReturnTheDependencyResolveFromTheRegisteredDatasource() throws Exception {
    // given
    DataSourceManager dataSourceManager = new DataSourceManager();
    DependencyResolverSupplier supplier = new DependencyResolverSupplier(dataSourceManager);
    NeoStoreDataSource neoStoreDataSource = mock(NeoStoreDataSource.class);
    DependencyResolver dependencyResolver = mock(DependencyResolver.class);
    when(neoStoreDataSource.getDependencyResolver()).thenReturn(dependencyResolver);
    // when
    dataSourceManager.register(neoStoreDataSource);
    // then
    assertEquals(dependencyResolver, supplier.get());
}
Also used : NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) DependencyResolverSupplier(org.neo4j.kernel.impl.transaction.state.DataSourceManager.DependencyResolverSupplier) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 23 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class CypherExecutor method start.

@Override
public void start() throws Throwable {
    DependencyResolver resolver = database.getGraph().getDependencyResolver();
    this.executionEngine = (ExecutionEngine) resolver.resolveDependency(QueryExecutionEngine.class);
    this.service = resolver.resolveDependency(GraphDatabaseQueryService.class);
    this.contextFactory = Neo4jTransactionalContextFactory.create(this.service, locker);
}
Also used : GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 24 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class SessionRule method apply.

@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            Map<Setting<?>, String> config = new HashMap<>();
            config.put(GraphDatabaseSettings.auth_enabled, Boolean.toString(authEnabled));
            gdb = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase(config);
            DependencyResolver resolver = gdb.getDependencyResolver();
            Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class), resolver.resolveDependency(UserManagerSupplier.class));
            boltFactory = new BoltFactoryImpl(gdb, new UsageData(null), NullLogService.getInstance(), resolver.resolveDependency(ThreadToStatementContextBridge.class), authentication, BoltConnectionTracker.NOOP, Config.defaults());
            boltFactory.start();
            try {
                base.evaluate();
            } finally {
                try {
                    if (runningMachines != null) {
                        runningMachines.forEach(BoltStateMachine::close);
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
                gdb.shutdown();
            }
        }
    };
}
Also used : UsageData(org.neo4j.udc.UsageData) HashMap(java.util.HashMap) AuthManager(org.neo4j.kernel.api.security.AuthManager) Statement(org.junit.runners.model.Statement) Setting(org.neo4j.graphdb.config.Setting) UserManagerSupplier(org.neo4j.kernel.api.security.UserManagerSupplier) DependencyResolver(org.neo4j.graphdb.DependencyResolver) BoltFactoryImpl(org.neo4j.bolt.v1.runtime.BoltFactoryImpl) BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) Authentication(org.neo4j.bolt.security.auth.Authentication) BasicAuthentication(org.neo4j.bolt.security.auth.BasicAuthentication) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 25 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class BoltFactoryImplTest method txIdStoreRefreshedAfterRestart.

@Test
public void txIdStoreRefreshedAfterRestart() throws Throwable {
    GraphDatabaseAPI db = newDbMock();
    DependencyResolver dependencyResolver = db.getDependencyResolver();
    TransactionIdStore txIdStoreBeforeRestart = mock(TransactionIdStore.class);
    when(txIdStoreBeforeRestart.getLastClosedTransactionId()).thenReturn(42L);
    TransactionIdStore txIdStoreAfterRestart = mock(TransactionIdStore.class);
    when(txIdStoreAfterRestart.getLastClosedTransactionId()).thenReturn(4242L);
    when(dependencyResolver.resolveDependency(TransactionIdStore.class)).thenReturn(txIdStoreBeforeRestart).thenReturn(txIdStoreAfterRestart);
    BoltFactoryImpl boltFactory = newBoltFactory(db);
    boltFactory.start();
    BoltStateMachine stateMachine1 = boltFactory.newMachine(CONNECTION_DESCRIPTOR, mock(Runnable.class), CLOCK);
    assertEquals(42, stateMachine1.spi.transactionSpi().newestEncounteredTxId());
    boltFactory.stop();
    boltFactory.start();
    BoltStateMachine stateMachine2 = boltFactory.newMachine(CONNECTION_DESCRIPTOR, mock(Runnable.class), CLOCK);
    assertEquals(4242, stateMachine2.spi.transactionSpi().newestEncounteredTxId());
}
Also used : TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Aggregations

DependencyResolver (org.neo4j.graphdb.DependencyResolver)51 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)18 Test (org.junit.Test)15 Transaction (org.neo4j.graphdb.Transaction)10 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)9 Before (org.junit.Before)8 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 Monitors (org.neo4j.kernel.monitoring.Monitors)7 Node (org.neo4j.graphdb.Node)6 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)6 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)5 Statement (org.neo4j.kernel.api.Statement)5 File (java.io.File)4 IOException (java.io.IOException)4 Label (org.neo4j.graphdb.Label)4 PageCache (org.neo4j.io.pagecache.PageCache)4 Guard (org.neo4j.kernel.guard.Guard)4 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)4