[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:
Eric Gao 2022-10-19 11:08:04 +08:00 committed by GitHub
parent 1e11034049
commit d46e4659d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
948 changed files with 5934 additions and 4764 deletions

View File

@ -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
**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 (
depends), and plans to support dynamic plug-in expansion, note: **SUB_PROCESS** need relation with another workflow definition which also a separate process

View File

@ -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.
## 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.

View File

@ -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):
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.
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.
@ -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 should send an email using the following template to the new committer:
```
To: <invitee name>@gmail.com
Cc: private@dolphinscheduler.apache.org

View File

@ -4,18 +4,18 @@
## Datasource Parameters
| **Datasource** | **Description** |
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| Datasource | Select Oracle. |
| Datasource Name | Enter the name of the datasource. |
| Description | Enter a description of the datasource. |
| IP/Host Name | Enter the Oracle service IP. |
| Port | Enter the Oracle service port. |
| Username | Set the username for Oracle connection. |
| Password | Set the password for 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. |
| jdbc connect parameters | Parameter settings for Oracle connection, in JSON format. For example, you can use {"schema": "abc"} to specify database abc for using. |
| **Datasource** | **Description** |
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| Datasource | Select Oracle. |
| Datasource Name | Enter the name of the datasource. |
| Description | Enter a description of the datasource. |
| IP/Host Name | Enter the Oracle service IP. |
| Port | Enter the Oracle service port. |
| Username | Set the username for Oracle connection. |
| Password | Set the password for 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. |
| 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

View File

@ -2,8 +2,8 @@
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 want to experience more complete functions and schedule massive tasks, we recommend you install follow [pseudo-cluster deployment](pseudo-cluster.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 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.

View File

@ -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)
* Use semicolon as default sql segment separator [#10869](https://github.com/apache/dolphinscheduler/pull/10869)

View File

@ -47,4 +47,5 @@ DolphinScheduler正常运行提供如下的网络端口配置
DolphinScheduler 推荐 Chrome 以及使用 Chromium 内核的较新版本浏览器访问前端可视化操作界面
## 时钟同步
为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间
为避免可能影响任务执行的内部集群通信问题,请确保所有集群节点上的时钟与公共时钟源同步,例如使用 Chrony 和/或 NTP。 同步时间确保集群中的每个节点都有相同的时间

View File

@ -28,6 +28,7 @@ PMC会定期基于活跃贡献者们对Dolphinscheduler的贡献从他们中提
发起提名的PMC成员负责向新的committer发出邀请并指导他/她建立ASF精神思想。
PMC成员应使用以下模板向新的committer发送一封电子邮件:
```
To: <invitee name>@gmail.com
Cc: private@dolphinscheduler.apache.org

View File

@ -12,3 +12,4 @@
- 数据库名:输入连接 ORACLE 的 ServiceName 或 SID
- Jdbc 连接参数:用于 ORACLE 连接的参数设置,以 JSON 形式填写
- 比如 `{"schema": "abc"}` 指定使用 `username` 用户下的 `abc` 数据库

View File

