Skip to content

Commit

Permalink
Fix Astra migrations with LWTs not being properly allowed.
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Oct 22, 2020
1 parent a7070a3 commit 7c19b86
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public CassandraStorage(

this.reaperInstanceId = reaperInstanceId;
CassandraFactory cassandraFactory = config.getCassandraFactory();
overrideQueryOptions(cassandraFactory);
overrideQueryOptions(cassandraFactory, mode);
overrideRetryPolicy(cassandraFactory);
overridePoolingOptions(cassandraFactory);

Expand Down Expand Up @@ -1676,13 +1676,19 @@ public void saveHeartbeat() {
}


private static void overrideQueryOptions(CassandraFactory cassandraFactory) {
// all INSERT and DELETE stmt prepared in this class are idempoten
private static void overrideQueryOptions(CassandraFactory cassandraFactory, CassandraMode mode) {
// all INSERT and DELETE stmt prepared in this class are idempotent
ConsistencyLevel requiredCl = mode.equals(CassandraMode.ASTRA)
? ConsistencyLevel.LOCAL_QUORUM
: ConsistencyLevel.LOCAL_ONE;
if (cassandraFactory.getQueryOptions().isPresent()
&& ConsistencyLevel.LOCAL_ONE != cassandraFactory.getQueryOptions().get().getConsistencyLevel()) {
LOG.warn("Customization of cassandra's queryOptions is not supported and will be overridden");
}
cassandraFactory.setQueryOptions(java.util.Optional.of(new QueryOptions().setDefaultIdempotence(true)));
cassandraFactory.setQueryOptions(java.util.Optional.of(
new QueryOptions()
.setConsistencyLevel(requiredCl)
.setDefaultIdempotence(true)));
}

private static void overrideRetryPolicy(CassandraFactory cassandraFactory) {
Expand Down

0 comments on commit 7c19b86

Please sign in to comment.