Configure Cassandra JMX Reporting
Allow Cassandra JMX reporting to be configured via a property, and disable it by default since it won't work with Dropwizard metrics 4. Also update some of our own tests to explicitly disable it. Closes gh-14778
This commit is contained in:
@@ -83,6 +83,8 @@ public class CassandraAutoConfiguration {
|
||||
map.from(properties::getContactPoints)
|
||||
.as((list) -> StringUtils.toStringArray(list))
|
||||
.to(builder::addContactPoints);
|
||||
map.from(properties::isJmxReporting).whenFalse()
|
||||
.toCall(builder::withoutJMXReporting);
|
||||
customize(builder);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -132,6 +132,12 @@ public class CassandraProperties {
|
||||
*/
|
||||
private boolean ssl = false;
|
||||
|
||||
/**
|
||||
* If JMX reporting should be enabled. Default to false as Cassandra JMX reporting is
|
||||
* not compatible with Dropwizrd Metrics 4.
|
||||
*/
|
||||
private boolean jmxReporting = false;
|
||||
|
||||
/**
|
||||
* Pool configuration.
|
||||
*/
|
||||
@@ -272,6 +278,14 @@ public class CassandraProperties {
|
||||
this.ssl = ssl;
|
||||
}
|
||||
|
||||
public boolean isJmxReporting() {
|
||||
return this.jmxReporting;
|
||||
}
|
||||
|
||||
public void setJmxReporting(boolean jmxReporting) {
|
||||
this.jmxReporting = jmxReporting;
|
||||
}
|
||||
|
||||
public String getSchemaAction() {
|
||||
return this.schemaAction;
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ public class CassandraDataAutoConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
private void createTestKeyspaceIfNotExists() {
|
||||
Cluster cluster = Cluster.builder().withPort(cassandra.getMappedPort())
|
||||
.addContactPoint("localhost").build();
|
||||
Cluster cluster = Cluster.builder().withoutJMXReporting()
|
||||
.withPort(cassandra.getMappedPort()).addContactPoint("localhost").build();
|
||||
try (Session session = cluster.connect()) {
|
||||
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
|
||||
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CassandraContainer extends Container {
|
||||
|
||||
private Callable<Boolean> checkConnection() {
|
||||
return () -> {
|
||||
try (Cluster cluster = Cluster.builder()
|
||||
try (Cluster cluster = Cluster.builder().withoutJMXReporting()
|
||||
.withPort(this.container.getMappedPort(CassandraContainer.PORT))
|
||||
.addContactPoint("localhost").build()) {
|
||||
cluster.connect();
|
||||
|
||||
Reference in New Issue
Block a user