-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Connector-V2] Add Kudu source and sink connector #2254
Merged
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1737798
0
2013650523 eedef28
Update pom.xml
2013650523 146fa24
Update plugin-mapping.properties
2013650523 9b1f10b
Update pom.xml
2013650523 8c28e80
add email sink connector
2013650523 ed790c8
Delete seatunnel-connectors-v2/connector-email directory
2013650523 5ba8049
Update plugin-mapping.properties
2013650523 48018fa
Merge branch 'dev' into api-draft
2013650523 2c1bf27
Update plugin-mapping.properties
2013650523 843ba43
Update pom.xml
2013650523 6893447
Create pom.xml
2013650523 aa2cf30
[Connector-V2] Add Kudu source and sink connector
2013650523 42ea0f0
[Connector-V2] Add Kudu source and sink connector
2013650523 a79807f
[Connector-V2] update
2013650523 d4fc941
[Connector-V2] solve ci error
2013650523 b7ceb54
[Connector-V2] fix problem on code review
2013650523 2043c6e
[Connector-V2] add kudu usage document and fix problem on code review
2013650523 582e77e
Merge branch 'dev' into api-draft
2013650523 a323b17
Update ExceptionUtil.java
2013650523 5f213b8
Merge branch 'dev' into api-draft
Hisoka-X f40b9d9
Update pom.xml
2013650523 6cde18d
Update Kudu.md
2013650523 548855f
Update ExceptionUtil.java
2013650523 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Kudu | ||
|
||
## Description | ||
|
||
Write data to Kudu. | ||
|
||
The tested kudu version is 1.11.1. | ||
|
||
## Options | ||
|
||
| name | type | required | default value | | ||
|--------------------------|---------|----------|---------------| | ||
| kudu_master | string | yes | - | | ||
| kudu_table | string | yes | - | | ||
| save_mode | string | yes | - | | ||
|
||
### kudu_master [string] | ||
|
||
`kudu_master` The address of kudu master,such as '192.168.88.110:7051'. | ||
|
||
### kudu_table [string] | ||
|
||
`kudu_table` The name of kudu table.. | ||
|
||
### save_mode [string] | ||
|
||
Storage mode, we need support `overwrite` and `append`. `append` is now supported. | ||
|
||
## Example | ||
|
||
```bash | ||
|
||
kuduSink { | ||
kudu_master = "192.168.88.110:7051" | ||
kudu_table = "studentlyhresultflink" | ||
save_mode="append" | ||
} | ||
|
||
``` |
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,41 @@ | ||
# Kudu | ||
|
||
## Description | ||
|
||
Used to read data from Kudu. Currently, only supports Query with Batch Mode. | ||
|
||
The tested kudu version is 1.11.1. | ||
|
||
## Options | ||
|
||
| name | type | required | default value | | ||
|--------------------------|---------|----------|---------------| | ||
| kudu_master | string | yes | - | | ||
| kudu_table | string | yes | - | | ||
| columnsList | string | yes | - | | ||
|
||
### kudu_master [string] | ||
|
||
`kudu_master` The address of kudu master,such as '192.168.88.110:7051'. | ||
|
||
### kudu_table [string] | ||
|
||
`kudu_table` The name of kudu table.. | ||
|
||
### columnsList [string] | ||
|
||
`columnsList` Specifies the column names of the table. | ||
|
||
## Examples | ||
|
||
```hocon | ||
source { | ||
KuduSource { | ||
result_table_name = "studentlyh2" | ||
kudu_master = "192.168.88.110:7051" | ||
kudu_table = "studentlyh2" | ||
columnsList = "id,name,age,sex" | ||
} | ||
|
||
} | ||
``` |
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
49 changes: 49 additions & 0 deletions
49
seatunnel-common/src/main/java/org/apache/seatunnel/common/ExceptionUtil.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,49 @@ | ||
/* | ||
* 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.seatunnel.common; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
|
||
public class ExceptionUtil { | ||
public static String getMessage(Throwable e) { | ||
StringWriter sw = null; | ||
PrintWriter pw = null; | ||
try { | ||
sw = new StringWriter(); | ||
pw = new PrintWriter(sw); | ||
// Output the error stack information to the printWriter | ||
e.printStackTrace(pw); | ||
pw.flush(); | ||
sw.flush(); | ||
} finally { | ||
if (sw != null) { | ||
try { | ||
sw.close(); | ||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
} | ||
} | ||
if (pw != null) { | ||
pw.close(); | ||
} | ||
} | ||
return sw.toString(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
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. | ||
|
||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>seatunnel-connectors-v2</artifactId> | ||
<groupId>org.apache.seatunnel</groupId> | ||
<version>${revision}</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>connector-kudu</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.seatunnel</groupId> | ||
<artifactId>seatunnel-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.seatunnel</groupId> | ||
<artifactId>seatunnel-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.kudu</groupId> | ||
<artifactId>kudu-client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.seatunnel</groupId> | ||
<artifactId>connector-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
64 changes: 64 additions & 0 deletions
64
...u/src/main/java/org/apache/seatunnel/connectors/seatunnel/kudu/config/KuduSinkConfig.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,64 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.kudu.config; | ||
|
||
import org.apache.seatunnel.shade.com.typesafe.config.Config; | ||
|
||
import lombok.Data; | ||
import lombok.NonNull; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
@Data | ||
public class KuduSinkConfig { | ||
|
||
private static final String KUDU_SAVE_MODE = "save_mode"; | ||
private static final String KUDU_MASTER = "kudu_master"; | ||
private static final String KUDU_TABLE_NAME = "kudu_table"; | ||
|
||
private SaveMode saveMode = SaveMode.APPEND; | ||
|
||
private String kuduMaster; | ||
|
||
/** | ||
* Specifies the name of the table | ||
*/ | ||
private String kuduTableName; | ||
|
||
public enum SaveMode { | ||
APPEND(), | ||
OVERWRITE(); | ||
|
||
public static SaveMode fromStr(String str) { | ||
if ("overwrite".equals(str)) { | ||
return OVERWRITE; | ||
} else { | ||
return APPEND; | ||
} | ||
} | ||
} | ||
|
||
public KuduSinkConfig(@NonNull Config pluginConfig) { | ||
if (pluginConfig.hasPath(KUDU_SAVE_MODE) && pluginConfig.hasPath(KUDU_MASTER) && pluginConfig.hasPath(KUDU_TABLE_NAME)) { | ||
this.saveMode = StringUtils.isBlank(pluginConfig.getString(KUDU_SAVE_MODE)) ? SaveMode.APPEND : SaveMode.fromStr(pluginConfig.getString(KUDU_SAVE_MODE)); | ||
this.kuduMaster = pluginConfig.getString(KUDU_MASTER); | ||
this.kuduTableName = pluginConfig.getString(KUDU_TABLE_NAME); | ||
} else { | ||
throw new RuntimeException("Missing Sink configuration parameters"); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...src/main/java/org/apache/seatunnel/connectors/seatunnel/kudu/config/KuduSourceConfig.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,29 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.kudu.config; | ||
|
||
import java.io.Serializable; | ||
|
||
public class KuduSourceConfig implements Serializable { | ||
|
||
public static final String KUDUMASTER = "kudu_master"; | ||
public static final String TABLENAME = "kudu_table"; | ||
public static final String COLUMNSLIST = "columnsList"; | ||
|
||
|
||
} |
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.
used
try-with-resources
to simplify this