mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-03 03:40:24 +08:00
commit
4097c01d15
84
oscarwriter/pom.xml
Normal file
84
oscarwriter/pom.xml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?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>oscarwriter</artifactId>
|
||||||
|
<name>oscarwriter</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>writer data into oscar database</description>
|
||||||
|
|
||||||
|
<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.alibaba.datax</groupId>
|
||||||
|
<artifactId>plugin-rdbms-util</artifactId>
|
||||||
|
<version>${datax-project-version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oscar</groupId>
|
||||||
|
<artifactId>oscar</artifactId>
|
||||||
|
<version>7.0.8</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/src/main/lib/oscarJDBC.jar</systemPath>
|
||||||
|
</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>
|
42
oscarwriter/src/main/assembly/package.xml
Normal file
42
oscarwriter/src/main/assembly/package.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<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>
|
||||||
|
<include>plugin_job_template.json</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>plugin/writer/oscarwriter</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>src/main/lib</directory>
|
||||||
|
<includes>
|
||||||
|
<include>oscarJDBC.jar</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>plugin/writer/oscarwriter/libs</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>target/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>oscarwriter-0.0.1-SNAPSHOT.jar</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>plugin/writer/oscarwriter</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
|
||||||
|
<dependencySets>
|
||||||
|
<dependencySet>
|
||||||
|
<useProjectArtifact>false</useProjectArtifact>
|
||||||
|
<outputDirectory>plugin/writer/oscarwriter/libs</outputDirectory>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependencySet>
|
||||||
|
</dependencySets>
|
||||||
|
</assembly>
|
@ -0,0 +1,90 @@
|
|||||||
|
package com.alibaba.datax.plugin.writer.oscarwriter;
|
||||||
|
|
||||||
|
import com.alibaba.datax.common.plugin.RecordReceiver;
|
||||||
|
import com.alibaba.datax.common.spi.Writer;
|
||||||
|
import com.alibaba.datax.common.util.Configuration;
|
||||||
|
import com.alibaba.datax.plugin.rdbms.util.DataBaseType;
|
||||||
|
import com.alibaba.datax.plugin.rdbms.writer.CommonRdbmsWriter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OscarWriter extends Writer {
|
||||||
|
private static final DataBaseType DATABASE_TYPE = DataBaseType.Oscar;
|
||||||
|
|
||||||
|
public static class Job extends Writer.Job {
|
||||||
|
private Configuration originalConfig = null;
|
||||||
|
private CommonRdbmsWriter.Job commonRdbmsWriterJob;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preCheck() {
|
||||||
|
this.init();
|
||||||
|
this.commonRdbmsWriterJob.writerPreCheck(this.originalConfig, DATABASE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.originalConfig = super.getPluginJobConf();
|
||||||
|
|
||||||
|
this.commonRdbmsWriterJob = new CommonRdbmsWriter.Job(
|
||||||
|
DATABASE_TYPE);
|
||||||
|
this.commonRdbmsWriterJob.init(this.originalConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepare() {
|
||||||
|
this.commonRdbmsWriterJob.prepare(this.originalConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Configuration> split(int mandatoryNumber) {
|
||||||
|
return this.commonRdbmsWriterJob.split(this.originalConfig,
|
||||||
|
mandatoryNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void post() {
|
||||||
|
this.commonRdbmsWriterJob.post(this.originalConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
this.commonRdbmsWriterJob.destroy(this.originalConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Task extends Writer.Task {
|
||||||
|
private Configuration writerSliceConfig;
|
||||||
|
private CommonRdbmsWriter.Task commonRdbmsWriterTask;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.writerSliceConfig = super.getPluginJobConf();
|
||||||
|
this.commonRdbmsWriterTask = new CommonRdbmsWriter.Task(DATABASE_TYPE);
|
||||||
|
this.commonRdbmsWriterTask.init(this.writerSliceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepare() {
|
||||||
|
this.commonRdbmsWriterTask.prepare(this.writerSliceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startWrite(RecordReceiver recordReceiver) {
|
||||||
|
this.commonRdbmsWriterTask.startWrite(recordReceiver,
|
||||||
|
this.writerSliceConfig, super.getTaskPluginCollector());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void post() {
|
||||||
|
this.commonRdbmsWriterTask.post(this.writerSliceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
this.commonRdbmsWriterTask.destroy(this.writerSliceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.alibaba.datax.plugin.writer.oscarwriter;
|
||||||
|
|
||||||
|
import com.alibaba.datax.common.spi.ErrorCode;
|
||||||
|
|
||||||
|
public enum OscarWriterErrorCode implements ErrorCode {
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String describe;
|
||||||
|
|
||||||
|
private OscarWriterErrorCode(String code, String describe) {
|
||||||
|
this.code = code;
|
||||||
|
this.describe = describe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return this.describe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("Code:[%s], Describe:[%s]. ", this.code,
|
||||||
|
this.describe);
|
||||||
|
}
|
||||||
|
}
|
6
oscarwriter/src/main/resources/plugin.json
Normal file
6
oscarwriter/src/main/resources/plugin.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "oscarwriter",
|
||||||
|
"class": "com.alibaba.datax.plugin.writer.oscarwriter.OscarWriter",
|
||||||
|
"description": "useScene: prod. mechanism: Jdbc connection using the database, execute insert sql. warn: The more you know about the database, the less problems you encounter.",
|
||||||
|
"developer": "linjiayu"
|
||||||
|
}
|
15
oscarwriter/src/main/resources/plugin_job_template.json
Normal file
15
oscarwriter/src/main/resources/plugin_job_template.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "oscarwriter",
|
||||||
|
"parameter": {
|
||||||
|
"username": "",
|
||||||
|
"password": "",
|
||||||
|
"column": [],
|
||||||
|
"preSql": [],
|
||||||
|
"connection": [
|
||||||
|
{
|
||||||
|
"jdbcUrl": "",
|
||||||
|
"table": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -378,5 +378,12 @@
|
|||||||
</includes>
|
</includes>
|
||||||
<outputDirectory>datax</outputDirectory>
|
<outputDirectory>datax</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>oscarwriter/target/datax/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.*</include>
|
||||||
|
</includes>
|
||||||
|
<outputDirectory>datax</outputDirectory>
|
||||||
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
@ -20,7 +20,8 @@ public enum DataBaseType {
|
|||||||
DB2("db2", "com.ibm.db2.jcc.DB2Driver"),
|
DB2("db2", "com.ibm.db2.jcc.DB2Driver"),
|
||||||
ADS("ads","com.mysql.jdbc.Driver"),
|
ADS("ads","com.mysql.jdbc.Driver"),
|
||||||
ClickHouse("clickhouse", "ru.yandex.clickhouse.ClickHouseDriver"),
|
ClickHouse("clickhouse", "ru.yandex.clickhouse.ClickHouseDriver"),
|
||||||
KingbaseES("kingbasees", "com.kingbase8.Driver");
|
KingbaseES("kingbasees", "com.kingbase8.Driver"),
|
||||||
|
Oscar("oscar", "com.oscar.Driver");
|
||||||
|
|
||||||
|
|
||||||
private String typeName;
|
private String typeName;
|
||||||
@ -62,6 +63,8 @@ public enum DataBaseType {
|
|||||||
break;
|
break;
|
||||||
case KingbaseES:
|
case KingbaseES:
|
||||||
break;
|
break;
|
||||||
|
case Oscar:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
||||||
}
|
}
|
||||||
@ -103,6 +106,8 @@ public enum DataBaseType {
|
|||||||
break;
|
break;
|
||||||
case KingbaseES:
|
case KingbaseES:
|
||||||
break;
|
break;
|
||||||
|
case Oscar:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
||||||
}
|
}
|
||||||
@ -128,6 +133,7 @@ public enum DataBaseType {
|
|||||||
case DB2:
|
case DB2:
|
||||||
case PostgreSQL:
|
case PostgreSQL:
|
||||||
case KingbaseES:
|
case KingbaseES:
|
||||||
|
case Oscar:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type.");
|
||||||
@ -152,6 +158,7 @@ public enum DataBaseType {
|
|||||||
case DB2:
|
case DB2:
|
||||||
case PostgreSQL:
|
case PostgreSQL:
|
||||||
case KingbaseES:
|
case KingbaseES:
|
||||||
|
case Oscar:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type");
|
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type");
|
||||||
@ -177,6 +184,8 @@ public enum DataBaseType {
|
|||||||
break;
|
break;
|
||||||
case KingbaseES:
|
case KingbaseES:
|
||||||
break;
|
break;
|
||||||
|
case Oscar:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type");
|
throw DataXException.asDataXException(DBUtilErrorCode.UNSUPPORTED_TYPE, "unsupported database type");
|
||||||
}
|
}
|
||||||
|
1
pom.xml
1
pom.xml
@ -97,6 +97,7 @@
|
|||||||
<module>gdbwriter</module>
|
<module>gdbwriter</module>
|
||||||
<module>cassandrawriter</module>
|
<module>cassandrawriter</module>
|
||||||
<module>clickhousewriter</module>
|
<module>clickhousewriter</module>
|
||||||
|
<module>oscarwriter</module>
|
||||||
<!-- common support module -->
|
<!-- common support module -->
|
||||||
<module>plugin-rdbms-util</module>
|
<module>plugin-rdbms-util</module>
|
||||||
<module>plugin-unstructured-storage-util</module>
|
<module>plugin-unstructured-storage-util</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user