use of org.neo4j.dbms.database.DatabaseManager in project neo4j by neo4j.
the class FabricServicesBootstrap method bootstrapServices.
public void bootstrapServices() {
LogProvider internalLogProvider = logService.getInternalLogProvider();
@SuppressWarnings("unchecked") var databaseManager = (DatabaseManager<DatabaseContext>) resolve(DatabaseManager.class);
var fabricDatabaseManager = register(createFabricDatabaseManager(fabricConfig), FabricDatabaseManager.class);
var jobScheduler = resolve(JobScheduler.class);
var monitors = resolve(Monitors.class);
var databaseAccess = createFabricDatabaseAccess();
var remoteExecutor = bootstrapRemoteStack();
var localExecutor = register(new FabricLocalExecutor(fabricConfig, fabricDatabaseManager, databaseAccess), FabricLocalExecutor.class);
var systemNanoClock = resolve(SystemNanoClock.class);
var transactionMonitor = register(new FabricTransactionMonitor(systemNanoClock, logService, fabricConfig), FabricTransactionMonitor.class);
var transactionCheckInterval = config.get(GraphDatabaseSettings.transaction_monitor_check_interval).toMillis();
register(new TransactionMonitorScheduler(transactionMonitor, jobScheduler, transactionCheckInterval, null), TransactionMonitorScheduler.class);
var errorReporter = new ErrorReporter(logService);
register(new TransactionManager(remoteExecutor, localExecutor, errorReporter, fabricConfig, transactionMonitor, securityLog, systemNanoClock, config, availabilityGuard), TransactionManager.class);
var cypherConfig = CypherConfiguration.fromConfig(config);
Supplier<GlobalProcedures> proceduresSupplier = () -> resolve(GlobalProcedures.class);
var catalogManager = register(createCatalogManger(), CatalogManager.class);
var signatureResolver = new SignatureResolver(proceduresSupplier);
var statementLifecycles = new FabricStatementLifecycles(databaseManager, monitors, config, systemNanoClock);
var monitoredExecutor = jobScheduler.monitoredJobExecutor(CYPHER_CACHE);
var cacheFactory = new ExecutorBasedCaffeineCacheFactory(job -> monitoredExecutor.execute(systemJob("Query plan cache maintenance"), job));
var planner = register(new FabricPlanner(fabricConfig, cypherConfig, monitors, cacheFactory, signatureResolver), FabricPlanner.class);
var useEvaluation = register(new UseEvaluation(catalogManager, proceduresSupplier, signatureResolver), UseEvaluation.class);
register(new FabricReactorHooksService(errorReporter), FabricReactorHooksService.class);
Executor fabricWorkerExecutor = jobScheduler.executor(FABRIC_WORKER);
var fabricExecutor = new FabricExecutor(fabricConfig, planner, useEvaluation, catalogManager, internalLogProvider, statementLifecycles, fabricWorkerExecutor);
register(fabricExecutor, FabricExecutor.class);
register(new TransactionBookmarkManagerFactory(fabricDatabaseManager), TransactionBookmarkManagerFactory.class);
}
use of org.neo4j.dbms.database.DatabaseManager in project neo4j by neo4j.
the class CommunitySecurityModule method setup.
@Override
public void setup() {
Supplier<GraphDatabaseService> systemSupplier = () -> {
DatabaseManager<?> databaseManager = globalDependencies.resolveDependency(DatabaseManager.class);
return databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID).orElseThrow(() -> new RuntimeException("No database called `" + SYSTEM_DATABASE_NAME + "` was found.")).databaseFacade();
};
authManager = new BasicSystemGraphRealm(new SystemGraphRealmHelper(systemSupplier, new SecureHasher()), createAuthenticationStrategy(config));
registerProcedure(globalDependencies.resolveDependency(GlobalProcedures.class), logProvider.getLog(getClass()), AuthProcedures.class, null);
}
use of org.neo4j.dbms.database.DatabaseManager in project neo4j by neo4j.
the class FabricServicesBootstrap method createBoltDatabaseManagementServiceProvider.
public BoltGraphDatabaseManagementServiceSPI createBoltDatabaseManagementServiceProvider(BoltGraphDatabaseManagementServiceSPI kernelDatabaseManagementService, DatabaseManagementService managementService, Monitors monitors, SystemNanoClock clock) {
FabricExecutor fabricExecutor = dependencies.resolveDependency(FabricExecutor.class);
TransactionManager transactionManager = dependencies.resolveDependency(TransactionManager.class);
FabricDatabaseManager fabricDatabaseManager = dependencies.resolveDependency(FabricDatabaseManager.class);
var serverConfig = dependencies.resolveDependency(Config.class);
var transactionIdTracker = new TransactionIdTracker(managementService, monitors, clock);
var databaseManager = (DatabaseManager<DatabaseContext>) dependencies.resolveDependency(DatabaseManager.class);
var databaseIdRepository = databaseManager.databaseIdRepository();
var transactionBookmarkManagerFactory = dependencies.resolveDependency(TransactionBookmarkManagerFactory.class);
var localGraphTransactionIdTracker = new LocalGraphTransactionIdTracker(transactionIdTracker, databaseIdRepository, serverConfig);
var fabricDatabaseManagementService = dependencies.satisfyDependency(new BoltFabricDatabaseManagementService(fabricExecutor, fabricConfig, transactionManager, fabricDatabaseManager, localGraphTransactionIdTracker, transactionBookmarkManagerFactory));
return new BoltGraphDatabaseManagementServiceSPI() {
@Override
public BoltGraphDatabaseServiceSPI database(String databaseName, MemoryTracker memoryTracker) throws UnavailableException, DatabaseNotFoundException {
if (fabricDatabaseManager.hasMultiGraphCapabilities(databaseName)) {
return fabricDatabaseManagementService.database(databaseName, memoryTracker);
}
return kernelDatabaseManagementService.database(databaseName, memoryTracker);
}
@Override
public Optional<CustomBookmarkFormatParser> getCustomBookmarkFormatParser() {
return fabricDatabaseManagementService.getCustomBookmarkFormatParser();
}
};
}
use of org.neo4j.dbms.database.DatabaseManager in project neo4j by neo4j.
the class DbmsDiagnosticsManagerTest method setUp.
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() throws IOException {
logProvider = new AssertableLogProvider();
databaseManager = mock(DatabaseManager.class);
storageEngine = mock(StorageEngine.class);
storageEngineFactory = mock(StorageEngineFactory.class);
defaultContext = mock(StandaloneDatabaseContext.class);
defaultDatabase = prepareDatabase();
when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(Collections.emptyList());
dependencies = new Dependencies();
dependencies.satisfyDependency(Config.defaults());
dependencies.satisfyDependency(databaseManager);
when(defaultContext.database()).thenReturn(defaultDatabase);
when(databaseManager.getDatabaseContext(DEFAULT_DATABASE_ID)).thenReturn(Optional.of(defaultContext));
when(databaseManager.registeredDatabases()).thenReturn(new TreeMap<>(singletonMap(DEFAULT_DATABASE_ID, defaultContext)));
diagnosticsManager = new DbmsDiagnosticsManager(dependencies, new SimpleLogService(logProvider));
}
use of org.neo4j.dbms.database.DatabaseManager in project neo4j by neo4j.
the class DatabaseManagementServiceFactory method setupProcedures.
/**
* Creates and registers the systems procedures, including those which belong to a particular edition.
* N.B. This method takes a {@link DatabaseManager} as an unused parameter *intentionally*, in
* order to enforce that the databaseManager must be constructed first.
*/
@SuppressWarnings("unused")
private static void setupProcedures(GlobalModule globalModule, AbstractEditionModule editionModule, DatabaseManager<?> databaseManager) {
Supplier<GlobalProcedures> procedureInitializer = () -> {
Config globalConfig = globalModule.getGlobalConfig();
Path proceduresDirectory = globalConfig.get(GraphDatabaseSettings.plugin_dir);
LogService logService = globalModule.getLogService();
Log internalLog = logService.getInternalLog(GlobalProcedures.class);
Log proceduresLog = logService.getUserLog(GlobalProcedures.class);
ProcedureConfig procedureConfig = new ProcedureConfig(globalConfig);
Edition neo4jEdition = globalModule.getDbmsInfo().edition;
SpecialBuiltInProcedures builtInProcedures = new SpecialBuiltInProcedures(Version.getNeo4jVersion(), neo4jEdition.toString());
GlobalProceduresRegistry globalProcedures = new GlobalProceduresRegistry(builtInProcedures, proceduresDirectory, internalLog, procedureConfig);
globalProcedures.registerType(Node.class, NTNode);
globalProcedures.registerType(NodeValue.class, NTNode);
globalProcedures.registerType(Relationship.class, NTRelationship);
globalProcedures.registerType(RelationshipValue.class, NTRelationship);
globalProcedures.registerType(org.neo4j.graphdb.Path.class, NTPath);
globalProcedures.registerType(PathValue.class, NTPath);
globalProcedures.registerType(Geometry.class, NTGeometry);
globalProcedures.registerType(Point.class, NTPoint);
globalProcedures.registerType(PointValue.class, NTPoint);
// Below components are not public API, but are made available for internal
// procedures to call, and to provide temporary workarounds for the following
// patterns:
// - Batch-transaction imports (GDAPI, needs to be real and passed to background processing threads)
// - Group-transaction writes (same pattern as above, but rather than splitting large transactions,
// combine lots of small ones)
// - Bleeding-edge performance (KernelTransaction, to bypass overhead of working with Core API)
globalProcedures.registerComponent(DependencyResolver.class, Context::dependencyResolver, false);
globalProcedures.registerComponent(KernelTransaction.class, ctx -> ctx.internalTransaction().kernelTransaction(), false);
globalProcedures.registerComponent(GraphDatabaseAPI.class, Context::graphDatabaseAPI, false);
globalProcedures.registerComponent(SystemGraphComponents.class, ctx -> globalModule.getSystemGraphComponents(), false);
globalProcedures.registerComponent(ValueMapper.class, Context::valueMapper, true);
// Register injected public API components
globalProcedures.registerComponent(Log.class, ctx -> proceduresLog, true);
globalProcedures.registerComponent(Transaction.class, new ProcedureTransactionProvider(), true);
globalProcedures.registerComponent(org.neo4j.procedure.TerminationGuard.class, new TerminationGuardProvider(), true);
globalProcedures.registerComponent(SecurityContext.class, Context::securityContext, true);
globalProcedures.registerComponent(ProcedureCallContext.class, Context::procedureCallContext, true);
globalProcedures.registerComponent(FulltextAdapter.class, ctx -> ctx.dependencyResolver().resolveDependency(FulltextAdapter.class), true);
globalProcedures.registerComponent(GraphDatabaseService.class, ctx -> new GraphDatabaseFacade((GraphDatabaseFacade) ctx.graphDatabaseAPI(), new ProcedureLoginContextTransformer(ctx)), true);
globalProcedures.registerComponent(DataCollector.class, ctx -> ctx.dependencyResolver().resolveDependency(DataCollector.class), false);
// Edition procedures
try {
editionModule.registerProcedures(globalProcedures, procedureConfig, globalModule, databaseManager);
} catch (KernelException e) {
internalLog.error("Failed to register built-in edition procedures at start up: " + e.getMessage());
}
globalModule.getGlobalLife().add(globalProcedures);
return globalProcedures;
};
GlobalProcedures procedures = tryResolveOrCreate(GlobalProcedures.class, globalModule.getExternalDependencyResolver(), procedureInitializer);
if (procedures instanceof Consumer) {
((Consumer) procedures).accept(procedureInitializer);
}
globalModule.getGlobalDependencies().satisfyDependency(procedures);
}
Aggregations