Search in sources :

Example 41 with DependencyResolver

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

the class AbstractNeoServer method createTransactionalActions.

private TransactionFacade createTransactionalActions() {
    final long timeoutMillis = getTransactionTimeoutMillis();
    final Clock clock = Clocks.systemClock();
    transactionRegistry = new TransactionHandleRegistry(clock, timeoutMillis, logProvider);
    // ensure that this is > 0
    long runEvery = round(timeoutMillis / 2.0);
    resolveDependency(JobScheduler.class).scheduleRecurring(serverTransactionTimeout, () -> {
        long maxAge = clock.millis() - timeoutMillis;
        transactionRegistry.rollbackSuspendedTransactionsIdleSince(maxAge);
    }, runEvery, MILLISECONDS);
    DependencyResolver dependencyResolver = database.getGraph().getDependencyResolver();
    return new TransactionFacade(new TransitionalPeriodTransactionMessContainer(database.getGraph()), dependencyResolver.resolveDependency(QueryExecutionEngine.class), dependencyResolver.resolveDependency(GraphDatabaseQueryService.class), transactionRegistry, logProvider);
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) TransitionalPeriodTransactionMessContainer(org.neo4j.server.rest.transactional.TransitionalPeriodTransactionMessContainer) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) TransactionFacade(org.neo4j.server.rest.transactional.TransactionFacade) TransactionHandleRegistry(org.neo4j.server.rest.transactional.TransactionHandleRegistry) Clock(java.time.Clock) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 42 with DependencyResolver

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

the class GuardIT method notIncludeGuardingOperationLayerOnNonGuardingParts.

@Test
public void notIncludeGuardingOperationLayerOnNonGuardingParts() throws Exception {
    GraphDatabaseAPI database = startDataBase();
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    StatementOperationContainer operationParts = dependencyResolver.resolveDependency(StatementOperationContainer.class);
    StatementOperationParts guardedParts = operationParts.nonGuarderParts();
    assertThat(guardedParts.entityReadOperations(), not(instanceOf(GuardingStatementOperations.class)));
    assertThat(guardedParts.entityWriteOperations(), not(instanceOf(GuardingStatementOperations.class)));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 43 with DependencyResolver

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

the class GuardIT method includeGuardingOperationLayerOnGuardingParts.

@Test
public void includeGuardingOperationLayerOnGuardingParts() throws Exception {
    GraphDatabaseAPI database = startDataBase();
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    StatementOperationContainer operationParts = dependencyResolver.resolveDependency(StatementOperationContainer.class);
    StatementOperationParts guardedParts = operationParts.guardedParts();
    assertThat(guardedParts.entityReadOperations(), instanceOf(GuardingStatementOperations.class));
    assertThat(guardedParts.entityWriteOperations(), instanceOf(GuardingStatementOperations.class));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) GuardingStatementOperations(org.neo4j.kernel.impl.api.GuardingStatementOperations) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 44 with DependencyResolver

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

the class GuardIT method useTimeoutGuard.

@Test
public void useTimeoutGuard() throws Exception {
    GraphDatabaseAPI database = startDataBase();
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    Guard guard = dependencyResolver.resolveDependency(Guard.class);
    assertThat(guard, instanceOf(TimeoutGuard.class));
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) TimeoutGuard(org.neo4j.kernel.guard.TimeoutGuard) Guard(org.neo4j.kernel.guard.Guard) TimeoutGuard(org.neo4j.kernel.guard.TimeoutGuard) DependencyResolver(org.neo4j.graphdb.DependencyResolver) Test(org.junit.Test)

Example 45 with DependencyResolver

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

the class StorageLayerRelTypesAndDegreeTest method relTypeId.

private int relTypeId(TestRelType type) {
    DependencyResolver resolver = db.getDependencyResolver();
    RelationshipTypeTokenHolder relTypeHolder = resolver.resolveDependency(RelationshipTypeTokenHolder.class);
    int id = relTypeHolder.getIdByName(type.name());
    assertNotEquals(NO_ID, id);
    return id;
}
Also used : RelationshipTypeTokenHolder(org.neo4j.kernel.impl.core.RelationshipTypeTokenHolder) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

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