Skip to content

Commit 224e8ac

Browse files
committed
Minor logging changes (making logs consistent)
1 parent ca6bb39 commit 224e8ac

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/main/java/datastax/astra/migrate/CopyJobSession.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class CopyJobSession extends AbstractJobSession {
1717
private static CopyJobSession copyJobSession;
1818
public Logger logger = LoggerFactory.getLogger(this.getClass().getName());
1919
protected AtomicLong readCounter = new AtomicLong(0);
20+
protected AtomicLong skippedCounter = new AtomicLong(0);
2021
protected AtomicLong writeCounter = new AtomicLong(0);
2122

2223
protected CopyJobSession(CqlSession sourceSession, CqlSession astraSession, SparkConf sc) {
@@ -56,6 +57,8 @@ public void getDataAndInsert(BigInteger min, BigInteger max) {
5657
Long sourceWriteTimeStamp = getLargestWriteTimeStamp(sourceRow);
5758
if (sourceWriteTimeStamp < minWriteTimeStampFilter
5859
|| sourceWriteTimeStamp > maxWriteTimeStampFilter) {
60+
readCounter.incrementAndGet();
61+
skippedCounter.incrementAndGet();
5962
continue;
6063
}
6164
}
@@ -131,6 +134,7 @@ public synchronized void printCounts(boolean isFinal) {
131134
logger.info("################################################################################################");
132135
}
133136
logger.info("{} Read Record Count: {}", msg, readCounter.get());
137+
logger.info("{} Skipped Record Count: {}", msg, skippedCounter.get());
134138
logger.info("{} Write Record Count: {}", msg, writeCounter.get());
135139
if (isFinal) {
136140
logger.info("################################################################################################");

src/main/java/datastax/astra/migrate/CopyPKJobSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void printCounts(boolean isFinal) {
7171
logger.info("################################################################################################");
7272
}
7373
logger.info("ThreadID: {} Read Record Count: {}", Thread.currentThread().getId(), readCounter.get());
74-
logger.info("ThreadID: {} Read Missing Count: {}", Thread.currentThread().getId(), missingCounter.get());
74+
logger.info("ThreadID: {} Missing Record Count: {}", Thread.currentThread().getId(), missingCounter.get());
7575
logger.info("ThreadID: {} Inserted Record Count: {}", Thread.currentThread().getId(), writeCounter.get());
7676
if (isFinal) {
7777
logger.info("################################################################################################");

src/main/java/datastax/astra/migrate/DiffJobSession.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ public synchronized void printCounts(boolean isFinal) {
114114
msg += " Final";
115115
logger.info("################################################################################################");
116116
}
117-
logger.info(msg + " Read Record Count: " + readCounter.get());
118-
logger.info(msg + " Read Mismatch Count: " + mismatchCounter.get());
119-
logger.info(msg + " Corrected Mismatch Count: " + correctedMismatchCounter.get());
120-
logger.info(msg + " Read Missing Count: " + missingCounter.get());
121-
logger.info(msg + " Corrected Missing Count: " + correctedMissingCounter.get());
122-
logger.info(msg + " Read Valid Count: " + validCounter.get());
123-
logger.info(msg + " Read Skipped Count: " + skippedCounter.get());
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());
124124
if (isFinal) {
125125
logger.info("################################################################################################");
126126
}
@@ -129,13 +129,13 @@ public synchronized void printCounts(boolean isFinal) {
129129
private void diff(Row sourceRow, Row astraRow) {
130130
if (astraRow == null) {
131131
missingCounter.incrementAndGet();
132-
logger.error("Missing target row found for key: " + getKey(sourceRow));
132+
logger.error("Missing target row found for key: {}", getKey(sourceRow));
133133
//correct data
134134

135135
if (autoCorrectMissing) {
136136
astraSession.execute(bindInsert(astraInsertStatement, sourceRow, null));
137137
correctedMissingCounter.incrementAndGet();
138-
logger.error("Inserted missing row in target: " + getKey(sourceRow));
138+
logger.error("Inserted missing row in target: {}", getKey(sourceRow));
139139
}
140140

141141
return;
@@ -144,7 +144,7 @@ private void diff(Row sourceRow, Row astraRow) {
144144
String diffData = isDifferent(sourceRow, astraRow);
145145
if (!diffData.isEmpty()) {
146146
mismatchCounter.incrementAndGet();
147-
logger.error("Mismatch row found for key: " + getKey(sourceRow) + " Mismatch: " + diffData);
147+
logger.error("Mismatch row found for key: {} Mismatch: {}", getKey(sourceRow), diffData);
148148

149149
if (autoCorrectMismatch) {
150150
if (isCounterTable) {
@@ -153,7 +153,7 @@ private void diff(Row sourceRow, Row astraRow) {
153153
astraSession.execute(bindInsert(astraInsertStatement, sourceRow, null));
154154
}
155155
correctedMismatchCounter.incrementAndGet();
156-
logger.error("Updated mismatch row in target: " + getKey(sourceRow));
156+
logger.error("Updated mismatch row in target: {}", getKey(sourceRow));
157157
}
158158

159159
return;

0 commit comments

Comments
 (0)