-
Notifications
You must be signed in to change notification settings - Fork 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
[FLINK-36931][cdc] FlinkCDC YAML supports batch mode #3812
Open
aiwenmo
wants to merge
24
commits into
apache:master
Choose a base branch
from
aiwenmo:FLINK-36931
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
02a987e
[FLINK-36931][cdc] FlinkCDC YAML supports batch mode
aiwenmo 7360c4c
rebase onto master
aiwenmo fbd0ba9
Support regular batch mode
aiwenmo 572f167
Support merge create table event in source operator
aiwenmo e902e4a
Support merge create table event in schema batch operator
aiwenmo e24cf41
Fix test after rebased master
aiwenmo a220dc9
Fix the random field order in merged tables.
aiwenmo 69ba498
Remove CreateTableCompletedEvent
aiwenmo 6efce32
Remove the useless code
aiwenmo f025f5f
add parse test
aiwenmo aca444e
Add e2e test
aiwenmo 7fead6e
Fix rebase
aiwenmo 72434e6
Fix deduceMergedCreateTableEventInBatchMode
aiwenmo 5e7258a
Fix groupSourceTablesByRouteRule
aiwenmo 438f4c3
Remove testSyncWholeDatabaseWithDebeziumJsonInBatchMode and testSyncW…
aiwenmo 25a6881
Fix multi-parallelism
aiwenmo 9cad887
Fix sink multi-parallelism
aiwenmo d11e3ac
Optimize code
aiwenmo 42d1257
Optimize code
aiwenmo ad298b2
Update TableIdRouter.java
aiwenmo 10896f1
Update OceanBaseE2eITCase.java
aiwenmo 4c5829c
Add verifyBatchMode
aiwenmo 081565d
Add scan.startup.mode: snapshot into e2e test
aiwenmo 7e52b27
add verifyBatchMode into test
aiwenmo 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
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import org.apache.flink.cdc.composer.definition.SinkDef; | ||
import org.apache.flink.cdc.composer.flink.FlinkEnvironmentUtils; | ||
import org.apache.flink.cdc.composer.utils.FactoryDiscoveryUtils; | ||
import org.apache.flink.cdc.runtime.operators.sink.DataBatchSinkFunctionOperator; | ||
import org.apache.flink.cdc.runtime.operators.sink.DataSinkFunctionOperator; | ||
import org.apache.flink.cdc.runtime.operators.sink.DataSinkWriterOperatorFactory; | ||
import org.apache.flink.core.io.SimpleVersionedSerializer; | ||
|
@@ -46,6 +47,7 @@ | |
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; | ||
import org.apache.flink.streaming.api.functions.sink.SinkFunction; | ||
import org.apache.flink.streaming.api.operators.OneInputStreamOperatorFactory; | ||
import org.apache.flink.streaming.api.operators.StreamSink; | ||
import org.apache.flink.streaming.api.transformations.LegacySinkTransformation; | ||
import org.apache.flink.streaming.api.transformations.PhysicalTransformation; | ||
|
||
|
@@ -82,20 +84,29 @@ public void translate( | |
DataStream<Event> input, | ||
DataSink dataSink, | ||
OperatorID schemaOperatorID) { | ||
translate(sinkDef, input, dataSink, false, schemaOperatorID); | ||
} | ||
|
||
public void translate( | ||
SinkDef sinkDef, | ||
DataStream<Event> input, | ||
DataSink dataSink, | ||
boolean isBatchMode, | ||
OperatorID schemaOperatorID) { | ||
// Get sink provider | ||
EventSinkProvider eventSinkProvider = dataSink.getEventSinkProvider(); | ||
String sinkName = generateSinkName(sinkDef); | ||
if (eventSinkProvider instanceof FlinkSinkProvider) { | ||
// Sink V2 | ||
FlinkSinkProvider sinkProvider = (FlinkSinkProvider) eventSinkProvider; | ||
Sink<Event> sink = sinkProvider.getSink(); | ||
sinkTo(input, sink, sinkName, schemaOperatorID); | ||
sinkTo(input, sink, sinkName, isBatchMode, schemaOperatorID); | ||
} else if (eventSinkProvider instanceof FlinkSinkFunctionProvider) { | ||
// SinkFunction | ||
FlinkSinkFunctionProvider sinkFunctionProvider = | ||
(FlinkSinkFunctionProvider) eventSinkProvider; | ||
SinkFunction<Event> sinkFunction = sinkFunctionProvider.getSinkFunction(); | ||
sinkTo(input, sinkFunction, sinkName, schemaOperatorID); | ||
sinkTo(input, sinkFunction, sinkName, isBatchMode, schemaOperatorID); | ||
} | ||
} | ||
|
||
|
@@ -104,6 +115,7 @@ void sinkTo( | |
DataStream<Event> input, | ||
Sink<Event> sink, | ||
String sinkName, | ||
boolean isBatchMode, | ||
OperatorID schemaOperatorID) { | ||
DataStream<Event> stream = input; | ||
// Pre-write topology | ||
|
@@ -112,22 +124,27 @@ void sinkTo( | |
} | ||
|
||
if (sink instanceof TwoPhaseCommittingSink) { | ||
addCommittingTopology(sink, stream, sinkName, schemaOperatorID); | ||
addCommittingTopology(sink, stream, sinkName, isBatchMode, schemaOperatorID); | ||
} else { | ||
stream.transform( | ||
SINK_WRITER_PREFIX + sinkName, | ||
CommittableMessageTypeInfo.noOutput(), | ||
new DataSinkWriterOperatorFactory<>(sink, schemaOperatorID)); | ||
new DataSinkWriterOperatorFactory<>(sink, isBatchMode, schemaOperatorID)); | ||
} | ||
} | ||
|
||
private void sinkTo( | ||
DataStream<Event> input, | ||
SinkFunction<Event> sinkFunction, | ||
String sinkName, | ||
boolean isBatchMode, | ||
OperatorID schemaOperatorID) { | ||
DataSinkFunctionOperator sinkOperator = | ||
new DataSinkFunctionOperator(sinkFunction, schemaOperatorID); | ||
StreamSink<Event> sinkOperator; | ||
if (isBatchMode) { | ||
sinkOperator = new DataBatchSinkFunctionOperator(sinkFunction); | ||
} else { | ||
sinkOperator = new DataSinkFunctionOperator(sinkFunction, schemaOperatorID); | ||
} | ||
final StreamExecutionEnvironment executionEnvironment = input.getExecutionEnvironment(); | ||
PhysicalTransformation<Event> transformation = | ||
new LegacySinkTransformation<>( | ||
|
@@ -143,23 +160,23 @@ private <CommT> void addCommittingTopology( | |
Sink<Event> sink, | ||
DataStream<Event> inputStream, | ||
String sinkName, | ||
boolean isBatchMode, | ||
OperatorID schemaOperatorID) { | ||
TypeInformation<CommittableMessage<CommT>> typeInformation = | ||
CommittableMessageTypeInfo.of(() -> getCommittableSerializer(sink)); | ||
DataStream<CommittableMessage<CommT>> written = | ||
inputStream.transform( | ||
SINK_WRITER_PREFIX + sinkName, | ||
typeInformation, | ||
new DataSinkWriterOperatorFactory<>(sink, schemaOperatorID)); | ||
new DataSinkWriterOperatorFactory<>(sink, isBatchMode, schemaOperatorID)); | ||
|
||
DataStream<CommittableMessage<CommT>> preCommitted = written; | ||
if (sink instanceof WithPreCommitTopology) { | ||
preCommitted = | ||
((WithPreCommitTopology<Event, CommT>) sink).addPreCommitTopology(written); | ||
} | ||
|
||
// TODO: Hard coding stream mode and checkpoint | ||
boolean isBatchMode = false; | ||
// TODO: Hard coding checkpoint | ||
boolean isCheckpointingEnabled = true; | ||
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. Just curious, is it possible to enable checkpointing in batch mode? 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. Some sinks need to rely on checkpointing to complete the writing. |
||
DataStream<CommittableMessage<CommT>> committed = | ||
preCommitted.transform( | ||
|
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
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.
minor: since batchMode is disabled by default, maybe we can turn it on here to verify if it could be enabled correctly?
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.
Many parameters are not effective in batch mode, so "false" is written here.