Search in sources :

Example 6 with DatabaseNotFoundException

use of org.neo4j.dbms.api.DatabaseNotFoundException in project neo4j by neo4j.

the class DefaultDatabaseManager method upgradeDatabase.

@Override
public synchronized void upgradeDatabase(NamedDatabaseId namedDatabaseId) throws DatabaseNotFoundException {
    StandaloneDatabaseContext context = getDatabaseContext(namedDatabaseId).orElseThrow(() -> new DatabaseNotFoundException("Database not found: " + namedDatabaseId));
    Database database = context.database();
    log.info("Upgrading '%s'.", namedDatabaseId);
    // Clear any failed state, e.g. due to format being too old on startup.
    context.fail(null);
    try {
        database.upgrade(true);
    } catch (Throwable throwable) {
        String message = "Failed to upgrade " + namedDatabaseId;
        context.fail(throwable);
        throw new DatabaseManagementException(message, throwable);
    }
}
Also used : DatabaseManagementException(org.neo4j.dbms.api.DatabaseManagementException) DatabaseNotFoundException(org.neo4j.dbms.api.DatabaseNotFoundException) Database(org.neo4j.kernel.database.Database)

Example 7 with DatabaseNotFoundException

use of org.neo4j.dbms.api.DatabaseNotFoundException in project neo4j by neo4j.

the class TransactionStateMachineSPIProviderV4Test method shouldErrorIfDatabaseNotFound.

@Test
void shouldErrorIfDatabaseNotFound() {
    DatabaseManagementService managementService = mock(DatabaseManagementService.class);
    var databaseName = "database";
    when(managementService.database(databaseName)).thenThrow(new DatabaseNotFoundException(databaseName));
    TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
    BoltIOException error = assertThrows(BoltIOException.class, () -> spiProvider.getTransactionStateMachineSPI(databaseName, mock(StatementProcessorReleaseManager.class)));
    assertThat(error.status()).isEqualTo(Status.Database.DatabaseNotFound);
    assertThat(error.getMessage()).contains("Database does not exist. Database name: 'database'.");
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) DatabaseNotFoundException(org.neo4j.dbms.api.DatabaseNotFoundException) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) Test(org.junit.jupiter.api.Test)

Aggregations

DatabaseNotFoundException (org.neo4j.dbms.api.DatabaseNotFoundException)7 CompletionException (java.util.concurrent.CompletionException)1 Test (org.junit.jupiter.api.Test)1 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)1 TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)1 DatabaseManagementException (org.neo4j.dbms.api.DatabaseManagementException)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1 DatabaseManagementServiceImpl (org.neo4j.dbms.database.DatabaseManagementServiceImpl)1 BoltFabricDatabaseManagementService (org.neo4j.fabric.bolt.BoltFabricDatabaseManagementService)1 UnavailableException (org.neo4j.kernel.availability.UnavailableException)1 Database (org.neo4j.kernel.database.Database)1 NamedDatabaseId (org.neo4j.kernel.database.NamedDatabaseId)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1 JobScheduler (org.neo4j.scheduler.JobScheduler)1