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