Search in sources :

Example 1 with DatabaseStorageException

use of tech.pegasys.teku.storage.server.DatabaseStorageException in project teku by ConsenSys.

the class BeaconNodeCommand method call.

@Override
public Integer call() {
    try {
        startLogging();
        final TekuConfiguration tekuConfig = tekuConfiguration();
        startAction.start(tekuConfig, false);
        return 0;
    } catch (InvalidConfigurationException | DatabaseStorageException ex) {
        reportUserError(ex);
    } catch (CompletionException e) {
        ExceptionUtil.<Throwable>getCause(e, InvalidConfigurationException.class).or(() -> ExceptionUtil.getCause(e, DatabaseStorageException.class)).ifPresentOrElse(this::reportUserError, () -> reportUnexpectedError(e));
    } catch (Throwable t) {
        reportUnexpectedError(t);
    }
    return 1;
}
Also used : DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) CompletionException(java.util.concurrent.CompletionException) InvalidConfigurationException(tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException)

Example 2 with DatabaseStorageException

use of tech.pegasys.teku.storage.server.DatabaseStorageException in project teku by ConsenSys.

the class RocksDbExceptionUtilTest method shouldIdentifyRecoverableExceptions.

@ParameterizedTest
@MethodSource("recoverableErrorCodes")
void shouldIdentifyRecoverableExceptions(final Code code) {
    final RocksDBException exception = new RocksDBException(new Status(code, SubCode.None, null));
    final DatabaseStorageException result = RocksDbExceptionUtil.wrapException("Test", exception);
    assertThat(result).hasMessage("Test");
    assertThat(result.isUnrecoverable()).isFalse();
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with DatabaseStorageException

use of tech.pegasys.teku.storage.server.DatabaseStorageException in project teku by ConsenSys.

the class ValidatorClientCommand method call.

@Override
public Integer call() {
    try {
        startLogging();
        final TekuConfiguration globalConfiguration = tekuConfiguration();
        parentCommand.getStartAction().start(globalConfiguration, true);
        return 0;
    } catch (InvalidConfigurationException | DatabaseStorageException ex) {
        parentCommand.reportUserError(ex);
    } catch (CompletionException e) {
        ExceptionUtil.<Throwable>getCause(e, InvalidConfigurationException.class).or(() -> ExceptionUtil.getCause(e, DatabaseStorageException.class)).ifPresentOrElse(parentCommand::reportUserError, () -> parentCommand.reportUnexpectedError(e));
    } catch (Throwable t) {
        parentCommand.reportUnexpectedError(t);
    }
    return 1;
}
Also used : DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) TekuConfiguration(tech.pegasys.teku.config.TekuConfiguration) CompletionException(java.util.concurrent.CompletionException) InvalidConfigurationException(tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException)

Example 4 with DatabaseStorageException

use of tech.pegasys.teku.storage.server.DatabaseStorageException in project teku by ConsenSys.

the class RocksDbExceptionUtilTest method shouldBeUnrecoverableWhenCodeIsNotRecoverable.

@Test
void shouldBeUnrecoverableWhenCodeIsNotRecoverable() {
    final RocksDBException exception = new RocksDBException(new Status(Code.IOError, SubCode.None, null));
    final DatabaseStorageException result = RocksDbExceptionUtil.wrapException("Test", exception);
    assertThat(result.isUnrecoverable()).isTrue();
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with DatabaseStorageException

use of tech.pegasys.teku.storage.server.DatabaseStorageException in project teku by ConsenSys.

the class RocksDbExceptionUtilTest method shouldBeUnrecoverableWhenNoStatusIsSet.

@Test
void shouldBeUnrecoverableWhenNoStatusIsSet() {
    final RocksDBException exception = new RocksDBException("Oh dear");
    final DatabaseStorageException result = RocksDbExceptionUtil.wrapException("Test", exception);
    assertThat(result.isUnrecoverable()).isTrue();
}
Also used : RocksDBException(org.rocksdb.RocksDBException) DatabaseStorageException(tech.pegasys.teku.storage.server.DatabaseStorageException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DatabaseStorageException (tech.pegasys.teku.storage.server.DatabaseStorageException)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 RocksDBException (org.rocksdb.RocksDBException)3 CompletionException (java.util.concurrent.CompletionException)2 Test (org.junit.jupiter.api.Test)2 Status (org.rocksdb.Status)2 TekuConfiguration (tech.pegasys.teku.config.TekuConfiguration)2 InvalidConfigurationException (tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)1