forked from birdLark/LarkMidTable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wxgzgl
committed
Aug 10, 2020
1 parent
b041116
commit df73e6b
Showing
7 changed files
with
129 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
1.Main方法获取Reader,114行 | ||
|
||
``` | ||
BaseDataReader dataReader = DataReaderFactory.getDataReader(config, env); | ||
``` | ||
|
||
2.刨析DataReaderFactory的getDataReader方法 | ||
|
||
```java | ||
public static BaseDataReader getDataReader(DataTransferConfig config, StreamExecutionEnvironment env) { | ||
try { | ||
String pluginName =config.getJob().getContent().get(0).getReader().getName(); | ||
String pluginClassName = PluginUtil.getPluginClassName(pluginName); | ||
Set<URL> urlList = PluginUtil.getJarFileDirPath(pluginName, config.getPluginRoot()); | ||
return ClassLoaderManager.newInstance(urlList, cl -> { | ||
Class<?> clazz = cl.loadClass(pluginClassName); | ||
Constructor constructor = | ||
clazz.getConstructor(DataTransferConfig.class, StreamExecutionEnvironment.class); | ||
return (BaseDataReader)constructor.newInstance(config, env); | ||
}); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
``` | ||
|
||
pluginName:streamReader | ||
|
||
pluginClassName:com.dtstack.flinkx.stream.reader.StreamReader | ||
|
||
urlList: |
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,55 @@ | ||
public class JSONTemplate { | ||
public static String mysqlTemplate ="{\n" + | ||
" \"job\": {\n" + | ||
" \"content\": [\n" + | ||
" {\n" + | ||
" \"reader\": {\n" + | ||
" \"parameter\": {\n" + | ||
" \"username\": \"dtstack\",\n" + | ||
" \"password\": \"abc123\",\n" + | ||
" \"connection\": [{\n" + | ||
" \"jdbcUrl\": [\"jdbc:mysql://kudu3:3306/tudou?useUnicode=true&characterEncoding=utf8\"],\n" + | ||
" \"table\": [\"kudu\"]\n" + | ||
" }],\n" + | ||
" \"column\": [\"*\"],\n" + | ||
" \"customSql\": \"\",\n" + | ||
" \"where\": \"id < 100\",\n" + | ||
" \"splitPk\": \"\",\n" + | ||
" \"queryTimeOut\": 1000,\n" + | ||
" \"requestAccumulatorInterval\": 2\n" + | ||
" },\n" + | ||
" \"name\": \"mysqlreader\"\n" + | ||
" },\n" + | ||
" \"writer\": {\n" + | ||
" \"name\": \"streamwriter\",\n" + | ||
" \"parameter\": {\n" + | ||
" \"print\": true\n" + | ||
" }\n" + | ||
" }\n" + | ||
" }\n" + | ||
" ],\n" + | ||
" \"setting\": {\n" + | ||
" \"speed\": {\n" + | ||
" \"channel\": 1,\n" + | ||
" \"bytes\": 0\n" + | ||
" },\n" + | ||
" \"errorLimit\": {\n" + | ||
" \"record\": 100\n" + | ||
" },\n" + | ||
" \"restore\": {\n" + | ||
" \"maxRowNumForCheckpoint\": 0,\n" + | ||
" \"isRestore\": false,\n" + | ||
" \"restoreColumnName\": \"\",\n" + | ||
" \"restoreColumnIndex\": 0\n" + | ||
" },\n" + | ||
" \"log\" : {\n" + | ||
" \"isLogger\": false,\n" + | ||
" \"level\" : \"debug\",\n" + | ||
" \"path\" : \"\",\n" + | ||
" \"pattern\":\"\"\n" + | ||
" }\n" + | ||
" }\n" + | ||
" }\n" + | ||
"}"; | ||
|
||
} |
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,6 @@ | ||
public class MysqlTemplate { | ||
public static void main(String[] args) { | ||
|
||
System.out.println(JSONTemplate.mysqlTemplate); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.