Search in sources :

Example 1 with TsBoundPersisterConfiguration

use of com.palantir.timelock.config.TsBoundPersisterConfiguration in project atlasdb by palantir.

the class TimeLockAgent method verifyTimestampBoundPersisterConfiguration.

@VisibleForTesting
static void verifyTimestampBoundPersisterConfiguration(HikariDataSource sqliteDataSource, TsBoundPersisterConfiguration currentUserConfiguration, boolean reseedPersistedPersisterConfiguration, ObjectMapper objectMapper) {
    PersistenceConfigStore store = new PersistenceConfigStore(objectMapper, SqliteBlobStore.create(sqliteDataSource));
    if (reseedPersistedPersisterConfiguration) {
        log.info("As configured, updating the configuration persisted in the SQLite database.", SafeArg.of("ourConfiguration", currentUserConfiguration));
        store.storeConfig(currentUserConfiguration);
        return;
    }
    Optional<TsBoundPersisterConfiguration> configInDatabase = store.getPersistedConfig();
    if (!configInDatabase.isPresent()) {
        log.info("There is no config in the SQLite database indicating where timestamps are being stored. We are" + " thus assuming that your current configuration is indeed correct, and using that as a" + " future reference.", SafeArg.of("configuration", currentUserConfiguration));
        store.storeConfig(currentUserConfiguration);
        return;
    }
    TsBoundPersisterConfiguration presentConfig = configInDatabase.get();
    if (currentUserConfiguration.isLocationallyIncompatible(presentConfig)) {
        log.error("Configuration in the SQLite database does not agree with what the user has provided!", SafeArg.of("ourConfiguration", currentUserConfiguration), SafeArg.of("persistedConfiguration", presentConfig));
        throw new SafeIllegalStateException("Configuration in the SQLite database does not agree with the" + " configuration the user has provided, in a way that is known to be incompatible. For integrity" + " of the service, we will shut down and cannot serve any user requests. If you have" + " accidentally changed the DB configs, please revert them. If this is intentional, you can" + " update the config stored in the database by setting the relevant override flag.");
    } else {
        log.info("Passed consistency check: the config in the SQLite database agrees with our config.");
    }
}
Also used : TsBoundPersisterConfiguration(com.palantir.timelock.config.TsBoundPersisterConfiguration) DatabaseTsBoundPersisterConfiguration(com.palantir.timelock.config.DatabaseTsBoundPersisterConfiguration) PaxosTsBoundPersisterConfiguration(com.palantir.timelock.config.PaxosTsBoundPersisterConfiguration) PersistenceConfigStore(com.palantir.timelock.store.PersistenceConfigStore) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SafeIllegalStateException (com.palantir.logsafe.exceptions.SafeIllegalStateException)1 DatabaseTsBoundPersisterConfiguration (com.palantir.timelock.config.DatabaseTsBoundPersisterConfiguration)1 PaxosTsBoundPersisterConfiguration (com.palantir.timelock.config.PaxosTsBoundPersisterConfiguration)1 TsBoundPersisterConfiguration (com.palantir.timelock.config.TsBoundPersisterConfiguration)1 PersistenceConfigStore (com.palantir.timelock.store.PersistenceConfigStore)1