Search in sources :

Example 1 with TransactionIdTracker

use of org.neo4j.bolt.txtracking.TransactionIdTracker in project neo4j by neo4j.

the class DatabaseServiceBookmarkTest method createDbSpi.

private BoltGraphDatabaseServiceSPI createDbSpi(TransactionIdStore txIdStore, Duration txAwaitDuration, DatabaseAvailabilityGuard availabilityGuard, SystemNanoClock clock) {
    var queryExecutionEngine = mock(QueryExecutionEngine.class);
    var db = mock(Database.class);
    when(db.getNamedDatabaseId()).thenReturn(DATABASE_ID);
    when(db.getDatabaseAvailabilityGuard()).thenReturn(availabilityGuard);
    var dependencyResolver = mock(Dependencies.class);
    when(dependencyResolver.resolveDependency(QueryExecutionEngine.class)).thenReturn(queryExecutionEngine);
    when(dependencyResolver.resolveDependency(DatabaseAvailabilityGuard.class)).thenReturn(availabilityGuard);
    when(dependencyResolver.resolveDependency(TransactionIdStore.class)).thenReturn(txIdStore);
    when(dependencyResolver.resolveDependency(Database.class)).thenReturn(db);
    when(db.getDependencyResolver()).thenReturn(dependencyResolver);
    var facade = mock(GraphDatabaseAPI.class);
    when(facade.getDependencyResolver()).thenReturn(dependencyResolver);
    var tx = mock(InternalTransaction.class);
    when(facade.beginTransaction(any(), any(), any())).thenReturn(tx);
    var queryService = mock(GraphDatabaseQueryService.class);
    when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
    when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
    var managementService = mock(DatabaseManagementService.class);
    when(managementService.database(DATABASE_ID.name())).thenReturn(facade);
    var transactionIdTracker = new TransactionIdTracker(managementService, new Monitors(), clock);
    return new BoltKernelGraphDatabaseServiceProvider(facade, transactionIdTracker, txAwaitDuration, mock(MemoryTracker.class, RETURNS_MOCKS));
}
Also used : BoltKernelGraphDatabaseServiceProvider(org.neo4j.bolt.dbapi.impl.BoltKernelGraphDatabaseServiceProvider) Monitors(org.neo4j.monitoring.Monitors) TransactionIdTracker(org.neo4j.bolt.txtracking.TransactionIdTracker) MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 2 with TransactionIdTracker

use of org.neo4j.bolt.txtracking.TransactionIdTracker 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();
        }
    };
}
Also used : BoltFabricDatabaseManagementService(org.neo4j.fabric.bolt.BoltFabricDatabaseManagementService) FabricExecutor(org.neo4j.fabric.executor.FabricExecutor) DatabaseManager(org.neo4j.dbms.database.DatabaseManager) FabricDatabaseManager(org.neo4j.fabric.FabricDatabaseManager) TransactionManager(org.neo4j.fabric.transaction.TransactionManager) CustomBookmarkFormatParser(org.neo4j.bolt.dbapi.CustomBookmarkFormatParser) FabricDatabaseManager(org.neo4j.fabric.FabricDatabaseManager) LocalGraphTransactionIdTracker(org.neo4j.fabric.bookmark.LocalGraphTransactionIdTracker) TransactionIdTracker(org.neo4j.bolt.txtracking.TransactionIdTracker) LocalGraphTransactionIdTracker(org.neo4j.fabric.bookmark.LocalGraphTransactionIdTracker) BoltGraphDatabaseManagementServiceSPI(org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI) MemoryTracker(org.neo4j.memory.MemoryTracker)

Aggregations

TransactionIdTracker (org.neo4j.bolt.txtracking.TransactionIdTracker)2 MemoryTracker (org.neo4j.memory.MemoryTracker)2 BoltGraphDatabaseManagementServiceSPI (org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI)1 CustomBookmarkFormatParser (org.neo4j.bolt.dbapi.CustomBookmarkFormatParser)1 BoltKernelGraphDatabaseServiceProvider (org.neo4j.bolt.dbapi.impl.BoltKernelGraphDatabaseServiceProvider)1 DatabaseManager (org.neo4j.dbms.database.DatabaseManager)1 FabricDatabaseManager (org.neo4j.fabric.FabricDatabaseManager)1 BoltFabricDatabaseManagementService (org.neo4j.fabric.bolt.BoltFabricDatabaseManagementService)1 LocalGraphTransactionIdTracker (org.neo4j.fabric.bookmark.LocalGraphTransactionIdTracker)1 FabricExecutor (org.neo4j.fabric.executor.FabricExecutor)1 TransactionManager (org.neo4j.fabric.transaction.TransactionManager)1 Monitors (org.neo4j.monitoring.Monitors)1