-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[FLINK-38729] Add Flink2 support for Source/Pipeline connector. #4322
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f1f09e6
[FLINK-38729] Add Flink2 support for Source/Pipeline connector.
lvyanquan 7663f00
Address comments and remove pipeline_e2e for 1.19.
lvyanquan 8eaef82
Address comments.
lvyanquan c6aa4e9
Add test back.
lvyanquan 49245a7
Add flink.classifier for distinguishing Flink 1.x and Flink 2.x builds.
lvyanquan ad74d64
Avoid changing MongoDBConnectorDeserializationSchema.
lvyanquan 2f07d8d
Add test back.
lvyanquan fb6cb61
Revert "Add flink.classifier for distinguishing Flink 1.x and Flink 2…
lvyanquan b0670ae
Address comment and remove useless code.
lvyanquan 79eb9ab
Add end test for Doris/OceanBase back.
lvyanquan 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
135 changes: 135 additions & 0 deletions
135
...eline-connector-doris/src/main/java/org/apache/doris/flink/sink/batch/DorisBatchSink.java
This file contains hidden or 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,135 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.doris.flink.sink.batch; | ||
|
|
||
| import org.apache.flink.annotation.PublicEvolving; | ||
| import org.apache.flink.annotation.VisibleForTesting; | ||
| import org.apache.flink.api.connector.sink2.InitContextAdapter; | ||
| import org.apache.flink.api.connector.sink2.Sink; | ||
| import org.apache.flink.api.connector.sink2.SinkWriter; | ||
| import org.apache.flink.api.connector.sink2.WriterInitContext; | ||
| import org.apache.flink.util.Preconditions; | ||
|
|
||
| import org.apache.doris.flink.cfg.DorisExecutionOptions; | ||
| import org.apache.doris.flink.cfg.DorisOptions; | ||
| import org.apache.doris.flink.cfg.DorisReadOptions; | ||
| import org.apache.doris.flink.sink.writer.serializer.DorisRecordSerializer; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Copy from <a | ||
| * href="https://github.com/apache/doris-flink-connector/blob/25.1.0/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/batch/DorisBatchSink.java">DorisBatchSink</a> | ||
| * to add {@link #createWriter(WriterInitContext)}} method. | ||
| */ | ||
| @Deprecated | ||
| @PublicEvolving | ||
| public class DorisBatchSink<IN> implements Sink<IN> { | ||
| private final DorisOptions dorisOptions; | ||
| private final DorisReadOptions dorisReadOptions; | ||
| private final DorisExecutionOptions dorisExecutionOptions; | ||
| private final DorisRecordSerializer<IN> serializer; | ||
|
|
||
| public DorisBatchSink( | ||
| DorisOptions dorisOptions, | ||
| DorisReadOptions dorisReadOptions, | ||
| DorisExecutionOptions dorisExecutionOptions, | ||
| DorisRecordSerializer<IN> serializer) { | ||
| this.dorisOptions = dorisOptions; | ||
| this.dorisReadOptions = dorisReadOptions; | ||
| this.dorisExecutionOptions = dorisExecutionOptions; | ||
| this.serializer = serializer; | ||
| } | ||
|
|
||
| @Override | ||
| public SinkWriter<IN> createWriter(InitContext initContext) throws IOException { | ||
| DorisBatchWriter<IN> dorisBatchWriter = | ||
| new DorisBatchWriter<IN>( | ||
| initContext, | ||
| serializer, | ||
| dorisOptions, | ||
| dorisReadOptions, | ||
| dorisExecutionOptions); | ||
| return dorisBatchWriter; | ||
| } | ||
|
|
||
| @Override | ||
| public SinkWriter<IN> createWriter(WriterInitContext context) throws IOException { | ||
| DorisBatchWriter<IN> dorisBatchWriter = | ||
| new DorisBatchWriter<IN>( | ||
| new InitContextAdapter(context), | ||
| serializer, | ||
| dorisOptions, | ||
| dorisReadOptions, | ||
| dorisExecutionOptions); | ||
| return dorisBatchWriter; | ||
| } | ||
|
|
||
| public static <IN> DorisBatchSink.Builder<IN> builder() { | ||
| return new DorisBatchSink.Builder<>(); | ||
| } | ||
|
|
||
| /** | ||
| * build for DorisBatchSink. | ||
| * | ||
| * @param <IN> record type. | ||
| */ | ||
| public static class Builder<IN> { | ||
| private DorisOptions dorisOptions; | ||
| private DorisReadOptions dorisReadOptions; | ||
| private DorisExecutionOptions dorisExecutionOptions; | ||
| private DorisRecordSerializer<IN> serializer; | ||
|
|
||
| public DorisBatchSink.Builder<IN> setDorisOptions(DorisOptions dorisOptions) { | ||
| this.dorisOptions = dorisOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public DorisBatchSink.Builder<IN> setDorisReadOptions(DorisReadOptions dorisReadOptions) { | ||
| this.dorisReadOptions = dorisReadOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public DorisBatchSink.Builder<IN> setDorisExecutionOptions( | ||
| DorisExecutionOptions dorisExecutionOptions) { | ||
| this.dorisExecutionOptions = dorisExecutionOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public DorisBatchSink.Builder<IN> setSerializer(DorisRecordSerializer<IN> serializer) { | ||
| this.serializer = serializer; | ||
| return this; | ||
| } | ||
|
|
||
| public DorisBatchSink<IN> build() { | ||
| Preconditions.checkNotNull(dorisOptions); | ||
| Preconditions.checkNotNull(dorisExecutionOptions); | ||
| Preconditions.checkNotNull(serializer); | ||
| if (dorisReadOptions == null) { | ||
| dorisReadOptions = DorisReadOptions.builder().build(); | ||
| } | ||
| return new DorisBatchSink<>( | ||
| dorisOptions, dorisReadOptions, dorisExecutionOptions, serializer); | ||
| } | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public DorisReadOptions getDorisReadOptions() { | ||
| return dorisReadOptions; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.