Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARKC-568: Allow to remove JMX Reporting through configuration #1226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object DefaultConnectionFactory extends CassandraConnectionFactory {
.setConnectTimeoutMillis(conf.connectTimeoutMillis)
.setReadTimeoutMillis(conf.readTimeoutMillis)

val builder = Cluster.builder()
var builder = Cluster.builder()
.addContactPoints(conf.hosts.toSeq: _*)
.withPort(conf.port)
.withRetryPolicy(
Expand All @@ -58,6 +58,8 @@ object DefaultConnectionFactory extends CassandraConnectionFactory {
.setRefreshNodeListIntervalMillis(0)
.setRefreshSchemaIntervalMillis(0))

if (!conf.jmxEnabled) builder = builder.withoutJMXReporting()

if (conf.cassandraSSLConf.enabled) {
maybeCreateSSLOptions(conf.cassandraSSLConf) match {
case Some(sslOptions) ⇒ builder.withSSL(sslOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ case class CassandraConnectorConf(
connectTimeoutMillis: Int = CassandraConnectorConf.ConnectionTimeoutParam.default,
readTimeoutMillis: Int = CassandraConnectorConf.ReadTimeoutParam.default,
connectionFactory: CassandraConnectionFactory = DefaultConnectionFactory,
cassandraSSLConf: CassandraConnectorConf.CassandraSSLConf = CassandraConnectorConf.DefaultCassandraSSLConf
cassandraSSLConf: CassandraConnectorConf.CassandraSSLConf = CassandraConnectorConf.DefaultCassandraSSLConf,
jmxEnabled: Boolean = true
) {

@transient
Expand Down Expand Up @@ -87,6 +88,12 @@ object CassandraConnectorConf extends Logging {
default = 9042,
description = """Cassandra native connection port""")

val JmxEnabledParam = ConfigParameter[Boolean](
name = "spark.cassandra.connection.jmxEnabled",
section = ReferenceSection,
default = true,
description = """Cassandra JMX Reporting""")

val LocalDCParam = ConfigParameter[Option[String]](
name = "spark.cassandra.connection.local_dc",
section = ReferenceSection,
Expand Down Expand Up @@ -219,6 +226,7 @@ object CassandraConnectorConf extends Logging {
ConnectionPortParam,
LocalDCParam,
ConnectionTimeoutParam,
JmxEnabledParam,
KeepAliveMillisParam,
MinReconnectionDelayParam,
MaxReconnectionDelayParam,
Expand Down Expand Up @@ -254,10 +262,11 @@ object CassandraConnectorConf extends Logging {
hostName <- hostsStr.split(",").toSet[String]
hostAddress <- resolveHost(hostName.trim)
} yield hostAddress

val port = conf.getInt(ConnectionPortParam.name, ConnectionPortParam.default)

val authConf = AuthConf.fromSparkConf(conf)
val jmxEnabled = conf.getOption(JmxEnabledParam.name).map(_.toBoolean).getOrElse(JmxEnabledParam.default)
val keepAlive = conf.getInt(KeepAliveMillisParam.name, KeepAliveMillisParam.default)

val localDC = conf.getOption(LocalDCParam.name)
Expand Down Expand Up @@ -312,7 +321,8 @@ object CassandraConnectorConf extends Logging {
connectTimeoutMillis = connectTimeout,
readTimeoutMillis = readTimeout,
connectionFactory = connectionFactory,
cassandraSSLConf = cassandraSSLConf
cassandraSSLConf = cassandraSSLConf,
jmxEnabled = jmxEnabled
)
}
}