-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1523 from dingxiaobo/opensoure_20220922
DataX 2209, MaxCompute、DataHub、SLS、MySQL、OceanBase、StarRocks、ElasticSearch
- Loading branch information
Showing
133 changed files
with
5,505 additions
and
2,537 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>datax-all</artifactId> | ||
<groupId>com.alibaba.datax</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>datahubreader</artifactId> | ||
|
||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.alibaba.datax</groupId> | ||
<artifactId>datax-common</artifactId> | ||
<version>${datax-project-version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<groupId>org.slf4j</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.aliyun.datahub</groupId> | ||
<artifactId>aliyun-sdk-datahub</artifactId> | ||
<version>2.21.6-public</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<!-- compiler plugin --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${jdk-version}</source> | ||
<target>${jdk-version}</target> | ||
<encoding>${project-sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<!-- assembly plugin --> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>src/main/assembly/package.xml</descriptor> | ||
</descriptors> | ||
<finalName>datax</finalName> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>dwzip</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,34 @@ | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> | ||
<id></id> | ||
<formats> | ||
<format>dir</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>plugin.json</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/datahubreader</outputDirectory> | ||
</fileSet> | ||
<fileSet> | ||
<directory>target/</directory> | ||
<includes> | ||
<include>datahubreader-0.0.1-SNAPSHOT.jar</include> | ||
</includes> | ||
<outputDirectory>plugin/reader/datahubreader</outputDirectory> | ||
</fileSet> | ||
</fileSets> | ||
|
||
<dependencySets> | ||
<dependencySet> | ||
<useProjectArtifact>false</useProjectArtifact> | ||
<outputDirectory>plugin/reader/datahubreader/libs</outputDirectory> | ||
<scope>runtime</scope> | ||
</dependencySet> | ||
</dependencySets> | ||
</assembly> |
8 changes: 8 additions & 0 deletions
8
datahubreader/src/main/java/com/alibaba/datax/plugin/reader/datahubreader/Constant.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,8 @@ | ||
package com.alibaba.datax.plugin.reader.datahubreader; | ||
|
||
public class Constant { | ||
|
||
public static String DATETIME_FORMAT = "yyyyMMddHHmmss"; | ||
public static String DATE_FORMAT = "yyyyMMdd"; | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...ader/src/main/java/com/alibaba/datax/plugin/reader/datahubreader/DatahubClientHelper.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,42 @@ | ||
package com.alibaba.datax.plugin.reader.datahubreader; | ||
|
||
import com.alibaba.datax.common.util.Configuration; | ||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.TypeReference; | ||
import com.aliyun.datahub.client.DatahubClient; | ||
import com.aliyun.datahub.client.DatahubClientBuilder; | ||
import com.aliyun.datahub.client.auth.Account; | ||
import com.aliyun.datahub.client.auth.AliyunAccount; | ||
import com.aliyun.datahub.client.common.DatahubConfig; | ||
import com.aliyun.datahub.client.http.HttpConfig; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class DatahubClientHelper { | ||
public static DatahubClient getDatahubClient(Configuration jobConfig) { | ||
String accessId = jobConfig.getNecessaryValue(Key.CONFIG_KEY_ACCESS_ID, | ||
DatahubWriterErrorCode.MISSING_REQUIRED_VALUE); | ||
String accessKey = jobConfig.getNecessaryValue(Key.CONFIG_KEY_ACCESS_KEY, | ||
DatahubWriterErrorCode.MISSING_REQUIRED_VALUE); | ||
String endpoint = jobConfig.getNecessaryValue(Key.CONFIG_KEY_ENDPOINT, | ||
DatahubWriterErrorCode.MISSING_REQUIRED_VALUE); | ||
Account account = new AliyunAccount(accessId, accessKey); | ||
// 是否开启二进制传输,服务端2.12版本开始支持 | ||
boolean enableBinary = jobConfig.getBool("enableBinary", false); | ||
DatahubConfig datahubConfig = new DatahubConfig(endpoint, account, enableBinary); | ||
// HttpConfig可不设置,不设置时采用默认值 | ||
// 读写数据推荐打开网络传输 LZ4压缩 | ||
HttpConfig httpConfig = null; | ||
String httpConfigStr = jobConfig.getString("httpConfig"); | ||
if (StringUtils.isNotBlank(httpConfigStr)) { | ||
httpConfig = JSON.parseObject(httpConfigStr, new TypeReference<HttpConfig>() { | ||
}); | ||
} | ||
|
||
DatahubClientBuilder builder = DatahubClientBuilder.newBuilder().setDatahubConfig(datahubConfig); | ||
if (null != httpConfig) { | ||
builder.setHttpConfig(httpConfig); | ||
} | ||
DatahubClient datahubClient = builder.build(); | ||
return datahubClient; | ||
} | ||
} |
Oops, something went wrong.