[Improvement][Style] Fix remaining style errors and wildcard imports (#12412)
* Fix remaining style errors and wildcard imports * Upgrade spotless to the latest stable version, exclude .github folder from spotless check and fix dead link * Fix spotless matching scope of markdown files
This commit is contained in:
parent
1e11034049
commit
d46e4659d9
|
|
@ -17,7 +17,7 @@ there are no subsequent nodes. Examples are as follows:
|
||||||
manual start or scheduled scheduling. Each time the process definition runs, a process instance is generated
|
manual start or scheduled scheduling. Each time the process definition runs, a process instance is generated
|
||||||
|
|
||||||
**Task instance**: The task instance is the instantiation of the task node in the process definition, which identifies
|
**Task instance**: The task instance is the instantiation of the task node in the process definition, which identifies
|
||||||
the specific task
|
the specific task
|
||||||
|
|
||||||
**Task type**: Currently supports SHELL, SQL, SUB_PROCESS (sub-process), PROCEDURE, MR, SPARK, PYTHON, DEPENDENT (
|
**Task type**: Currently supports SHELL, SQL, SUB_PROCESS (sub-process), PROCEDURE, MR, SPARK, PYTHON, DEPENDENT (
|
||||||
depends), and plans to support dynamic plug-in expansion, note: **SUB_PROCESS** need relation with another workflow definition which also a separate process
|
depends), and plans to support dynamic plug-in expansion, note: **SUB_PROCESS** need relation with another workflow definition which also a separate process
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,5 @@ DolphinScheduler provides the following network port configurations for normal o
|
||||||
The minimum supported version of Google Chrome is version 85, but version 90 or above is recommended.
|
The minimum supported version of Google Chrome is version 85, but version 90 or above is recommended.
|
||||||
|
|
||||||
## Synchronize clocks
|
## Synchronize clocks
|
||||||
To avoid problems with internal cluster communications that can impact your task execution, make sure that the clocks on all of the cluster nodes are synchronized from a common clock source, such as using Chrony and/or NTP. Synchronizing the time ensures that every node in the cluster has the same time.
|
|
||||||
|
To avoid problems with internal cluster communications that can impact your task execution, make sure that the clocks on all of the cluster nodes are synchronized from a common clock source, such as using Chrony and/or NTP. Synchronizing the time ensures that every node in the cluster has the same time.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ In Dolphinscheduler, **new committer nomination** could only be officially start
|
||||||
|
|
||||||
The following steps are recommended (to be initiated only by an existing PMC member):
|
The following steps are recommended (to be initiated only by an existing PMC member):
|
||||||
1. Send an email titled `[DISCUSS] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`. List the important contributions of the candidate,
|
1. Send an email titled `[DISCUSS] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`. List the important contributions of the candidate,
|
||||||
so you could gather support from other PMC members for your proposal.
|
so you could gather support from other PMC members for your proposal.
|
||||||
2. Keep the discussion open for more than 3 days but no more than 1 week, unless there is any express objection or concern.
|
2. Keep the discussion open for more than 3 days but no more than 1 week, unless there is any express objection or concern.
|
||||||
3. If the PMC generally agrees to the proposal, send an email titled `[VOTE] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`.
|
3. If the PMC generally agrees to the proposal, send an email titled `[VOTE] Promote xxx as new committer` to `private@dolphinscheduler.apache.org`.
|
||||||
4. Keep the voting process open for more than 3 days, but no more than 1 week. Consider the result as `Consensus Approval` if there are `3 + 1` votes with `NO` vetos. Please note that +1 votes > -1 votes.
|
4. Keep the voting process open for more than 3 days, but no more than 1 week. Consider the result as `Consensus Approval` if there are `3 + 1` votes with `NO` vetos. Please note that +1 votes > -1 votes.
|
||||||
|
|
@ -31,6 +31,7 @@ The following steps are recommended (to be initiated only by an existing PMC mem
|
||||||
The PMC member who starts the promotion is responsible for sending an invitation to the new committer and guiding him/her to set up the ASF env.
|
The PMC member who starts the promotion is responsible for sending an invitation to the new committer and guiding him/her to set up the ASF env.
|
||||||
|
|
||||||
The PMC member should send an email using the following template to the new committer:
|
The PMC member should send an email using the following template to the new committer:
|
||||||
|
|
||||||
```
|
```
|
||||||
To: <invitee name>@gmail.com
|
To: <invitee name>@gmail.com
|
||||||
Cc: private@dolphinscheduler.apache.org
|
Cc: private@dolphinscheduler.apache.org
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,18 @@
|
||||||
|
|
||||||
## Datasource Parameters
|
## Datasource Parameters
|
||||||
|
|
||||||
| **Datasource** | **Description** |
|
| **Datasource** | **Description** |
|
||||||
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
|
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| Datasource | Select Oracle. |
|
| Datasource | Select Oracle. |
|
||||||
| Datasource Name | Enter the name of the datasource. |
|
| Datasource Name | Enter the name of the datasource. |
|
||||||
| Description | Enter a description of the datasource. |
|
| Description | Enter a description of the datasource. |
|
||||||
| IP/Host Name | Enter the Oracle service IP. |
|
| IP/Host Name | Enter the Oracle service IP. |
|
||||||
| Port | Enter the Oracle service port. |
|
| Port | Enter the Oracle service port. |
|
||||||
| Username | Set the username for Oracle connection. |
|
| Username | Set the username for Oracle connection. |
|
||||||
| Password | Set the password for Oracle connection. |
|
| Password | Set the password for Oracle connection. |
|
||||||
| Database Name | Enter the ServiceName or SID of the Oracle connection. |
|
| Database Name | Enter the ServiceName or SID of the Oracle connection. |
|
||||||
| ServiceName or SID | Choose ServiceName or SID according to your entry in Database Name column. |
|
| ServiceName or SID | Choose ServiceName or SID according to your entry in Database Name column. |
|
||||||
| jdbc connect parameters | Parameter settings for Oracle connection, in JSON format. For example, you can use {"schema": "abc"} to specify database abc for using. |
|
| jdbc connect parameters | Parameter settings for Oracle connection, in JSON format. For example, you can use {"schema": "abc"} to specify database abc for using. |
|
||||||
|
|
||||||
## Native Supported
|
## Native Supported
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
Standalone only for quick experience for DolphinScheduler.
|
Standalone only for quick experience for DolphinScheduler.
|
||||||
|
|
||||||
If you are a newbie and want to experience DolphinScheduler functions, we recommend you install follow [Standalone deployment](standalone.md).
|
If you are a newbie and want to experience DolphinScheduler functions, we recommend you install follow [Standalone deployment](standalone.md).
|
||||||
If you want to experience more complete functions and schedule massive tasks, we recommend you install follow [pseudo-cluster deployment](pseudo-cluster.md).
|
If you want to experience more complete functions and schedule massive tasks, we recommend you install follow [pseudo-cluster deployment](pseudo-cluster.md).
|
||||||
If you want to deploy DolphinScheduler in production, we recommend you follow [cluster deployment](cluster.md) or [Kubernetes deployment](kubernetes.md).
|
If you want to deploy DolphinScheduler in production, we recommend you follow [cluster deployment](cluster.md) or [Kubernetes deployment](kubernetes.md).
|
||||||
|
|
||||||
> **_Note:_** Standalone only recommends the usage of fewer than 20 workflows, because it uses in-memory H2 Database in default, ZooKeeper Testing Server, too many tasks may cause instability.
|
> **_Note:_** Standalone only recommends the usage of fewer than 20 workflows, because it uses in-memory H2 Database in default, ZooKeeper Testing Server, too many tasks may cause instability.
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@ This document records the incompatible updates between each version. You need to
|
||||||
|
|
||||||
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
|
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
|
||||||
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)
|
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,5 @@ DolphinScheduler正常运行提供如下的网络端口配置:
|
||||||
DolphinScheduler 推荐 Chrome 以及使用 Chromium 内核的较新版本浏览器访问前端可视化操作界面
|
DolphinScheduler 推荐 Chrome 以及使用 Chromium 内核的较新版本浏览器访问前端可视化操作界面
|
||||||
|
|
||||||
## 时钟同步
|
## 时钟同步
|
||||||
为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间
|
|
||||||
|
为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ PMC会定期基于活跃贡献者们对Dolphinscheduler的贡献从他们中提
|
||||||
发起提名的PMC成员负责向新的committer发出邀请,并指导他/她建立ASF精神思想。
|
发起提名的PMC成员负责向新的committer发出邀请,并指导他/她建立ASF精神思想。
|
||||||
|
|
||||||
PMC成员应使用以下模板向新的committer发送一封电子邮件:
|
PMC成员应使用以下模板向新的committer发送一封电子邮件:
|
||||||
|
|
||||||
```
|
```
|
||||||
To: <invitee name>@gmail.com
|
To: <invitee name>@gmail.com
|
||||||
Cc: private@dolphinscheduler.apache.org
|
Cc: private@dolphinscheduler.apache.org
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@
|
||||||
- 数据库名:输入连接 ORACLE 的 ServiceName 或 SID
|
- 数据库名:输入连接 ORACLE 的 ServiceName 或 SID
|
||||||
- Jdbc 连接参数:用于 ORACLE 连接的参数设置,以 JSON 形式填写
|
- Jdbc 连接参数:用于 ORACLE 连接的参数设置,以 JSON 形式填写
|
||||||
- 比如 `{"schema": "abc"}` 指定使用 `username` 用户下的 `abc` 数据库
|
- 比如 `{"schema": "abc"}` 指定使用 `username` 用户下的 `abc` 数据库
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,33 +29,34 @@
|
||||||
|
|
||||||
- 也可以通过以下两种方式:
|
- 也可以通过以下两种方式:
|
||||||
|
|
||||||
1.使用add_months()函数,该函数用于加减月份,
|
1.使用add_months()函数,该函数用于加减月份,
|
||||||
第一个入口参数为[yyyyMMdd],表示返回时间的格式
|
第一个入口参数为[yyyyMMdd],表示返回时间的格式
|
||||||
第二个入口参数为月份偏移量,表示加减多少个月
|
第二个入口参数为月份偏移量,表示加减多少个月
|
||||||
* 后 N 年:$[add_months(yyyyMMdd,12*N)]
|
* 后 N 年:$[add_months(yyyyMMdd,12*N)]
|
||||||
* 前 N 年:$[add_months(yyyyMMdd,-12*N)]
|
* 前 N 年:$[add_months(yyyyMMdd,-12*N)]
|
||||||
* 后 N 月:$[add_months(yyyyMMdd,N)]
|
* 后 N 月:$[add_months(yyyyMMdd,N)]
|
||||||
* 前 N 月:$[add_months(yyyyMMdd,-N)]
|
* 前 N 月:$[add_months(yyyyMMdd,-N)]
|
||||||
*******************************************
|
*******************************************
|
||||||
2.直接加减数字
|
2.直接加减数字
|
||||||
在自定义格式后直接“+/-”数字
|
在自定义格式后直接“+/-”数字
|
||||||
* 后 N 周:$[yyyyMMdd+7*N]
|
* 后 N 周:$[yyyyMMdd+7*N]
|
||||||
* 前 N 周:$[yyyyMMdd-7*N]
|
* 前 N 周:$[yyyyMMdd-7*N]
|
||||||
* 后 N 天:$[yyyyMMdd+N]
|
* 后 N 天:$[yyyyMMdd+N]
|
||||||
* 前 N 天:$[yyyyMMdd-N]
|
* 前 N 天:$[yyyyMMdd-N]
|
||||||
* 后 N 小时:$[HHmmss+N/24]
|
* 后 N 小时:$[HHmmss+N/24]
|
||||||
* 前 N 小时:$[HHmmss-N/24]
|
* 前 N 小时:$[HHmmss-N/24]
|
||||||
* 后 N 分钟:$[HHmmss+N/24/60]
|
* 后 N 分钟:$[HHmmss+N/24/60]
|
||||||
* 前 N 分钟:$[HHmmss-N/24/60]
|
* 前 N 分钟:$[HHmmss-N/24/60]
|
||||||
*******************************************
|
*******************************************
|
||||||
3.业务属性方式
|
3.业务属性方式
|
||||||
在自定义格式后直接“+/-”数字
|
在自定义格式后直接“+/-”数字
|
||||||
支持日志格式:所有日期表达式,例如:yyyy-MM-dd/yyyyMMddHHmmss
|
支持日志格式:所有日期表达式,例如:yyyy-MM-dd/yyyyMMddHHmmss
|
||||||
* 当天:$[this_day(yyyy-MM-dd)],如:2022-08-26 => 2022-08-26
|
* 当天:$[this_day(yyyy-MM-dd)],如:2022-08-26 => 2022-08-26
|
||||||
* 昨天:$[last_day(yyyy-MM-dd)],如:2022-08-26 => 2022-08-25
|
* 昨天:$[last_day(yyyy-MM-dd)],如:2022-08-26 => 2022-08-25
|
||||||
* 年的第N周,以周一为起点:$[year_week(yyyy-MM-dd)],如:2022-08-26 => 2022-34
|
* 年的第N周,以周一为起点:$[year_week(yyyy-MM-dd)],如:2022-08-26 => 2022-34
|
||||||
* 年的第N周,以周N为起点:$[year_week(yyyy-MM-dd,N)],如:N=5时 2022-08-26 => 2022-35
|
* 年的第N周,以周N为起点:$[year_week(yyyy-MM-dd,N)],如:N=5时 2022-08-26 => 2022-35
|
||||||
* 前(-)/后(+) N 月第一天:$[month_first_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-26 => 2022-07-01
|
* 前(-)/后(+) N 月第一天:$[month_first_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-26 => 2022-07-01
|
||||||
* 前(-)/后(+) N 月最后一天:$[month_last_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-28 => 2022-07-31
|
* 前(-)/后(+) N 月最后一天:$[month_last_day(yyyy-MM-dd,-N)],如:N=1时 2022-08-28 => 2022-07-31
|
||||||
* 前(-)/后(+) N 周的周一:$[week_first_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-15
|
* 前(-)/后(+) N 周的周一:$[week_first_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-15
|
||||||
* 前(-)/后(+) N 周的周日:$[week_last_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-21
|
* 前(-)/后(+) N 周的周日:$[week_last_day(yyyy-MM-dd,-N)],如:N=1 2022-08-26 => 2022-08-21
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,4 @@
|
||||||
|
|
||||||
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
|
* Copy and import workflow without 'copy' suffix [#10607](https://github.com/apache/dolphinscheduler/pull/10607)
|
||||||
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)
|
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,21 @@
|
||||||
~ specific language governing permissions and limitations
|
~ specific language governing permissions and limitations
|
||||||
~ under the License.
|
~ under the License.
|
||||||
-->
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-api</artifactId>
|
<artifactId>dolphinscheduler-alert-api</artifactId>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
<artifactId>dolphinscheduler-spi</artifactId> <!-- TODO should get rid off this -->
|
<artifactId>dolphinscheduler-spi</artifactId>
|
||||||
|
<!-- TODO should get rid off this -->
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import lombok.NonNull;
|
||||||
* alert channel for sending alerts
|
* alert channel for sending alerts
|
||||||
*/
|
*/
|
||||||
public interface AlertChannel {
|
public interface AlertChannel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process and send alert
|
* process and send alert
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
package org.apache.dolphinscheduler.alert.api;
|
package org.apache.dolphinscheduler.alert.api;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||||
import org.apache.dolphinscheduler.spi.plugin.SPIIdentify;
|
|
||||||
import org.apache.dolphinscheduler.spi.plugin.PrioritySPI;
|
import org.apache.dolphinscheduler.spi.plugin.PrioritySPI;
|
||||||
|
import org.apache.dolphinscheduler.spi.plugin.SPIIdentify;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||||
* alert channel factory
|
* alert channel factory
|
||||||
*/
|
*/
|
||||||
public interface AlertChannelFactory extends PrioritySPI {
|
public interface AlertChannelFactory extends PrioritySPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the alert channel
|
* Returns the name of the alert channel
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
package org.apache.dolphinscheduler.alert.api;
|
package org.apache.dolphinscheduler.alert.api;
|
||||||
|
|
||||||
public final class AlertConstants {
|
public final class AlertConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the field name of alert show type
|
* the field name of alert show type
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import lombok.Getter;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum ShowType {
|
public enum ShowType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0 TABLE;
|
* 0 TABLE;
|
||||||
* 1 TEXT;
|
* 1 TEXT;
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-dingtalk</artifactId>
|
<artifactId>dolphinscheduler-alert-dingtalk</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "DingTalk";
|
return "DingTalk";
|
||||||
|
|
@ -67,8 +68,10 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
RadioParam msgTypeParam = RadioParam
|
RadioParam msgTypeParam = RadioParam
|
||||||
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_MSG_TYPE, DingTalkParamsConstants.DING_TALK_MSG_TYPE)
|
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_MSG_TYPE, DingTalkParamsConstants.DING_TALK_MSG_TYPE)
|
||||||
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, false))
|
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT,
|
||||||
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, false))
|
DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT, false))
|
||||||
|
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN,
|
||||||
|
DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, false))
|
||||||
.setValue(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT)
|
.setValue(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
|
|
@ -76,13 +79,15 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam atMobilesParam = InputParam
|
InputParam atMobilesParam = InputParam
|
||||||
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_MOBILES, DingTalkParamsConstants.DING_TALK_AT_MOBILES)
|
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_MOBILES,
|
||||||
|
DingTalkParamsConstants.DING_TALK_AT_MOBILES)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
InputParam atUserIdsParam = InputParam
|
InputParam atUserIdsParam = InputParam
|
||||||
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_USERIDS, DingTalkParamsConstants.DING_TALK_AT_USERIDS)
|
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_AT_USERIDS,
|
||||||
|
DingTalkParamsConstants.DING_TALK_AT_USERIDS)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.build())
|
.build())
|
||||||
|
|
@ -98,7 +103,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RadioParam isEnableProxy = RadioParam
|
RadioParam isEnableProxy = RadioParam
|
||||||
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.DING_TALK_PROXY_ENABLE)
|
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE,
|
||||||
|
DingTalkParamsConstants.DING_TALK_PROXY_ENABLE)
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.setValue(STRING_FALSE)
|
.setValue(STRING_FALSE)
|
||||||
|
|
@ -131,7 +137,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||||
.setPlaceholder("if enable use authentication, you need input password")
|
.setPlaceholder("if enable use authentication, you need input password")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam, isAtAll, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
return Arrays.asList(webHookParam, keywordParam, secretParam, msgTypeParam, atMobilesParam, atUserIdsParam,
|
||||||
|
isAtAll, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.dingtalk;
|
package org.apache.dolphinscheduler.plugin.alert.dingtalk;
|
||||||
|
|
||||||
public final class DingTalkParamsConstants {
|
public final class DingTalkParamsConstants {
|
||||||
|
|
||||||
static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')";
|
static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')";
|
||||||
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";
|
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,8 @@ public final class DingTalkSender {
|
||||||
|
|
||||||
String msg = generateMsgJson(title, content);
|
String msg = generateMsgJson(title, content);
|
||||||
|
|
||||||
HttpPost httpPost = constructHttpPost(org.apache.dolphinscheduler.spi.utils.StringUtils.isBlank(secret) ? url : generateSignedUrl(), msg);
|
HttpPost httpPost = constructHttpPost(
|
||||||
|
org.apache.dolphinscheduler.spi.utils.StringUtils.isBlank(secret) ? url : generateSignedUrl(), msg);
|
||||||
|
|
||||||
CloseableHttpClient httpClient;
|
CloseableHttpClient httpClient;
|
||||||
if (Boolean.TRUE.equals(enableProxy)) {
|
if (Boolean.TRUE.equals(enableProxy)) {
|
||||||
|
|
@ -289,8 +290,12 @@ public final class DingTalkSender {
|
||||||
private void setMsgAt(Map<String, Object> items) {
|
private void setMsgAt(Map<String, Object> items) {
|
||||||
Map<String, Object> at = new HashMap<>();
|
Map<String, Object> at = new HashMap<>();
|
||||||
|
|
||||||
String[] atMobileArray = org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atMobiles) ? atMobiles.split(",") : new String[0];
|
String[] atMobileArray =
|
||||||
String[] atUserArray = org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atUserIds) ? atUserIds.split(",") : new String[0];
|
org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atMobiles) ? atMobiles.split(",")
|
||||||
|
: new String[0];
|
||||||
|
String[] atUserArray =
|
||||||
|
org.apache.dolphinscheduler.spi.utils.StringUtils.isNotBlank(atUserIds) ? atUserIds.split(",")
|
||||||
|
: new String[0];
|
||||||
boolean isAtAll = Objects.isNull(atAll) ? false : atAll;
|
boolean isAtAll = Objects.isNull(atAll) ? false : atAll;
|
||||||
|
|
||||||
at.put("atMobiles", atMobileArray);
|
at.put("atMobiles", atMobileArray);
|
||||||
|
|
@ -313,7 +318,7 @@ public final class DingTalkSender {
|
||||||
Mac mac = Mac.getInstance("HmacSHA256");
|
Mac mac = Mac.getInstance("HmacSHA256");
|
||||||
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
|
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
|
||||||
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
|
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
|
||||||
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)),"UTF-8");
|
sign = URLEncoder.encode(new String(Base64.encodeBase64(signData)), "UTF-8");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("generate sign error, message:{}", e);
|
logger.error("generate sign error, message:{}", e);
|
||||||
}
|
}
|
||||||
|
|
@ -321,6 +326,7 @@ public final class DingTalkSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class DingTalkSendMsgResponse {
|
static final class DingTalkSendMsgResponse {
|
||||||
|
|
||||||
private Integer errcode;
|
private Integer errcode;
|
||||||
private String errmsg;
|
private String errmsg;
|
||||||
|
|
||||||
|
|
@ -378,7 +384,8 @@ public final class DingTalkSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")";
|
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg="
|
||||||
|
+ this.getErrmsg() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-email</artifactId>
|
<artifactId>dolphinscheduler-alert-email</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class EmailAlertChannel implements AlertChannel {
|
public final class EmailAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class);
|
private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class EmailAlertChannelFactory implements AlertChannelFactory {
|
public final class EmailAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "Email";
|
return "Email";
|
||||||
|
|
@ -48,73 +49,88 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
List<PluginParams> paramsList = new ArrayList<>();
|
List<PluginParams> paramsList = new ArrayList<>();
|
||||||
InputParam receivesParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
|
InputParam receivesParam = InputParam
|
||||||
.setPlaceholder("please input receives")
|
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS,
|
||||||
.addValidate(Validate.newBuilder()
|
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
|
||||||
.setRequired(true)
|
.setPlaceholder("please input receives")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam receiveCcsParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERCCS)
|
InputParam receiveCcsParam = InputParam
|
||||||
.build();
|
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS,
|
||||||
|
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERCCS)
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam mailSmtpHost = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, MailParamsConstants.MAIL_SMTP_HOST)
|
InputParam mailSmtpHost =
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, MailParamsConstants.MAIL_SMTP_HOST)
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam mailSmtpPort = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
|
InputParam mailSmtpPort =
|
||||||
.setValue("25")
|
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
|
||||||
.addValidate(Validate.newBuilder()
|
.setValue("25")
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam mailSender = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER)
|
InputParam mailSender =
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER)
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam enableSmtpAuth = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH)
|
RadioParam enableSmtpAuth =
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH)
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.setValue(STRING_TRUE)
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.setValue(STRING_TRUE)
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, MailParamsConstants.MAIL_USER)
|
InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, MailParamsConstants.MAIL_USER)
|
||||||
.setPlaceholder("if enable use authentication, you need input user")
|
.setPlaceholder("if enable use authentication, you need input user")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
|
PasswordParam mailPassword =
|
||||||
.setPlaceholder("if enable use authentication, you need input password")
|
PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
|
||||||
.build();
|
.setPlaceholder("if enable use authentication, you need input password")
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam enableTls = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE, MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE)
|
RadioParam enableTls = RadioParam
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE,
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE)
|
||||||
.setValue(STRING_FALSE)
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.build();
|
.setValue(STRING_FALSE)
|
||||||
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam enableSsl = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, MailParamsConstants.MAIL_SMTP_SSL_ENABLE)
|
RadioParam enableSsl = RadioParam
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, MailParamsConstants.MAIL_SMTP_SSL_ENABLE)
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.setValue(STRING_FALSE)
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.setValue(STRING_FALSE)
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam sslTrust = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST)
|
InputParam sslTrust = InputParam
|
||||||
.setValue("*")
|
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST)
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.setValue("*")
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
|
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false))
|
.addParamsOptions(
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(), ShowType.TABLE_ATTACHMENT.getDescp(), false))
|
new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false))
|
||||||
.setValue(ShowType.TABLE.getDescp())
|
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(),
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
ShowType.TABLE_ATTACHMENT.getDescp(), false))
|
||||||
.build();
|
.setValue(ShowType.TABLE.getDescp())
|
||||||
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
paramsList.add(receivesParam);
|
paramsList.add(receivesParam);
|
||||||
paramsList.add(receiveCcsParam);
|
paramsList.add(receiveCcsParam);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.email;
|
package org.apache.dolphinscheduler.plugin.alert.email;
|
||||||
|
|
||||||
public final class EmailConstants {
|
public final class EmailConstants {
|
||||||
|
|
||||||
public static final String XLS_FILE_PATH = "xls.file.path";
|
public static final String XLS_FILE_PATH = "xls.file.path";
|
||||||
|
|
||||||
public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
|
public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
|
||||||
|
|
@ -38,19 +39,20 @@ public final class EmailConstants {
|
||||||
|
|
||||||
public static final String TH_END = "</th>";
|
public static final String TH_END = "</th>";
|
||||||
|
|
||||||
public static final String HTML_HEADER_PREFIX = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"
|
public static final String HTML_HEADER_PREFIX =
|
||||||
+ "<html>"
|
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"
|
||||||
+ "<head>"
|
+ "<html>"
|
||||||
+ "<title>dolphinscheduler</title>"
|
+ "<head>"
|
||||||
+ "<meta name='Keywords' content=''>"
|
+ "<title>dolphinscheduler</title>"
|
||||||
+ "<meta name='Description' content=''>"
|
+ "<meta name='Keywords' content=''>"
|
||||||
+ "<style type=\"text/css\">"
|
+ "<meta name='Description' content=''>"
|
||||||
+ "table {margin-top:0px;padding-top:0px;border:1px solid;font-size: 14px;color: #333333;border-width: 1px;border-color: #666666;border-collapse: collapse;}"
|
+ "<style type=\"text/css\">"
|
||||||
+ "table th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;text-align: left;}"
|
+ "table {margin-top:0px;padding-top:0px;border:1px solid;font-size: 14px;color: #333333;border-width: 1px;border-color: #666666;border-collapse: collapse;}"
|
||||||
+ "table td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;text-align: left;}"
|
+ "table th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;text-align: left;}"
|
||||||
+ "</style>"
|
+ "table td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;text-align: left;}"
|
||||||
+ "</head>"
|
+ "</style>"
|
||||||
+ "<body style=\"margin:0;padding:0\"><table border=\"1px\" cellpadding=\"5px\" cellspacing=\"-10px\"> ";
|
+ "</head>"
|
||||||
|
+ "<body style=\"margin:0;padding:0\"><table border=\"1px\" cellpadding=\"5px\" cellspacing=\"-10px\"> ";
|
||||||
|
|
||||||
public static final String TABLE_BODY_HTML_TAIL = "</table></body></html>";
|
public static final String TABLE_BODY_HTML_TAIL = "</table></body></html>";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class ExcelUtils {
|
public final class ExcelUtils {
|
||||||
|
|
||||||
private static final int XLSX_WINDOW_ROW = 10000;
|
private static final int XLSX_WINDOW_ROW = 10000;
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
|
||||||
|
|
||||||
|
|
@ -74,32 +75,33 @@ public final class ExcelUtils {
|
||||||
for (Map.Entry<String, Object> en : headerMap.entrySet()) {
|
for (Map.Entry<String, Object> en : headerMap.entrySet()) {
|
||||||
headerList.add(en.getKey());
|
headerList.add(en.getKey());
|
||||||
}
|
}
|
||||||
try (SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);
|
try (
|
||||||
FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) {
|
SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);
|
||||||
|
FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) {
|
||||||
// declare a workbook
|
// declare a workbook
|
||||||
// generate a table
|
// generate a table
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
//set the height of the first line
|
// set the height of the first line
|
||||||
row.setHeight((short) 500);
|
row.setHeight((short) 500);
|
||||||
|
|
||||||
//set Horizontal right
|
// set Horizontal right
|
||||||
CellStyle cellStyle = wb.createCellStyle();
|
CellStyle cellStyle = wb.createCellStyle();
|
||||||
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
|
||||||
//setting excel headers
|
// setting excel headers
|
||||||
for (int i = 0; i < headerList.size(); i++) {
|
for (int i = 0; i < headerList.size(); i++) {
|
||||||
Cell cell = row.createCell(i);
|
Cell cell = row.createCell(i);
|
||||||
cell.setCellStyle(cellStyle);
|
cell.setCellStyle(cellStyle);
|
||||||
cell.setCellValue(headerList.get(i));
|
cell.setCellValue(headerList.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//setting excel body
|
// setting excel body
|
||||||
int rowIndex = 1;
|
int rowIndex = 1;
|
||||||
for (LinkedHashMap<String, Object> itemsMap : itemsList) {
|
for (LinkedHashMap<String, Object> itemsMap : itemsList) {
|
||||||
Object[] values = itemsMap.values().toArray();
|
Object[] values = itemsMap.values().toArray();
|
||||||
row = sheet.createRow(rowIndex);
|
row = sheet.createRow(rowIndex);
|
||||||
//setting excel body height
|
// setting excel body height
|
||||||
row.setHeight((short) 500);
|
row.setHeight((short) 500);
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
for (int j = 0; j < values.length; j++) {
|
for (int j = 0; j < values.length; j++) {
|
||||||
|
|
@ -117,7 +119,7 @@ public final class ExcelUtils {
|
||||||
sheet.setColumnWidth(i, headerList.get(i).length() * 800);
|
sheet.setColumnWidth(i, headerList.get(i).length() * 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
//setting file output
|
// setting file output
|
||||||
wb.write(fos);
|
wb.write(fos);
|
||||||
wb.dispose();
|
wb.dispose();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.email;
|
package org.apache.dolphinscheduler.plugin.alert.email;
|
||||||
|
|
||||||
public final class MailParamsConstants {
|
public final class MailParamsConstants {
|
||||||
|
|
||||||
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
|
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
|
||||||
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";
|
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import com.sun.mail.smtp.SMTPProvider;
|
import com.sun.mail.smtp.SMTPProvider;
|
||||||
|
|
||||||
public final class MailSender {
|
public final class MailSender {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
|
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
|
||||||
|
|
||||||
private final List<String> receivers;
|
private final List<String> receivers;
|
||||||
|
|
@ -178,7 +179,7 @@ public final class MailSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(receiverCcs)) {
|
if (CollectionUtils.isNotEmpty(receiverCcs)) {
|
||||||
//cc
|
// cc
|
||||||
for (String receiverCc : receiverCcs) {
|
for (String receiverCc : receiverCcs) {
|
||||||
email.addCc(receiverCc);
|
email.addCc(receiverCc);
|
||||||
}
|
}
|
||||||
|
|
@ -188,12 +189,13 @@ public final class MailSender {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException(alertResult, e);
|
handleException(alertResult, e);
|
||||||
}
|
}
|
||||||
} else if (showType.equals(ShowType.ATTACHMENT.getDescp()) || showType.equals(ShowType.TABLE_ATTACHMENT.getDescp())) {
|
} else if (showType.equals(ShowType.ATTACHMENT.getDescp())
|
||||||
|
|| showType.equals(ShowType.TABLE_ATTACHMENT.getDescp())) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp())
|
String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp())
|
||||||
? "Please see the attachment " + title + EmailConstants.EXCEL_SUFFIX_XLSX
|
? "Please see the attachment " + title + EmailConstants.EXCEL_SUFFIX_XLSX
|
||||||
: htmlTable(content, false));
|
: htmlTable(content, false));
|
||||||
|
|
||||||
attachment(title, content, partContent);
|
attachment(title, content, partContent);
|
||||||
|
|
||||||
|
|
@ -294,6 +296,7 @@ public final class MailSender {
|
||||||
props.setProperty(MailParamsConstants.MAIL_SMTP_SSL_TRUST, sslTrust);
|
props.setProperty(MailParamsConstants.MAIL_SMTP_SSL_TRUST, sslTrust);
|
||||||
|
|
||||||
Authenticator auth = new Authenticator() {
|
Authenticator auth = new Authenticator() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
// mail username and password
|
// mail username and password
|
||||||
|
|
@ -309,7 +312,8 @@ public final class MailSender {
|
||||||
/**
|
/**
|
||||||
* attach content
|
* attach content
|
||||||
*/
|
*/
|
||||||
private void attachContent(String title, String content, String partContent, MimeMessage msg) throws MessagingException, IOException {
|
private void attachContent(String title, String content, String partContent,
|
||||||
|
MimeMessage msg) throws MessagingException, IOException {
|
||||||
/*
|
/*
|
||||||
* set receiverCc
|
* set receiverCc
|
||||||
*/
|
*/
|
||||||
|
|
@ -329,7 +333,8 @@ public final class MailSender {
|
||||||
MimeBodyPart part2 = new MimeBodyPart();
|
MimeBodyPart part2 = new MimeBodyPart();
|
||||||
// add random uuid to filename to avoid potential issue
|
// add random uuid to filename to avoid potential issue
|
||||||
String randomFilename = title + UUID.randomUUID();
|
String randomFilename = title + UUID.randomUUID();
|
||||||
File file = new File(xlsFilePath + EmailConstants.SINGLE_SLASH + randomFilename + EmailConstants.EXCEL_SUFFIX_XLSX);
|
File file =
|
||||||
|
new File(xlsFilePath + EmailConstants.SINGLE_SLASH + randomFilename + EmailConstants.EXCEL_SUFFIX_XLSX);
|
||||||
if (!file.getParentFile().exists()) {
|
if (!file.getParentFile().exists()) {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +357,8 @@ public final class MailSender {
|
||||||
/**
|
/**
|
||||||
* the string object map
|
* the string object map
|
||||||
*/
|
*/
|
||||||
private AlertResult getStringObjectMap(String title, String content, AlertResult alertResult, HtmlEmail email) throws EmailException {
|
private AlertResult getStringObjectMap(String title, String content, AlertResult alertResult,
|
||||||
|
HtmlEmail email) throws EmailException {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the subject of the message to be sent
|
* the subject of the message to be sent
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.email.exception;
|
package org.apache.dolphinscheduler.plugin.alert.email.exception;
|
||||||
|
|
||||||
public class AlertEmailException extends RuntimeException {
|
public class AlertEmailException extends RuntimeException {
|
||||||
|
|
||||||
public AlertEmailException(String errMsg) {
|
public AlertEmailException(String errMsg) {
|
||||||
super(errMsg);
|
super(errMsg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,14 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.configurationprocessor.json.JSONArray;
|
||||||
|
import org.springframework.boot.configurationprocessor.json.JSONException;
|
||||||
|
import org.springframework.boot.configurationprocessor.json.JSONTokener;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import org.springframework.boot.configurationprocessor.json.JSONArray;
|
|
||||||
import org.springframework.boot.configurationprocessor.json.JSONException;
|
|
||||||
import org.springframework.boot.configurationprocessor.json.JSONTokener;
|
|
||||||
|
|
||||||
public class DefaultHTMLTemplate implements AlertTemplate {
|
public class DefaultHTMLTemplate implements AlertTemplate {
|
||||||
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class);
|
public static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class);
|
||||||
|
|
@ -55,7 +54,8 @@ public class DefaultHTMLTemplate implements AlertTemplate {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
return getTextTypeMessage(content);
|
return getTextTypeMessage(content);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(String.format("not support showType: %s in DefaultHTMLTemplate", showType));
|
throw new IllegalArgumentException(
|
||||||
|
String.format("not support showType: %s in DefaultHTMLTemplate", showType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-feishu</artifactId>
|
<artifactId>dolphinscheduler-alert-feishu</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class FeiShuAlertChannel implements AlertChannel {
|
public final class FeiShuAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertInfo) {
|
public AlertResult process(AlertInfo alertInfo) {
|
||||||
AlertData alertData = alertInfo.getAlertData();
|
AlertData alertData = alertInfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
|
public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "Feishu";
|
return "Feishu";
|
||||||
|
|
@ -45,39 +46,44 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
InputParam webHookParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK)
|
InputParam webHookParam =
|
||||||
.addValidate(Validate.newBuilder()
|
InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK)
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
RadioParam isEnableProxy =
|
RadioParam isEnableProxy =
|
||||||
RadioParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE, FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE)
|
RadioParam
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE,
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE)
|
||||||
.setValue(STRING_TRUE)
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.addValidate(Validate.newBuilder()
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.setRequired(false)
|
.setValue(STRING_TRUE)
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
InputParam proxyParam =
|
InputParam proxyParam =
|
||||||
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY, FeiShuParamsConstants.FEI_SHU_PROXY)
|
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY, FeiShuParamsConstants.FEI_SHU_PROXY)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false).build())
|
.setRequired(false).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam portParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
|
InputParam portParam =
|
||||||
.addValidate(Validate.newBuilder()
|
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
|
||||||
.setRequired(false).build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam userParam =
|
InputParam userParam =
|
||||||
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_USER, FeiShuParamsConstants.FEI_SHU_USER)
|
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_USER, FeiShuParamsConstants.FEI_SHU_USER)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false).build())
|
.setRequired(false).build())
|
||||||
.build();
|
.build();
|
||||||
PasswordParam passwordParam = PasswordParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
|
PasswordParam passwordParam = PasswordParam
|
||||||
.setPlaceholder("if enable use authentication, you need input password")
|
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
|
||||||
.build();
|
.setPlaceholder("if enable use authentication, you need input password")
|
||||||
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(webHookParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
return Arrays.asList(webHookParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.feishu;
|
package org.apache.dolphinscheduler.plugin.alert.feishu;
|
||||||
|
|
||||||
public final class FeiShuParamsConstants {
|
public final class FeiShuParamsConstants {
|
||||||
|
|
||||||
public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')";
|
public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')";
|
||||||
static final String WEB_HOOK = "$t('webhook')";
|
static final String WEB_HOOK = "$t('webhook')";
|
||||||
static final String NAME_WEB_HOOK = "WebHook";
|
static final String NAME_WEB_HOOK = "WebHook";
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public final class FeiShuSender {
|
public final class FeiShuSender {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
|
private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
|
||||||
private final String url;
|
private final String url;
|
||||||
private final Boolean enableProxy;
|
private final Boolean enableProxy;
|
||||||
|
|
@ -98,7 +99,8 @@ public final class FeiShuSender {
|
||||||
return alertResult;
|
return alertResult;
|
||||||
}
|
}
|
||||||
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage()));
|
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage()));
|
||||||
logger.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), sendMsgResponse.getExtra());
|
logger.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(),
|
||||||
|
sendMsgResponse.getExtra());
|
||||||
return alertResult;
|
return alertResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +166,8 @@ public final class FeiShuSender {
|
||||||
} finally {
|
} finally {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp);
|
logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(),
|
||||||
|
resp);
|
||||||
return resp;
|
return resp;
|
||||||
} finally {
|
} finally {
|
||||||
httpClient.close();
|
httpClient.close();
|
||||||
|
|
@ -172,6 +175,7 @@ public final class FeiShuSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class FeiShuSendMsgResponse {
|
static final class FeiShuSendMsgResponse {
|
||||||
|
|
||||||
@JsonProperty("Extra")
|
@JsonProperty("Extra")
|
||||||
private String extra;
|
private String extra;
|
||||||
@JsonProperty("StatusCode")
|
@JsonProperty("StatusCode")
|
||||||
|
|
@ -229,7 +233,8 @@ public final class FeiShuSender {
|
||||||
}
|
}
|
||||||
final Object this$statusMessage = this.getStatusMessage();
|
final Object this$statusMessage = this.getStatusMessage();
|
||||||
final Object other$statusMessage = other.getStatusMessage();
|
final Object other$statusMessage = other.getStatusMessage();
|
||||||
if (this$statusMessage == null ? other$statusMessage != null : !this$statusMessage.equals(other$statusMessage)) {
|
if (this$statusMessage == null ? other$statusMessage != null
|
||||||
|
: !this$statusMessage.equals(other$statusMessage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -248,7 +253,8 @@ public final class FeiShuSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FeiShuSender.FeiShuSendMsgResponse(extra=" + this.getExtra() + ", statusCode=" + this.getStatusCode() + ", statusMessage=" + this.getStatusMessage() + ")";
|
return "FeiShuSender.FeiShuSendMsgResponse(extra=" + this.getExtra() + ", statusCode="
|
||||||
|
+ this.getStatusCode() + ", statusMessage=" + this.getStatusMessage() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,13 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
|
||||||
public final class HttpRequestUtil {
|
public final class HttpRequestUtil {
|
||||||
|
|
||||||
private HttpRequestUtil() {
|
private HttpRequestUtil() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CloseableHttpClient getHttpClient(boolean enableProxy, String proxy, Integer port, String user, String password) {
|
public static CloseableHttpClient getHttpClient(boolean enableProxy, String proxy, Integer port, String user,
|
||||||
|
String password) {
|
||||||
if (enableProxy) {
|
if (enableProxy) {
|
||||||
HttpHost httpProxy = new HttpHost(proxy, port);
|
HttpHost httpProxy = new HttpHost(proxy, port);
|
||||||
CredentialsProvider provider = new BasicCredentialsProvider();
|
CredentialsProvider provider = new BasicCredentialsProvider();
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-http</artifactId>
|
<artifactId>dolphinscheduler-alert-http</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class HttpAlertChannel implements AlertChannel {
|
public final class HttpAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertInfo) {
|
public AlertResult process(AlertInfo alertInfo) {
|
||||||
AlertData alertData = alertInfo.getAlertData();
|
AlertData alertData = alertInfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "Http";
|
return "Http";
|
||||||
|
|
@ -39,39 +40,43 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
|
|
||||||
InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
|
InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
|
||||||
.setPlaceholder("input request URL")
|
.setPlaceholder("input request URL")
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
|
InputParam headerParams =
|
||||||
.setPlaceholder("input request headers as JSON format ")
|
InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
|
||||||
.addValidate(Validate.newBuilder()
|
.setPlaceholder("input request headers as JSON format ")
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
|
InputParam bodyParams =
|
||||||
.setPlaceholder("input request body as JSON format ")
|
InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
|
||||||
.addValidate(Validate.newBuilder()
|
.setPlaceholder("input request body as JSON format ")
|
||||||
.setRequired(false)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(false)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam contentField = InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
|
InputParam contentField =
|
||||||
.setPlaceholder("input alert msg field name")
|
InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
|
||||||
.addValidate(Validate.newBuilder()
|
.setPlaceholder("input alert msg field name")
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam requestType = InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
|
InputParam requestType =
|
||||||
.setPlaceholder("input request type POST or GET")
|
InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
|
||||||
.addValidate(Validate.newBuilder()
|
.setPlaceholder("input request type POST or GET")
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(url, requestType, headerParams, bodyParams, contentField);
|
return Arrays.asList(url, requestType, headerParams, bodyParams, contentField);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.http;
|
package org.apache.dolphinscheduler.plugin.alert.http;
|
||||||
|
|
||||||
public final class HttpAlertConstants {
|
public final class HttpAlertConstants {
|
||||||
|
|
||||||
public static final String URL = "$t('url')";
|
public static final String URL = "$t('url')";
|
||||||
|
|
||||||
public static final String NAME_URL = "url";
|
public static final String NAME_URL = "url";
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-pagerduty</artifactId>
|
<artifactId>dolphinscheduler-alert-pagerduty</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class PagerDutyAlertChannel implements AlertChannel {
|
public final class PagerDutyAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertInfo) {
|
public AlertResult process(AlertInfo alertInfo) {
|
||||||
AlertData alertData = alertInfo.getAlertData();
|
AlertData alertData = alertInfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,20 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||||
import org.apache.dolphinscheduler.spi.params.input.InputParam;
|
import org.apache.dolphinscheduler.spi.params.input.InputParam;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
|
public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "PagerDuty";
|
return "PagerDuty";
|
||||||
|
|
@ -35,7 +38,9 @@ public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
InputParam integrationKey = InputParam.newBuilder(PagerDutyParamsConstants.NAME_PAGER_DUTY_INTEGRATION_KEY_NAME, PagerDutyParamsConstants.PAGER_DUTY_INTEGRATION_KEY)
|
InputParam integrationKey = InputParam
|
||||||
|
.newBuilder(PagerDutyParamsConstants.NAME_PAGER_DUTY_INTEGRATION_KEY_NAME,
|
||||||
|
PagerDutyParamsConstants.PAGER_DUTY_INTEGRATION_KEY)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
||||||
|
|
||||||
public final class PagerDutyParamsConstants {
|
public final class PagerDutyParamsConstants {
|
||||||
|
|
||||||
public static final String NAME_PAGER_DUTY_INTEGRATION_KEY_NAME = "IntegrationKey";
|
public static final String NAME_PAGER_DUTY_INTEGRATION_KEY_NAME = "IntegrationKey";
|
||||||
public static final String PAGER_DUTY_INTEGRATION_KEY = "integrationKey";
|
public static final String PAGER_DUTY_INTEGRATION_KEY = "integrationKey";
|
||||||
public static final String PAGER_DUTY_EVENT_ACTION_TRIGGER = "trigger";
|
public static final String PAGER_DUTY_EVENT_ACTION_TRIGGER = "trigger";
|
||||||
|
|
|
||||||
|
|
@ -17,21 +17,29 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
public final class PagerDutySender {
|
public final class PagerDutySender {
|
||||||
|
|
||||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(PagerDutySender.class);
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(PagerDutySender.class);
|
||||||
|
|
||||||
private final String integrationKey;
|
private final String integrationKey;
|
||||||
|
|
@ -41,7 +49,7 @@ public final class PagerDutySender {
|
||||||
Preconditions.checkArgument(!Objects.isNull(integrationKey), "PagerDuty integration key can not be null");
|
Preconditions.checkArgument(!Objects.isNull(integrationKey), "PagerDuty integration key can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertResult sendPagerDutyAlter(String title, String content){
|
public AlertResult sendPagerDutyAlter(String title, String content) {
|
||||||
AlertResult alertResult = new AlertResult();
|
AlertResult alertResult = new AlertResult();
|
||||||
alertResult.setStatus("false");
|
alertResult.setStatus("false");
|
||||||
alertResult.setMessage("send pager duty alert fail.");
|
alertResult.setMessage("send pager duty alert fail.");
|
||||||
|
|
@ -72,10 +80,10 @@ public final class PagerDutySender {
|
||||||
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
|
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
|
||||||
alertResult.setStatus("true");
|
alertResult.setStatus("true");
|
||||||
alertResult.setMessage("send pager duty alert success");
|
alertResult.setMessage("send pager duty alert success");
|
||||||
}else {
|
} else {
|
||||||
log.info("send pager duty alert fail, statusCode : {}", statusCode);
|
log.info("send pager duty alert fail, statusCode : {}", statusCode);
|
||||||
}
|
}
|
||||||
}finally {
|
} finally {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-script</artifactId>
|
<artifactId>dolphinscheduler-alert-script</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.script;
|
package org.apache.dolphinscheduler.plugin.alert.script;
|
||||||
|
|
||||||
public final class OSUtils {
|
public final class OSUtils {
|
||||||
|
|
||||||
private OSUtils() {
|
private OSUtils() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class ProcessUtils {
|
public final class ProcessUtils {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
|
||||||
|
|
||||||
private ProcessUtils() {
|
private ProcessUtils() {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class ScriptAlertChannel implements AlertChannel {
|
public final class ScriptAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertinfo) {
|
public AlertResult process(AlertInfo alertinfo) {
|
||||||
AlertData alertData = alertinfo.getAlertData();
|
AlertData alertData = alertinfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class ScriptAlertChannelFactory implements AlertChannelFactory {
|
public final class ScriptAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "Script";
|
return "Script";
|
||||||
|
|
@ -40,26 +41,30 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
|
|
||||||
InputParam scriptUserParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS)
|
InputParam scriptUserParam = InputParam
|
||||||
.addValidate(Validate.newBuilder()
|
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS)
|
||||||
.setRequired(false)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(false)
|
||||||
.setPlaceholder("please enter your custom parameters, which will be passed to you when calling your script")
|
.build())
|
||||||
.build();
|
.setPlaceholder(
|
||||||
|
"please enter your custom parameters, which will be passed to you when calling your script")
|
||||||
|
.build();
|
||||||
// need check file type and file exist
|
// need check file type and file exist
|
||||||
InputParam scriptPathParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
|
InputParam scriptPathParam =
|
||||||
.addValidate(Validate.newBuilder()
|
InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.setPlaceholder("please upload the file to the disk directory of the alert server,"
|
.build())
|
||||||
+ " and ensure that the path is absolute and has the corresponding access rights")
|
.setPlaceholder("please upload the file to the disk directory of the alert server,"
|
||||||
.build();
|
+ " and ensure that the path is absolute and has the corresponding access rights")
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam scriptTypeParams = RadioParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_TYPE, ScriptParamsConstants.SCRIPT_TYPE)
|
RadioParam scriptTypeParams = RadioParam
|
||||||
.addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false))
|
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_TYPE, ScriptParamsConstants.SCRIPT_TYPE)
|
||||||
.setValue(ScriptType.SHELL.getDescp())
|
.addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.setValue(ScriptType.SHELL.getDescp())
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(scriptUserParam, scriptPathParam, scriptTypeParams);
|
return Arrays.asList(scriptUserParam, scriptPathParam, scriptTypeParams);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.script;
|
package org.apache.dolphinscheduler.plugin.alert.script;
|
||||||
|
|
||||||
public final class ScriptParamsConstants {
|
public final class ScriptParamsConstants {
|
||||||
|
|
||||||
static final String SCRIPT_TYPE = "$t('scriptType')";
|
static final String SCRIPT_TYPE = "$t('scriptType')";
|
||||||
|
|
||||||
static final String NAME_SCRIPT_TYPE = "type";
|
static final String NAME_SCRIPT_TYPE = "type";
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.script;
|
package org.apache.dolphinscheduler.plugin.alert.script;
|
||||||
|
|
||||||
public enum ScriptType {
|
public enum ScriptType {
|
||||||
|
|
||||||
SHELL(0, "SHELL"),
|
SHELL(0, "SHELL"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class StreamGobbler extends Thread {
|
public final class StreamGobbler extends Thread {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class);
|
private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class);
|
||||||
|
|
||||||
private final InputStream inputStream;
|
private final InputStream inputStream;
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-slack</artifactId>
|
<artifactId>dolphinscheduler-alert-slack</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class SlackAlertChannel implements AlertChannel {
|
public final class SlackAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertInfo) {
|
public AlertResult process(AlertInfo alertInfo) {
|
||||||
AlertData alertData = alertInfo.getAlertData();
|
AlertData alertData = alertInfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class SlackAlertChannelFactory implements AlertChannelFactory {
|
public final class SlackAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "Slack";
|
return "Slack";
|
||||||
|
|
@ -39,19 +40,20 @@ public final class SlackAlertChannelFactory implements AlertChannelFactory {
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
List<PluginParams> paramsList = new LinkedList<>();
|
List<PluginParams> paramsList = new LinkedList<>();
|
||||||
|
|
||||||
InputParam webHookParam = InputParam.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL)
|
InputParam webHookParam = InputParam
|
||||||
.addValidate(Validate.newBuilder()
|
.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL)
|
||||||
.setRequired(true)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(true)
|
||||||
.setPlaceholder("Input WebHook Url")
|
.build())
|
||||||
.build();
|
.setPlaceholder("Input WebHook Url")
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam botName = InputParam.newBuilder(SlackParamsConstants.SLACK_BOT_NAME, SlackParamsConstants.SLACK_BOT)
|
InputParam botName = InputParam.newBuilder(SlackParamsConstants.SLACK_BOT_NAME, SlackParamsConstants.SLACK_BOT)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.setPlaceholder("Input the bot username")
|
.setPlaceholder("Input the bot username")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
paramsList.add(webHookParam);
|
paramsList.add(webHookParam);
|
||||||
paramsList.add(botName);
|
paramsList.add(botName);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.slack;
|
package org.apache.dolphinscheduler.plugin.alert.slack;
|
||||||
|
|
||||||
public final class SlackParamsConstants {
|
public final class SlackParamsConstants {
|
||||||
|
|
||||||
public static final String SLACK_WEB_HOOK_URL = "$t('webhook')";
|
public static final String SLACK_WEB_HOOK_URL = "$t('webhook')";
|
||||||
public static final String SLACK_WEB_HOOK_URL_NAME = "webHook";
|
public static final String SLACK_WEB_HOOK_URL_NAME = "webHook";
|
||||||
public static final String SLACK_BOT = "$t('Username')";
|
public static final String SLACK_BOT = "$t('Username')";
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
public final class SlackSender {
|
public final class SlackSender {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(SlackSender.class);
|
private static final Logger logger = LoggerFactory.getLogger(SlackSender.class);
|
||||||
|
|
||||||
private final String webHookUrl;
|
private final String webHookUrl;
|
||||||
|
|
@ -53,7 +54,8 @@ public final class SlackSender {
|
||||||
webHookUrl = slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME);
|
webHookUrl = slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME);
|
||||||
botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME);
|
botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME);
|
||||||
Preconditions.checkArgument(!Objects.isNull(webHookUrl), "SlackWebHookURL can not be null");
|
Preconditions.checkArgument(!Objects.isNull(webHookUrl), "SlackWebHookURL can not be null");
|
||||||
Preconditions.checkArgument(webHookUrl.startsWith("https://hooks.slack.com/services/"), "SlackWebHookURL invalidate");
|
Preconditions.checkArgument(webHookUrl.startsWith("https://hooks.slack.com/services/"),
|
||||||
|
"SlackWebHookURL invalidate");
|
||||||
Preconditions.checkArgument(!Objects.isNull(botName), "slack bot name can not be null");
|
Preconditions.checkArgument(!Objects.isNull(botName), "slack bot name can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,17 +122,17 @@ public final class SlackSender {
|
||||||
final int elementLen = maxLen;
|
final int elementLen = maxLen;
|
||||||
StringBuilder stringBuilder = new StringBuilder(200);
|
StringBuilder stringBuilder = new StringBuilder(200);
|
||||||
stringBuilder.append(headers.stream()
|
stringBuilder.append(headers.stream()
|
||||||
.map(header -> generateString(header, elementLen, " "))
|
.map(header -> generateString(header, elementLen, " "))
|
||||||
.collect(Collectors.joining("|")));
|
.collect(Collectors.joining("|")));
|
||||||
stringBuilder.append("\n");
|
stringBuilder.append("\n");
|
||||||
for (List<String> element : elements) {
|
for (List<String> element : elements) {
|
||||||
stringBuilder.append(element.stream()
|
stringBuilder.append(element.stream()
|
||||||
.map(lement -> generateString("", elementLen, "-"))
|
.map(lement -> generateString("", elementLen, "-"))
|
||||||
.collect(Collectors.joining("|")));
|
.collect(Collectors.joining("|")));
|
||||||
stringBuilder.append("\n");
|
stringBuilder.append("\n");
|
||||||
stringBuilder.append(element.stream()
|
stringBuilder.append(element.stream()
|
||||||
.map(e -> generateString(e, elementLen, " "))
|
.map(e -> generateString(e, elementLen, " "))
|
||||||
.collect(Collectors.joining("|")));
|
.collect(Collectors.joining("|")));
|
||||||
stringBuilder.append("\n");
|
stringBuilder.append("\n");
|
||||||
}
|
}
|
||||||
return String.format("```%s```", stringBuilder);
|
return String.format("```%s```", stringBuilder);
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-telegram</artifactId>
|
<artifactId>dolphinscheduler-alert-telegram</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class TelegramAlertChannel implements AlertChannel {
|
public final class TelegramAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo info) {
|
public AlertResult process(AlertInfo info) {
|
||||||
Map<String, String> alertParams = info.getAlertParams();
|
Map<String, String> alertParams = info.getAlertParams();
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_FALSE;
|
||||||
|
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_NO;
|
||||||
|
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_TRUE;
|
||||||
|
import static org.apache.dolphinscheduler.spi.utils.Constants.STRING_YES;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||||
import org.apache.dolphinscheduler.spi.params.PasswordParam;
|
import org.apache.dolphinscheduler.spi.params.PasswordParam;
|
||||||
|
|
@ -31,7 +35,7 @@ import org.apache.dolphinscheduler.spi.params.select.SelectParam;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.spi.utils.Constants.*;
|
import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
@ -49,40 +53,50 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
|
|
||||||
|
InputParam webHookParam = InputParam
|
||||||
InputParam webHookParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK)
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.setPlaceholder("telegram web hook")
|
.setPlaceholder("telegram web hook")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam botTokenParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN, TelegramParamsConstants.TELEGRAM_BOT_TOKEN)
|
InputParam botTokenParam = InputParam
|
||||||
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN, TelegramParamsConstants.TELEGRAM_BOT_TOKEN)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.setPlaceholder("telegram bot token")
|
.setPlaceholder("telegram bot token")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam chatIdParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_CHAT_ID, TelegramParamsConstants.TELEGRAM_CHAT_ID)
|
InputParam chatIdParam = InputParam
|
||||||
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_CHAT_ID, TelegramParamsConstants.TELEGRAM_CHAT_ID)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.setPlaceholder("telegram channel chat id")
|
.setPlaceholder("telegram channel chat id")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
SelectParam parseMode = SelectParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE, TelegramParamsConstants.TELEGRAM_PARSE_MODE)
|
SelectParam parseMode = SelectParam
|
||||||
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT, TelegramAlertConstants.PARSE_MODE_TXT, false))
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE,
|
||||||
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN, TelegramAlertConstants.PARSE_MODE_MARKDOWN, false))
|
TelegramParamsConstants.TELEGRAM_PARSE_MODE)
|
||||||
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, false))
|
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT,
|
||||||
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_HTML, TelegramAlertConstants.PARSE_MODE_HTML, false))
|
TelegramAlertConstants.PARSE_MODE_TXT, false))
|
||||||
|
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN,
|
||||||
|
TelegramAlertConstants.PARSE_MODE_MARKDOWN, false))
|
||||||
|
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2,
|
||||||
|
TelegramAlertConstants.PARSE_MODE_MARKDOWN_V2, false))
|
||||||
|
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_HTML,
|
||||||
|
TelegramAlertConstants.PARSE_MODE_HTML, false))
|
||||||
.setValue(TelegramAlertConstants.PARSE_MODE_TXT)
|
.setValue(TelegramAlertConstants.PARSE_MODE_TXT)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RadioParam isEnableProxy = RadioParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY_ENABLE, TelegramParamsConstants.TELEGRAM_PROXY_ENABLE)
|
RadioParam isEnableProxy = RadioParam
|
||||||
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY_ENABLE,
|
||||||
|
TelegramParamsConstants.TELEGRAM_PROXY_ENABLE)
|
||||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||||
.setValue(STRING_FALSE)
|
.setValue(STRING_FALSE)
|
||||||
|
|
@ -91,33 +105,37 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam proxyParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY, TelegramParamsConstants.TELEGRAM_PROXY)
|
InputParam proxyParam = InputParam
|
||||||
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PROXY, TelegramParamsConstants.TELEGRAM_PROXY)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
InputParam portParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
|
InputParam portParam =
|
||||||
.addValidate(Validate.newBuilder()
|
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
|
||||||
.setRequired(false)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(false)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam userParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER)
|
InputParam userParam =
|
||||||
.addValidate(Validate.newBuilder()
|
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER)
|
||||||
.setRequired(false)
|
.addValidate(Validate.newBuilder()
|
||||||
.build())
|
.setRequired(false)
|
||||||
.build();
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
PasswordParam passwordParam = PasswordParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PASSWORD, TelegramParamsConstants.TELEGRAM_PASSWORD)
|
PasswordParam passwordParam = PasswordParam
|
||||||
|
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PASSWORD, TelegramParamsConstants.TELEGRAM_PASSWORD)
|
||||||
.addValidate(Validate.newBuilder()
|
.addValidate(Validate.newBuilder()
|
||||||
.setRequired(false)
|
.setRequired(false)
|
||||||
.build())
|
.build())
|
||||||
.setPlaceholder("if enable use authentication, you need input password")
|
.setPlaceholder("if enable use authentication, you need input password")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(webHookParam, botTokenParam, chatIdParam, parseMode, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
return Arrays.asList(webHookParam, botTokenParam, chatIdParam, parseMode, isEnableProxy, proxyParam, portParam,
|
||||||
|
userParam, passwordParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
||||||
|
|
||||||
|
|
||||||
public final class TelegramParamsConstants {
|
public final class TelegramParamsConstants {
|
||||||
|
|
||||||
static final String TELEGRAM_WEB_HOOK = "$t('webHook')";
|
static final String TELEGRAM_WEB_HOOK = "$t('webHook')";
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
package org.apache.dolphinscheduler.plugin.alert.telegram;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertData;
|
import org.apache.dolphinscheduler.alert.api.AlertData;
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpHeaders;
|
import org.apache.http.HttpHeaders;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
|
|
@ -37,14 +37,17 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public final class TelegramSender {
|
public final class TelegramSender {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TelegramSender.class);
|
private static final Logger logger = LoggerFactory.getLogger(TelegramSender.class);
|
||||||
|
|
@ -69,7 +72,6 @@ public final class TelegramSender {
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
TelegramSender(Map<String, String> config) {
|
TelegramSender(Map<String, String> config) {
|
||||||
url = config.get(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK);
|
url = config.get(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK);
|
||||||
botToken = config.get(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN);
|
botToken = config.get(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN);
|
||||||
|
|
@ -132,14 +134,13 @@ public final class TelegramSender {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String sendInvoke(String title, String content) throws IOException {
|
private String sendInvoke(String title, String content) throws IOException {
|
||||||
HttpPost httpPost = buildHttpPost(url, buildMsgJsonStr(content));
|
HttpPost httpPost = buildHttpPost(url, buildMsgJsonStr(content));
|
||||||
CloseableHttpClient httpClient;
|
CloseableHttpClient httpClient;
|
||||||
if (Boolean.TRUE.equals(enableProxy)) {
|
if (Boolean.TRUE.equals(enableProxy)) {
|
||||||
if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
|
if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
|
||||||
httpClient = getProxyClient(proxy, port, user, password);
|
httpClient = getProxyClient(proxy, port, user, password);
|
||||||
}else {
|
} else {
|
||||||
httpClient = getDefaultClient();
|
httpClient = getDefaultClient();
|
||||||
}
|
}
|
||||||
RequestConfig rcf = getProxyConfig(proxy, port);
|
RequestConfig rcf = getProxyConfig(proxy, port);
|
||||||
|
|
@ -180,6 +181,7 @@ public final class TelegramSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TelegramSendMsgResponse {
|
static class TelegramSendMsgResponse {
|
||||||
|
|
||||||
@JsonProperty("ok")
|
@JsonProperty("ok")
|
||||||
private Boolean ok;
|
private Boolean ok;
|
||||||
@JsonProperty("error_code")
|
@JsonProperty("error_code")
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-webexteams</artifactId>
|
<artifactId>dolphinscheduler-alert-webexteams</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.webexteams;
|
package org.apache.dolphinscheduler.plugin.alert.webexteams;
|
||||||
|
|
||||||
public class WebexMessage {
|
public class WebexMessage {
|
||||||
|
|
||||||
private String roomId;
|
private String roomId;
|
||||||
private String toPersonId;
|
private String toPersonId;
|
||||||
private String toPersonEmail;
|
private String toPersonEmail;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class WebexTeamsAlertChannel implements AlertChannel {
|
public final class WebexTeamsAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo alertInfo) {
|
public AlertResult process(AlertInfo alertInfo) {
|
||||||
AlertData alertData = alertInfo.getAlertData();
|
AlertData alertData = alertInfo.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory {
|
public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "WebexTeams";
|
return "WebexTeams";
|
||||||
|
|
@ -40,48 +41,63 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
List<PluginParams> paramsList = new ArrayList<>();
|
List<PluginParams> paramsList = new ArrayList<>();
|
||||||
InputParam botAccessToken = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN, WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
|
InputParam botAccessToken = InputParam
|
||||||
.setPlaceholder("Please enter the robot's access token you were given")
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN,
|
||||||
.addValidate(Validate.newBuilder()
|
WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
|
||||||
.setRequired(true)
|
.setPlaceholder("Please enter the robot's access token you were given")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam roomId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
|
InputParam roomId = InputParam
|
||||||
.setPlaceholder("The room ID of the message")
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID,
|
||||||
.addValidate(Validate.newBuilder()
|
WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
|
||||||
.setRequired(false)
|
.setPlaceholder("The room ID of the message")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam toPersonId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
|
InputParam toPersonId = InputParam
|
||||||
.setPlaceholder("The person ID of the message recipient")
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID,
|
||||||
.addValidate(Validate.newBuilder()
|
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
|
||||||
.setRequired(false)
|
.setPlaceholder("The person ID of the message recipient")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam toPersonEmail = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
|
InputParam toPersonEmail = InputParam
|
||||||
.setPlaceholder("The email address of the message recipient")
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL,
|
||||||
.addValidate(Validate.newBuilder()
|
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
|
||||||
.setRequired(false)
|
.setPlaceholder("The email address of the message recipient")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam atSomeoneInRoom = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM, WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
|
InputParam atSomeoneInRoom = InputParam
|
||||||
.setPlaceholder("use ,(eng commas) to separate multiple emails")
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM,
|
||||||
.addValidate(Validate.newBuilder()
|
WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
|
||||||
.setRequired(false)
|
.setPlaceholder("use ,(eng commas) to separate multiple emails")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam destination = RadioParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION, WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION)
|
RadioParam destination = RadioParam
|
||||||
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(), WebexTeamsDestination.ROOM_ID.getDescp(), false))
|
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION,
|
||||||
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(), WebexTeamsDestination.PERSON_EMAIL.getDescp(), false))
|
WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION)
|
||||||
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_ID.getDescp(), WebexTeamsDestination.PERSON_ID.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(),
|
||||||
.setValue(WebexTeamsDestination.ROOM_ID.getDescp())
|
WebexTeamsDestination.ROOM_ID.getDescp(), false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(),
|
||||||
.build();
|
WebexTeamsDestination.PERSON_EMAIL.getDescp(), false))
|
||||||
|
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_ID.getDescp(),
|
||||||
|
WebexTeamsDestination.PERSON_ID.getDescp(), false))
|
||||||
|
.setValue(WebexTeamsDestination.ROOM_ID.getDescp())
|
||||||
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
|
|
||||||
paramsList.add(botAccessToken);
|
paramsList.add(botAccessToken);
|
||||||
paramsList.add(roomId);
|
paramsList.add(roomId);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
|
|
||||||
public enum WebexTeamsDestination {
|
public enum WebexTeamsDestination {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0 ROOM_ID;
|
* 0 ROOM_ID;
|
||||||
* 1 PERSON_EMAIL;
|
* 1 PERSON_EMAIL;
|
||||||
|
|
@ -51,7 +52,8 @@ public enum WebexTeamsDestination {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<String, WebexTeamsDestination> WEBEX_TEAMS_DESTINATION_MAP =
|
private static final Map<String, WebexTeamsDestination> WEBEX_TEAMS_DESTINATION_MAP =
|
||||||
Arrays.stream(WebexTeamsDestination.values()).collect(toMap(WebexTeamsDestination::getDescp, Functions.identity()));
|
Arrays.stream(WebexTeamsDestination.values())
|
||||||
|
.collect(toMap(WebexTeamsDestination::getDescp, Functions.identity()));
|
||||||
|
|
||||||
public static WebexTeamsDestination of(String descp) {
|
public static WebexTeamsDestination of(String descp) {
|
||||||
if (WEBEX_TEAMS_DESTINATION_MAP.containsKey(descp)) {
|
if (WEBEX_TEAMS_DESTINATION_MAP.containsKey(descp)) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import org.slf4j.Logger;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
public final class WebexTeamsSender {
|
public final class WebexTeamsSender {
|
||||||
|
|
||||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(WebexTeamsSender.class);
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(WebexTeamsSender.class);
|
||||||
|
|
||||||
private final String botAccessToken;
|
private final String botAccessToken;
|
||||||
|
|
@ -57,7 +58,9 @@ public final class WebexTeamsSender {
|
||||||
destination = WebexTeamsDestination.of(config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION));
|
destination = WebexTeamsDestination.of(config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION));
|
||||||
Preconditions.checkArgument(!Objects.isNull(botAccessToken), "WebexTeams bot access token can not be null");
|
Preconditions.checkArgument(!Objects.isNull(botAccessToken), "WebexTeams bot access token can not be null");
|
||||||
Preconditions.checkArgument(!Objects.isNull(destination), "WebexTeams message destination can not be null");
|
Preconditions.checkArgument(!Objects.isNull(destination), "WebexTeams message destination can not be null");
|
||||||
Preconditions.checkArgument((!Objects.isNull(roomId) || !Objects.isNull(toPersonId) || !Objects.isNull(toPersonEmail)),"WebexTeams message destination could not be determined. Provide only one destination in the roomId, toPersonEmail, or toPersonId field");
|
Preconditions.checkArgument(
|
||||||
|
(!Objects.isNull(roomId) || !Objects.isNull(toPersonId) || !Objects.isNull(toPersonEmail)),
|
||||||
|
"WebexTeams message destination could not be determined. Provide only one destination in the roomId, toPersonEmail, or toPersonId field");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertResult sendWebexTeamsAlter(AlertData alertData) {
|
public AlertResult sendWebexTeamsAlter(AlertData alertData) {
|
||||||
|
|
@ -137,11 +140,11 @@ public final class WebexTeamsSender {
|
||||||
public static String addAtPersonEmailInRoom(String formatContent, String atPersonEmailInRoom) {
|
public static String addAtPersonEmailInRoom(String formatContent, String atPersonEmailInRoom) {
|
||||||
String[] emailArr = atPersonEmailInRoom.split(",");
|
String[] emailArr = atPersonEmailInRoom.split(",");
|
||||||
StringBuilder formatContentBuilder = new StringBuilder(formatContent);
|
StringBuilder formatContentBuilder = new StringBuilder(formatContent);
|
||||||
for (String email: emailArr) {
|
for (String email : emailArr) {
|
||||||
formatContentBuilder.append(" <@personEmail:").append(email).append(">");
|
formatContentBuilder.append(" <@personEmail:").append(email).append(">");
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatContentBuilder.toString();
|
return formatContentBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatContent(AlertData alertData) {
|
public static String formatContent(AlertData alertData) {
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-wechat</artifactId>
|
<artifactId>dolphinscheduler-alert-wechat</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class WeChatAlertChannel implements AlertChannel {
|
public final class WeChatAlertChannel implements AlertChannel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlertResult process(AlertInfo info) {
|
public AlertResult process(AlertInfo info) {
|
||||||
AlertData alertData = info.getAlertData();
|
AlertData alertData = info.getAlertData();
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
@AutoService(AlertChannelFactory.class)
|
@AutoService(AlertChannelFactory.class)
|
||||||
public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public String name() {
|
||||||
return "WeChat";
|
return "WeChat";
|
||||||
|
|
@ -41,47 +42,58 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PluginParams> params() {
|
public List<PluginParams> params() {
|
||||||
InputParam corpIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
|
InputParam corpIdParam = InputParam
|
||||||
.setPlaceholder("please input corp id ")
|
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID,
|
||||||
.addValidate(Validate.newBuilder()
|
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
|
||||||
.setRequired(true)
|
.setPlaceholder("please input corp id ")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam secretParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
|
InputParam secretParam = InputParam
|
||||||
.setPlaceholder("please input secret ")
|
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET,
|
||||||
.addValidate(Validate.newBuilder()
|
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
|
||||||
.setRequired(true)
|
.setPlaceholder("please input secret ")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam usersParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
|
InputParam usersParam = InputParam
|
||||||
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
|
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS,
|
||||||
.addValidate(Validate.newBuilder()
|
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
|
||||||
.setRequired(false)
|
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(false)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
InputParam agentIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
|
InputParam agentIdParam = InputParam
|
||||||
.setPlaceholder("please input agent id or chat id ")
|
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID,
|
||||||
.addValidate(Validate.newBuilder()
|
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
|
||||||
.setRequired(true)
|
.setPlaceholder("please input agent id or chat id ")
|
||||||
.build())
|
.addValidate(Validate.newBuilder()
|
||||||
.build();
|
.setRequired(true)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
|
||||||
RadioParam sendType = RadioParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SEND_TYPE)
|
RadioParam sendType = RadioParam
|
||||||
|
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SEND_TYPE,
|
||||||
|
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SEND_TYPE)
|
||||||
.addParamsOptions(new ParamsOptions(WeChatType.APP.getDescp(), WeChatType.APP.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(WeChatType.APP.getDescp(), WeChatType.APP.getDescp(), false))
|
||||||
.addParamsOptions(new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
|
.addParamsOptions(
|
||||||
|
new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
|
||||||
.setValue(WeChatType.APP.getDescp())
|
.setValue(WeChatType.APP.getDescp())
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
|
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.MARKDOWN.getDescp(), ShowType.MARKDOWN.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(ShowType.MARKDOWN.getDescp(), ShowType.MARKDOWN.getDescp(), false))
|
||||||
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
|
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
|
||||||
.setValue(ShowType.MARKDOWN.getDescp())
|
.setValue(ShowType.MARKDOWN.getDescp())
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return Arrays.asList(corpIdParam, secretParam, usersParam, agentIdParam, sendType, showType);
|
return Arrays.asList(corpIdParam, secretParam, usersParam, agentIdParam, sendType, showType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
||||||
|
|
||||||
public final class WeChatAlertConstants {
|
public final class WeChatAlertConstants {
|
||||||
|
|
||||||
static final String MARKDOWN_QUOTE = ">";
|
static final String MARKDOWN_QUOTE = ">";
|
||||||
|
|
||||||
static final String MARKDOWN_ENTER = "\n";
|
static final String MARKDOWN_ENTER = "\n";
|
||||||
|
|
@ -29,7 +30,8 @@ public final class WeChatAlertConstants {
|
||||||
static final String WE_CHAT_APP_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token" +
|
static final String WE_CHAT_APP_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/appchat/send?access_token" +
|
||||||
"={token}";
|
"={token}";
|
||||||
|
|
||||||
static final String WE_CHAT_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";
|
static final String WE_CHAT_TOKEN_URL =
|
||||||
|
"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";
|
||||||
|
|
||||||
static final String WE_CHAT_CONTENT_KEY = "content";
|
static final String WE_CHAT_CONTENT_KEY = "content";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
||||||
|
|
||||||
public final class WeChatAlertParamsConstants {
|
public final class WeChatAlertParamsConstants {
|
||||||
|
|
||||||
static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')";
|
static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')";
|
||||||
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId";
|
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId";
|
||||||
static final String ENTERPRISE_WE_CHAT_SECRET = "$t('secret')";
|
static final String ENTERPRISE_WE_CHAT_SECRET = "$t('secret')";
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,16 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO;
|
||||||
|
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_ENABLE_ID_TRANS;
|
||||||
|
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.WE_CHAT_MESSAGE_SAFE_PUBLICITY;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertConstants;
|
import org.apache.dolphinscheduler.alert.api.AlertConstants;
|
||||||
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
import org.apache.dolphinscheduler.alert.api.AlertResult;
|
||||||
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
|
@ -29,8 +35,6 @@ import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -40,11 +44,11 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
import static java.util.Objects.requireNonNull;
|
import org.slf4j.LoggerFactory;
|
||||||
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.*;
|
|
||||||
|
|
||||||
public final class WeChatSender {
|
public final class WeChatSender {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
|
private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
|
||||||
private static final String MUST_NOT_NULL = " must not null";
|
private static final String MUST_NOT_NULL = " must not null";
|
||||||
private static final String ALERT_STATUS = "false";
|
private static final String ALERT_STATUS = "false";
|
||||||
|
|
@ -210,11 +214,15 @@ public final class WeChatSender {
|
||||||
String msgJson = "";
|
String msgJson = "";
|
||||||
if (sendType.equals(WeChatType.APP.getDescp())) {
|
if (sendType.equals(WeChatType.APP.getDescp())) {
|
||||||
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
|
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
|
||||||
WechatAppMessage wechatAppMessage = new WechatAppMessage(weChatUsers, showType, Integer.valueOf(weChatAgentIdChatId), contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY, WE_CHAT_ENABLE_ID_TRANS, WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO);
|
WechatAppMessage wechatAppMessage = new WechatAppMessage(weChatUsers, showType,
|
||||||
|
Integer.valueOf(weChatAgentIdChatId), contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY,
|
||||||
|
WE_CHAT_ENABLE_ID_TRANS, WE_CHAT_DUPLICATE_CHECK_INTERVAL_ZERO);
|
||||||
msgJson = JSONUtils.toJsonString(wechatAppMessage);
|
msgJson = JSONUtils.toJsonString(wechatAppMessage);
|
||||||
} else if (sendType.equals(WeChatType.APPCHAT.getDescp())) {
|
} else if (sendType.equals(WeChatType.APPCHAT.getDescp())) {
|
||||||
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
|
enterpriseWeChatPushUrlReplace =
|
||||||
WechatAppChatMessage wechatAppChatMessage = new WechatAppChatMessage(weChatAgentIdChatId, showType, contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY);
|
WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
|
||||||
|
WechatAppChatMessage wechatAppChatMessage =
|
||||||
|
new WechatAppChatMessage(weChatAgentIdChatId, showType, contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY);
|
||||||
msgJson = JSONUtils.toJsonString(wechatAppChatMessage);
|
msgJson = JSONUtils.toJsonString(wechatAppChatMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,6 +256,7 @@ public final class WeChatSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class WeChatSendMsgResponse {
|
static final class WeChatSendMsgResponse {
|
||||||
|
|
||||||
private Integer errcode;
|
private Integer errcode;
|
||||||
private String errmsg;
|
private String errmsg;
|
||||||
|
|
||||||
|
|
@ -302,7 +311,8 @@ public final class WeChatSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")";
|
return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg()
|
||||||
|
+ ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
||||||
|
|
||||||
public enum WeChatType {
|
public enum WeChatType {
|
||||||
|
|
||||||
APP(1, "APP/应用"),
|
APP(1, "APP/应用"),
|
||||||
APPCHAT(2, "GROUP CHAT/群聊"),
|
APPCHAT(2, "GROUP CHAT/群聊"),
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ public class WechatAppChatMessage {
|
||||||
|
|
||||||
private String chatid;
|
private String chatid;
|
||||||
private String msgtype;
|
private String msgtype;
|
||||||
private Map<String,String> text;
|
private Map<String, String> text;
|
||||||
private Map<String,String> markdown;
|
private Map<String, String> markdown;
|
||||||
private Integer safe;
|
private Integer safe;
|
||||||
|
|
||||||
public String getChatid() {
|
public String getChatid() {
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,8 @@ public class WechatAppMessage {
|
||||||
public WechatAppMessage() {
|
public WechatAppMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WechatAppMessage(String touser, String msgtype, Integer agentid, Map<String, String> contentMap, Integer safe, Integer enableIdTrans, Integer enableDuplicateCheck) {
|
public WechatAppMessage(String touser, String msgtype, Integer agentid, Map<String, String> contentMap,
|
||||||
|
Integer safe, Integer enableIdTrans, Integer enableDuplicateCheck) {
|
||||||
this.touser = touser;
|
this.touser = touser;
|
||||||
this.msgtype = msgtype;
|
this.msgtype = msgtype;
|
||||||
this.agentid = agentid;
|
this.agentid = agentid;
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,14 @@
|
||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler-alert</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-alert</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
<artifactId>dolphinscheduler-alert-plugins</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,6 @@ import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||||
import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
|
import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
|
||||||
import org.apache.dolphinscheduler.spi.plugin.PrioritySPIFactory;
|
import org.apache.dolphinscheduler.spi.plugin.PrioritySPIFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
|
||||||
import org.springframework.context.event.EventListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -42,10 +37,15 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public final class AlertPluginManager {
|
public final class AlertPluginManager {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
|
||||||
|
|
||||||
private final PluginDao pluginDao;
|
private final PluginDao pluginDao;
|
||||||
|
|
@ -59,20 +59,22 @@ public final class AlertPluginManager {
|
||||||
private final PluginParams warningTypeParams = getWarningTypeParams();
|
private final PluginParams warningTypeParams = getWarningTypeParams();
|
||||||
|
|
||||||
public PluginParams getWarningTypeParams() {
|
public PluginParams getWarningTypeParams() {
|
||||||
return
|
return RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE)
|
||||||
RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE)
|
.addParamsOptions(
|
||||||
.addParamsOptions(new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false))
|
new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false))
|
||||||
.addParamsOptions(new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false))
|
.addParamsOptions(
|
||||||
.addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false))
|
new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false))
|
||||||
.setValue(WarningType.ALL.getDescp())
|
.addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false))
|
||||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
.setValue(WarningType.ALL.getDescp())
|
||||||
.build();
|
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void installPlugin(ApplicationReadyEvent readyEvent) {
|
public void installPlugin(ApplicationReadyEvent readyEvent) {
|
||||||
|
|
||||||
PrioritySPIFactory<AlertChannelFactory> prioritySPIFactory = new PrioritySPIFactory<>(AlertChannelFactory.class);
|
PrioritySPIFactory<AlertChannelFactory> prioritySPIFactory =
|
||||||
|
new PrioritySPIFactory<>(AlertChannelFactory.class);
|
||||||
for (Map.Entry<String, AlertChannelFactory> entry : prioritySPIFactory.getSPIMap().entrySet()) {
|
for (Map.Entry<String, AlertChannelFactory> entry : prioritySPIFactory.getSPIMap().entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
AlertChannelFactory factory = entry.getValue();
|
AlertChannelFactory factory = entry.getValue();
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import io.netty.channel.Channel;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public final class AlertRequestProcessor implements NettyRequestProcessor {
|
public final class AlertRequestProcessor implements NettyRequestProcessor {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class);
|
private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class);
|
||||||
|
|
||||||
private final AlertSenderService alertSenderService;
|
private final AlertSenderService alertSenderService;
|
||||||
|
|
@ -44,18 +45,19 @@ public final class AlertRequestProcessor implements NettyRequestProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Channel channel, Command command) {
|
public void process(Channel channel, Command command) {
|
||||||
checkArgument(CommandType.ALERT_SEND_REQUEST == command.getType(), "invalid command type: %s", command.getType());
|
checkArgument(CommandType.ALERT_SEND_REQUEST == command.getType(), "invalid command type: %s",
|
||||||
|
command.getType());
|
||||||
|
|
||||||
AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize(
|
AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize(
|
||||||
command.getBody(), AlertSendRequestCommand.class);
|
command.getBody(), AlertSendRequestCommand.class);
|
||||||
|
|
||||||
logger.info("Received command : {}", alertSendRequestCommand);
|
logger.info("Received command : {}", alertSendRequestCommand);
|
||||||
|
|
||||||
AlertSendResponseCommand alertSendResponseCommand = alertSenderService.syncHandler(
|
AlertSendResponseCommand alertSendResponseCommand = alertSenderService.syncHandler(
|
||||||
alertSendRequestCommand.getGroupId(),
|
alertSendRequestCommand.getGroupId(),
|
||||||
alertSendRequestCommand.getTitle(),
|
alertSendRequestCommand.getTitle(),
|
||||||
alertSendRequestCommand.getContent(),
|
alertSendRequestCommand.getContent(),
|
||||||
alertSendRequestCommand.getWarnType());
|
alertSendRequestCommand.getWarnType());
|
||||||
channel.writeAndFlush(alertSendResponseCommand.convert2Command(command.getOpaque()));
|
channel.writeAndFlush(alertSendResponseCommand.convert2Command(command.getOpaque()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.alert;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import io.micrometer.core.instrument.Counter;
|
import io.micrometer.core.instrument.Counter;
|
||||||
import io.micrometer.core.instrument.Gauge;
|
import io.micrometer.core.instrument.Gauge;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class AlertServerMetrics {
|
public class AlertServerMetrics {
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,16 @@
|
||||||
~ specific language governing permissions and limitations
|
~ specific language governing permissions and limitations
|
||||||
~ under the License.
|
~ under the License.
|
||||||
-->
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>dolphinscheduler</artifactId>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler</artifactId>
|
||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<artifactId>dolphinscheduler-alert</artifactId>
|
<artifactId>dolphinscheduler-alert</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>dolphinscheduler-alert-api</module>
|
<module>dolphinscheduler-alert-api</module>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.common.enums.PluginType;
|
||||||
import org.apache.dolphinscheduler.dao.PluginDao;
|
import org.apache.dolphinscheduler.dao.PluginDao;
|
||||||
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
|
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginException;
|
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
|
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
|
||||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.lang.annotation.Target;
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface AccessLogAnnotation {
|
public @interface AccessLogAnnotation {
|
||||||
|
|
||||||
// ignore request args
|
// ignore request args
|
||||||
String[] ignoreRequestArgs() default {"loginUser"};
|
String[] ignoreRequestArgs() default {"loginUser"};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
public class AccessLogAspect {
|
public class AccessLogAspect {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AccessLogAspect.class);
|
private static final Logger logger = LoggerFactory.getLogger(AccessLogAspect.class);
|
||||||
|
|
||||||
private static final String TRACE_ID = "traceId";
|
private static final String TRACE_ID = "traceId";
|
||||||
|
|
@ -56,7 +57,7 @@ public class AccessLogAspect {
|
||||||
private static final Pattern sensitiveDataPattern = Pattern.compile(sensitiveDataRegEx, Pattern.CASE_INSENSITIVE);
|
private static final Pattern sensitiveDataPattern = Pattern.compile(sensitiveDataRegEx, Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
@Pointcut("@annotation(org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation)")
|
@Pointcut("@annotation(org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation)")
|
||||||
public void logPointCut(){
|
public void logPointCut() {
|
||||||
// Do nothing because of it's a pointcut
|
// Do nothing because of it's a pointcut
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ public class AccessLogAspect {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// fetch AccessLogAnnotation
|
// fetch AccessLogAnnotation
|
||||||
MethodSignature sign = (MethodSignature) proceedingJoinPoint.getSignature();
|
MethodSignature sign = (MethodSignature) proceedingJoinPoint.getSignature();
|
||||||
Method method = sign.getMethod();
|
Method method = sign.getMethod();
|
||||||
AccessLogAnnotation annotation = method.getAnnotation(AccessLogAnnotation.class);
|
AccessLogAnnotation annotation = method.getAnnotation(AccessLogAnnotation.class);
|
||||||
|
|
||||||
|
|
@ -73,7 +74,8 @@ public class AccessLogAspect {
|
||||||
|
|
||||||
// log request
|
// log request
|
||||||
if (!annotation.ignoreRequest()) {
|
if (!annotation.ignoreRequest()) {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes attributes =
|
||||||
|
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
if (attributes != null) {
|
if (attributes != null) {
|
||||||
HttpServletRequest request = attributes.getRequest();
|
HttpServletRequest request = attributes.getRequest();
|
||||||
String traceIdFromHeader = request.getHeader(TRACE_ID);
|
String traceIdFromHeader = request.getHeader(TRACE_ID);
|
||||||
|
|
@ -92,7 +94,8 @@ public class AccessLogAspect {
|
||||||
userName,
|
userName,
|
||||||
request.getRequestURI(),
|
request.getRequestURI(),
|
||||||
request.getMethod(),
|
request.getMethod(),
|
||||||
proceedingJoinPoint.getSignature().getDeclaringTypeName() + "." + proceedingJoinPoint.getSignature().getName(),
|
proceedingJoinPoint.getSignature().getDeclaringTypeName() + "."
|
||||||
|
+ proceedingJoinPoint.getSignature().getName(),
|
||||||
argsString);
|
argsString);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +105,8 @@ public class AccessLogAspect {
|
||||||
|
|
||||||
// log response
|
// log response
|
||||||
if (!annotation.ignoreResponse()) {
|
if (!annotation.ignoreResponse()) {
|
||||||
logger.info("RESPONSE TRACE_ID:{}, BODY:{}, REQUEST DURATION:{} milliseconds", traceId, ob, (System.currentTimeMillis() - startTime));
|
logger.info("RESPONSE TRACE_ID:{}, BODY:{}, REQUEST DURATION:{} milliseconds", traceId, ob,
|
||||||
|
(System.currentTimeMillis() - startTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ob;
|
return ob;
|
||||||
|
|
@ -134,7 +138,7 @@ public class AccessLogAspect {
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
if (matcher.groupCount() == 3) {
|
if (matcher.groupCount() == 3) {
|
||||||
stream = IntStream.concat(stream, IntStream.range(matcher.end(1),matcher.end(2)));
|
stream = IntStream.concat(stream, IntStream.range(matcher.end(1), matcher.end(2)));
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class AuditMessage {
|
public class AuditMessage {
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
private Date auditDate;
|
private Date auditDate;
|
||||||
|
|
@ -34,7 +35,8 @@ public class AuditMessage {
|
||||||
|
|
||||||
private Integer resourceId;
|
private Integer resourceId;
|
||||||
|
|
||||||
public AuditMessage(User user, Date auditDate, AuditResourceType resourceType, AuditOperationType operation, Integer resourceId) {
|
public AuditMessage(User user, Date auditDate, AuditResourceType resourceType, AuditOperationType operation,
|
||||||
|
Integer resourceId) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.auditDate = auditDate;
|
this.auditDate = auditDate;
|
||||||
this.resourceType = resourceType;
|
this.resourceType = resourceType;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
@ConfigurationProperties(value = "audit", ignoreUnknownFields = false)
|
@ConfigurationProperties(value = "audit", ignoreUnknownFields = false)
|
||||||
public class AuditConfiguration {
|
public class AuditConfiguration {
|
||||||
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
public boolean getEnabled() {
|
public boolean getEnabled() {
|
||||||
|
|
@ -34,4 +35,4 @@ public class AuditConfiguration {
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,21 +18,25 @@ package org.apache.dolphinscheduler.api.configuration;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.springframework.context.MessageSource;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import springfox.documentation.service.Operation;
|
import springfox.documentation.service.Operation;
|
||||||
import springfox.documentation.service.RequestParameter;
|
import springfox.documentation.service.RequestParameter;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.OperationBuilderPlugin;
|
import springfox.documentation.spi.service.OperationBuilderPlugin;
|
||||||
import springfox.documentation.spi.service.contexts.OperationContext;
|
import springfox.documentation.spi.service.contexts.OperationContext;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OpenAPITranslationConfiguration {
|
public class OpenAPITranslationConfiguration {
|
||||||
|
|
||||||
|
|
@ -60,20 +64,20 @@ public class OpenAPITranslationConfiguration {
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
|
|
||||||
Collection<RequestParameter> parameters = operation.getRequestParameters().stream()
|
Collection<RequestParameter> parameters = operation.getRequestParameters().stream()
|
||||||
.map(it -> new RequestParameter(
|
.map(it -> new RequestParameter(
|
||||||
it.getName(),
|
it.getName(),
|
||||||
it.getIn(),
|
it.getIn(),
|
||||||
messageSource.getMessage(it.getDescription(), null, it.getDescription(), locale),
|
messageSource.getMessage(it.getDescription(), null, it.getDescription(), locale),
|
||||||
it.getRequired(),
|
it.getRequired(),
|
||||||
it.getDeprecated(),
|
it.getDeprecated(),
|
||||||
it.getHidden(),
|
it.getHidden(),
|
||||||
it.getParameterSpecification(),
|
it.getParameterSpecification(),
|
||||||
it.getScalarExample(),
|
it.getScalarExample(),
|
||||||
it.getExamples(),
|
it.getExamples(),
|
||||||
it.getPrecedence(),
|
it.getPrecedence(),
|
||||||
it.getExtensions(),
|
it.getExtensions(),
|
||||||
it.getParameterIndex()))
|
it.getParameterIndex()))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|
||||||
context.operationBuilder()
|
context.operationBuilder()
|
||||||
.notes(notes)
|
.notes(notes)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
@ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false)
|
@ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false)
|
||||||
public class PythonGatewayConfiguration {
|
public class PythonGatewayConfiguration {
|
||||||
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private String gatewayServerAddress;
|
private String gatewayServerAddress;
|
||||||
private int gatewayServerPort;
|
private int gatewayServerPort;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ import org.apache.dolphinscheduler.common.config.YamlPropertySourceFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
@ -31,9 +34,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
@PropertySource(value = {"classpath:task-type-config.yaml"}, factory = YamlPropertySourceFactory.class)
|
@PropertySource(value = {"classpath:task-type-config.yaml"}, factory = YamlPropertySourceFactory.class)
|
||||||
|
|
@ -62,9 +62,11 @@ public class TaskTypeConfiguration {
|
||||||
universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL)));
|
universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL)));
|
||||||
cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD)));
|
cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD)));
|
||||||
logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC)));
|
logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC)));
|
||||||
dataIntegration.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION)));
|
dataIntegration
|
||||||
|
.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION)));
|
||||||
dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY)));
|
dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY)));
|
||||||
machineLearning.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING)));
|
machineLearning
|
||||||
|
.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING)));
|
||||||
other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
|
other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
|
||||||
return defaultTaskTypes;
|
return defaultTaskTypes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.api.configuration;
|
package org.apache.dolphinscheduler.api.configuration;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.api.constants;
|
package org.apache.dolphinscheduler.api.constants;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.ExecuteType;
|
import org.apache.dolphinscheduler.api.enums.ExecuteType;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ public class ApiFuncIdentificationConstant {
|
||||||
public static final String ACCESS_TOKEN_DELETE = "security:token:delete";
|
public static final String ACCESS_TOKEN_DELETE = "security:token:delete";
|
||||||
public static final String ALERT_GROUP_VIEW = "security:alert-group:view";
|
public static final String ALERT_GROUP_VIEW = "security:alert-group:view";
|
||||||
public static final String ALERT_GROUP_CREATE = "security:alert-group:create";
|
public static final String ALERT_GROUP_CREATE = "security:alert-group:create";
|
||||||
public static final String ALERT_GROUP_UPDATE = "security:alert-group:update";
|
public static final String ALERT_GROUP_UPDATE = "security:alert-group:update";
|
||||||
public static final String ALERT_GROUP_DELETE = "security:alert-group:delete";
|
public static final String ALERT_GROUP_DELETE = "security:alert-group:delete";
|
||||||
public static final String TENANT_MANAGER = "security:tenant:view";
|
public static final String TENANT_MANAGER = "security:tenant:view";
|
||||||
public static final String TENANT_CREATE = "security:tenant:create";
|
public static final String TENANT_CREATE = "security:tenant:create";
|
||||||
|
|
@ -156,28 +157,28 @@ public class ApiFuncIdentificationConstant {
|
||||||
|
|
||||||
public static final String MONITOR_STATISTICS_VIEW = "monitor:statistics:view";
|
public static final String MONITOR_STATISTICS_VIEW = "monitor:statistics:view";
|
||||||
|
|
||||||
public final static Map<ExecuteType,String> map = new HashMap<ExecuteType,String>();
|
public final static Map<ExecuteType, String> map = new HashMap<ExecuteType, String>();
|
||||||
|
|
||||||
static{
|
static {
|
||||||
for(ExecuteType type : ExecuteType.values()){
|
for (ExecuteType type : ExecuteType.values()) {
|
||||||
switch (type){
|
switch (type) {
|
||||||
case REPEAT_RUNNING:
|
case REPEAT_RUNNING:
|
||||||
map.put(type,RERUN);
|
map.put(type, RERUN);
|
||||||
break;
|
break;
|
||||||
case RECOVER_SUSPENDED_PROCESS:
|
case RECOVER_SUSPENDED_PROCESS:
|
||||||
map.put(type,RECOVERY_SUSPEND);
|
map.put(type, RECOVERY_SUSPEND);
|
||||||
break;
|
break;
|
||||||
case START_FAILURE_TASK_PROCESS:
|
case START_FAILURE_TASK_PROCESS:
|
||||||
map.put(type,FAILED_TO_RETRY);
|
map.put(type, FAILED_TO_RETRY);
|
||||||
break;
|
break;
|
||||||
case STOP:
|
case STOP:
|
||||||
map.put(type,STOP);
|
map.put(type, STOP);
|
||||||
break;
|
break;
|
||||||
case PAUSE:
|
case PAUSE:
|
||||||
map.put(type,PAUSE);
|
map.put(type, PAUSE);
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
map.put(type,null);
|
map.put(type, null);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.ClusterService;
|
import org.apache.dolphinscheduler.api.service.ClusterService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.service.DqExecuteResultService;
|
||||||
import org.apache.dolphinscheduler.api.service.DqRuleService;
|
import org.apache.dolphinscheduler.api.service.DqRuleService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,10 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.DataSourceService;
|
import org.apache.dolphinscheduler.api.service.DataSourceService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
|
||||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
import org.apache.dolphinscheduler.service.utils.CommonUtils;
|
import org.apache.dolphinscheduler.service.utils.CommonUtils;
|
||||||
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
||||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package org.apache.dolphinscheduler.api.controller;
|
||||||
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
@ -29,6 +30,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class DsErrorController implements ErrorController {
|
public class DsErrorController implements ErrorController {
|
||||||
|
|
||||||
@RequestMapping("/error")
|
@RequestMapping("/error")
|
||||||
public ModelAndView handleError(HttpServletRequest request) {
|
public ModelAndView handleError(HttpServletRequest request) {
|
||||||
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
|
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.EnvironmentService;
|
import org.apache.dolphinscheduler.api.service.EnvironmentService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue