Search in sources :

Example 11 with DependencyResolver

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

the class GraphDbStructureGuideTest method setUp.

@Before
public void setUp() throws InvalidTransactionTypeKernelException {
    GraphDatabaseAPI api = dbRule.getGraphDatabaseAPI();
    graph = api;
    DependencyResolver dependencyResolver = api.getDependencyResolver();
    this.bridge = dependencyResolver.resolveDependency(ThreadToStatementContextBridge.class);
    this.tx = graph.beginTx();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Before(org.junit.Before)

Example 12 with DependencyResolver

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

the class Neo4jTransactionalContextFactory method create.

@Deprecated
public static TransactionalContextFactory create(GraphDatabaseQueryService queryService, PropertyContainerLocker locker) {
    DependencyResolver resolver = queryService.getDependencyResolver();
    ThreadToStatementContextBridge txBridge = resolver.resolveDependency(ThreadToStatementContextBridge.class);
    Guard guard = resolver.resolveDependency(Guard.class);
    Neo4jTransactionalContext.Creator contextCreator = (Supplier<Statement> statementSupplier, InternalTransaction tx, Statement initialStatement, ExecutingQuery executingQuery) -> new Neo4jTransactionalContext(queryService, statementSupplier, guard, txBridge, locker, tx, initialStatement, executingQuery);
    return new Neo4jTransactionalContextFactory(txBridge, contextCreator);
}
Also used : ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) Statement(org.neo4j.kernel.api.Statement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) Guard(org.neo4j.kernel.guard.Guard) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 13 with DependencyResolver

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

the class BoltFactoryImpl method start.

@Override
public void start() throws Throwable {
    DependencyResolver dependencyResolver = gds.getDependencyResolver();
    queryExecutionEngine = dependencyResolver.resolveDependency(QueryExecutionEngine.class);
    queryService = dependencyResolver.resolveDependency(GraphDatabaseQueryService.class);
    transactionIdStore = dependencyResolver.resolveDependency(TransactionIdStore.class);
    availabilityGuard = dependencyResolver.resolveDependency(AvailabilityGuard.class);
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 14 with DependencyResolver

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

the class ShutdownOnIndexUpdateIT method shutdownWhileFinishingTransactionWithIndexUpdates.

@Test
public void shutdownWhileFinishingTransactionWithIndexUpdates() throws Exception {
    GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();
    createConstraint(database);
    waitIndexesOnline(database);
    try (Transaction transaction = database.beginTx()) {
        Node node = database.createNode(constraintIndexLabel);
        node.setProperty(UNIQUE_PROPERTY_NAME, indexProvider.getAndIncrement());
        DependencyResolver dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
        NeoStoreDataSource dataSource = dependencyResolver.resolveDependency(NeoStoreDataSource.class);
        LifeSupport dataSourceLife = dataSource.getLife();
        TransactionCloseListener closeListener = new TransactionCloseListener(transaction);
        dataSourceLife.addLifecycleListener(closeListener);
        dataSource.stop();
        assertTrue("Transaction should be closed and no exception should be thrown.", closeListener.isTransactionClosed());
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Node(org.neo4j.graphdb.Node) NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 15 with DependencyResolver

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

the class FileWatchIT method doNotNotifyAboutLuceneIndexFilesDeletion.

@Test(timeout = TEST_TIMEOUT)
public void doNotNotifyAboutLuceneIndexFilesDeletion() throws InterruptedException, IOException {
    DependencyResolver dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
    FileWatcher fileWatcher = getFileWatcher(database);
    CheckPointer checkPointer = dependencyResolver.resolveDependency(CheckPointer.class);
    String propertyStoreName = MetaDataStore.DEFAULT_NAME + StoreFactory.PROPERTY_STORE_NAME;
    AccumulativeDeletionEventListener accumulativeListener = new AccumulativeDeletionEventListener();
    ModificationEventListener modificationListener = new ModificationEventListener(propertyStoreName);
    fileWatcher.addFileWatchEventListener(modificationListener);
    fileWatcher.addFileWatchEventListener(accumulativeListener);
    String labelName = "labelName";
    String propertyName = "propertyName";
    Label testLabel = Label.label(labelName);
    createIndexes(database, propertyName, testLabel);
    do {
        createNode(database, propertyName, testLabel);
        forceCheckpoint(checkPointer);
    } while (!modificationListener.awaitModificationNotification());
    fileWatcher.removeFileWatchEventListener(modificationListener);
    ModificationEventListener afterRemovalListener = new ModificationEventListener(propertyStoreName);
    fileWatcher.addFileWatchEventListener(afterRemovalListener);
    dropAllIndexes(database);
    do {
        createNode(database, propertyName, testLabel);
        forceCheckpoint(checkPointer);
    } while (!afterRemovalListener.awaitModificationNotification());
    accumulativeListener.assertDoesNotHaveAnyDeletions();
}
Also used : FileWatcher(org.neo4j.io.fs.watcher.FileWatcher) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) CheckPointer(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer) Label(org.neo4j.graphdb.Label) Matchers.containsString(org.hamcrest.Matchers.containsString) 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