Upgrade to Apache Cassandra 4.3.1

See gh-19588
This commit is contained in:
Stephane Nicoll
2020-01-13 14:49:29 +01:00
parent d282eb619f
commit ca1710ee56
31 changed files with 410 additions and 593 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,8 @@
package org.springframework.boot.actuate.cassandra;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
@@ -53,9 +52,9 @@ public class CassandraHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
Select select = QueryBuilder.select("release_version").from("system", "local");
SimpleStatement select = SimpleStatement.newInstance("SELECT release_version FROM system.local");
ResultSet results = this.cassandraOperations.getCqlOperations().queryForResultSet(select);
if (results.isExhausted()) {
if (results.isFullyFetched()) {
builder.up();
return;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,7 @@
*/
package org.springframework.boot.actuate.cassandra;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import reactor.core.publisher.Mono;
import org.springframework.boot.actuate.health.AbstractReactiveHealthIndicator;
@@ -47,7 +46,7 @@ public class CassandraReactiveHealthIndicator extends AbstractReactiveHealthIndi
@Override
protected Mono<Health> doHealthCheck(Health.Builder builder) {
Select select = QueryBuilder.select("release_version").from("system", "local");
SimpleStatement select = SimpleStatement.newInstance("SELECT release_version FROM system.local");
return this.reactiveCassandraOperations.getReactiveCqlOperations().queryForObject(select, String.class)
.map((version) -> builder.up().withDetail("version", version).build()).single();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.springframework.boot.actuate.cassandra;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.health.Health;
@@ -51,8 +51,8 @@ class CassandraHealthIndicatorTests {
ResultSet resultSet = mock(ResultSet.class);
CassandraHealthIndicator healthIndicator = new CassandraHealthIndicator(cassandraOperations);
given(cassandraOperations.getCqlOperations()).willReturn(cqlOperations);
given(cqlOperations.queryForResultSet(any(Select.class))).willReturn(resultSet);
given(resultSet.isExhausted()).willReturn(true);
given(cqlOperations.queryForResultSet(any(SimpleStatement.class))).willReturn(resultSet);
given(resultSet.isFullyFetched()).willReturn(true);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
}
@@ -65,8 +65,8 @@ class CassandraHealthIndicatorTests {
Row row = mock(Row.class);
CassandraHealthIndicator healthIndicator = new CassandraHealthIndicator(cassandraOperations);
given(cassandraOperations.getCqlOperations()).willReturn(cqlOperations);
given(cqlOperations.queryForResultSet(any(Select.class))).willReturn(resultSet);
given(resultSet.isExhausted()).willReturn(false);
given(cqlOperations.queryForResultSet(any(SimpleStatement.class))).willReturn(resultSet);
given(resultSet.isFullyFetched()).willReturn(false);
given(resultSet.one()).willReturn(row);
String expectedVersion = "1.0.0";
given(row.getString(0)).willReturn(expectedVersion);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.springframework.boot.actuate.cassandra;
import com.datastax.driver.core.querybuilder.Select;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -42,7 +42,8 @@ class CassandraReactiveHealthIndicatorTests {
@Test
void testCassandraIsUp() {
ReactiveCqlOperations reactiveCqlOperations = mock(ReactiveCqlOperations.class);
given(reactiveCqlOperations.queryForObject(any(Select.class), eq(String.class))).willReturn(Mono.just("6.0.0"));
given(reactiveCqlOperations.queryForObject(any(SimpleStatement.class), eq(String.class)))
.willReturn(Mono.just("6.0.0"));
ReactiveCassandraOperations reactiveCassandraOperations = mock(ReactiveCassandraOperations.class);
given(reactiveCassandraOperations.getReactiveCqlOperations()).willReturn(reactiveCqlOperations);