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()));
}
}
}
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);
}
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);
}
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);
}
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"));
}
Aggregations