8
8
import datastax .astra .migrate .schema .ColumnInfo ;
9
9
import datastax .astra .migrate .schema .TableInfo ;
10
10
import datastax .astra .migrate .schema .TypeInfo ;
11
- import org .apache .commons .lang .StringUtils ;
11
+ import org .apache .commons .lang3 .StringUtils ;
12
12
import org .apache .spark .SparkConf ;
13
13
import org .slf4j .Logger ;
14
14
import org .slf4j .LoggerFactory ;
@@ -30,6 +30,8 @@ public class AbstractJobSession extends BaseJobSession {
30
30
protected List <String > ttlWTCols ;
31
31
protected String tsReplaceValStr ;
32
32
protected long tsReplaceVal ;
33
+ protected long customWriteTime = 0l ;
34
+ protected long incrementWriteTime = 0l ;
33
35
34
36
protected AbstractJobSession (CqlSession sourceSession , CqlSession astraSession , SparkConf sc ) {
35
37
this (sourceSession , astraSession , sc , false );
@@ -67,7 +69,6 @@ protected AbstractJobSession(CqlSession sourceSession, CqlSession astraSession,
67
69
logger .info ("PARAM -- Destination Table: {}" , astraKeyspaceTable .split ("\\ ." )[1 ]);
68
70
logger .info ("PARAM -- ReadRateLimit: {}" , readLimiter .getRate ());
69
71
logger .info ("PARAM -- WriteRateLimit: {}" , writeLimiter .getRate ());
70
- logger .info ("PARAM -- WriteTimestampFilter: {}" , writeTimeStampFilter );
71
72
72
73
tableInfo = TableInfo .getInstance (sourceSession , sourceKeyspaceTable .split ("\\ ." )[0 ],
73
74
sourceKeyspaceTable .split ("\\ ." )[1 ], Util .getSparkPropOrEmpty (sc , "spark.query.origin" ));
@@ -90,18 +91,26 @@ protected AbstractJobSession(CqlSession sourceSession, CqlSession astraSession,
90
91
}
91
92
String maxWriteTimeStampFilterStr =
92
93
Util .getSparkPropOr (sc , "spark.origin.maxWriteTimeStampFilter" , "0" );
93
- if (null != maxWriteTimeStampFilterStr && maxWriteTimeStampFilterStr . trim (). length () > 1 ) {
94
+ if (StringUtils . isNotBlank ( maxWriteTimeStampFilterStr ) ) {
94
95
maxWriteTimeStampFilter = Long .parseLong (maxWriteTimeStampFilterStr );
95
96
}
96
97
97
98
String customWriteTimeStr =
98
- Util .getSparkPropOr (sc , "spark.target.custom.writeTime" , "0" );
99
- if (null != customWriteTimeStr && customWriteTimeStr .trim ().length () > 1 && StringUtils .isNumeric (customWriteTimeStr .trim ())) {
100
- customWritetime = Long .parseLong (customWriteTimeStr );
99
+ Util .getSparkPropOr (sc , "spark.target.writeTime.fixedValue" , "0" );
100
+ if (StringUtils .isNotBlank (customWriteTimeStr ) && StringUtils .isNumeric (customWriteTimeStr )) {
101
+ customWriteTime = Long .parseLong (customWriteTimeStr );
102
+ }
103
+
104
+ String incrWriteTimeStr =
105
+ Util .getSparkPropOr (sc , "spark.target.writeTime.incrementBy" , "0" );
106
+ if (StringUtils .isNotBlank (incrWriteTimeStr ) && StringUtils .isNumeric (incrWriteTimeStr )) {
107
+ incrementWriteTime = Long .parseLong (incrWriteTimeStr );
101
108
}
102
109
103
110
logger .info ("PARAM -- TTL-WriteTime Columns: {}" , ttlWTCols );
104
- logger .info ("PARAM -- WriteTimestampFilter: {}" , writeTimeStampFilter );
111
+ logger .info ("PARAM -- WriteTimes Filter: {}" , writeTimeStampFilter );
112
+ logger .info ("PARAM -- WriteTime Custom Value: {}" , customWriteTime );
113
+ logger .info ("PARAM -- WriteTime Increment Value: {}" , incrementWriteTime );
105
114
if (writeTimeStampFilter ) {
106
115
logger .info ("PARAM -- minWriteTimeStampFilter: {} datetime is {}" , minWriteTimeStampFilter ,
107
116
Instant .ofEpochMilli (minWriteTimeStampFilter / 1000 ));
@@ -193,10 +202,10 @@ public BoundStatement bindInsert(PreparedStatement insertStatement, Row sourceRo
193
202
if (!ttlWTCols .isEmpty ()) {
194
203
boundInsertStatement = boundInsertStatement .set (index , getLargestTTL (sourceRow ), Integer .class );
195
204
index ++;
196
- if (customWritetime > 0 ) {
197
- boundInsertStatement = boundInsertStatement .set (index , customWritetime , Long .class );
205
+ if (customWriteTime > 0 ) {
206
+ boundInsertStatement = boundInsertStatement .set (index , customWriteTime , Long .class );
198
207
} else {
199
- boundInsertStatement = boundInsertStatement .set (index , getLargestWriteTimeStamp (sourceRow ), Long .class );
208
+ boundInsertStatement = boundInsertStatement .set (index , getLargestWriteTimeStamp (sourceRow ) + incrementWriteTime , Long .class );
200
209
}
201
210
}
202
211
}
0 commit comments