Skip to content

Commit

Permalink
use mermaid to creat diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzhao committed Mar 5, 2023
1 parent a46e9b7 commit f4a4f41
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 11 deletions.
Binary file removed docs/images/addax-framework_new.png
Binary file not shown.
Binary file removed docs/images/addax_arch.png
Binary file not shown.
Binary file removed docs/images/excel_demo.png
Binary file not shown.
Binary file removed docs/images/plugin_dev_guide_1.png
Binary file not shown.
Binary file removed docs/images/plugin_dev_guide_2.png
Binary file not shown.
Binary file removed docs/images/plugin_dev_guide_3.png
Binary file not shown.
Binary file removed docs/images/transform-arch.png
Binary file not shown.
80 changes: 78 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@ Addax 是一个异构数据源离线同步工具,最初来源于阿里的 [Dat

## 框架设计

![addax_framework_new](images/addax-framework_new.png)
```mermaid
%%{init: {"theme": "neutral"}}%%
graph LR
MySQL
subgraph Addax
direction LR
subgraph reader["Reader Plugin"]
mr["MySQLReader"]
end
subgraph writer["Writer Plugin"]
hw["HDFSWriter"]
end
Framework:::f1
mr --> Framework --> writer
end
MySQL:::f1 ==> Addax ==> HDFS:::f1
classDef f1 fill:#62B3D4,stroke-width:0px;
```

Addax本身作为离线数据同步框架,采用 Framework + plugin 架构构建。将数据源读取和写入抽象成为 Reader/Writer 插件,纳入到整个同步框架中。

Expand All @@ -24,7 +43,64 @@ Addax Framework提供了简单的接口与插件交互,提供简单的插件

本小节按一个Addax作业生命周期的时序图,从整体架构设计非常简要说明各个模块相互关系。

![addax_arch](images/addax_arch.png)
```mermaid
%%{init: {"theme": "neutral"}}%%
graph TB
subgraph Job
end
subgraph task
direction TB
t1["Task"]
t2["Task"]
t3["Task"]
t4["Task"]
t5["Task"]
t6["Task"]
end
subgraph taskgroup[" "]
direction TB
subgraph tg1["TaskGroup"]
subgraph tg1_Task["Task"]
tg1_r["Reader"]
tg1_c["Channel"]
tg1_w["Writer"]
end
t7["Task"]
t8["Task"]
end
subgraph tg2["TaskGroup"]
subgraph tg2_Task["Task"]
direction LR
tg2_r["Reader"]
tg2_c["Channel"]
tg2_w["Writer"]
end
t9["Task"]
t10["Task"]
end
subgraph tg3["TaskGroup"]
direction LR
subgraph tg3_Task["Task"]
tg3_r["Reader"]
tg3_c["Channel"]
tg3_w["Writer"]
end
t11["Task"]
t12["Task"]
end
end
Job == split ==> task
task == Schedule ==> taskgroup
style taskgroup fill:gray
style task fill:#bbb
```



### 核心模块介绍

Expand Down
99 changes: 95 additions & 4 deletions docs/plugin_development.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,79 @@ public class SomeReader

框架按照如下的顺序执行 `Job``Task` 的接口:

![AddaxReaderWriter](images/plugin_dev_guide_1.png)
```mermaid
stateDiagram-v2
direction TB
Init:::job --> Prepare:::job
Prepare --> Split:::job
Split --> Schedule:::fw
state Schedule {
direction LR
init\nprepare\nstartRead\npost\ndestroy1 --> init\nprepare\nstartRead\npost\ndestroy : Channel
}
Schedule --> Post:::job
classDef job fill:yellow
classDef fw fill:#c6fac4
classDef ctask fill:blue
```

上图中,黄色表示 `Job` 部分的执行阶段,蓝色表示 `Task` 部分的执行阶段,绿色表示框架执行阶段。
上图中,黄色表示 `Job` 部分的执行阶段,灰色表示 `Task` 部分的执行阶段,绿色表示框架执行阶段。

相关类关系如下:

![Addax](images/plugin_dev_guide_2.png)
```mermaid
%%{init: {"theme": "neutral"}}%%
classDiagram
class Pluginable {
+ init()
+ destroy()
+ others()
}
class AbstractPlugin {
+ prepare()
+ post()
+ others()
}
class AbstractJobPlugin {
+ getJobPluginCollector(): JobPluginCollector
+ setJobPluginCollector(JobPluginCollector)
}
class AbstractTaskPlugin {
+ getTaskPluginCollector(): TaskPluginCollector
+ setTaskPluginCollector(TaskPluginCollector)
}
class Reader_Job {
+ split(init): List<<Configuration>>
}
class Writer_Job {
+ split(init): List<<Configuration>>
}
class Reader_Task {
+ startRead(RecordSender)
}
class Writer_Task {
+ startWrite(RecordReceiver)
}
AbstractJobPlugin <|-- Reader_Job
AbstractJobPlugin <|-- Writer_Job
AbstractTaskPlugin <|-- Reader_Task
AbstractTaskPlugin <|-- Writer_Task
AbstractPlugin <|-- AbstractJobPlugin
AbstractPlugin <|-- AbstractTaskPlugin
Pluginable <|-- AbstractPlugin
```



### 插件定义

Expand Down Expand Up @@ -390,7 +456,32 @@ public interface Record

`Column` 除了提供数据相关的方法外,还提供一系列以 `as` 开头的数据类型转换转换方法。

![Columns](images/plugin_dev_guide_3.png)
```mermaid
%%{init: {"theme": "neutral"}}%%
classDiagram
direction TB
class Column {
<<interface>>
- rawData: Object
- type: Type
+ getRawData(): Object
+ getType(): Type
+ getByteSize(): init
+ asLong(): Long
+ asDouble(): Doule
+ asString(): String
+ asDate(): Date
+ asBytes(): Bytes
+ asBigDecimal(): BigDecimal
+ asBoolean(): Boolean
}
Column <|-- Stringcolumn
Column <|-- Doublecolumn
Column <|-- Longcolumn
Column <|-- Datecolumn
Column <|-- Boolcolumn
Column <|-- Bytescolumn
```

Addax的内部类型在实现上会选用不同的java类型:

Expand Down
27 changes: 24 additions & 3 deletions docs/reader/excelreader.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,30 @@
- `demo.xls` 是 Excel 老格式
- `demo_gbk.xlsx` 是在Windows下创建,已GBK编码存储的文件

文件内容,如下图所示:

![excel demo](../images/excel_demo.png)
文件内容,如下表所示:

| 编号 | 整数类型 | 浮点数类型 | 字符串类型 | 日期类型 | 公式计算 | 单元格式化 |
| ---- | -------- | ---------- | ------------- | --------- | -------- | ---------- |
| 1 | 11 | 1102.234 | Addax加上中文 | 2021/9/10 | 5544.17 | ¥1,102.23 |
| 2 | 12 | 1103.234 | Addax加上中文 | 2021/9/11 | 5552.17 | ¥1,103.23 |
| 3 | 13 | 1104.234 | Addax加上中文 | 2021/9/12 | 5560.17 | ¥1,104.23 |
| 4 | 14 | 1105.234 | Addax加上中文 | 2021/9/13 | 5568.17 | ¥1,105.23 |
| 5 | 15 | 1106.234 | Addax加上中文 | 2021/9/14 | 5576.17 | ¥1,106.23 |
| 6 | 16 | 1107.234 | Addax加上中文 | 2021/9/15 | 5584.17 | ¥1,107.23 |
| 7 | 17 | 1108.234 | Addax加上中文 | 2021/9/16 | 5592.17 | ¥1,108.23 |
| 8 | 18 | 1109.234 | Addax加上中文 | 2021/9/17 | 5600.17 | ¥1,109.23 |
| 9 | 19 | 1110.234 | Addax加上中文 | 2021/9/18 | 5608.17 | ¥1,110.23 |
| 10 | 20 | 1111.234 | Addax加上中文 | 2021/9/19 | 5616.17 | ¥1,111.23 |
| 11 | 21 | 1112.234 | Addax加上中文 | 2021/9/20 | 5624.17 | ¥1,112.23 |
| 12 | 22 | 1113.234 | Addax加上中文 | 2021/9/21 | 5632.17 | ¥1,113.23 |
| 13 | 23 | 1114.234 | Addax加上中文 | 2021/9/22 | 5640.17 | ¥1,114.23 |
| 14 | 24 | 1115.234 | Addax加上中文 | 2021/9/23 | 5648.17 | ¥1,115.23 |
| 15 | 25 | 1116.234 | Addax加上中文 | 2021/9/24 | 5656.17 | ¥1,116.23 |
| 16 | 26 | 1117.234 | Addax加上中文 | 2021/9/25 | 5664.17 | ¥1,117.23 |
| 17 | 27 | 1118.234 | Addax加上中文 | 2021/9/26 | 5672.17 | ¥1,118.23 |
| 18 | 28 | 1119.234 | Addax加上中文 | 2021/9/27 | 5680.17 | ¥1,119.23 |
| 19 | 29 | 1120.234 | Addax加上中文 | 2021/9/28 | 5688.17 | ¥1,120.23 |
| 20 | 30 | 1121.234 | Addax加上中文 | 2021/9/29 | 5696.17 | ¥1,121.23 |

表头大致说明了单元数据的特征

Expand Down
1 change: 0 additions & 1 deletion docs/reader/ftpreader.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ boolean captureRawRecord = true;

| Addax 内部类型 | 远程FTP文件 数据类型 |
| -------------- | -------------------- |
| |
| Long | Long |
| Double | Double |
| String | String |
Expand Down
18 changes: 17 additions & 1 deletion docs/transformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@

## 运行模型

![image](images/transform-arch.png)
```mermaid
graph LR
source(("source")):::s1
subgraph fr["Addax Framework"]
direction LR
Reader:::s2 ==> Transformer ==>Writer:::s2
end
target(("target"))
source ==> fr ==> target:::s1
classDef s1 fill:#66bed5,stroke-width:0px;
classDef s2 fill:#efef,stroke-width:0px;
style Transformer fill:orange,stroke-width:0px;
```



## UDF 函数

Expand Down

0 comments on commit f4a4f41

Please sign in to comment.