Search in sources :

Example 1 with UnavailableException

use of org.neo4j.kernel.availability.UnavailableException in project neo4j by neo4j.

the class TestFabricDatabaseManagementServiceFactory method createManagementService.

@Override
protected DatabaseManagementService createManagementService(GlobalModule globalModule, LifeSupport globalLife, Log internalLog, DatabaseManager<?> databaseManager) {
    return new DatabaseManagementServiceImpl(databaseManager, globalModule.getGlobalAvailabilityGuard(), globalLife, globalModule.getDatabaseEventListeners(), globalModule.getTransactionEventListeners(), internalLog, globalModule.getGlobalConfig()) {

        @Override
        public GraphDatabaseService database(String name) throws DatabaseNotFoundException {
            BoltFabricDatabaseManagementService fabricBoltDbms = globalModule.getGlobalDependencies().resolveDependency(BoltFabricDatabaseManagementService.class);
            var baseDb = databaseManager.getDatabaseContext(name).orElseThrow(() -> new DatabaseNotFoundException(name)).databaseFacade();
            // Therefore the lookup of Bolt API representation of a database has to be done lazily.
            return new TestFabricGraphDatabaseService(baseDb, config, () -> {
                try {
                    return fabricBoltDbms.getDatabase(name, EmptyMemoryTracker.INSTANCE);
                } catch (UnavailableException e) {
                    throw new RuntimeException(e);
                }
            });
        }
    };
}
Also used : BoltFabricDatabaseManagementService(org.neo4j.fabric.bolt.BoltFabricDatabaseManagementService) DatabaseManagementServiceImpl(org.neo4j.dbms.database.DatabaseManagementServiceImpl) DatabaseNotFoundException(org.neo4j.dbms.api.DatabaseNotFoundException) UnavailableException(org.neo4j.kernel.availability.UnavailableException)

Example 2 with UnavailableException

use of org.neo4j.kernel.availability.UnavailableException in project neo4j by neo4j.

the class TransactionImpl method execute.

private Result execute(InternalTransaction transaction, String query, MapValue parameters) throws QueryExecutionException {
    checkInTransaction();
    TransactionalContext context = contextFactory.newContext(transaction, query, parameters);
    try {
        availabilityGuard.assertDatabaseAvailable();
        return executionEngine.executeQuery(query, parameters, context, false);
    } catch (UnavailableException ue) {
        throw new org.neo4j.graphdb.TransactionFailureException(ue.getMessage(), ue);
    } catch (QueryExecutionKernelException e) {
        throw e.asUserException();
    }
}
Also used : QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) UnavailableException(org.neo4j.kernel.availability.UnavailableException) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext)

Aggregations

UnavailableException (org.neo4j.kernel.availability.UnavailableException)2 DatabaseNotFoundException (org.neo4j.dbms.api.DatabaseNotFoundException)1 DatabaseManagementServiceImpl (org.neo4j.dbms.database.DatabaseManagementServiceImpl)1 BoltFabricDatabaseManagementService (org.neo4j.fabric.bolt.BoltFabricDatabaseManagementService)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)1