@@ -7,58 +7,14 @@ import org.slf4j.LoggerFactory
7
7
import java .math .BigInteger
8
8
import java .lang .Long
9
9
10
- class AbstractJob extends App {
11
-
12
- val abstractLogger = LoggerFactory .getLogger(this .getClass.getName)
13
- val spark = SparkSession .builder
14
- .appName(" Datastax Data Validation" )
15
- .getOrCreate()
16
-
17
- val sc = spark.sparkContext
18
-
19
- val sourceIsAstra = sc.getConf.get(" spark.source.isAstra" , " false" )
20
- val sourceScbPath = sc.getConf.get(" spark.source.scb" , " " )
21
- val sourceHost = sc.getConf.get(" spark.source.host" , " " )
22
- val sourceUsername = sc.getConf.get(" spark.source.username" , " " )
23
- val sourcePassword = sc.getConf.get(" spark.source.password" , " " )
24
- val sourceReadConsistencyLevel = sc.getConf.get(" spark.source.read.consistency.level" , " LOCAL_QUORUM" )
25
- val sourceTrustStorePath = sc.getConf.get(" spark.source.trustStore.path" , " " )
26
- val sourceTrustStorePassword = sc.getConf.get(" spark.source.trustStore.password" , " " )
27
- val sourceTrustStoreType = sc.getConf.get(" spark.source.trustStore.type" , " JKS" )
28
- val sourceKeyStorePath = sc.getConf.get(" spark.source.keyStore.path" , " " )
29
- val sourceKeyStorePassword = sc.getConf.get(" spark.source.keyStore.password" , " " )
30
- val sourceEnabledAlgorithms = sc.getConf.get(" spark.source.enabledAlgorithms" , " " )
31
-
32
- val destinationIsAstra = sc.getConf.get(" spark.destination.isAstra" , " true" )
33
- val destinationScbPath = sc.getConf.get(" spark.destination.scb" , " " )
34
- val destinationHost = sc.getConf.get(" spark.destination.host" , " " )
35
- val destinationUsername = sc.getConf.get(" spark.destination.username" )
36
- val destinationPassword = sc.getConf.get(" spark.destination.password" )
37
- val destinationReadConsistencyLevel = sc.getConf.get(" spark.destination.read.consistency.level" , " LOCAL_QUORUM" )
38
- val destinationTrustStorePath = sc.getConf.get(" spark.destination.trustStore.path" , " " )
39
- val destinationTrustStorePassword = sc.getConf.get(" spark.destination.trustStore.password" , " " )
40
- val destinationTrustStoreType = sc.getConf.get(" spark.destination.trustStore.type" , " JKS" )
41
- val destinationKeyStorePath = sc.getConf.get(" spark.destination.keyStore.path" , " " )
42
- val destinationKeyStorePassword = sc.getConf.get(" spark.destination.keyStore.password" , " " )
43
- val destinationEnabledAlgorithms = sc.getConf.get(" spark.destination.enabledAlgorithms" , " " )
44
-
45
- val minPartition = new BigInteger (sc.getConf.get(" spark.source.minPartition" ," -9223372036854775808" ))
46
- val maxPartition = new BigInteger (sc.getConf.get(" spark.source.maxPartition" ," 9223372036854775807" ))
47
- val coveragePercent = sc.getConf.get(" spark.coveragePercent" , " 100" )
48
- val splitSize = sc.getConf.get(" spark.splitSize" , " 10000" )
49
- val partitions = SplitPartitions .getRandomSubPartitions(BigInteger .valueOf(Long .parseLong(splitSize)), minPartition, maxPartition,Integer .parseInt(coveragePercent))
10
+ class AbstractJob extends BaseJob {
50
11
51
12
var sourceConnection = getConnection(true , sourceIsAstra, sourceScbPath, sourceHost, sourceUsername, sourcePassword, sourceReadConsistencyLevel,
52
13
sourceTrustStorePath, sourceTrustStorePassword, sourceTrustStoreType, sourceKeyStorePath, sourceKeyStorePassword, sourceEnabledAlgorithms);
53
14
54
15
var destinationConnection = getConnection(false , destinationIsAstra, destinationScbPath, destinationHost, destinationUsername, destinationPassword, destinationReadConsistencyLevel,
55
16
destinationTrustStorePath, destinationTrustStorePassword, destinationTrustStoreType, destinationKeyStorePath, destinationKeyStorePassword, destinationEnabledAlgorithms);
56
17
57
- protected def exitSpark () = {
58
- spark.stop()
59
- sys.exit(0 )
60
- }
61
-
62
18
private def getConnection (isSource : Boolean , isAstra : String , scbPath : String , host : String , username : String , password : String , readConsistencyLevel : String ,
63
19
trustStorePath : String , trustStorePassword : String , trustStoreType : String ,
64
20
keyStorePath : String , keyStorePassword : String , enabledAlgorithms : String ): CassandraConnector = {
0 commit comments