@@ -36,10 +36,10 @@ private DiffJobSession(CqlSession sourceSession, CqlSession astraSession, SparkC
36
36
super (sourceSession , astraSession , sc );
37
37
38
38
autoCorrectMissing = Boolean .parseBoolean (Util .getSparkPropOr (sc , "spark.target.autocorrect.missing" , "false" ));
39
- logger .info ("PARAM -- Autocorrect Missing: " + autoCorrectMissing );
39
+ logger .info ("PARAM -- Autocorrect Missing: {}" , autoCorrectMissing );
40
40
41
41
autoCorrectMismatch = Boolean .parseBoolean (Util .getSparkPropOr (sc , "spark.target.autocorrect.mismatch" , "false" ));
42
- logger .info ("PARAM -- Autocorrect Mismatch: " + autoCorrectMismatch );
42
+ logger .info ("PARAM -- Autocorrect Mismatch: {}" , autoCorrectMismatch );
43
43
}
44
44
45
45
public static DiffJobSession getInstance (CqlSession sourceSession , CqlSession astraSession , SparkConf sparkConf ) {
@@ -55,7 +55,7 @@ public static DiffJobSession getInstance(CqlSession sourceSession, CqlSession as
55
55
}
56
56
57
57
public void getDataAndDiff (BigInteger min , BigInteger max ) {
58
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " Processing min: " + min + " max:" + max );
58
+ logger .info ("ThreadID: {} Processing min: {} max: {}" , Thread .currentThread ().getId (), min , max );
59
59
int maxAttempts = maxRetries ;
60
60
for (int retryCount = 1 ; retryCount <= maxAttempts ; retryCount ++) {
61
61
@@ -71,7 +71,7 @@ public void getDataAndDiff(BigInteger min, BigInteger max) {
71
71
if (!(writeTimeStampFilter && (getLargestWriteTimeStamp (srcRow ) < minWriteTimeStampFilter
72
72
|| getLargestWriteTimeStamp (srcRow ) > maxWriteTimeStampFilter ))) {
73
73
if (readCounter .incrementAndGet () % printStatsAfter == 0 ) {
74
- printCounts ("Current" );
74
+ printCounts (false );
75
75
}
76
76
77
77
CompletionStage <AsyncResultSet > targetRowFuture = astraSession
@@ -86,14 +86,11 @@ public void getDataAndDiff(BigInteger min, BigInteger max) {
86
86
}
87
87
});
88
88
diffAndClear (srcToTargetRowMap );
89
-
90
- printCounts ("Final" );
91
-
92
89
retryCount = maxAttempts ;
93
90
} catch (Exception e ) {
94
- logger .error ("Error occurred retry#: " + retryCount , e );
95
- logger .error ("Error with PartitionRange -- TreadID: " + Thread . currentThread (). getId ()
96
- + " Processing min: " + min + " max:" + max + " -- Retry# " + retryCount );
91
+ logger .error ("Error occurred retry#: {}" , retryCount , e );
92
+ logger .error ("Error with PartitionRange -- ThreadID: {} Processing min: {} max: {} -- Retry# {}" ,
93
+ Thread . currentThread (). getId (), min , max , retryCount );
97
94
}
98
95
}
99
96
@@ -105,39 +102,40 @@ private void diffAndClear(Map<Row, CompletionStage<AsyncResultSet>> srcToTargetR
105
102
Row targetRow = srcToTargetRowMap .get (srcRow ).toCompletableFuture ().get ().one ();
106
103
diff (srcRow , targetRow );
107
104
} catch (Exception e ) {
108
- logger .error ("Could not perform diff for Key: " + getKey (srcRow ), e );
105
+ logger .error ("Could not perform diff for Key: {}" , getKey (srcRow ), e );
109
106
}
110
107
}
111
108
srcToTargetRowMap .clear ();
112
109
}
113
110
114
- public void printCounts (String finalStr ) {
115
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Read Record Count: "
116
- + readCounter .get ());
117
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Read Mismatch Count: "
118
- + mismatchCounter .get ());
119
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Corrected Mismatch Count: "
120
- + correctedMismatchCounter .get ());
121
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Read Missing Count: "
122
- + missingCounter .get ());
123
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Corrected Missing Count: "
124
- + correctedMissingCounter .get ());
125
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Read Valid Count: "
126
- + validCounter .get ());
127
- logger .info ("TreadID: " + Thread .currentThread ().getId () + " " + finalStr + " Read Skipped Count: "
128
- + skippedCounter .get ());
111
+ public synchronized void printCounts (boolean isFinal ) {
112
+ String msg = "ThreadID: " + Thread .currentThread ().getId ();
113
+ if (isFinal ) {
114
+ msg += " Final" ;
115
+ logger .info ("################################################################################################" );
116
+ }
117
+ logger .info ("{} Read Record Count: {}" , msg , readCounter .get ());
118
+ logger .info ("{} Mismatch Record Count: {}" , msg , mismatchCounter .get ());
119
+ logger .info ("{} Corrected Mismatch Record Count: {}" , msg , correctedMismatchCounter .get ());
120
+ logger .info ("{} Missing Record Count: {}" , msg , missingCounter .get ());
121
+ logger .info ("{} Corrected Missing Record Count: {}" , msg , correctedMissingCounter .get ());
122
+ logger .info ("{} Valid Record Count: {}" , msg , validCounter .get ());
123
+ logger .info ("{} Skipped Record Count: {}" , msg , skippedCounter .get ());
124
+ if (isFinal ) {
125
+ logger .info ("################################################################################################" );
126
+ }
129
127
}
130
128
131
129
private void diff (Row sourceRow , Row astraRow ) {
132
130
if (astraRow == null ) {
133
131
missingCounter .incrementAndGet ();
134
- logger .error ("Missing target row found for key: " + getKey (sourceRow ));
132
+ logger .error ("Missing target row found for key: {}" , getKey (sourceRow ));
135
133
//correct data
136
134
137
135
if (autoCorrectMissing ) {
138
136
astraSession .execute (bindInsert (astraInsertStatement , sourceRow , null ));
139
137
correctedMissingCounter .incrementAndGet ();
140
- logger .error ("Inserted missing row in target: " + getKey (sourceRow ));
138
+ logger .error ("Inserted missing row in target: {}" , getKey (sourceRow ));
141
139
}
142
140
143
141
return ;
@@ -146,7 +144,7 @@ private void diff(Row sourceRow, Row astraRow) {
146
144
String diffData = isDifferent (sourceRow , astraRow );
147
145
if (!diffData .isEmpty ()) {
148
146
mismatchCounter .incrementAndGet ();
149
- logger .error ("Mismatch row found for key: " + getKey ( sourceRow ) + " Mismatch: " + diffData );
147
+ logger .error ("Mismatch row found for key: {} Mismatch: {}" , getKey ( sourceRow ), diffData );
150
148
151
149
if (autoCorrectMismatch ) {
152
150
if (isCounterTable ) {
@@ -155,7 +153,7 @@ private void diff(Row sourceRow, Row astraRow) {
155
153
astraSession .execute (bindInsert (astraInsertStatement , sourceRow , null ));
156
154
}
157
155
correctedMismatchCounter .incrementAndGet ();
158
- logger .error ("Updated mismatch row in target: " + getKey (sourceRow ));
156
+ logger .error ("Updated mismatch row in target: {}" , getKey (sourceRow ));
159
157
}
160
158
161
159
return ;
0 commit comments