@ -29,33 +29,34 @@
- 也可以通过以下两种方式:
1.使用add_months()函数,该函数用于加减月份,
第一个入口参数为[yyyyMMdd],表示返回时间的格式
第二个入口参数为月份偏移量,表示加减多少个月
* 后 N 年:$[add_months(yyyyMMdd,12*N)]
* 前 N 年:$[add_months(yyyyMMdd,-12*N)]
* 后 N 月:$[add_months(yyyyMMdd,N)]
* 前 N 月:$[add_months(yyyyMMdd,-N)]
*******************************************
2.直接加减数字
在自定义格式后直接“+/-”数字
* 后 N 周:$[yyyyMMdd+7*N]
* 前 N 周:$[yyyyMMdd-7*N]
* 后 N 天:$[yyyyMMdd+N]
* 前 N 天:$[yyyyMMdd-N]
* 后 N 小时:$[HHmmss+N/24]
* 前 N 小时:$[HHmmss-N/24]
* 后 N 分钟:$[HHmmss+N/24/60]
* 前 N 分钟:$[HHmmss-N/24/60]
*******************************************
3.业务属性方式
在自定义格式后直接“+/-”数字
支持日志格式所有日期表达式例如yyyy-MM-dd/yyyyMMddHHmmss
* 当天:$[this_day(yyyy-MM-dd)]2022-08-26 => 2022-08-26
* 昨天:$[last_day(yyyy-MM-dd)]2022-08-26 => 2022-08-25
* 年的第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 月第一天:$[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 周的周一:$[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
1.使用add_months()函数,该函数用于加减月份,
第一个入口参数为[yyyyMMdd],表示返回时间的格式
第二个入口参数为月份偏移量,表示加减多少个月
* 后 N 年:$[add_months(yyyyMMdd,12*N)]
* 前 N 年:$[add_months(yyyyMMdd,-12*N)]
* 后 N 月:$[add_months(yyyyMMdd,N)]
* 前 N 月:$[add_months(yyyyMMdd,-N)]
*******************************************
2.直接加减数字
在自定义格式后直接“+/-”数字
* 后 N 周:$[yyyyMMdd+7*N]
* 前 N 周:$[yyyyMMdd-7*N]
* 后 N 天:$[yyyyMMdd+N]
* 前 N 天:$[yyyyMMdd-N]
* 后 N 小时:$[HHmmss+N/24]
* 前 N 小时:$[HHmmss-N/24]
* 后 N 分钟:$[HHmmss+N/24/60]
* 前 N 分钟:$[HHmmss-N/24/60]
*******************************************
3.业务属性方式
在自定义格式后直接“+/-”数字
支持日志格式所有日期表达式例如yyyy-MM-dd/yyyyMMddHHmmss
* 当天:$[this_day(yyyy-MM-dd)]2022-08-26 => 2022-08-26
* 昨天:$[last_day(yyyy-MM-dd)]2022-08-26 => 2022-08-25
* 年的第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 月第一天:$[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 周的周一:$[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

View File

@ -11,3 +11,4 @@
* 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)

View File

@ -17,22 +17,21 @@
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-api</artifactId>
<dependencies>
<dependency>
<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>
</dependencies>
</project>

View File

@ -25,6 +25,7 @@ import lombok.NonNull;
* alert channel for sending alerts
*/
public interface AlertChannel {
/**
* process and send alert
*

View File

@ -20,8 +20,8 @@
package org.apache.dolphinscheduler.alert.api;
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.SPIIdentify;
import java.util.List;
@ -29,6 +29,7 @@ import java.util.List;
* alert channel factory
*/
public interface AlertChannelFactory extends PrioritySPI {
/**
* Returns the name of the alert channel
*

View File

@ -20,6 +20,7 @@
package org.apache.dolphinscheduler.alert.api;
public final class AlertConstants {
/**
* the field name of alert show type
**/

View File

@ -25,6 +25,7 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum ShowType {
/**
* 0 TABLE;
* 1 TEXT;

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-dingtalk</artifactId>
<packaging>jar</packaging>

View File

@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "DingTalk";
@ -67,8 +68,10 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
RadioParam msgTypeParam = RadioParam
.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_MARKDOWN, DingTalkParamsConstants.DING_TALK_MSG_TYPE_MARKDOWN, false))
.addParamsOptions(new ParamsOptions(DingTalkParamsConstants.DING_TALK_MSG_TYPE_TEXT,
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)
.addValidate(Validate.newBuilder()
.setRequired(false)
@ -76,13 +79,15 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.build();
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()
.setRequired(false)
.build())
.build();
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()
.setRequired(false)
.build())
@ -98,7 +103,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.build();
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_NO, STRING_FALSE, false))
.setValue(STRING_FALSE)
@ -131,7 +137,8 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
.setPlaceholder("if enable use authentication, you need input password")
.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

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.dingtalk;
public final class DingTalkParamsConstants {
static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')";
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";

View File

@ -171,7 +171,8 @@ public final class DingTalkSender {
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;
if (Boolean.TRUE.equals(enableProxy)) {
@ -289,8 +290,12 @@ public final class DingTalkSender {
private void setMsgAt(Map<String, Object> items) {
Map<String, Object> at = new HashMap<>();
String[] atMobileArray = 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];
String[] atMobileArray =
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;
at.put("atMobiles", atMobileArray);
@ -313,7 +318,7 @@ public final class DingTalkSender {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
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) {
logger.error("generate sign error, message:{}", e);
}
@ -321,6 +326,7 @@ public final class DingTalkSender {
}
static final class DingTalkSendMsgResponse {
private Integer errcode;
private String errmsg;
@ -378,7 +384,8 @@ public final class DingTalkSender {
@Override
public String toString() {
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")";
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg="
+ this.getErrmsg() + ")";
}
}
}

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-email</artifactId>
<packaging>jar</packaging>

View File

@ -28,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class EmailAlertChannel implements AlertChannel {
private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class);
@Override

View File

@ -40,6 +40,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class EmailAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "Email";
@ -48,73 +49,88 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
@Override
public List<PluginParams> params() {
List<PluginParams> paramsList = new ArrayList<>();
InputParam receivesParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
.setPlaceholder("please input receives")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam receivesParam = InputParam
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS,
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
.setPlaceholder("please input receives")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam receiveCcsParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS, MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERCCS)
.build();
InputParam receiveCcsParam = InputParam
.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)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam mailSmtpHost =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, MailParamsConstants.MAIL_SMTP_HOST)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam mailSmtpPort = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
.setValue("25")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam mailSmtpPort =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, MailParamsConstants.MAIL_SMTP_PORT)
.setValue("25")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam mailSender = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam mailSender =
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, MailParamsConstants.MAIL_SENDER)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
RadioParam enableSmtpAuth = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
RadioParam enableSmtpAuth =
RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, MailParamsConstants.MAIL_SMTP_AUTH)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, MailParamsConstants.MAIL_USER)
.setPlaceholder("if enable use authentication, you need input user")
.build();
.setPlaceholder("if enable use authentication, you need input user")
.build();
PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
.setPlaceholder("if enable use authentication, you need input password")
.build();
PasswordParam mailPassword =
PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
.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)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
RadioParam enableTls = RadioParam
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE,
MailParamsConstants.MAIL_SMTP_STARTTLS_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.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)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.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)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_FALSE)
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam sslTrust = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST)
.setValue("*")
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam sslTrust = InputParam
.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, MailParamsConstants.MAIL_SMTP_SSL_TRUST)
.setValue("*")
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
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.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(), ShowType.TABLE_ATTACHMENT.getDescp(), false))
.setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.addParamsOptions(
new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TABLE_ATTACHMENT.getDescp(),
ShowType.TABLE_ATTACHMENT.getDescp(), false))
.setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
paramsList.add(receivesParam);
paramsList.add(receiveCcsParam);

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email;
public final class EmailConstants {
public static final String XLS_FILE_PATH = "xls.file.path";
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 HTML_HEADER_PREFIX = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"
+ "<html>"
+ "<head>"
+ "<title>dolphinscheduler</title>"
+ "<meta name='Keywords' content=''>"
+ "<meta name='Description' content=''>"
+ "<style type=\"text/css\">"
+ "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 th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;text-align: left;}"
+ "table td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;text-align: left;}"
+ "</style>"
+ "</head>"
+ "<body style=\"margin:0;padding:0\"><table border=\"1px\" cellpadding=\"5px\" cellspacing=\"-10px\"> ";
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'>"
+ "<html>"
+ "<head>"
+ "<title>dolphinscheduler</title>"
+ "<meta name='Keywords' content=''>"
+ "<meta name='Description' content=''>"
+ "<style type=\"text/css\">"
+ "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 th {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #dedede;text-align: left;}"
+ "table td {border-width: 1px;padding: 8px;border-style: solid;border-color: #666666;background-color: #ffffff;text-align: left;}"
+ "</style>"
+ "</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>";

View File

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ExcelUtils {
private static final int XLSX_WINDOW_ROW = 10000;
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()) {
headerList.add(en.getKey());
}
try (SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);
FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) {
try (
SXSSFWorkbook wb = new SXSSFWorkbook(XLSX_WINDOW_ROW);
FileOutputStream fos = new FileOutputStream(String.format("%s/%s.xlsx", xlsFilePath, title))) {
// declare a workbook
// generate a table
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
//set the height of the first line
// set the height of the first line
row.setHeight((short) 500);
//set Horizontal right
// set Horizontal right
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.RIGHT);
//setting excel headers
// setting excel headers
for (int i = 0; i < headerList.size(); i++) {
Cell cell = row.createCell(i);
cell.setCellStyle(cellStyle);
cell.setCellValue(headerList.get(i));
}
//setting excel body
// setting excel body
int rowIndex = 1;
for (LinkedHashMap<String, Object> itemsMap : itemsList) {
Object[] values = itemsMap.values().toArray();
row = sheet.createRow(rowIndex);
//setting excel body height
// setting excel body height
row.setHeight((short) 500);
rowIndex++;
for (int j = 0; j < values.length; j++) {
@ -117,7 +119,7 @@ public final class ExcelUtils {
sheet.setColumnWidth(i, headerList.get(i).length() * 800);
}
//setting file output
// setting file output
wb.write(fos);
wb.dispose();
} catch (Exception e) {

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email;
public final class MailParamsConstants {
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";

View File

@ -60,6 +60,7 @@ import org.slf4j.LoggerFactory;
import com.sun.mail.smtp.SMTPProvider;
public final class MailSender {
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
private final List<String> receivers;
@ -178,7 +179,7 @@ public final class MailSender {
}
if (CollectionUtils.isNotEmpty(receiverCcs)) {
//cc
// cc
for (String receiverCc : receiverCcs) {
email.addCc(receiverCc);
}
@ -188,12 +189,13 @@ public final class MailSender {
} catch (Exception 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 {
String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp())
? "Please see the attachment " + title + EmailConstants.EXCEL_SUFFIX_XLSX
: htmlTable(content, false));
? "Please see the attachment " + title + EmailConstants.EXCEL_SUFFIX_XLSX
: htmlTable(content, false));
attachment(title, content, partContent);
@ -294,6 +296,7 @@ public final class MailSender {
props.setProperty(MailParamsConstants.MAIL_SMTP_SSL_TRUST, sslTrust);
Authenticator auth = new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
// mail username and password
@ -309,7 +312,8 @@ public final class MailSender {
/**
* 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
*/
@ -329,7 +333,8 @@ public final class MailSender {
MimeBodyPart part2 = new MimeBodyPart();
// add random uuid to filename to avoid potential issue
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()) {
file.getParentFile().mkdirs();
}
@ -352,7 +357,8 @@ public final class MailSender {
/**
* 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

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.email.exception;
public class AlertEmailException extends RuntimeException {
public AlertEmailException(String errMsg) {
super(errMsg);
}

View File

@ -33,15 +33,14 @@ import java.util.Set;
import org.slf4j.Logger;
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.node.ArrayNode;
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 static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class);
@ -55,7 +54,8 @@ public class DefaultHTMLTemplate implements AlertTemplate {
case TEXT:
return getTextTypeMessage(content);
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));
}
}

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-feishu</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class FeiShuAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData();

View File

@ -38,6 +38,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "Feishu";
@ -45,39 +46,44 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
@Override
public List<PluginParams> params() {
InputParam webHookParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam webHookParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_WEB_HOOK, FeiShuParamsConstants.WEB_HOOK)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
RadioParam isEnableProxy =
RadioParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE, FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
RadioParam
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY_ENABLE,
FeiShuParamsConstants.FEI_SHU_PROXY_ENABLE)
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
.setValue(STRING_TRUE)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam proxyParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY, FeiShuParamsConstants.FEI_SHU_PROXY)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PROXY, FeiShuParamsConstants.FEI_SHU_PROXY)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
InputParam portParam = InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
InputParam portParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PORT, FeiShuParamsConstants.FEI_SHU_PORT)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
InputParam userParam =
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_USER, FeiShuParamsConstants.FEI_SHU_USER)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
PasswordParam passwordParam = PasswordParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password")
.build();
InputParam.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_USER, FeiShuParamsConstants.FEI_SHU_USER)
.addValidate(Validate.newBuilder()
.setRequired(false).build())
.build();
PasswordParam passwordParam = PasswordParam
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password")
.build();
return Arrays.asList(webHookParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.feishu;
public final class FeiShuParamsConstants {
public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')";
static final String WEB_HOOK = "$t('webhook')";
static final String NAME_WEB_HOOK = "WebHook";

View File

@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
public final class FeiShuSender {
private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
private final String url;
private final Boolean enableProxy;
@ -98,7 +99,8 @@ public final class FeiShuSender {
return alertResult;
}
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;
}
@ -164,7 +166,8 @@ public final class FeiShuSender {
} finally {
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;
} finally {
httpClient.close();
@ -172,6 +175,7 @@ public final class FeiShuSender {
}
static final class FeiShuSendMsgResponse {
@JsonProperty("Extra")
private String extra;
@JsonProperty("StatusCode")
@ -229,7 +233,8 @@ public final class FeiShuSender {
}
final Object this$statusMessage = this.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 true;
@ -248,7 +253,8 @@ public final class FeiShuSender {
}
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() + ")";
}
}
}

View File

@ -29,11 +29,13 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
public final class HttpRequestUtil {
private HttpRequestUtil() {
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) {
HttpHost httpProxy = new HttpHost(proxy, port);
CredentialsProvider provider = new BasicCredentialsProvider();

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-http</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class HttpAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData();

View File

@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class HttpAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "Http";
@ -39,39 +40,43 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
public List<PluginParams> params() {
InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
.setPlaceholder("input request URL")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
.setPlaceholder("input request URL")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
.setPlaceholder("input request headers as JSON format ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam headerParams =
InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
.setPlaceholder("input request headers as JSON format ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
.setPlaceholder("input request body as JSON format ")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam bodyParams =
InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
.setPlaceholder("input request body as JSON format ")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam contentField = InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
.setPlaceholder("input alert msg field name")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam contentField =
InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
.setPlaceholder("input alert msg field name")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam requestType = InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
.setPlaceholder("input request type POST or GET")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam requestType =
InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
.setPlaceholder("input request type POST or GET")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
return Arrays.asList(url, requestType, headerParams, bodyParams, contentField);
}

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.http;
public final class HttpAlertConstants {
public static final String URL = "$t('url')";
public static final String NAME_URL = "url";

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-pagerduty</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class PagerDutyAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData();

View File

@ -17,17 +17,20 @@
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.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.input.InputParam;
import java.util.Collections;
import java.util.List;
import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "PagerDuty";
@ -35,7 +38,9 @@ public final class PagerDutyAlertChannelFactory implements AlertChannelFactory {
@Override
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()
.setRequired(true)
.build())

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
public final class PagerDutyParamsConstants {
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_EVENT_ACTION_TRIGGER = "trigger";

View File

@ -17,21 +17,29 @@
package org.apache.dolphinscheduler.plugin.alert.pagerduty;
import com.google.common.base.Preconditions;
import org.apache.dolphinscheduler.alert.api.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import java.io.IOException;
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 {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(PagerDutySender.class);
private final String integrationKey;
@ -41,7 +49,7 @@ public final class PagerDutySender {
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.setStatus("false");
alertResult.setMessage("send pager duty alert fail.");
@ -72,10 +80,10 @@ public final class PagerDutySender {
if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
alertResult.setStatus("true");
alertResult.setMessage("send pager duty alert success");
}else {
} else {
log.info("send pager duty alert fail, statusCode : {}", statusCode);
}
}finally {
} finally {
response.close();
}
} catch (IOException e) {

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-script</artifactId>
<packaging>jar</packaging>
</project>

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script;
public final class OSUtils {
private OSUtils() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}

View File

@ -23,6 +23,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ProcessUtils {
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
private ProcessUtils() {

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class ScriptAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertinfo) {
AlertData alertData = alertinfo.getAlertData();

View File

@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class ScriptAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "Script";
@ -40,26 +41,30 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
@Override
public List<PluginParams> params() {
InputParam scriptUserParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.setPlaceholder("please enter your custom parameters, which will be passed to you when calling your script")
.build();
InputParam scriptUserParam = InputParam
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS, ScriptParamsConstants.SCRIPT_USER_PARAMS)
.addValidate(Validate.newBuilder()
.setRequired(false)
.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
InputParam scriptPathParam = InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("please upload the file to the disk directory of the alert server,"
+ " and ensure that the path is absolute and has the corresponding access rights")
.build();
InputParam scriptPathParam =
InputParam.newBuilder(ScriptParamsConstants.NAME_SCRIPT_PATH, ScriptParamsConstants.SCRIPT_PATH)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("please upload the file to the disk directory of the alert server,"
+ " 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)
.addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false))
.setValue(ScriptType.SHELL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
RadioParam scriptTypeParams = RadioParam
.newBuilder(ScriptParamsConstants.NAME_SCRIPT_TYPE, ScriptParamsConstants.SCRIPT_TYPE)
.addParamsOptions(new ParamsOptions(ScriptType.SHELL.getDescp(), ScriptType.SHELL.getDescp(), false))
.setValue(ScriptType.SHELL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
return Arrays.asList(scriptUserParam, scriptPathParam, scriptTypeParams);
}

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script;
public final class ScriptParamsConstants {
static final String SCRIPT_TYPE = "$t('scriptType')";
static final String NAME_SCRIPT_TYPE = "type";

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.script;
public enum ScriptType {
SHELL(0, "SHELL"),
;

View File

@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class StreamGobbler extends Thread {
private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class);
private final InputStream inputStream;

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-slack</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class SlackAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData();

View File

@ -30,6 +30,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class SlackAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "Slack";
@ -39,19 +40,20 @@ public final class SlackAlertChannelFactory implements AlertChannelFactory {
public List<PluginParams> params() {
List<PluginParams> paramsList = new LinkedList<>();
InputParam webHookParam = InputParam.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input WebHook Url")
.build();
InputParam webHookParam = InputParam
.newBuilder(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME, SlackParamsConstants.SLACK_WEB_HOOK_URL)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input WebHook Url")
.build();
InputParam botName = InputParam.newBuilder(SlackParamsConstants.SLACK_BOT_NAME, SlackParamsConstants.SLACK_BOT)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input the bot username")
.build();
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("Input the bot username")
.build();
paramsList.add(webHookParam);
paramsList.add(botName);

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.slack;
public final class SlackParamsConstants {
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_BOT = "$t('Username')";

View File

@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
public final class SlackSender {
private static final Logger logger = LoggerFactory.getLogger(SlackSender.class);
private final String webHookUrl;
@ -53,7 +54,8 @@ public final class SlackSender {
webHookUrl = slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME);
botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME);
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");
}
@ -120,17 +122,17 @@ public final class SlackSender {
final int elementLen = maxLen;
StringBuilder stringBuilder = new StringBuilder(200);
stringBuilder.append(headers.stream()
.map(header -> generateString(header, elementLen, " "))
.collect(Collectors.joining("|")));
.map(header -> generateString(header, elementLen, " "))
.collect(Collectors.joining("|")));
stringBuilder.append("\n");
for (List<String> element : elements) {
stringBuilder.append(element.stream()
.map(lement -> generateString("", elementLen, "-"))
.collect(Collectors.joining("|")));
.map(lement -> generateString("", elementLen, "-"))
.collect(Collectors.joining("|")));
stringBuilder.append("\n");
stringBuilder.append(element.stream()
.map(e -> generateString(e, elementLen, " "))
.collect(Collectors.joining("|")));
.map(e -> generateString(e, elementLen, " "))
.collect(Collectors.joining("|")));
stringBuilder.append("\n");
}
return String.format("```%s```", stringBuilder);

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-telegram</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class TelegramAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo info) {
Map<String, String> alertParams = info.getAlertParams();

View File

@ -17,7 +17,11 @@
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.AlertChannelFactory;
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.List;
import static org.apache.dolphinscheduler.spi.utils.Constants.*;
import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class TelegramAlertChannelFactory implements AlertChannelFactory {
@ -49,40 +53,50 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
@Override
public List<PluginParams> params() {
InputParam webHookParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK)
InputParam webHookParam = InputParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK, TelegramParamsConstants.TELEGRAM_WEB_HOOK)
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.setPlaceholder("telegram web hook")
.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()
.setRequired(true)
.build())
.setPlaceholder("telegram bot token")
.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()
.setRequired(true)
.build())
.setPlaceholder("telegram channel chat id")
.build();
SelectParam parseMode = SelectParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE, TelegramParamsConstants.TELEGRAM_PARSE_MODE)
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT, 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))
SelectParam parseMode = SelectParam
.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PARSE_MODE,
TelegramParamsConstants.TELEGRAM_PARSE_MODE)
.addOptions(new ParamsOptions(TelegramAlertConstants.PARSE_MODE_TXT,
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)
.addValidate(Validate.newBuilder()
.setRequired(true)
.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_NO, STRING_FALSE, false))
.setValue(STRING_FALSE)
@ -91,33 +105,37 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
.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()
.setRequired(false)
.build())
.build();
InputParam portParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam portParam =
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_PORT, TelegramParamsConstants.TELEGRAM_PORT)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam userParam = InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER)
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam userParam =
InputParam.newBuilder(TelegramParamsConstants.NAME_TELEGRAM_USER, TelegramParamsConstants.TELEGRAM_USER)
.addValidate(Validate.newBuilder()
.setRequired(false)
.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()
.setRequired(false)
.build())
.setPlaceholder("if enable use authentication, you need input password")
.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);
}
}

View File

@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.plugin.alert.telegram;
public final class TelegramParamsConstants {
static final String TELEGRAM_WEB_HOOK = "$t('webHook')";

View File

@ -17,11 +17,11 @@
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.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
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.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;
public final class TelegramSender {
private static final Logger logger = LoggerFactory.getLogger(TelegramSender.class);
@ -69,7 +72,6 @@ public final class TelegramSender {
private String password;
TelegramSender(Map<String, String> config) {
url = config.get(TelegramParamsConstants.NAME_TELEGRAM_WEB_HOOK);
botToken = config.get(TelegramParamsConstants.NAME_TELEGRAM_BOT_TOKEN);
@ -132,14 +134,13 @@ public final class TelegramSender {
return result;
}
private String sendInvoke(String title, String content) throws IOException {
HttpPost httpPost = buildHttpPost(url, buildMsgJsonStr(content));
CloseableHttpClient httpClient;
if (Boolean.TRUE.equals(enableProxy)) {
if (StringUtils.isNotEmpty(user) && StringUtils.isNotEmpty(password)) {
httpClient = getProxyClient(proxy, port, user, password);
}else {
} else {
httpClient = getDefaultClient();
}
RequestConfig rcf = getProxyConfig(proxy, port);
@ -180,6 +181,7 @@ public final class TelegramSender {
}
static class TelegramSendMsgResponse {
@JsonProperty("ok")
private Boolean ok;
@JsonProperty("error_code")

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-webexteams</artifactId>
<packaging>jar</packaging>

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.webexteams;
public class WebexMessage {
private String roomId;
private String toPersonId;
private String toPersonEmail;

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class WebexTeamsAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData();

View File

@ -32,6 +32,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "WebexTeams";
@ -40,48 +41,63 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
@Override
public List<PluginParams> params() {
List<PluginParams> paramsList = new ArrayList<>();
InputParam botAccessToken = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN, WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
.setPlaceholder("Please enter the robot's access token you were given")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam botAccessToken = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN,
WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
.setPlaceholder("Please enter the robot's access token you were given")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam roomId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
.setPlaceholder("The room ID of the message")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam roomId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
.setPlaceholder("The room ID of the message")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam toPersonId = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
.setPlaceholder("The person ID of the message recipient")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam toPersonId = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
.setPlaceholder("The person ID of the message recipient")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam toPersonEmail = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL, WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
.setPlaceholder("The email address of the message recipient")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam toPersonEmail = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL,
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
.setPlaceholder("The email address of the message recipient")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam atSomeoneInRoom = InputParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM, WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
.setPlaceholder("use ,(eng commas) to separate multiple emails")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam atSomeoneInRoom = InputParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM,
WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
.setPlaceholder("use ,(eng commas) to separate multiple emails")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
RadioParam destination = RadioParam.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION, WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION)
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(), WebexTeamsDestination.ROOM_ID.getDescp(), false))
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(), 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();
RadioParam destination = RadioParam
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_DESTINATION,
WebexTeamsParamsConstants.WEBEX_TEAMS_DESTINATION)
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.ROOM_ID.getDescp(),
WebexTeamsDestination.ROOM_ID.getDescp(), false))
.addParamsOptions(new ParamsOptions(WebexTeamsDestination.PERSON_EMAIL.getDescp(),
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(roomId);

View File

@ -25,6 +25,7 @@ import java.util.Map;
import com.google.common.base.Functions;
public enum WebexTeamsDestination {
/**
* 0 ROOM_ID;
* 1 PERSON_EMAIL;
@ -51,7 +52,8 @@ public enum WebexTeamsDestination {
}
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) {
if (WEBEX_TEAMS_DESTINATION_MAP.containsKey(descp)) {

View File

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import com.google.common.base.Preconditions;
public final class WebexTeamsSender {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(WebexTeamsSender.class);
private final String botAccessToken;
@ -57,7 +58,9 @@ public final class WebexTeamsSender {
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(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) {
@ -137,11 +140,11 @@ public final class WebexTeamsSender {
public static String addAtPersonEmailInRoom(String formatContent, String atPersonEmailInRoom) {
String[] emailArr = atPersonEmailInRoom.split(",");
StringBuilder formatContentBuilder = new StringBuilder(formatContent);
for (String email: emailArr) {
for (String email : emailArr) {
formatContentBuilder.append(" <@personEmail:").append(email).append(">");
}
return formatContentBuilder.toString();
return formatContentBuilder.toString();
}
public static String formatContent(AlertData alertData) {

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-wechat</artifactId>
<packaging>jar</packaging>

View File

@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
import java.util.Map;
public final class WeChatAlertChannel implements AlertChannel {
@Override
public AlertResult process(AlertInfo info) {
AlertData alertData = info.getAlertData();

View File

@ -34,6 +34,7 @@ import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class)
public final class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "WeChat";
@ -41,47 +42,58 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override
public List<PluginParams> params() {
InputParam corpIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
.setPlaceholder("please input corp id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam corpIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
.setPlaceholder("please input corp id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam secretParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
.setPlaceholder("please input secret ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam secretParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
.setPlaceholder("please input secret ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam usersParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam usersParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
.setPlaceholder("use `|` to separate userIds and `@all` to everyone ")
.addValidate(Validate.newBuilder()
.setRequired(false)
.build())
.build();
InputParam agentIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
.setPlaceholder("please input agent id or chat id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam agentIdParam = InputParam
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID,
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
.setPlaceholder("please input agent id or chat id ")
.addValidate(Validate.newBuilder()
.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.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
.addParamsOptions(
new ParamsOptions(WeChatType.APPCHAT.getDescp(), WeChatType.APPCHAT.getDescp(), false))
.setValue(WeChatType.APP.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
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.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.setValue(ShowType.MARKDOWN.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
.addParamsOptions(new ParamsOptions(ShowType.MARKDOWN.getDescp(), ShowType.MARKDOWN.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.setValue(ShowType.MARKDOWN.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
return Arrays.asList(corpIdParam, secretParam, usersParam, agentIdParam, sendType, showType);
}

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.wechat;
public final class WeChatAlertConstants {
static final String MARKDOWN_QUOTE = ">";
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" +
"={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";

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.plugin.alert.wechat;
public final class WeChatAlertParamsConstants {
static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')";
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId";
static final String ENTERPRISE_WE_CHAT_SECRET = "$t('secret')";

View File

@ -17,10 +17,16 @@
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.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
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.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
@ -40,11 +44,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import static java.util.Objects.requireNonNull;
import static org.apache.dolphinscheduler.plugin.alert.wechat.WeChatAlertConstants.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class WeChatSender {
private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
private static final String MUST_NOT_NULL = " must not null";
private static final String ALERT_STATUS = "false";
@ -210,11 +214,15 @@ public final class WeChatSender {
String msgJson = "";
if (sendType.equals(WeChatType.APP.getDescp())) {
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);
} else if (sendType.equals(WeChatType.APPCHAT.getDescp())) {
enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_APP_CHAT_PUSH_URL.replace(TOKEN_REGEX, weChatToken);
WechatAppChatMessage wechatAppChatMessage = new WechatAppChatMessage(weChatAgentIdChatId, showType, contentMap, WE_CHAT_MESSAGE_SAFE_PUBLICITY);
enterpriseWeChatPushUrlReplace =
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);
}
@ -248,6 +256,7 @@ public final class WeChatSender {
}
static final class WeChatSendMsgResponse {
private Integer errcode;
private String errmsg;
@ -302,7 +311,8 @@ public final class WeChatSender {
}
public String toString() {
return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")";
return "WeChatSender.WeChatSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg()
+ ")";
}
}
}

View File

@ -15,10 +15,10 @@
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.alert.wechat;
public enum WeChatType {
APP(1, "APP/应用"),
APPCHAT(2, "GROUP CHAT/群聊"),
;

View File

@ -25,8 +25,8 @@ public class WechatAppChatMessage {
private String chatid;
private String msgtype;
private Map<String,String> text;
private Map<String,String> markdown;
private Map<String, String> text;
private Map<String, String> markdown;
private Integer safe;
public String getChatid() {

View File

@ -99,7 +99,8 @@ public class 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.msgtype = msgtype;
this.agentid = agentid;

View File

@ -15,15 +15,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler-alert</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler-alert</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dolphinscheduler-alert-plugins</artifactId>
<packaging>pom</packaging>

View File

@ -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.radio.RadioParam;
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.HashMap;
@ -42,10 +37,15 @@ import java.util.List;
import java.util.Map;
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
public final class AlertPluginManager {
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
private final PluginDao pluginDao;
@ -59,20 +59,22 @@ public final class AlertPluginManager {
private final PluginParams warningTypeParams = getWarningTypeParams();
public PluginParams getWarningTypeParams() {
return
RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE)
.addParamsOptions(new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false))
.addParamsOptions(new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false))
.addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false))
.setValue(WarningType.ALL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
return RadioParam.newBuilder(AlertConstants.NAME_WARNING_TYPE, AlertConstants.WARNING_TYPE)
.addParamsOptions(
new ParamsOptions(WarningType.SUCCESS.getDescp(), WarningType.SUCCESS.getDescp(), false))
.addParamsOptions(
new ParamsOptions(WarningType.FAILURE.getDescp(), WarningType.FAILURE.getDescp(), false))
.addParamsOptions(new ParamsOptions(WarningType.ALL.getDescp(), WarningType.ALL.getDescp(), false))
.setValue(WarningType.ALL.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
}
@EventListener
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()) {
String name = entry.getKey();
AlertChannelFactory factory = entry.getValue();

View File

@ -34,6 +34,7 @@ import io.netty.channel.Channel;
@Component
public final class AlertRequestProcessor implements NettyRequestProcessor {
private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class);
private final AlertSenderService alertSenderService;
@ -44,18 +45,19 @@ public final class AlertRequestProcessor implements NettyRequestProcessor {
@Override
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(
command.getBody(), AlertSendRequestCommand.class);
command.getBody(), AlertSendRequestCommand.class);
logger.info("Received command : {}", alertSendRequestCommand);
AlertSendResponseCommand alertSendResponseCommand = alertSenderService.syncHandler(
alertSendRequestCommand.getGroupId(),
alertSendRequestCommand.getTitle(),
alertSendRequestCommand.getContent(),
alertSendRequestCommand.getWarnType());
alertSendRequestCommand.getGroupId(),
alertSendRequestCommand.getTitle(),
alertSendRequestCommand.getContent(),
alertSendRequestCommand.getWarnType());
channel.writeAndFlush(alertSendResponseCommand.convert2Command(command.getOpaque()));
}
}

View File

@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.alert;
import java.util.function.Supplier;
import lombok.experimental.UtilityClass;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.Metrics;
import lombok.experimental.UtilityClass;
@UtilityClass
public class AlertServerMetrics {

View File

@ -17,18 +17,16 @@
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dolphinscheduler</artifactId>
<groupId>org.apache.dolphinscheduler</groupId>
<artifactId>dolphinscheduler</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>dolphinscheduler-alert</artifactId>
<packaging>pom</packaging>
<modules>
<module>dolphinscheduler-alert-api</module>

View File

@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.common.enums.PluginType;
import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
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.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;

View File

@ -27,6 +27,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AccessLogAnnotation {
// ignore request args
String[] ignoreRequestArgs() default {"loginUser"};

View File

@ -47,6 +47,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
@Aspect
@Component
public class AccessLogAspect {
private static final Logger logger = LoggerFactory.getLogger(AccessLogAspect.class);
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);
@Pointcut("@annotation(org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation)")
public void logPointCut(){
public void logPointCut() {
// Do nothing because of it's a pointcut
}
@ -65,7 +66,7 @@ public class AccessLogAspect {
long startTime = System.currentTimeMillis();
// fetch AccessLogAnnotation
MethodSignature sign = (MethodSignature) proceedingJoinPoint.getSignature();
MethodSignature sign = (MethodSignature) proceedingJoinPoint.getSignature();
Method method = sign.getMethod();
AccessLogAnnotation annotation = method.getAnnotation(AccessLogAnnotation.class);
@ -73,7 +74,8 @@ public class AccessLogAspect {
// log request
if (!annotation.ignoreRequest()) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
ServletRequestAttributes attributes =
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes != null) {
HttpServletRequest request = attributes.getRequest();
String traceIdFromHeader = request.getHeader(TRACE_ID);
@ -92,7 +94,8 @@ public class AccessLogAspect {
userName,
request.getRequestURI(),
request.getMethod(),
proceedingJoinPoint.getSignature().getDeclaringTypeName() + "." + proceedingJoinPoint.getSignature().getName(),
proceedingJoinPoint.getSignature().getDeclaringTypeName() + "."
+ proceedingJoinPoint.getSignature().getName(),
argsString);
}
@ -102,7 +105,8 @@ public class AccessLogAspect {
// log response
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;
@ -134,7 +138,7 @@ public class AccessLogAspect {
boolean exists = false;
while (matcher.find()) {
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;
}
}

View File

@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date;
public class AuditMessage {
private User user;
private Date auditDate;
@ -34,7 +35,8 @@ public class AuditMessage {
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.auditDate = auditDate;
this.resourceType = resourceType;

View File

@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
@EnableConfigurationProperties
@ConfigurationProperties(value = "audit", ignoreUnknownFields = false)
public class AuditConfiguration {
private boolean enabled;
public boolean getEnabled() {
@ -34,4 +35,4 @@ public class AuditConfiguration {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
}

View File

@ -18,21 +18,25 @@ package org.apache.dolphinscheduler.api.configuration;
import static java.util.stream.Collectors.toList;
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.RequestParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.OperationBuilderPlugin;
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
public class OpenAPITranslationConfiguration {
@ -60,20 +64,20 @@ public class OpenAPITranslationConfiguration {
.collect(toSet());
Collection<RequestParameter> parameters = operation.getRequestParameters().stream()
.map(it -> new RequestParameter(
it.getName(),
it.getIn(),
messageSource.getMessage(it.getDescription(), null, it.getDescription(), locale),
it.getRequired(),
it.getDeprecated(),
it.getHidden(),
it.getParameterSpecification(),
it.getScalarExample(),
it.getExamples(),
it.getPrecedence(),
it.getExtensions(),
it.getParameterIndex()))
.collect(toList());
.map(it -> new RequestParameter(
it.getName(),
it.getIn(),
messageSource.getMessage(it.getDescription(), null, it.getDescription(), locale),
it.getRequired(),
it.getDeprecated(),
it.getHidden(),
it.getParameterSpecification(),
it.getScalarExample(),
it.getExamples(),
it.getPrecedence(),
it.getExtensions(),
it.getParameterIndex()))
.collect(toList());
context.operationBuilder()
.notes(notes)

View File

@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
@EnableConfigurationProperties
@ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false)
public class PythonGatewayConfiguration {
private boolean enabled;
private String gatewayServerAddress;
private int gatewayServerPort;

View File

@ -24,6 +24,9 @@ import org.apache.dolphinscheduler.common.config.YamlPropertySourceFactory;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.stereotype.Component;
import lombok.Getter;
import lombok.Setter;
@Component
@EnableConfigurationProperties
@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)));
cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD)));
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)));
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)));
return defaultTaskTypes;
}

View File

@ -17,11 +17,11 @@
package org.apache.dolphinscheduler.api.configuration;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

View File

@ -18,6 +18,7 @@
package org.apache.dolphinscheduler.api.constants;
import org.apache.dolphinscheduler.api.enums.ExecuteType;
import java.util.HashMap;
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 ALERT_GROUP_VIEW = "security:alert-group:view";
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 TENANT_MANAGER = "security:tenant:view";
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 final static Map<ExecuteType,String> map = new HashMap<ExecuteType,String>();
public final static Map<ExecuteType, String> map = new HashMap<ExecuteType, String>();
static{
for(ExecuteType type : ExecuteType.values()){
switch (type){
static {
for (ExecuteType type : ExecuteType.values()) {
switch (type) {
case REPEAT_RUNNING:
map.put(type,RERUN);
map.put(type, RERUN);
break;
case RECOVER_SUSPENDED_PROCESS:
map.put(type,RECOVERY_SUSPEND);
map.put(type, RECOVERY_SUSPEND);
break;
case START_FAILURE_TASK_PROCESS:
map.put(type,FAILED_TO_RETRY);
map.put(type, FAILED_TO_RETRY);
break;
case STOP:
map.put(type,STOP);
map.put(type, STOP);
break;
case PAUSE:
map.put(type,PAUSE);
map.put(type, PAUSE);
break;
case NONE:
map.put(type,null);
map.put(type, null);
break;
default:
}

View File

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AccessTokenService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;

View File

@ -30,8 +30,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AlertGroupService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;

View File

@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;

View File

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.ClusterService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;

View File

@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.service.DqExecuteResultService;
import org.apache.dolphinscheduler.api.service.DqRuleService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;

View File

@ -36,10 +36,10 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.DataSourceService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
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.spi.datasource.ConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;

View File

@ -21,6 +21,7 @@ package org.apache.dolphinscheduler.api.controller;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
@ -29,6 +30,7 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
public class DsErrorController implements ErrorController {
@RequestMapping("/error")
public ModelAndView handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);

View File

@ -29,8 +29,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.EnvironmentService;
import org.apache.dolphinscheduler.api.utils.Result;
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.plugin.task.api.utils.ParameterUtils;
import springfox.documentation.annotations.ApiIgnore;

Some files were not shown because too many files have changed in this diff Show More