-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL Source : add CDC heartbeat support #23984
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a1ba5a9
MySQL Source : add CDC heartbeat support
VitaliiMaltsev 6d7dad7
Merge branch 'master' into mysql-heartbets
VitaliiMaltsev b0109ff
removed logs
VitaliiMaltsev 2bd11a1
Merge remote-tracking branch 'origin/mysql-heartbets' into mysql-hear…
VitaliiMaltsev 653667a
fixed DebeziumRecordIteratorTest
VitaliiMaltsev 0d9b820
Automated Change
VitaliiMaltsev a166682
Merge branch 'master' into mysql-heartbets
VitaliiMaltsev 9a193ff
use generics to simplify implementation
subodh1810 03e5484
use Duration
subodh1810 18b70a4
Merge branch 'master' into mysql-heartbets
subodh1810 0668650
Merge branch 'master' into mysql-heartbets
subodh1810 4c57694
more refactoring
subodh1810 410a44e
removed redundant null check
VitaliiMaltsev b0eecb5
Automated Change
VitaliiMaltsev 807cbda
Merge branch 'master' into mysql-heartbets
VitaliiMaltsev a846712
bump version
VitaliiMaltsev 6daa0b0
auto-bump connector version
octavia-squidington-iii 3379f55
Merge branch 'master' into mysql-heartbets
VitaliiMaltsev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,12 @@ | |
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.integrations.debezium.CdcTargetPosition; | ||
import io.debezium.engine.ChangeEvent; | ||
import java.time.Duration; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.concurrent.LinkedBlockingQueue; | ||
import org.apache.kafka.connect.source.SourceRecord; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -19,8 +21,20 @@ public class DebeziumRecordIteratorTest { | |
|
||
@Test | ||
public void getHeartbeatPositionTest() { | ||
final DebeziumRecordIterator debeziumRecordIterator = new DebeziumRecordIterator(mock(LinkedBlockingQueue.class), | ||
mock(CdcTargetPosition.class), | ||
final DebeziumRecordIterator<Long> debeziumRecordIterator = new DebeziumRecordIterator<>(mock(LinkedBlockingQueue.class), | ||
new CdcTargetPosition<>() { | ||
|
||
@Override | ||
public boolean reachedTargetPosition(JsonNode valueAsJson) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Long extractPositionFromHeartbeatOffset(final Map<String, ?> sourceOffset) { | ||
return (long) sourceOffset.get("lsn"); | ||
} | ||
|
||
}, | ||
() -> false, | ||
() -> {}, | ||
Duration.ZERO); | ||
|
@@ -50,7 +64,6 @@ public SourceRecord sourceRecord() { | |
}); | ||
|
||
assertEquals(lsn, 358824993496L); | ||
assertEquals(-1, debeziumRecordIterator.getHeartbeatPosition(null)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should keep this test, but instead of making it equal to |
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlCdcPosition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.airbyte.integrations.source.mysql; | ||
|
||
import java.util.Objects; | ||
|
||
public class MySqlCdcPosition { | ||
public final String fileName; | ||
public final Long position; | ||
|
||
public MySqlCdcPosition(final String fileName, final Long position) { | ||
this.fileName = fileName; | ||
this.position = position; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (obj instanceof final MySqlCdcPosition mySqlCdcPosition) { | ||
return fileName.equals(mySqlCdcPosition.fileName) && mySqlCdcPosition.position.equals(position); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(fileName, position); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FileName: " + fileName + ", Position : " + position; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove the default?
It just throw an exception as it's an interface and all the classes needs to implement it.
Otherwise we can make default the method
extractPositionFromHeartbeatOffset
.