@@ -32,6 +32,7 @@ public class CassandraContainer<SELF extends CassandraContainer<SELF>> extends G
3232
3333 private String configLocation ;
3434 private String initScriptPath ;
35+ private boolean enableJmxReporting ;
3536
3637 public CassandraContainer () {
3738 this (IMAGE + ":3.11.2" );
@@ -41,6 +42,7 @@ public CassandraContainer(String dockerImageName) {
4142 super (dockerImageName );
4243 addExposedPort (CQL_PORT );
4344 setStartupAttempts (3 );
45+ this .enableJmxReporting = false ;
4446 }
4547
4648 @ Override
@@ -116,6 +118,14 @@ public SELF withInitScript(String initScriptPath) {
116118 return self ();
117119 }
118120
121+ /**
122+ * Initialize Cassandra client with JMX reporting enabled or disabled
123+ */
124+ public SELF withJmxReporting (boolean enableJmxReporting ) {
125+ this .enableJmxReporting = enableJmxReporting ;
126+ return self ();
127+ }
128+
119129 /**
120130 * Get username
121131 *
@@ -146,14 +156,21 @@ public String getPassword() {
146156 * Can be used to obtain connections to Cassandra in the container
147157 */
148158 public Cluster getCluster () {
149- return getCluster (this );
159+ return getCluster (this , enableJmxReporting );
150160 }
151161
152- public static Cluster getCluster (ContainerState containerState ) {
153- return Cluster .builder ()
162+ public static Cluster getCluster (ContainerState containerState , boolean enableJmxReporting ) {
163+ final Cluster . Builder builder = Cluster .builder ()
154164 .addContactPoint (containerState .getContainerIpAddress ())
155- .withPort (containerState .getMappedPort (CQL_PORT ))
156- .build ();
165+ .withPort (containerState .getMappedPort (CQL_PORT ));
166+ if (!enableJmxReporting ) {
167+ builder .withoutJMXReporting ();
168+ }
169+ return builder .build ();
170+ }
171+
172+ public static Cluster getCluster (ContainerState containerState ) {
173+ return getCluster (containerState , false );
157174 }
158175
159176 private DatabaseDelegate getDatabaseDelegate () {
0 commit comments