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
pull/14783/head
Phillip Webb 6 years ago
parent b3bdbd0e84
commit 94798062ab

@ -83,6 +83,8 @@ public class CassandraAutoConfiguration {
map.from(properties::getContactPoints) map.from(properties::getContactPoints)
.as((list) -> StringUtils.toStringArray(list)) .as((list) -> StringUtils.toStringArray(list))
.to(builder::addContactPoints); .to(builder::addContactPoints);
map.from(properties::isJmxReporting).whenFalse()
.toCall(builder::withoutJMXReporting);
customize(builder); customize(builder);
return builder.build(); return builder.build();
} }

@ -132,6 +132,12 @@ public class CassandraProperties {
*/ */
private boolean ssl = false; 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. * Pool configuration.
*/ */
@ -272,6 +278,14 @@ public class CassandraProperties {
this.ssl = ssl; this.ssl = ssl;
} }
public boolean isJmxReporting() {
return this.jmxReporting;
}
public void setJmxReporting(boolean jmxReporting) {
this.jmxReporting = jmxReporting;
}
public String getSchemaAction() { public String getSchemaAction() {
return this.schemaAction; return this.schemaAction;
} }

@ -95,8 +95,8 @@ public class CassandraDataAutoConfigurationIntegrationTests {
} }
private void createTestKeyspaceIfNotExists() { private void createTestKeyspaceIfNotExists() {
Cluster cluster = Cluster.builder().withPort(cassandra.getMappedPort()) Cluster cluster = Cluster.builder().withoutJMXReporting()
.addContactPoint("localhost").build(); .withPort(cassandra.getMappedPort()).addContactPoint("localhost").build();
try (Session session = cluster.connect()) { try (Session session = cluster.connect()) {
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test" session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");

@ -67,7 +67,7 @@ public class CassandraContainer extends Container {
private Callable<Boolean> checkConnection() { private Callable<Boolean> checkConnection() {
return () -> { return () -> {
try (Cluster cluster = Cluster.builder() try (Cluster cluster = Cluster.builder().withoutJMXReporting()
.withPort(this.container.getMappedPort(CassandraContainer.PORT)) .withPort(this.container.getMappedPort(CassandraContainer.PORT))
.addContactPoint("localhost").build()) { .addContactPoint("localhost").build()) {
cluster.connect(); cluster.connect();

Loading…
Cancel
Save