-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[doc] Migrate develop docs from website (#9457)
* [doc] Migrate develop docs from website developer should also into main repo, because development setup should follow with the latest code * Add missing change from website
- Loading branch information
1 parent
ac2e1df
commit 51c1d8f
Showing
43 changed files
with
3,358 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# API design standard | ||
A standardized and unified API is the cornerstone of project design.The API of DolphinScheduler follows the REST ful standard. REST ful is currently the most popular Internet software architecture. It has a clear structure, conforms to standards, is easy to understand and extend. | ||
|
||
This article uses the DolphinScheduler API as an example to explain how to construct a Restful API. | ||
|
||
## 1. URI design | ||
REST is "Representational State Transfer".The design of Restful URI is based on resources.The resource corresponds to an entity on the network, for example: a piece of text, a picture, and a service. And each resource corresponds to a URI. | ||
|
||
+ One Kind of Resource: expressed in the plural, such as `task-instances`、`groups` ; | ||
+ A Resource: expressed in the singular, or use the ID to represent the corresponding resource, such as `group`、`groups/{groupId}`; | ||
+ Sub Resources: Resources under a certain resource, such as `/instances/{instanceId}/tasks`; | ||
+ A Sub Resource:`/instances/{instanceId}/tasks/{taskId}`; | ||
|
||
## 2. Method design | ||
We need to locate a certain resource by URI, and then use Method or declare actions in the path suffix to reflect the operation of the resource. | ||
|
||
### ① Query - GET | ||
Use URI to locate the resource, and use GET to indicate query. | ||
|
||
+ When the URI is a type of resource, it means to query a type of resource. For example, the following example indicates paging query `alter-groups`. | ||
``` | ||
Method: GET | ||
/api/dolphinscheduler/alert-groups | ||
``` | ||
|
||
+ When the URI is a single resource, it means to query this resource. For example, the following example means to query the specified `alter-group`. | ||
``` | ||
Method: GET | ||
/api/dolphinscheduler/alter-groups/{id} | ||
``` | ||
|
||
+ In addition, we can also express query sub-resources based on URI, as follows: | ||
``` | ||
Method: GET | ||
/api/dolphinscheduler/projects/{projectId}/tasks | ||
``` | ||
|
||
**The above examples all represent paging query. If we need to query all data, we need to add `/list` after the URI to distinguish. Do not mix the same API for both paged query and query.** | ||
``` | ||
Method: GET | ||
/api/dolphinscheduler/alert-groups/list | ||
``` | ||
|
||
### ② Create - POST | ||
Use URI to locate the resource, use POST to indicate create, and then return the created id to requester. | ||
|
||
+ create an `alter-group`: | ||
|
||
``` | ||
Method: POST | ||
/api/dolphinscheduler/alter-groups | ||
``` | ||
|
||
+ create sub-resources is also the same as above. | ||
``` | ||
Method: POST | ||
/api/dolphinscheduler/alter-groups/{alterGroupId}/tasks | ||
``` | ||
|
||
### ③ Modify - PUT | ||
Use URI to locate the resource, use PUT to indicate modify. | ||
+ modify an `alert-group` | ||
``` | ||
Method: PUT | ||
/api/dolphinscheduler/alter-groups/{alterGroupId} | ||
``` | ||
|
||
### ④ Delete -DELETE | ||
Use URI to locate the resource, use DELETE to indicate delete. | ||
|
||
+ delete an `alert-group` | ||
``` | ||
Method: DELETE | ||
/api/dolphinscheduler/alter-groups/{alterGroupId} | ||
``` | ||
|
||
+ batch deletion: batch delete the id array,we should use POST. **(Do not use the DELETE method, because the body of the DELETE request has no semantic meaning, and it is possible that some gateways, proxies, and firewalls will directly strip off the request body after receiving the DELETE request.)** | ||
``` | ||
Method: POST | ||
/api/dolphinscheduler/alter-groups/batch-delete | ||
``` | ||
|
||
### ⑤ Others | ||
In addition to creating, deleting, modifying and quering, we also locate the corresponding resource through url, and then append operations to it after the path, such as: | ||
``` | ||
/api/dolphinscheduler/alert-groups/verify-name | ||
/api/dolphinscheduler/projects/{projectCode}/process-instances/{code}/view-gantt | ||
``` | ||
|
||
## 3. Parameter design | ||
There are two types of parameters, one is request parameter and the other is path parameter. And the parameter must use small hump. | ||
|
||
In the case of paging, if the parameter entered by the user is less than 1, the front end needs to automatically turn to 1, indicating that the first page is requested; When the backend finds that the parameter entered by the user is greater than the total number of pages, it should directly return to the last page. | ||
|
||
## 4. Others design | ||
### base URL | ||
The URI of the project needs to use `/api/<project_name>` as the base path, so as to identify that these APIs are under this project. | ||
``` | ||
/api/dolphinscheduler | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
docs/docs/en/development/backend/mechanism/global-parameter.md
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,61 @@ | ||
# Global Parameter development document | ||
|
||
After the user defines the parameter with the direction OUT, it is saved in the localParam of the task. | ||
|
||
## Usage of parameters | ||
|
||
Getting the direct predecessor node `preTasks` of the current `taskInstance` to be created from the DAG, get the `varPool` of `preTasks`, merge this varPool (List) into one `varPool`, and in the merging process, if parameters with the same parameter name are found, they will be handled according to the following logics: | ||
|
||
* If all the values are null, the merged value is null | ||
* If one and only one value is non-null, then the merged value is the non-null value | ||
* If all the values are not null, it would be the earliest value of the endtime of taskInstance taken by VarPool. | ||
|
||
The direction of all the merged properties is updated to IN during the merge process. | ||
|
||
The result of the merge is saved in taskInstance.varPool. | ||
|
||
The worker receives and parses the varPool into the format of `Map<String,Property>`, where the key of the map is property.prop, which is the parameter name. | ||
|
||
When the processor processes the parameters, it will merge the varPool and localParam and globalParam parameters, and if there are parameters with duplicate names during the merging process, they will be replaced according to the following priorities, with the higher priority being retained and the lower priority being replaced: | ||
|
||
* globalParam: high | ||
* varPool: middle | ||
* localParam: low | ||
|
||
The parameters are replaced with the corresponding values using regular expressions compared to ${parameter name} before the node content is executed. | ||
|
||
## Parameter setting | ||
|
||
Currently, only SQL and SHELL nodes are supported to get parameters. | ||
|
||
Get the parameter with direction OUT from localParam, and do the following way according to the type of different nodes. | ||
|
||
### SQL node | ||
|
||
The structure returned by the parameter is List<Map<String,String>>, where the elements of List are each row of data, the key of Map is the column name, and the value is the value corresponding to the column. | ||
|
||
* If the SQL statement returns one row of data, match the OUT parameter name based on the OUT parameter name defined by the user when defining the task, or discard it if it does not match. | ||
* If the SQL statement returns multiple rows of data, the column names are matched based on the OUT parameter names defined by the user when defining the task of type LIST. All rows of the corresponding column are converted to `List<String>` as the value of this parameter. If there is no match, it is discarded. | ||
|
||
### SHELL node | ||
|
||
The result of the processor execution is returned as `Map<String,String>`. | ||
|
||
The user needs to define `${setValue(key=value)}` in the output when defining the shell script. | ||
|
||
Remove `${setValue()}` when processing parameters, split by "=", with the 0th being the key and the 1st being the value. | ||
|
||
Similarly match the OUT parameter name and key defined by the user when defining the task, and use value as the value of that parameter. | ||
|
||
Return parameter processing | ||
|
||
* The result of acquired Processor is String. | ||
* Determine whether the processor is empty or not, and exit if it is empty. | ||
* Determine whether the localParam is empty or not, and exit if it is empty. | ||
* Get the parameter of localParam which is OUT, and exit if it is empty. | ||
* Format String as per appeal format (`List<Map<String,String>>` for SQL, `Map<String,String>>` for shell). | ||
|
||
Assign the parameters with matching values to varPool (List, which contains the original IN's parameters) | ||
|
||
* Format the varPool as json and pass it to master. | ||
* The parameters that are OUT would be written into the localParam after the master has received the varPool. |
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 @@ | ||
# Overview | ||
|
||
<!-- TODO Since the side menu does not support multiple levels, add new page to keep all sub page here --> | ||
|
||
* [Global Parameter](global-parameter.md) | ||
* [Switch Task type](task/switch.md) |
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 @@ | ||
# SWITCH Task development | ||
|
||
Switch task workflow step as follows | ||
|
||
* User-defined expressions and branch information are stored in `taskParams` in `taskdefinition`. When the switch is executed, it will be formatted as `SwitchParameters` | ||
* `SwitchTaskExecThread` processes the expressions defined in `switch` from top to bottom, obtains the value of the variable from `varPool`, and parses the expression through `javascript`. If the expression returns true, stop checking and record The order of the expression, here we record as resultConditionLocation. The task of SwitchTaskExecThread is over | ||
* After the `switch` task runs, if there is no error (more commonly, the user-defined expression is out of specification or there is a problem with the parameter name), then `MasterExecThread.submitPostNode` will obtain the downstream node of the `DAG` to continue execution. | ||
* If it is found in `DagHelper.parsePostNodes` that the current node (the node that has just completed the work) is a `switch` node, the `resultConditionLocation` will be obtained, and all branches except `resultConditionLocation` in the SwitchParameters will be skipped. In this way, only the branches that need to be executed are left |
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,75 @@ | ||
### DolphinScheduler Alert SPI main design | ||
|
||
#### DolphinScheduler SPI Design | ||
|
||
DolphinScheduler is undergoing a microkernel + plug-in architecture change. All core capabilities such as tasks, resource storage, registration centers, etc. will be designed as extension points. We hope to use SPI to improve DolphinScheduler’s own flexibility and friendliness (extended sex). | ||
|
||
For alarm-related codes, please refer to the `dolphinscheduler-alert-api` module. This module defines the extension interface of the alarm plug-in and some basic codes. When we need to realize the plug-inization of related functions, it is recommended to read the code of this block first. Of course, it is recommended that you read the document. This will reduce a lot of time, but the document There is a certain degree of lag. When the document is missing, it is recommended to take the source code as the standard (if you are interested, we also welcome you to submit related documents). In addition, we will hardly make changes to the extended interface (excluding new additions) , Unless there is a major structural adjustment, there is an incompatible upgrade version, so the existing documents can generally be satisfied. | ||
|
||
We use the native JAVA-SPI, when you need to extend, in fact, you only need to pay attention to the extension of the `org.apache.dolphinscheduler.alert.api.AlertChannelFactory` interface, the underlying logic such as plug-in loading, and other kernels have been implemented, Which makes our development more focused and simple. | ||
|
||
By the way, we have adopted an excellent front-end component form-create, which supports the generation of front-end UI components based on JSON. If plug-in development involves the front-end, we will use JSON to generate related front-end UI components, org.apache.dolphinscheduler. The parameters of the plug-in are encapsulated in spi.params, which will convert all the relevant parameters into the corresponding JSON, which means that you can complete the drawing of the front-end components by way of Java code (here is mainly the form, we only care Data exchanged between the front and back ends). | ||
|
||
This article mainly focuses on the design and development of Alert. | ||
|
||
#### Main Modules | ||
|
||
If you don't care about its internal design, but simply want to know how to develop your own alarm plug-in, you can skip this content. | ||
|
||
* dolphinscheduler-alert-api | ||
|
||
This module is the core module of ALERT SPI. This module defines the interface of the alarm plug-in extension and some basic codes. The extension plug-in must implement the interface defined by this module: `org.apache.dolphinscheduler.alert.api.AlertChannelFactory` | ||
|
||
* dolphinscheduler-alert-plugins | ||
|
||
This module is currently a plug-in provided by us, such as Email, DingTalk, Script, etc. | ||
|
||
|
||
#### Alert SPI Main class information. | ||
AlertChannelFactory | ||
Alarm plug-in factory interface. All alarm plug-ins need to implement this interface. This interface is used to define the name of the alarm plug-in and the required parameters. The create method is used to create a specific alarm plug-in instance. | ||
|
||
AlertChannel | ||
The interface of the alert plug-in. The alert plug-in needs to implement this interface. There is only one method process in this interface. The upper-level alert system will call this method and obtain the return information of the alert through the AlertResult returned by this method. | ||
|
||
AlertData | ||
Alarm content information, including id, title, content, log. | ||
|
||
AlertInfo | ||
For alarm-related information, when the upper-level system calls an instance of the alarm plug-in, the instance of this class is passed to the specific alarm plug-in through the process method. It contains the alert content AlertData and the parameter information filled in by the front end of the called alert plug-in instance. | ||
|
||
AlertResult | ||
The alarm plug-in sends alarm return information. | ||
|
||
org.apache.dolphinscheduler.spi.params | ||
This package is a plug-in parameter definition. Our front-end uses the from-create front-end library http://www.form-create.com, which can dynamically generate the front-end UI based on the parameter list json returned by the plug-in definition, so We don't need to care about the front end when we are doing SPI plug-in development. | ||
|
||
Under this package, we currently only encapsulate RadioParam, TextParam, and PasswordParam, which are used to define text type parameters, radio parameters and password type parameters, respectively. | ||
|
||
AbsPluginParams This class is the base class of all parameters, RadioParam these classes all inherit this class. Each DS alert plug-in will return a list of AbsPluginParams in the implementation of AlertChannelFactory. | ||
|
||
The specific design of alert_spi can be seen in the issue: [Alert Plugin Design](https://github.com/apache/incubator-dolphinscheduler/issues/3049) | ||
|
||
#### Alert SPI built-in implementation | ||
|
||
|
||
Email alert notification | ||
|
||
* DingTalk | ||
|
||
Alert for DingTalk group chat bots | ||
|
||
* EnterpriseWeChat | ||
|
||
EnterpriseWeChat alert notifications | ||
|
||
Related parameter configuration can refer to the EnterpriseWeChat robot document. | ||
|
||
* Script | ||
|
||
We have implemented a shell script for alerting. We will pass the relevant alert parameters to the script and you can implement your alert logic in the shell. This is a good way to interface with internal alerting applications. | ||
|
||
* SMS | ||
|
||
SMS alerts |
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,23 @@ | ||
## DolphinScheduler Datasource SPI main design | ||
|
||
#### How do I use data sources? | ||
|
||
The data source center supports POSTGRESQL, HIVE/IMPALA, SPARK, CLICKHOUSE, SQLSERVER data sources by default. | ||
|
||
If you are using MySQL or ORACLE data source, you need to place the corresponding driver package in the lib directory | ||
|
||
#### How to do Datasource plugin development? | ||
|
||
org.apache.dolphinscheduler.spi.datasource.DataSourceChannel | ||
org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory | ||
org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient | ||
|
||
1. In the first step, the data source plug-in can implement the above interfaces and inherit the general client. For details, refer to the implementation of data source plug-ins such as sqlserver and mysql. The addition methods of all RDBMS plug-ins are the same. | ||
|
||
2. Add the driver configuration in the data source plug-in pom.xml | ||
|
||
We provide APIs for external access of all data sources in the dolphin scheduler data source API module | ||
|
||
#### **Future plan** | ||
|
||
Support data sources such as kafka, http, files, sparkSQL, FlinkSQL, etc. |
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,27 @@ | ||
### DolphinScheduler Registry SPI Extension | ||
|
||
#### how to use? | ||
|
||
Make the following configuration (take zookeeper as an example) | ||
|
||
* Registry plug-in configuration, take Zookeeper as an example (registry.properties) | ||
dolphinscheduler-service/src/main/resources/registry.properties | ||
```registry.properties | ||
registry.plugin.name=zookeeper | ||
registry.servers=127.0.0.1:2181 | ||
``` | ||
|
||
For specific configuration information, please refer to the parameter information provided by the specific plug-in, for example zk: `org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperConfiguration.java` | ||
All configuration information prefixes need to be +registry, such as base.sleep.time.ms, which should be configured in the registry as follows: registry.base.sleep.time.ms=100 | ||
|
||
#### How to expand | ||
|
||
`dolphinscheduler-registry-api` defines the standard for implementing plugins. When you need to extend plugins, you only need to implement `org.apache.dolphinscheduler.registry.api.RegistryFactory`. | ||
|
||
Under the `dolphinscheduler-registry-plugin` module is the registry plugin we currently provide. | ||
|
||
#### FAQ | ||
|
||
1: registry connect timeout | ||
|
||
You can increase the relevant timeout parameters. |
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,15 @@ | ||
## DolphinScheduler Task SPI extension | ||
|
||
#### How to develop task plugins? | ||
|
||
org.apache.dolphinscheduler.spi.task.TaskChannel | ||
|
||
The plug-in can implement the above interface. It mainly includes creating tasks (task initialization, task running, etc.) and task cancellation. If it is a yarn task, you need to implement org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask. | ||
|
||
We provide APIs for external access to all tasks in the dolphinscheduler-task-api module, while the dolphinscheduler-spi module is the spi general code library, which defines all the plug-in modules, such as the alarm module, the registry module, etc., you can read and view in detail . | ||
|
||
*NOTICE* | ||
|
||
Since the task plug-in involves the front-end page, the front-end SPI has not yet been implemented, so you need to implement the front-end page corresponding to the plug-in separately. | ||
|
||
If there is a class conflict in the task plugin, you can use [Shade-Relocating Classes](https://maven.apache.org/plugins/maven-shade-plugin/) to solve this problem. |
Oops, something went wrong.