Skip to content

Commit 5daf710

Browse files
committed
Added config to separately add port & improved docs
1 parent 13f9712 commit 5daf710

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>datastax.astra.migrate</groupId>
55
<artifactId>cassandra-data-migrator</artifactId>
6-
<version>3.0.6</version>
6+
<version>3.1.0</version>
77
<packaging>jar</packaging>
88

99
<properties>

src/main/scala/datastax/astra/migrate/AbstractJob.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class AbstractJob extends BaseJob {
1212
abstractLogger.info("PARAM -- Origin SSL Enabled: {}", sourceSSLEnabled);
1313
abstractLogger.info("PARAM -- Target SSL Enabled: {}", destinationSSLEnabled);
1414

15-
var sourceConnection = getConnection(true, sourceScbPath, sourceHost, sourceUsername, sourcePassword, sourceSSLEnabled,
15+
var sourceConnection = getConnection(true, sourceScbPath, sourceHost, sourcePort, sourceUsername, sourcePassword, sourceSSLEnabled,
1616
sourceTrustStorePath, sourceTrustStorePassword, sourceTrustStoreType, sourceKeyStorePath, sourceKeyStorePassword, sourceEnabledAlgorithms);
1717

18-
var destinationConnection = getConnection(false, destinationScbPath, destinationHost, destinationUsername, destinationPassword, destinationSSLEnabled,
18+
var destinationConnection = getConnection(false, destinationScbPath, destinationHost, destinationPort, destinationUsername, destinationPassword, destinationSSLEnabled,
1919
destinationTrustStorePath, destinationTrustStorePassword, destinationTrustStoreType, destinationKeyStorePath, destinationKeyStorePassword, destinationEnabledAlgorithms);
2020

21-
private def getConnection(isSource: Boolean, scbPath: String, host: String, username: String, password: String,
21+
private def getConnection(isSource: Boolean, scbPath: String, host: String, port: String, username: String, password: String,
2222
sslEnabled: String, trustStorePath: String, trustStorePassword: String, trustStoreType: String,
2323
keyStorePath: String, keyStorePassword: String, enabledAlgorithms: String): CassandraConnector = {
2424
var connType: String = "Source"
@@ -36,7 +36,7 @@ class AbstractJob extends BaseJob {
3636
.set("spark.cassandra.input.consistency.level", consistencyLevel)
3737
.set("spark.cassandra.connection.config.cloud.path", scbPath))
3838
} else if (trustStorePath.nonEmpty) {
39-
abstractLogger.info(connType + ": Connecting (with clientAuth) to Cassandra (or DSE) host: " + host);
39+
abstractLogger.info(connType + ": Connecting (with clientAuth) to Cassandra (or DSE) host:port " + host + ":" + port);
4040

4141
// Use defaults when not provided
4242
var enabledAlgorithmsVar = enabledAlgorithms
@@ -49,6 +49,7 @@ class AbstractJob extends BaseJob {
4949
.set("spark.cassandra.auth.password", password)
5050
.set("spark.cassandra.input.consistency.level", consistencyLevel)
5151
.set("spark.cassandra.connection.host", host)
52+
.set("spark.cassandra.connection.port", port)
5253
.set("spark.cassandra.connection.ssl.enabled", "true")
5354
.set("spark.cassandra.connection.ssl.enabledAlgorithms", enabledAlgorithmsVar)
5455
.set("spark.cassandra.connection.ssl.trustStore.password", trustStorePassword)
@@ -59,13 +60,14 @@ class AbstractJob extends BaseJob {
5960
.set("spark.cassandra.connection.ssl.clientAuth.enabled", "true")
6061
)
6162
} else {
62-
abstractLogger.info(connType + ": Connecting to Cassandra (or DSE) host: " + host);
63+
abstractLogger.info(connType + ": Connecting to Cassandra (or DSE) host:port " + host + ":" + port);
6364

6465
return CassandraConnector(config.set("spark.cassandra.auth.username", username)
6566
.set("spark.cassandra.connection.ssl.enabled", sslEnabled)
6667
.set("spark.cassandra.auth.password", password)
6768
.set("spark.cassandra.input.consistency.level", consistencyLevel)
68-
.set("spark.cassandra.connection.host", host))
69+
.set("spark.cassandra.connection.host", host)
70+
.set("spark.cassandra.connection.port", port))
6971
}
7072

7173
}

src/main/scala/datastax/astra/migrate/BaseJob.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class BaseJob extends App {
2222

2323
val sourceScbPath = Util.getSparkPropOrEmpty(sc, "spark.origin.scb")
2424
val sourceHost = Util.getSparkPropOrEmpty(sc, "spark.origin.host")
25+
val sourcePort = Util.getSparkPropOr(sc, "spark.origin.port", "9042")
2526
val sourceUsername = Util.getSparkPropOrEmpty(sc, "spark.origin.username")
2627
val sourcePassword = Util.getSparkPropOrEmpty(sc, "spark.origin.password")
2728
val sourceSSLEnabled = Util.getSparkPropOr(sc, "spark.origin.ssl.enabled", "false")
@@ -34,6 +35,7 @@ class BaseJob extends App {
3435

3536
val destinationScbPath = Util.getSparkPropOrEmpty(sc, "spark.target.scb")
3637
val destinationHost = Util.getSparkPropOrEmpty(sc, "spark.target.host")
38+
val destinationPort = Util.getSparkPropOr(sc, "spark.target.port", "9042")
3739
val destinationUsername = Util.getSparkProp(sc, "spark.target.username")
3840
val destinationPassword = Util.getSparkProp(sc, "spark.target.password")
3941
val destinationSSLEnabled = Util.getSparkPropOr(sc, "spark.target.ssl.enabled", "false")

src/resources/sparkConf.properties

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# Origin cluster credentials
1+
# Origin cluster credentials (use "host + port" OR "secure-connect-bundle" but not both)
22
spark.origin.host localhost
3+
spark.origin.port 9042
4+
#spark.origin.scb file:///aaa/bbb/secure-connect-enterprise.zip
35
spark.origin.username some-username
46
spark.origin.password some-secret-password
57
spark.origin.keyspaceTable test.a1
68

7-
# Target cluster credentials
9+
# Target cluster credentials (use "host + port" OR "secure-connect-bundle" but not both)
10+
#spark.target.host localhost
11+
#spark.target.port 9042
812
spark.target.scb file:///aaa/bbb/secure-connect-enterprise.zip
913
spark.target.username client-id
1014
spark.target.password client-secret
@@ -29,12 +33,13 @@ spark.splitSize 10000
2933
spark.batchSize 10
3034

3135
# Below 'query' properties are set based on table schema
32-
spark.query.origin partition-key,clustering-key,order-date,amount
33-
spark.query.origin.partitionKey partition-key
34-
spark.query.target.id partition-key,clustering-key
36+
spark.query.origin comma-separated-partition-key,comma-separated-clustering-key,comma-separated-other-columns
37+
spark.query.origin.partitionKey comma-separated-partition-key
38+
spark.query.target.id comma-separated-partition-key,comma-separated-clustering-key
39+
# Comma separated numeric data-type mapping (e.g. 'text' will map to '0') for all columns listed in "spark.query.origin"
3540
spark.query.types 9,1,4,3
3641
#############################################################################################################
37-
# Following are the supported data types and their corresponding [Cassandra data-types]
42+
# Following are the supported data types and their corresponding [Cassandra data-types] mapping
3843
# 0: ascii, text, varchar
3944
# 1: int
4045
# 2: bigint, counter

0 commit comments

Comments
 (0)