Search in sources :

Example 21 with DependencyResolver

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

the class IndexingServiceTest method shouldLogDeprecatedIndexesOnStart.

@Test
void shouldLogDeprecatedIndexesOnStart() throws Exception {
    // given two indexes per available index provider
    int id = 1;
    List<IndexDescriptor> indexDescriptors = new ArrayList<>();
    IndexProvider[] indexProviders = new IndexProvider[indexProviderDescriptors.length];
    for (int i = 0; i < indexProviderDescriptors.length; i++) {
        IndexProviderDescriptor indexProviderDescriptor = indexProviderDescriptors[i];
        IndexProvider indexProvider = mockIndexProviderWithAccessor(indexProviderDescriptor);
        indexProviders[i] = indexProvider;
        // Two indexes per provider
        for (int j = 0; j < 2; j++) {
            IndexDescriptor index = storeIndex(id, 1, id, indexProviderDescriptor);
            indexDescriptors.add(index);
            when(indexProvider.getInitialState(eq(index), any())).thenReturn(ONLINE);
            id++;
        }
    }
    Config config = Config.defaults(default_schema_provider, nativeBtree10Descriptor.name());
    DependencyResolver dependencies = buildIndexDependencies(indexProviders);
    DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(dependencies, config);
    providerMap.init();
    when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(1, 1, 1));
    IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, indexDescriptors, internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
    // when starting IndexingService
    indexingService.init();
    for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
        onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
    }
    userLogProvider.clear();
    indexingService.start();
    // then we should see log messages about deprecated providers if any
    for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
        if (isDeprecated(indexProviderDescriptor)) {
            assertThat(userLogProvider).containsMessages("Deprecated index providers in use:", indexProviderDescriptor.name() + " (2 indexes)", "Use procedure 'db.indexes()' to see what indexes use which index provider.");
        } else {
            onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
        }
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) ArrayList(java.util.ArrayList) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DependencyResolver(org.neo4j.common.DependencyResolver) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) IndexSample(org.neo4j.kernel.api.index.IndexSample) Test(org.junit.jupiter.api.Test)

Example 22 with DependencyResolver

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

the class HttpTransactionManager method createTransactionFacade.

public TransactionFacade createTransactionFacade(GraphDatabaseAPI databaseAPI, MemoryTracker memoryTracker) {
    DependencyResolver dependencyResolver = databaseAPI.getDependencyResolver();
    memoryTracker.allocateHeap(TransactionFacade.SHALLOW_SIZE);
    return new TransactionFacade(databaseAPI, dependencyResolver.resolveDependency(QueryExecutionEngine.class), transactionRegistry);
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 23 with DependencyResolver

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

the class Neo4jTransactionalContextTest method setUpMocks.

private void setUpMocks() {
    queryService = mock(GraphDatabaseQueryService.class);
    DependencyResolver resolver = mock(DependencyResolver.class);
    statement = mock(KernelStatement.class);
    statistics = new ConfiguredExecutionStatistics();
    QueryRegistry queryRegistry = mock(QueryRegistry.class);
    InternalTransaction internalTransaction = mock(InternalTransaction.class);
    when(internalTransaction.terminationReason()).thenReturn(Optional.empty());
    when(statement.queryRegistration()).thenReturn(queryRegistry);
    when(queryService.getDependencyResolver()).thenReturn(resolver);
    when(queryService.beginTransaction(any(), any(), any())).thenReturn(internalTransaction);
    KernelTransaction mockTransaction = mockTransaction(statement);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) QueryRegistry(org.neo4j.kernel.api.QueryRegistry) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 24 with DependencyResolver

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

the class SessionExtension method beforeEach.

@Override
public void beforeEach(ExtensionContext extensionContext) {
    managementService = builderFactory.get().impermanent().setConfig(GraphDatabaseSettings.auth_enabled, authEnabled).build();
    gdb = (GraphDatabaseAPI) managementService.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
    DependencyResolver resolver = gdb.getDependencyResolver();
    Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class));
    Config config = resolver.resolveDependency(Config.class);
    SystemNanoClock clock = Clocks.nanoClock();
    DefaultDatabaseResolver defaultDatabaseResolver = new CommunityDefaultDatabaseResolver(config, () -> managementService.database(GraphDatabaseSettings.SYSTEM_DATABASE_NAME));
    BoltGraphDatabaseManagementServiceSPI databaseManagementService = new BoltKernelDatabaseManagementServiceProvider(managementService, new Monitors(), clock, ofSeconds(30));
    boltFactory = new BoltStateMachineFactoryImpl(databaseManagementService, authentication, clock, config, NullLogService.getInstance(), defaultDatabaseResolver);
}
Also used : BoltStateMachineFactoryImpl(org.neo4j.bolt.runtime.statemachine.impl.BoltStateMachineFactoryImpl) SystemNanoClock(org.neo4j.time.SystemNanoClock) AuthManager(org.neo4j.kernel.api.security.AuthManager) BoltKernelDatabaseManagementServiceProvider(org.neo4j.bolt.dbapi.impl.BoltKernelDatabaseManagementServiceProvider) Authentication(org.neo4j.bolt.security.auth.Authentication) BasicAuthentication(org.neo4j.bolt.security.auth.BasicAuthentication) Config(org.neo4j.configuration.Config) DefaultDatabaseResolver(org.neo4j.kernel.database.DefaultDatabaseResolver) CommunityDefaultDatabaseResolver(org.neo4j.server.security.systemgraph.CommunityDefaultDatabaseResolver) CommunityDefaultDatabaseResolver(org.neo4j.server.security.systemgraph.CommunityDefaultDatabaseResolver) Monitors(org.neo4j.monitoring.Monitors) DependencyResolver(org.neo4j.common.DependencyResolver) BoltGraphDatabaseManagementServiceSPI(org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI)

Example 25 with DependencyResolver

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

the class LuceneIndexRecoveryIT method rotateLogsAndCheckPoint.

private void rotateLogsAndCheckPoint() throws IOException {
    DependencyResolver resolver = db.getDependencyResolver();
    resolver.resolveDependency(LogRotation.class).rotateLogFile(LogAppendEvent.NULL);
    resolver.resolveDependency(CheckPointer.class).forceCheckPoint(new SimpleTriggerInfo("test"));
}
Also used : SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) CheckPointer(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) DependencyResolver(org.neo4j.common.DependencyResolver)

Aggregations

DependencyResolver (org.neo4j.common.DependencyResolver)41 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)13 Config (org.neo4j.configuration.Config)12 Test (org.junit.jupiter.api.Test)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)8 DatabaseContext (org.neo4j.dbms.database.DatabaseContext)6 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)5 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)3 Transaction (org.neo4j.graphdb.Transaction)3 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)3 PageCache (org.neo4j.io.pagecache.PageCache)3 CheckPointer (org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer)3 SimpleTriggerInfo (org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo)3 TokenHolders (org.neo4j.token.TokenHolders)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2