diff --git a/.github/workflows/ci_ut.yml b/.github/workflows/ci_ut.yml
index 152d7ee8c9..a0b7d24278 100644
--- a/.github/workflows/ci_ut.yml
+++ b/.github/workflows/ci_ut.yml
@@ -15,7 +15,7 @@
# limitations under the License.
#
-on: ["pull_request"]
+on: [push, "pull_request"]
env:
DOCKER_DIR: ./docker
LOG_DIR: /tmp/dolphinscheduler
@@ -49,11 +49,12 @@ jobs:
export MAVEN_OPTS='-Dmaven.repo.local=.m2/repository -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -Xmx3g'
mvn test -Dmaven.test.skip=false cobertura:cobertura
CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash)
- - name: Run SonarCloud analysis
+ - name: Run SonarCloud Analysis
run: >
- mvn clean --batch-mode
- verify
- org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.1.1688:sonar
+ mvn verify --batch-mode
+ org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.1.1688:sonar
+ -Dsonar.junit.reportPaths=target/cobertura
+ -Dmaven.test.skip=true
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=apache
-Dsonar.projectKey=apache-dolphinscheduler
diff --git a/README.md b/README.md
index bc7dba684f..93fb7a40b7 100644
--- a/README.md
+++ b/README.md
@@ -58,25 +58,25 @@ Overload processing: Task queue mechanism, the number of schedulable tasks on a
### Document
-- Backend deployment documentation
+- Backend deployment documentation
-- Front-end deployment documentation
+- Front-end deployment documentation
-- [**User manual**](https://dolphinscheduler.apache.org/en-us/docs/user_doc/system-manual.html?_blank "System manual")
+- [**User manual**](https://dolphinscheduler.apache.org/en-us/docs/1.2.0/user_doc/system-manual.html?_blank "System manual")
-- [**Upgrade document**](https://dolphinscheduler.apache.org/en-us/docs/release/upgrade.html?_blank "Upgrade document")
+- [**Upgrade document**](https://dolphinscheduler.apache.org/en-us/docs/1.2.0/release/upgrade.html?_blank "Upgrade document")
- Online Demo
-More documentation please refer to [DolphinScheduler online documentation]
+More documentation please refer to [DolphinScheduler online documentation]
### Recent R&D plan
Work plan of Dolphin Scheduler: [R&D plan](https://github.com/apache/incubator-dolphinscheduler/projects/1), Under the `In Develop` card is what is currently being developed, TODO card is to be done (including feature ideas)
-### How to contribute code
+### How to contribute
-Welcome to participate in contributing code, please refer to the process of submitting the code:
-[[How to contribute code](https://github.com/apache/incubator-dolphinscheduler/issues/310)]
+Welcome to participate in contributing, please refer to the process of submitting the code:
+[[How to contribute](https://dolphinscheduler.apache.org/en-us/docs/development/contribute.html)]
### How to Build
diff --git a/README_zh_CN.md b/README_zh_CN.md
index 8141763c33..c7173ad9ba 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -44,27 +44,27 @@ Dolphin Scheduler Official Website
### 文档
-- 后端部署文档
+- 后端部署文档
-- 前端部署文档
+- 前端部署文档
-- [**使用手册**](https://dolphinscheduler.apache.org/zh-cn/docs/user_doc/system-manual.html?_blank "系统使用手册")
+- [**使用手册**](https://dolphinscheduler.apache.org/zh-cn/docs/1.2.0/user_doc/system-manual.html?_blank "系统使用手册")
-- [**升级文档**](https://dolphinscheduler.apache.org/zh-cn/docs/release/upgrade.html?_blank "升级文档")
+- [**升级文档**](https://dolphinscheduler.apache.org/zh-cn/docs/1.2.0/release/upgrade.html?_blank "升级文档")
- 我要体验
-更多文档请参考 DolphinScheduler中文在线文档
+更多文档请参考 DolphinScheduler中文在线文档
### 近期研发计划
DolphinScheduler的工作计划:研发计划 ,其中 In Develop卡片下是正在研发的功能,TODO卡片是待做事项(包括 feature ideas)
-### 贡献代码
+### 参与贡献
-非常欢迎大家来参与贡献代码,提交代码流程请参考:
-[[How to contribute code](https://github.com/apache/incubator-dolphinscheduler/issues/310)]
+非常欢迎大家来参与贡献,贡献流程请参考:
+[[参与贡献](https://dolphinscheduler.apache.org/zh-cn/docs/development/contribute.html)]
### How to Build
@@ -88,12 +88,12 @@ Dolphin Scheduler使用了很多优秀的开源项目,比如google的guava、g
### 获得帮助
-1. Submit an issue
-1. Mail to dev-subscribe@dolphinscheduler.apache.org, follow the reply to subscribe the mail list. then you can send mail to dev@dolphinscheduler.apache.org.
-1. Contact WeChat group manager, ID 510570367. This is for Mandarin(CN) discussion.
+1. 提交issue
+1. 先订阅邮件开发列表:[订阅邮件列表](https://dolphinscheduler.apache.org/zh-cn/docs/1.2.0/user_doc/subscribe.html), 订阅成功后发送邮件到dev@dolphinscheduler.apache.org.
+1. 联系微信群助手(ID:dailidong66). 微信仅用于中国用户讨论.
### 版权
-Please refer to [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) file.
+请参考 [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) 文件.
diff --git a/dolphinscheduler-alert/pom.xml b/dolphinscheduler-alert/pom.xml
index ead46f5e8d..188bfa3d9e 100644
--- a/dolphinscheduler-alert/pom.xml
+++ b/dolphinscheduler-alert/pom.xml
@@ -36,15 +36,34 @@
junittest
+
+ org.mockito
+ mockito-core
+ jar
+ test
+
- org.apache.commons
- commons-email
+ org.powermock
+ powermock-module-junit4
+ test
+
+
+
+ org.powermock
+ powermock-api-mockito2
+ test
+
+
+ org.mockito
+ mockito-core
+
+
- org.freemarker
- freemarker
+ org.apache.commons
+ commons-email
@@ -67,21 +86,6 @@
slf4j-api
-
- org.apache.commons
- commons-collections4
-
-
-
- commons-logging
- commons-logging
-
-
-
- org.apache.commons
- commons-lang3
-
-
com.google.guavaguava
@@ -92,12 +96,6 @@
logback-classic
-
- commons-io
- commons-io
-
-
-
org.apache.poi
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java
index 5e0c2545f8..3703b5d64a 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java
@@ -16,14 +16,14 @@
*/
package org.apache.dolphinscheduler.alert.runner;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.alert.manager.EmailManager;
import org.apache.dolphinscheduler.alert.manager.EnterpriseWeChatManager;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.EnterpriseWeChatUtils;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
+import org.apache.dolphinscheduler.common.utils.CollectionUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.User;
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplate.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplate.java
new file mode 100644
index 0000000000..cc74ff71ee
--- /dev/null
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplate.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.alert.template;
+
+import org.apache.dolphinscheduler.common.enums.ShowType;
+
+/**
+ * alert message template
+ */
+public interface AlertTemplate {
+
+ /**
+ * get a message from a specified alert template
+ * @param content alert message content
+ * @param showType show type
+ * @param showAll whether to show all
+ * @return a message from a specified alert template
+ */
+ String getMessageFromTemplate(String content, ShowType showType,boolean showAll);
+
+ /**
+ * default showAll is true
+ */
+ default String getMessageFromTemplate(String content,ShowType showType){
+ return getMessageFromTemplate(content,showType,true);
+ }
+}
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactory.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactory.java
new file mode 100644
index 0000000000..58e3800339
--- /dev/null
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.alert.template;
+
+import org.apache.dolphinscheduler.alert.template.impl.DefaultHTMLTemplate;
+import org.apache.dolphinscheduler.alert.utils.Constants;
+import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * the alert template factory
+ */
+public class AlertTemplateFactory {
+
+ private static final Logger logger = LoggerFactory.getLogger(AlertTemplateFactory.class);
+
+ private static final String alertTemplate = PropertyUtils.getString(Constants.ALERT_TEMPLATE);
+
+ private AlertTemplateFactory(){}
+
+ /**
+ * get a template from alert.properties conf file
+ * @return a template, default is DefaultHTMLTemplate
+ */
+ public static AlertTemplate getMessageTemplate() {
+
+ if(StringUtils.isEmpty(alertTemplate)){
+ return new DefaultHTMLTemplate();
+ }
+
+ switch (alertTemplate){
+ case "html":
+ return new DefaultHTMLTemplate();
+ default:
+ throw new IllegalArgumentException(String.format("not support alert template: %s",alertTemplate));
+ }
+ }
+}
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplate.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplate.java
new file mode 100644
index 0000000000..428fa4cb62
--- /dev/null
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplate.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.alert.template.impl;
+
+import org.apache.dolphinscheduler.alert.template.AlertTemplate;
+import org.apache.dolphinscheduler.alert.utils.Constants;
+import org.apache.dolphinscheduler.alert.utils.JSONUtils;
+import org.apache.dolphinscheduler.alert.utils.MailUtils;
+import org.apache.dolphinscheduler.common.enums.ShowType;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+
+import static org.apache.dolphinscheduler.common.utils.Preconditions.*;
+
+/**
+ * the default html alert message template
+ */
+public class DefaultHTMLTemplate implements AlertTemplate {
+
+ public static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplate.class);
+
+ @Override
+ public String getMessageFromTemplate(String content, ShowType showType,boolean showAll) {
+
+ switch (showType){
+ case TABLE:
+ return getTableTypeMessage(content,showAll);
+ case TEXT:
+ return getTextTypeMessage(content,showAll);
+ default:
+ throw new IllegalArgumentException(String.format("not support showType: %s in DefaultHTMLTemplate",showType));
+ }
+ }
+
+ /**
+ * get alert message which type is TABLE
+ * @param content message content
+ * @param showAll weather to show all
+ * @return alert message
+ */
+ private String getTableTypeMessage(String content,boolean showAll){
+
+ if (StringUtils.isNotEmpty(content)){
+ List mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
+
+ if(!showAll && mapItemsList.size() > Constants.NUMBER_1000){
+ mapItemsList = mapItemsList.subList(0,Constants.NUMBER_1000);
+ }
+
+ StringBuilder contents = new StringBuilder(200);
+
+ boolean flag = true;
+
+ String title = "";
+ for (LinkedHashMap mapItems : mapItemsList){
+
+ Set> entries = mapItems.entrySet();
+
+ Iterator> iterator = entries.iterator();
+
+ StringBuilder t = new StringBuilder(Constants.TR);
+ StringBuilder cs = new StringBuilder(Constants.TR);
+ while (iterator.hasNext()){
+
+ Map.Entry entry = iterator.next();
+ t.append(Constants.TH).append(entry.getKey()).append(Constants.TH_END);
+ cs.append(Constants.TD).append(String.valueOf(entry.getValue())).append(Constants.TD_END);
+
+ }
+ t.append(Constants.TR_END);
+ cs.append(Constants.TR_END);
+ if (flag){
+ title = t.toString();
+ }
+ flag = false;
+ contents.append(cs);
+ }
+
+ return getMessageFromHtmlTemplate(title,contents.toString());
+ }
+
+ return content;
+ }
+
+ /**
+ * get alert message which type is TEXT
+ * @param content message content
+ * @param showAll weather to show all
+ * @return alert message
+ */
+ private String getTextTypeMessage(String content,boolean showAll){
+
+ if (StringUtils.isNotEmpty(content)){
+ List list;
+ try {
+ list = JSONUtils.toList(content,String.class);
+ }catch (Exception e){
+ logger.error("json format exception",e);
+ return null;
+ }
+
+ StringBuilder contents = new StringBuilder(100);
+ for (String str : list){
+ contents.append(Constants.TR);
+ contents.append(Constants.TD).append(str).append(Constants.TD_END);
+ contents.append(Constants.TR_END);
+ }
+
+ return getMessageFromHtmlTemplate(null,contents.toString());
+
+ }
+
+ return content;
+ }
+
+ /**
+ * get alert message from a html template
+ * @param title message title
+ * @param content message content
+ * @return alert message which use html template
+ */
+ private String getMessageFromHtmlTemplate(String title,String content){
+
+ checkNotNull(content);
+ String htmlTableThead = StringUtils.isEmpty(title) ? "" : String.format("%s\n",title);
+
+ return "\n" +
+ " \n" +
+ " dolphinscheduler\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "
\n" + htmlTableThead + content +
+ "
\n" +
+ " \n" +
+ "";
+ }
+}
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/Constants.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/Constants.java
index 665aac246f..f96873bdde 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/Constants.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/Constants.java
@@ -75,6 +75,8 @@ public class Constants {
public static final int NUMBER_1000 = 1000;
+ public static final String ALERT_TEMPLATE = "alert.template";
+
public static final String SPRING_DATASOURCE_DRIVER_CLASS_NAME = "spring.datasource.driver-class-name";
public static final String SPRING_DATASOURCE_URL = "spring.datasource.url";
@@ -115,8 +117,6 @@ public class Constants {
public static final String DEVELOPMENT = "development";
- public static final String CLASSPATH_MAIL_TEMPLATES_ALERT_MAIL_TEMPLATE_FTL = "classpath:mail_templates/alert_mail_template.ftl";
-
public static final String TR = "
";
public static final String TD = "
";
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java
index 15e7e18855..a4c3720581 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java
@@ -17,11 +17,11 @@
package org.apache.dolphinscheduler.alert.utils;
import org.apache.dolphinscheduler.common.enums.ShowType;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.Alert;
import com.alibaba.fastjson.JSON;
import com.google.common.reflect.TypeToken;
-import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/FuncUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/FuncUtils.java
index 186a983e05..dd6ca4b8a6 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/FuncUtils.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/FuncUtils.java
@@ -16,7 +16,7 @@
*/
package org.apache.dolphinscheduler.alert.utils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
public class FuncUtils {
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java
index a88574f0e7..1cd9f490b2 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java
@@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.alert.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java
index d6edde240b..8bc8c35171 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java
@@ -16,16 +16,13 @@
*/
package org.apache.dolphinscheduler.alert.utils;
+import org.apache.dolphinscheduler.alert.template.AlertTemplate;
+import org.apache.dolphinscheduler.alert.template.AlertTemplateFactory;
import org.apache.dolphinscheduler.common.enums.ShowType;
-import freemarker.cache.StringTemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
+import org.apache.dolphinscheduler.common.utils.CollectionUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ResourceUtils;
@@ -35,7 +32,6 @@ import javax.mail.internet.*;
import java.io.*;
import java.util.*;
-import static org.apache.dolphinscheduler.alert.utils.PropertyUtils.getInt;
/**
@@ -69,25 +65,7 @@ public class MailUtils {
public static final String sslTrust = PropertyUtils.getString(Constants.MAIL_SMTP_SSL_TRUST);
- private static Template MAIL_TEMPLATE;
-
- static {
- Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
- cfg.setDefaultEncoding(Constants.UTF_8);
- StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
- cfg.setTemplateLoader(stringTemplateLoader);
- InputStreamReader isr = null;
- try {
- isr = new InputStreamReader(new FileInputStream(ResourceUtils.getFile(Constants.CLASSPATH_MAIL_TEMPLATES_ALERT_MAIL_TEMPLATE_FTL)),
- Constants.UTF_8);
-
- MAIL_TEMPLATE = new Template("alert_mail_template", isr, cfg);
- } catch (Exception e) {
- MAIL_TEMPLATE = null;
- } finally {
- IOUtils.closeQuietly(isr);
- }
- }
+ public static final AlertTemplate alertTemplate = AlertTemplateFactory.getMessageTemplate();
/**
@@ -174,46 +152,7 @@ public class MailUtils {
* @return the html table form
*/
private static String htmlTable(String content, boolean showAll){
- if (StringUtils.isNotEmpty(content)){
- List mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
-
- if(!showAll && mapItemsList.size() > Constants.NUMBER_1000){
- mapItemsList = mapItemsList.subList(0,Constants.NUMBER_1000);
- }
-
- StringBuilder contents = new StringBuilder(200);
-
- boolean flag = true;
-
- String title = "";
- for (LinkedHashMap mapItems : mapItemsList){
-
- Set> entries = mapItems.entrySet();
-
- Iterator> iterator = entries.iterator();
-
- StringBuilder t = new StringBuilder(Constants.TR);
- StringBuilder cs = new StringBuilder(Constants.TR);
- while (iterator.hasNext()){
-
- Map.Entry entry = iterator.next();
- t.append(Constants.TH).append(entry.getKey()).append(Constants.TH_END);
- cs.append(Constants.TD).append(String.valueOf(entry.getValue())).append(Constants.TD_END);
-
- }
- t.append(Constants.TR_END);
- cs.append(Constants.TR_END);
- if (flag){
- title = t.toString();
- }
- flag = false;
- contents.append(cs);
- }
-
- return getTemplateContent(title,contents.toString());
- }
-
- return null;
+ return alertTemplate.getMessageFromTemplate(content,ShowType.TABLE,showAll);
}
/**
@@ -231,33 +170,9 @@ public class MailUtils {
* @return text in html form
*/
private static String htmlText(String content){
-
- if (StringUtils.isNotEmpty(content)){
- List list;
- try {
- list = JSONUtils.toList(content,String.class);
- }catch (Exception e){
- logger.error("json format exception",e);
- return null;
- }
-
- StringBuilder contents = new StringBuilder(100);
- for (String str : list){
- contents.append(Constants.TR);
- contents.append(Constants.TD).append(str).append(Constants.TD_END);
- contents.append(Constants.TR_END);
- }
-
- return getTemplateContent(null,contents.toString());
-
- }
-
- return null;
+ return alertTemplate.getMessageFromTemplate(content,ShowType.TEXT);
}
-
-
-
/**
* send mail as Excel attachment
* @param receivers the receiver list
@@ -422,32 +337,8 @@ public class MailUtils {
* @param e the exception
*/
private static void handleException(Collection receivers, Map retMap, Exception e) {
- logger.error("Send email to {} failed", StringUtils.join(",", receivers), e);
- retMap.put(Constants.MESSAGE, "Send email to {" + StringUtils.join(",", receivers) + "} failed," + e.toString());
+ logger.error("Send email to {} failed {}", receivers, e);
+ retMap.put(Constants.MESSAGE, "Send email to {" + StringUtils.join(receivers, ",") + "} failed," + e.toString());
}
- /**
- * get the content of the template
- * @param title the title
- * @param content the content to retrieve
- * @return the content in the template or null if exception occurs
- */
- private static String getTemplateContent(String title,String content){
- StringWriter out = new StringWriter();
- Map map = new HashMap<>();
- if(null != title){
- map.put(Constants.TITLE,title);
- }
- map.put(Constants.CONTENT,content);
- try {
- MAIL_TEMPLATE.process(map, out);
- return out.toString();
- } catch (TemplateException e) {
- logger.error(e.getMessage(),e);
- } catch (IOException e) {
- logger.error(e.getMessage(),e);
- }
-
- return null;
- }
-}
+}
\ No newline at end of file
diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java
index 14ec4149eb..4367fbb4a8 100644
--- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java
+++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java
@@ -16,8 +16,8 @@
*/
package org.apache.dolphinscheduler.alert.utils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.dolphinscheduler.common.utils.IOUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/dolphinscheduler-alert/src/main/resources/alert.properties b/dolphinscheduler-alert/src/main/resources/alert.properties
index 127ab5a91b..000d0653b7 100644
--- a/dolphinscheduler-alert/src/main/resources/alert.properties
+++ b/dolphinscheduler-alert/src/main/resources/alert.properties
@@ -18,6 +18,9 @@
#alert type is EMAIL/SMS
alert.type=EMAIL
+# alter msg template, default is html template
+#alert.template=html
+
# mail server configuration
mail.protocol=SMTP
mail.server.host=xxx.xxx.com
diff --git a/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl b/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl
deleted file mode 100644
index 1ca9cab17e..0000000000
--- a/dolphinscheduler-alert/src/main/resources/mail_templates/alert_mail_template.ftl
+++ /dev/null
@@ -1,17 +0,0 @@
-<#--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
--->
- dolphinscheduler
\ No newline at end of file
diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactoryTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactoryTest.java
new file mode 100644
index 0000000000..6865b895e2
--- /dev/null
+++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/AlertTemplateFactoryTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.alert.template;
+
+import org.apache.dolphinscheduler.alert.template.impl.DefaultHTMLTemplate;
+import org.apache.dolphinscheduler.alert.utils.Constants;
+import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.mockito.Mockito.*;
+import static org.junit.Assert.*;
+
+/**
+ * test class for AlertTemplateFactory
+ */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(PropertyUtils.class)
+public class AlertTemplateFactoryTest {
+
+ private static final Logger logger = LoggerFactory.getLogger(AlertTemplateFactoryTest.class);
+
+ /**
+ * GetMessageTemplate method test
+ */
+ @Test
+ public void testGetMessageTemplate(){
+
+ PowerMockito.mockStatic(PropertyUtils.class);
+ when(PropertyUtils.getString(Constants.ALERT_TEMPLATE)).thenReturn("html");
+
+ AlertTemplate defaultTemplate = AlertTemplateFactory.getMessageTemplate();
+
+ assertTrue(defaultTemplate instanceof DefaultHTMLTemplate);
+ }
+
+ /**
+ * GetMessageTemplate method throw Exception test
+ */
+ @Test
+ public void testGetMessageTemplateException(){
+
+ AlertTemplate defaultTemplate = AlertTemplateFactory.getMessageTemplate();
+ assertTrue(defaultTemplate instanceof DefaultHTMLTemplate);
+ }
+}
diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplateTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplateTest.java
new file mode 100644
index 0000000000..58609c07cb
--- /dev/null
+++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/template/impl/DefaultHTMLTemplateTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.alert.template.impl;
+
+import org.apache.dolphinscheduler.alert.utils.JSONUtils;
+import org.apache.dolphinscheduler.common.enums.ShowType;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+/**
+ * test class for DefaultHTMLTemplate
+ */
+public class DefaultHTMLTemplateTest{
+
+ private static final Logger logger = LoggerFactory.getLogger(DefaultHTMLTemplateTest.class);
+
+ /**
+ * only need test method GetMessageFromTemplate
+ */
+ @Test
+ public void testGetMessageFromTemplate(){
+
+ DefaultHTMLTemplate template = new DefaultHTMLTemplate();
+
+ String tableTypeMessage = template.getMessageFromTemplate(list2String(), ShowType.TABLE,true);
+
+ assertEquals(tableTypeMessage,generateMockTableTypeResultByHand());
+
+ String textTypeMessage = template.getMessageFromTemplate(list2String(), ShowType.TEXT,true);
+
+ assertEquals(textTypeMessage,generateMockTextTypeResultByHand());
+ }
+
+ /**
+ * generate some simulation data
+ */
+ private String list2String(){
+
+ LinkedHashMap map1 = new LinkedHashMap<>();
+ map1.put("mysql service name","mysql200");
+ map1.put("mysql address","192.168.xx.xx");
+ map1.put("port","3306");
+ map1.put("no index of number","80");
+ map1.put("database client connections","190");
+
+ LinkedHashMap map2 = new LinkedHashMap<>();
+ map2.put("mysql service name","mysql210");
+ map2.put("mysql address","192.168.xx.xx");
+ map2.put("port","3306");
+ map2.put("no index of number","10");
+ map2.put("database client connections","90");
+
+ List> maps = new ArrayList<>();
+ maps.add(0,map1);
+ maps.add(1,map2);
+ String mapjson = JSONUtils.toJsonString(maps);
+ logger.info(mapjson);
+
+ return mapjson;
+ }
+
+ private String generateMockTableTypeResultByHand(){
+
+ return "\n" +
+ " \n" +
+ " dolphinscheduler\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "
{\"mysql service name\":\"mysql200\",\"mysql address\":\"192.168.xx.xx\",\"database client connections\":\"190\",\"port\":\"3306\",\"no index of number\":\"80\"}
{\"mysql service name\":\"mysql210\",\"mysql address\":\"192.168.xx.xx\",\"database client connections\":\"90\",\"port\":\"3306\",\"no index of number\":\"10\"}
\n" +
+ " \n" +
+ "";
+ }
+}
diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/MailUtilsTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/MailUtilsTest.java
index 96f1d9f21e..612de3e31d 100644
--- a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/MailUtilsTest.java
+++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/MailUtilsTest.java
@@ -23,21 +23,11 @@ import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.DaoFactory;
import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.User;
-import freemarker.cache.StringTemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.util.ResourceUtils;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
import java.util.*;
@@ -48,8 +38,8 @@ public class MailUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(MailUtilsTest.class);
@Test
public void testSendMails() {
- String[] receivers = new String[]{"xxx@qq.com"};
- String[] receiversCc = new String[]{"xxx@qq.com"};
+ String[] receivers = new String[]{"347801120@qq.com"};
+ String[] receiversCc = new String[]{"347801120@qq.com"};
String content ="[\"id:69\"," +
"\"name:UserBehavior-0--1193959466\"," +
@@ -114,7 +104,7 @@ public class MailUtilsTest {
@Test
public void testSendTableMail(){
- String[] mails = new String[]{"825193156@qq.com"};
+ String[] mails = new String[]{"347801120@qq.com"};
Alert alert = new Alert();
alert.setTitle("Mysql Exception");
alert.setShowType(ShowType.TABLE);
@@ -194,39 +184,4 @@ public class MailUtilsTest {
MailUtils.sendMails(Arrays.asList(mails),"gaojing",alert.getContent(),ShowType.TABLEATTACHMENT);
}
- @Test
- public void template(){
- Template MAIL_TEMPLATE;
- Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
- cfg.setDefaultEncoding(Constants.UTF_8);
- StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
- cfg.setTemplateLoader(stringTemplateLoader);
- InputStreamReader isr = null;
- try {
- isr = new InputStreamReader(new FileInputStream(ResourceUtils.getFile(Constants.CLASSPATH_MAIL_TEMPLATES_ALERT_MAIL_TEMPLATE_FTL)),
- Constants.UTF_8);
-
- MAIL_TEMPLATE = new Template("alert_mail_template", isr, cfg);
- } catch (Exception e) {
- MAIL_TEMPLATE = null;
- } finally {
- IOUtils.closeQuietly(isr);
- }
-
-
- StringWriter out = new StringWriter();
- Map map = new HashMap<>();
- map.put(Constants.TITLE,"title_test");
- try {
- MAIL_TEMPLATE.process(map, out);
- logger.info(out.toString());
-
- } catch (TemplateException e) {
- logger.error(e.getMessage(),e);
- } catch (IOException e) {
- logger.error(e.getMessage(),e);
- }
-
- }
-
}
diff --git a/dolphinscheduler-api/pom.xml b/dolphinscheduler-api/pom.xml
index 014799b0b6..ae28a48bb5 100644
--- a/dolphinscheduler-api/pom.xml
+++ b/dolphinscheduler-api/pom.xml
@@ -27,17 +27,13 @@
${project.artifactId}jar
-
- 5.5.23
- 2.5
-
-
-
- org.apache.dolphinscheduler
- dolphinscheduler-alert
-
-
+
+ org.apache.dolphinscheduler
+ dolphinscheduler-alert
+
+
+ org.apache.dolphinschedulerdolphinscheduler-server
@@ -96,25 +92,8 @@
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.ow2.asm
- asm
-
-
- org.springframework.boot
- spring-boot
-
-
- org.springframework.boot
- spring-boot-autoconfigure
-
-
-
+
+
org.springframework.bootspring-boot-starter-aop
@@ -125,33 +104,12 @@
+
org.springframeworkspring-context
-
- org.apache.httpcomponents
- httpcore
-
-
- org.apache.httpcomponents
- httpclient
-
-
-
- com.fasterxml.jackson.core
- jackson-annotations
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
com.alibabafastjson
@@ -181,19 +139,16 @@
io.springfoxspringfox-swagger2
- 2.9.2io.springfoxspringfox-swagger-ui
- 2.9.2com.github.xiaoyminswagger-bootstrap-ui
- 1.9.3
@@ -201,38 +156,37 @@
dolphinscheduler-rpc
-
- junit
- junit
- 4.12
- test
-
-
org.apache.curatorcurator-framework
+
org.apache.curatorcurator-recipes
+
org.apache.hadoophadoop-common
+
org.apache.hadoophadoop-client
+
org.apache.hadoophadoop-hdfs
+
org.apache.hadoophadoop-yarn-common
+
org.apache.hadoophadoop-aws
@@ -241,13 +195,38 @@
tomcatjasper-runtime
- ${jasper-runtime.version}javax.servletservlet-api
- ${servlet-api.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.ow2.asm
+ asm
+
+
+ org.springframework.boot
+ spring-boot
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+
+
+
+
+
+ junit
+ junit
+ test
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java
index 90d820910a..dac88925a2 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/ServiceModelToSwagger2MapperImpl.java
@@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.api.configuration;
import com.google.common.collect.Multimap;
import io.swagger.models.*;
import io.swagger.models.parameters.Parameter;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.MessageSource;
@@ -159,7 +159,8 @@ public class ServiceModelToSwagger2MapperImpl extends ServiceModelToSwagger2Mapp
Iterator it = from.getTags().iterator();
while(it.hasNext()){
String tag = it.next();
- list.add(StringUtils.isNotBlank(tag) ? messageSource.getMessage(tag, null, tag, locale) : " ");
+ list.add(
+ StringUtils.isNotBlank(tag) ? messageSource.getMessage(tag, null, tag, locale) : " ");
}
operation.setTags(list);
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java
index ba062472b3..46432569e1 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/BaseController.java
@@ -20,8 +20,8 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
-import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
@@ -67,7 +67,7 @@ public class BaseController {
public static String getClientIpAddress(HttpServletRequest request) {
String clientIp = request.getHeader(HTTP_X_FORWARDED_FOR);
- if (StringUtils.isNotEmpty(clientIp) && !StringUtils.equalsIgnoreCase(HTTP_HEADER_UNKNOWN, clientIp)) {
+ if (StringUtils.isNotEmpty(clientIp) && !clientIp.equalsIgnoreCase(HTTP_HEADER_UNKNOWN)) {
int index = clientIp.indexOf(COMMA);
if (index != -1) {
return clientIp.substring(0, index);
@@ -77,7 +77,7 @@ public class BaseController {
}
clientIp = request.getHeader(HTTP_X_REAL_IP);
- if (StringUtils.isNotEmpty(clientIp) && !StringUtils.equalsIgnoreCase(HTTP_HEADER_UNKNOWN, clientIp)) {
+ if (StringUtils.isNotEmpty(clientIp) && !clientIp.equalsIgnoreCase(HTTP_HEADER_UNKNOWN)) {
return clientIp;
}
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
index 92897ac7ff..1b1dc65e01 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
@@ -188,7 +188,7 @@ public class DataAnalysisController extends BaseController{
public Result countQueueState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value="projectId", required=false, defaultValue = "0") int projectId){
try{
- logger.info("count command state, user:{}, start date: {}, end date:{}, project id {}",
+ logger.info("count command state, user:{}, project id {}",
loginUser.getUserName(), projectId);
Map result = dataAnalysisService.countQueueState(loginUser, projectId);
return returnDataList(result);
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
index d4844a693d..9c04bf7d5c 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataSourceController.java
@@ -461,7 +461,7 @@ public class DataSourceController extends BaseController {
@GetMapping(value="/kerberos-startup-state")
@ResponseStatus(HttpStatus.OK)
public Result getKerberosStartupState(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser){
- logger.info("login user {},get kerberos startup state : {}", loginUser.getUserName());
+ logger.info("login user {}", loginUser.getUserName());
try{
// if upload resource is HDFS and kerberos startup is true , else false
return success(Status.SUCCESS.getMsg(), CommonUtils.getKerberosStartupState());
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java
index 63b2d8447d..e3a862d376 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoginController.java
@@ -18,14 +18,14 @@ package org.apache.dolphinscheduler.api.controller;
import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.security.Authenticator;
import org.apache.dolphinscheduler.api.service.SessionService;
-import org.apache.dolphinscheduler.api.service.UsersService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import io.swagger.annotations.*;
import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,6 +36,8 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
import static org.apache.dolphinscheduler.api.enums.Status.*;
/**
@@ -55,7 +57,7 @@ public class LoginController extends BaseController {
private SessionService sessionService;
@Autowired
- private UsersService userService;
+ private Authenticator authenticator;
/**
@@ -94,27 +96,20 @@ public class LoginController extends BaseController {
}
// verify username and password
- User user = userService.queryUser(userName, userPassword);
-
- if (user == null) {
- return error(Status.USER_NAME_PASSWD_ERROR.getCode(),Status.USER_NAME_PASSWD_ERROR.getMsg()
- );
- }
-
- // create session
- String sessionId = sessionService.createSession(user, ip);
-
- if (sessionId == null) {
- return error(Status.LOGIN_SESSION_FAILED.getCode(),
- Status.LOGIN_SESSION_FAILED.getMsg()
- );
+ Result
-
- org.projectlombok
- lombok
- ${lombok.version}
- compile
-
-
org.springframeworkspring-context
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java
index dfcda99141..457ddb0a1d 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java
@@ -66,7 +66,6 @@ public class ClickHouseDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("ClickHouse datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java
index e6d7b94b51..44ee200c5d 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java
@@ -66,7 +66,6 @@ public class DB2ServerDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("DB2 Server datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java
index 2970354e6b..101efae793 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java
@@ -69,7 +69,6 @@ public class HiveDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("hive datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java
index f50de0dee3..3cf2b2ce8c 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java
@@ -64,7 +64,6 @@ public class MySQLDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("Mysql datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java
index ddc30d939a..551c7823cb 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java
@@ -66,7 +66,6 @@ public class OracleDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("Oracle datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java
index ecc29c73e8..5241b4c7ef 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java
@@ -68,7 +68,6 @@ public class PostgreDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("Postgre datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java
index 7a51ff7a45..fe398eb88b 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java
@@ -62,7 +62,6 @@ public class SQLServerDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("SQL Server datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java
index 638664c47d..eb455124de 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java
@@ -71,7 +71,6 @@ public class SparkDataSource extends BaseDataSource {
con.close();
} catch (SQLException e) {
logger.error("Spark datasource try conn close conn error", e);
- throw e;
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java
index e3bca6ecbf..3519d5c535 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java
@@ -59,4 +59,5 @@ public class DateInterval {
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
+
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java
index 91436399c5..2fbc0e1654 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java
@@ -53,6 +53,7 @@ public class TaskNodeRelation {
}
+ @Override
public boolean equals(Object o){
if (!(o instanceof TaskNodeRelation)) {
return false;
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
index 45c6122341..8f5677d1b9 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/queue/TaskQueueZkImpl.java
@@ -37,8 +37,27 @@ public class TaskQueueZkImpl implements ITaskQueue {
private static final Logger logger = LoggerFactory.getLogger(TaskQueueZkImpl.class);
+ private final ZookeeperOperator zookeeperOperator;
+
@Autowired
- private ZookeeperOperator zookeeperOperator;
+ public TaskQueueZkImpl(ZookeeperOperator zookeeperOperator) {
+ this.zookeeperOperator = zookeeperOperator;
+
+ try {
+ String tasksQueuePath = getTasksPath(Constants.DOLPHINSCHEDULER_TASKS_QUEUE);
+ String tasksKillPath = getTasksPath(Constants.DOLPHINSCHEDULER_TASKS_KILL);
+
+ for (String key : new String[]{tasksQueuePath,tasksKillPath}){
+ if (!zookeeperOperator.isExisted(key)){
+ zookeeperOperator.persist(key, "");
+ logger.info("create tasks queue parent node success : {}", key);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("create tasks queue parent node failure", e);
+ }
+ }
+
/**
* get all tasks from tasks queue
@@ -321,20 +340,20 @@ public class TaskQueueZkImpl implements ITaskQueue {
public void delete(){
try {
String tasksQueuePath = getTasksPath(Constants.DOLPHINSCHEDULER_TASKS_QUEUE);
- String tasksCancelPath = getTasksPath(Constants.DOLPHINSCHEDULER_TASKS_KILL);
+ String tasksKillPath = getTasksPath(Constants.DOLPHINSCHEDULER_TASKS_KILL);
- for(String taskQueuePath : new String[]{tasksQueuePath,tasksCancelPath}){
- if(zookeeperOperator.isExisted(taskQueuePath)){
- List list = zookeeperOperator.getChildrenKeys(taskQueuePath);
+ for (String key : new String[]{tasksQueuePath,tasksKillPath}){
+ if (zookeeperOperator.isExisted(key)){
+ List list = zookeeperOperator.getChildrenKeys(key);
for (String task : list) {
- zookeeperOperator.remove(taskQueuePath + Constants.SINGLE_SLASH + task);
- logger.info("delete task from tasks queue : {}/{} ",taskQueuePath,task);
+ zookeeperOperator.remove(key + Constants.SINGLE_SLASH + task);
+ logger.info("delete task from tasks queue : {}/{} ", key, task);
}
}
}
} catch (Exception e) {
- logger.error("delete all tasks in tasks queue failure",e);
+ logger.error("delete all tasks in tasks queue failure", e);
}
}
@@ -344,7 +363,7 @@ public class TaskQueueZkImpl implements ITaskQueue {
* @return
*/
public String getTasksPath(String key){
- return "/dolphinscheduler" + Constants.SINGLE_SLASH + key;
+ return zookeeperOperator.getZookeeperConfig().getDsRoot() + Constants.SINGLE_SLASH + key;
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ArrayUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ArrayUtils.java
new file mode 100644
index 0000000000..163c56bbcc
--- /dev/null
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ArrayUtils.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+
+public class ArrayUtils {
+
+ public static boolean isEmpty(final int[] array) {
+ return array == null || array.length == 0;
+ }
+}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java
index 2bbb45b64c..c1c3ff5d57 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java
@@ -51,7 +51,6 @@ public class ConnectionUtils {
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
- throw new RuntimeException(e);
} finally {
try {
if (stmt != null) {
@@ -60,7 +59,6 @@ public class ConnectionUtils {
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
- throw new RuntimeException(e);
} finally {
try {
if (conn != null) {
@@ -69,7 +67,6 @@ public class ConnectionUtils {
}
} catch (SQLException e) {
logger.error(e.getMessage(),e);
- throw new RuntimeException(e);
}
}
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java
index 3455d5344c..ec060d486b 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java
@@ -1,397 +1 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dolphinscheduler.common.utils;
-
-import org.apache.dolphinscheduler.common.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.SimpleDateFormat;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * date utils
- */
-public class DateUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
-
- /**
- * date to local datetime
- *
- * @param date date
- * @return local datetime
- */
- private static LocalDateTime date2LocalDateTime(Date date) {
- return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
- }
-
- /**
- * local datetime to date
- *
- * @param localDateTime local datetime
- * @return date
- */
- private static Date localDateTime2Date(LocalDateTime localDateTime) {
- Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
- return Date.from(instant);
- }
-
- /**
- * get current date str
- *
- * @return date string
- */
- public static String getCurrentTime() {
- return getCurrentTime(Constants.YYYY_MM_DD_HH_MM_SS);
- }
-
- /**
- * get the date string in the specified format of the current time
- *
- * @param format date format
- * @return date string
- */
- public static String getCurrentTime(String format) {
- return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format));
- }
-
- /**
- * get the formatted date string
- *
- * @param date date
- * @param format e.g. yyyy-MM-dd HH:mm:ss
- * @return date string
- */
- public static String format(Date date, String format) {
- return format(date2LocalDateTime(date), format);
- }
-
- /**
- * get the formatted date string
- *
- * @param localDateTime local data time
- * @param format yyyy-MM-dd HH:mm:ss
- * @return date string
- */
- public static String format(LocalDateTime localDateTime, String format) {
- return localDateTime.format(DateTimeFormatter.ofPattern(format));
- }
-
- /**
- * convert time to yyyy-MM-dd HH:mm:ss format
- *
- * @param date date
- * @return date string
- */
- public static String dateToString(Date date) {
- return format(date, Constants.YYYY_MM_DD_HH_MM_SS);
- }
-
-
- /**
- * convert string to date and time
- *
- * @param date date
- * @param format format
- * @return date
- */
- public static Date parse(String date, String format) {
- try {
- LocalDateTime ldt = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(format));
- return localDateTime2Date(ldt);
- } catch (Exception e) {
- logger.error("error while parse date:" + date, e);
- }
- return null;
- }
-
-
- /**
- * convert date str to yyyy-MM-dd HH:mm:ss format
- *
- * @param str date string
- * @return yyyy-MM-dd HH:mm:ss format
- */
- public static Date stringToDate(String str) {
- return parse(str, Constants.YYYY_MM_DD_HH_MM_SS);
- }
-
- /**
- * get seconds between two dates
- *
- * @param d1 date1
- * @param d2 date2
- * @return differ seconds
- */
- public static long differSec(Date d1, Date d2) {
- if(d1 == null || d2 == null){
- return 0;
- }
- return (long) Math.ceil(differMs(d1, d2) / 1000.0);
- }
-
- /**
- * get ms between two dates
- *
- * @param d1 date1
- * @param d2 date2
- * @return differ ms
- */
- public static long differMs(Date d1, Date d2) {
- return Math.abs(d1.getTime() - d2.getTime());
- }
-
-
- /**
- * get hours between two dates
- *
- * @param d1 date1
- * @param d2 date2
- * @return differ hours
- */
- public static long diffHours(Date d1, Date d2) {
- return (long) Math.ceil(diffMin(d1, d2) / 60.0);
- }
-
- /**
- * get minutes between two dates
- *
- * @param d1 date1
- * @param d2 date2
- * @return differ minutes
- */
- public static long diffMin(Date d1, Date d2) {
- return (long) Math.ceil(differSec(d1, d2) / 60.0);
- }
-
-
- /**
- * get the date of the specified date in the days before and after
- *
- * @param date date
- * @param day day
- * @return the date of the specified date in the days before and after
- */
- public static Date getSomeDay(Date date, int day) {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- calendar.add(Calendar.DATE, day);
- return calendar.getTime();
- }
-
- /**
- * compare two dates
- *
- * @param future future date
- * @param old old date
- * @return true if future time greater than old time
- */
- public static boolean compare(Date future, Date old) {
- return future.getTime() > old.getTime();
- }
-
- /**
- * convert schedule string to date
- *
- * @param schedule schedule
- * @return convert schedule string to date
- */
- public static Date getScheduleDate(String schedule) {
- return stringToDate(schedule);
- }
-
- /**
- * format time to readable
- *
- * @param ms ms
- * @return format time
- */
- public static String format2Readable(long ms) {
-
- long days = ms / (1000 * 60 * 60 * 24);
- long hours = (ms % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
- long minutes = (ms % (1000 * 60 * 60)) / (1000 * 60);
- long seconds = (ms % (1000 * 60)) / 1000;
-
- return String.format("%02d %02d:%02d:%02d", days, hours, minutes, seconds);
-
- }
-
- /**
- * get monday
- *
- * note: Set the first day of the week to Monday, the default is Sunday
- * @param date date
- * @return get monday
- */
- public static Date getMonday(Date date) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
-
- cal.setFirstDayOfWeek(Calendar.MONDAY);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
-
- return cal.getTime();
- }
-
- /**
- * get sunday
- *
- * note: Set the first day of the week to Monday, the default is Sunday
- * @param date date
- * @return get sunday
- */
- public static Date getSunday(Date date) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
-
- cal.setFirstDayOfWeek(Calendar.MONDAY);
- cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
-
- return cal.getTime();
- }
-
- /**
- * get first day of month
- *
- * @param date date
- * @return first day of month
- * */
- public static Date getFirstDayOfMonth(Date date) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.set(Calendar.DAY_OF_MONTH, 1);
-
- return cal.getTime();
- }
-
- /**
- * get some hour of day
- *
- * @param date date
- * @param offsetHour hours
- * @return some hour of day
- * */
- public static Date getSomeHourOfDay(Date date, int offsetHour) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + offsetHour);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTime();
- }
-
- /**
- * get last day of month
- *
- * @param date date
- * @return get last day of month
- */
- public static Date getLastDayOfMonth(Date date) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
-
- cal.add(Calendar.MONTH, 1);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.add(Calendar.DAY_OF_MONTH, -1);
-
- return cal.getTime();
- }
-
- /**
- * return YYYY-MM-DD 00:00:00
- *
- * @param inputDay date
- * @return start day
- */
- public static Date getStartOfDay(Date inputDay) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(inputDay);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- return cal.getTime();
- }
-
- /**
- * return YYYY-MM-DD 23:59:59
- *
- * @param inputDay day
- * @return end of day
- */
- public static Date getEndOfDay(Date inputDay) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(inputDay);
- cal.set(Calendar.HOUR_OF_DAY, 23);
- cal.set(Calendar.MINUTE, 59);
- cal.set(Calendar.SECOND, 59);
- cal.set(Calendar.MILLISECOND, 999);
- return cal.getTime();
- }
-
- /**
- * return YYYY-MM-DD 00:00:00
- *
- * @param inputDay day
- * @return start of hour
- */
- public static Date getStartOfHour(Date inputDay) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(inputDay);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- return cal.getTime();
- }
-
- /**
- * return YYYY-MM-DD 23:59:59
- *
- * @param inputDay day
- * @return end of hour
- */
- public static Date getEndOfHour(Date inputDay) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(inputDay);
- cal.set(Calendar.MINUTE, 59);
- cal.set(Calendar.SECOND, 59);
- cal.set(Calendar.MILLISECOND, 999);
- return cal.getTime();
- }
-
- /**
- * get current date
- * @return current date
- */
- public static Date getCurrentDate() {
- return DateUtils.parse(DateUtils.getCurrentTime(),
- Constants.YYYY_MM_DD_HH_MM_SS);
- }
-}
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.common.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
/**
* date utils
*/
public class DateUtils {
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
/**
* date to local datetime
*
* @param date date
* @return local datetime
*/
private static LocalDateTime date2LocalDateTime(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
/**
* local datetime to date
*
* @param localDateTime local datetime
* @return date
*/
private static Date localDateTime2Date(LocalDateTime localDateTime) {
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
}
/**
* get current date str
*
* @return date string
*/
public static String getCurrentTime() {
return getCurrentTime(Constants.YYYY_MM_DD_HH_MM_SS);
}
/**
* get the date string in the specified format of the current time
*
* @param format date format
* @return date string
*/
public static String getCurrentTime(String format) {
return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format));
}
/**
* get the formatted date string
*
* @param date date
* @param format e.g. yyyy-MM-dd HH:mm:ss
* @return date string
*/
public static String format(Date date, String format) {
return format(date2LocalDateTime(date), format);
}
/**
* get the formatted date string
*
* @param localDateTime local data time
* @param format yyyy-MM-dd HH:mm:ss
* @return date string
*/
public static String format(LocalDateTime localDateTime, String format) {
return localDateTime.format(DateTimeFormatter.ofPattern(format));
}
/**
* convert time to yyyy-MM-dd HH:mm:ss format
*
* @param date date
* @return date string
*/
public static String dateToString(Date date) {
return format(date, Constants.YYYY_MM_DD_HH_MM_SS);
}
/**
* convert string to date and time
*
* @param date date
* @param format format
* @return date
*/
public static Date parse(String date, String format) {
try {
LocalDateTime ldt = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(format));
return localDateTime2Date(ldt);
} catch (Exception e) {
logger.error("error while parse date:" + date, e);
}
return null;
}
/**
* convert date str to yyyy-MM-dd HH:mm:ss format
*
* @param str date string
* @return yyyy-MM-dd HH:mm:ss format
*/
public static Date stringToDate(String str) {
return parse(str, Constants.YYYY_MM_DD_HH_MM_SS);
}
/**
* get seconds between two dates
*
* @param d1 date1
* @param d2 date2
* @return differ seconds
*/
public static long differSec(Date d1, Date d2) {
if(d1 == null || d2 == null){
return 0;
}
return (long) Math.ceil(differMs(d1, d2) / 1000.0);
}
/**
* get ms between two dates
*
* @param d1 date1
* @param d2 date2
* @return differ ms
*/
public static long differMs(Date d1, Date d2) {
return Math.abs(d1.getTime() - d2.getTime());
}
/**
* get hours between two dates
*
* @param d1 date1
* @param d2 date2
* @return differ hours
*/
public static long diffHours(Date d1, Date d2) {
return (long) Math.ceil(diffMin(d1, d2) / 60.0);
}
/**
* get minutes between two dates
*
* @param d1 date1
* @param d2 date2
* @return differ minutes
*/
public static long diffMin(Date d1, Date d2) {
return (long) Math.ceil(differSec(d1, d2) / 60.0);
}
/**
* get the date of the specified date in the days before and after
*
* @param date date
* @param day day
* @return the date of the specified date in the days before and after
*/
public static Date getSomeDay(Date date, int day) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, day);
return calendar.getTime();
}
/**
* compare two dates
*
* @param future future date
* @param old old date
* @return true if future time greater than old time
*/
public static boolean compare(Date future, Date old) {
return future.getTime() > old.getTime();
}
/**
* convert schedule string to date
*
* @param schedule schedule
* @return convert schedule string to date
*/
public static Date getScheduleDate(String schedule) {
return stringToDate(schedule);
}
/**
* format time to readable
*
* @param ms ms
* @return format time
*/
public static String format2Readable(long ms) {
long days = ms / (1000 * 60 * 60 * 24);
long hours = (ms % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (ms % (1000 * 60 * 60)) / (1000 * 60);
long seconds = (ms % (1000 * 60)) / 1000;
return String.format("%02d %02d:%02d:%02d", days, hours, minutes, seconds);
}
/**
* get monday
*
* note: Set the first day of the week to Monday, the default is Sunday
* @param date date
* @return get monday
*/
public static Date getMonday(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return cal.getTime();
}
/**
* get sunday
*
* note: Set the first day of the week to Monday, the default is Sunday
* @param date date
* @return get sunday
*/
public static Date getSunday(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
return cal.getTime();
}
/**
* get first day of month
*
* @param date date
* @return first day of month
* */
public static Date getFirstDayOfMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, 1);
return cal.getTime();
}
/**
* get some hour of day
*
* @param date date
* @param offsetHour hours
* @return some hour of day
* */
public static Date getSomeHourOfDay(Date date, int offsetHour) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + offsetHour);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* get last day of month
*
* @param date date
* @return get last day of month
*/
public static Date getLastDayOfMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
return cal.getTime();
}
/**
* return YYYY-MM-DD 00:00:00
*
* @param inputDay date
* @return start day
*/
public static Date getStartOfDay(Date inputDay) {
Calendar cal = Calendar.getInstance();
cal.setTime(inputDay);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* return YYYY-MM-DD 23:59:59
*
* @param inputDay day
* @return end of day
*/
public static Date getEndOfDay(Date inputDay) {
Calendar cal = Calendar.getInstance();
cal.setTime(inputDay);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();
}
/**
* return YYYY-MM-DD 00:00:00
*
* @param inputDay day
* @return start of hour
*/
public static Date getStartOfHour(Date inputDay) {
Calendar cal = Calendar.getInstance();
cal.setTime(inputDay);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* return YYYY-MM-DD 23:59:59
*
* @param inputDay day
* @return end of hour
*/
public static Date getEndOfHour(Date inputDay) {
Calendar cal = Calendar.getInstance();
cal.setTime(inputDay);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();
}
/**
* get current date
* @return current date
*/
public static Date getCurrentDate() {
return DateUtils.parse(DateUtils.getCurrentTime(),
Constants.YYYY_MM_DD_HH_MM_SS);
}
/**
* get date
* @return result date
*/
public static Date add(final Date date, final int calendarField, final int amount) {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
}
}
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/EnumUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/EnumUtils.java
index dc2e3a0750..924e8ff719 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/EnumUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/EnumUtils.java
@@ -30,4 +30,16 @@ public class EnumUtils {
return null;
}
}
+
+ public static > boolean isValidEnum(final Class enumClass, final String enumName) {
+ if (enumName == null) {
+ return false;
+ }
+ try {
+ Enum.valueOf(enumClass, enumName);
+ return true;
+ } catch (final IllegalArgumentException ex) {
+ return false;
+ }
+ }
}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
index 072266fb7f..afc3c44825 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
@@ -116,9 +116,9 @@ public class HadoopUtils implements Closeable {
if(StringUtils.isNotBlank(defaultFSProp)){
Map fsRelatedProps = PropertyUtils.getPrefixedProperties("fs.");
configuration.set(Constants.FS_DEFAULTFS,defaultFSProp);
- fsRelatedProps.entrySet().stream().forEach(entry -> configuration.set(entry.getKey(), entry.getValue()));
+ fsRelatedProps.forEach((key, value) -> configuration.set(key, value));
}else{
- logger.error("property:{} can not to be empty, please set!");
+ logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULTFS );
throw new RuntimeException("property:{} can not to be empty, please set!");
}
}else{
@@ -337,7 +337,6 @@ public class HadoopUtils implements Closeable {
* @throws Exception errors
*/
public FileStatus[] listFileStatus(String filePath)throws Exception{
- Path path = new Path(filePath);
try {
return fs.listStatus(new Path(filePath));
} catch (IOException e) {
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
index 7bb93d8c46..c163dcab3d 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
@@ -67,7 +67,7 @@ public class HttpUtils {
logger.warn("http entity is null");
}
}else{
- logger.error("htt get:{} response status code is not 200!");
+ logger.error("http get:{} response status code is not 200!", response.getStatusLine().getStatusCode());
}
}catch (Exception e){
logger.error(e.getMessage(),e);
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/IOUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/IOUtils.java
new file mode 100644
index 0000000000..73df158aa3
--- /dev/null
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/IOUtils.java
@@ -0,0 +1,45 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class IOUtils {
+
+ public static void closeQuietly(InputStream fis){
+ if(fis != null){
+ try {
+ fis.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+
+ public static void closeQuietly(InputStreamReader reader){
+ if(reader != null){
+ try {
+ reader.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+}
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
index 64dd4f3dcd..12b75fb0e5 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
@@ -18,6 +18,8 @@ package org.apache.dolphinscheduler.common.utils;
import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
+import java.util.Objects;
import java.util.regex.Pattern;
@@ -122,4 +124,32 @@ public class StringUtils {
}
return false;
}
+
+ public static String join(final Iterable> iterable, final String separator){
+ Iterator> iterator = iterable.iterator();
+ if (iterator == null) {
+ return null;
+ }
+ if (!iterator.hasNext()) {
+ return EMPTY;
+ }
+ final Object first = iterator.next();
+ if (!iterable.iterator().hasNext()) {
+ return Objects.toString(first, "");
+ }
+ final StringBuilder buf = new StringBuilder(64);
+ if (first != null) {
+ buf.append(first);
+ }
+ while (iterator.hasNext()) {
+ if (separator != null) {
+ buf.append(separator);
+ }
+ final Object obj = iterator.next();
+ if (obj != null) {
+ buf.append(obj);
+ }
+ }
+ return buf.toString();
+ }
}
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java
index 7311dcf5b6..43745c4e3c 100644
--- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java
@@ -34,18 +34,73 @@ public class DependentUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(ShellExecutorTest.class);
@Test
public void getDependResultForRelation() {
-
+ //failed
DependentRelation dependentRelation = DependentRelation.AND;
List dependResultList = new ArrayList<>();
dependResultList.add(DependResult.FAILED);
dependResultList.add(DependResult.SUCCESS);
- DependResult result = DependentUtils.getDependResultForRelation( dependentRelation, dependResultList);
+ DependResult result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.FAILED);
+
+ //waiting
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.WAITING);
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.WAITING);
+
+ //success
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.SUCCESS);
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.SUCCESS);
+
+ //one success
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.SUCCESS);
+
+ //one failed
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.FAILED);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
Assert.assertEquals(result, DependResult.FAILED);
+ //or success
dependentRelation = DependentRelation.OR;
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.FAILED);
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.SUCCESS);
+
+ //waiting
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.WAITING);
+ dependResultList.add(DependResult.FAILED);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.WAITING);
- Assert.assertEquals(DependentUtils.getDependResultForRelation( dependentRelation, dependResultList),
- DependResult.SUCCESS);
+ //success
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.SUCCESS);
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.SUCCESS);
+
+ //one success
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.SUCCESS);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.SUCCESS);
+
+ //one failed
+ dependResultList = new ArrayList<>();
+ dependResultList.add(DependResult.FAILED);
+ result = DependentUtils.getDependResultForRelation(dependentRelation, dependResultList);
+ Assert.assertEquals(result, DependResult.FAILED);
}
@Test
@@ -101,6 +156,115 @@ public class DependentUtilsTest {
Assert.assertEquals(dateIntervals.get(0), monthHead);
Assert.assertEquals(dateIntervals.get(dateIntervals.size() - 1), monthThis);
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-04 10:00:00"), "last1Hour");
+ DateInterval expect = new DateInterval(DateUtils.stringToDate("2019-02-04 09:00:00"),
+ DateUtils.getEndOfHour(DateUtils.stringToDate("2019-02-04 09:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-04 10:00:00"), "last2Hours");
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-04 08:00:00"),
+ DateUtils.getEndOfHour(DateUtils.stringToDate("2019-02-04 08:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-04 10:00:00"), "last3Hours");
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-04 07:00:00"),
+ DateUtils.getEndOfHour(DateUtils.stringToDate("2019-02-04 07:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+
+ dateValue = "last3Days";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-07 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-07 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+
+ dateValue = "last7Days";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-03 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-03 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+
+ dateValue = "lastWeek";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-28 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-28 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-03 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-03 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(6));
+ Assert.assertEquals(7, dateIntervals.size());
+
+ dateValue = "lastMonday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-28 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-28 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastTuesday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-29 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-29 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastWednesday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-30 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-30 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastThursday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-31 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-31 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastFriday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-01 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-01 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastSaturday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-02 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-02 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastSunday";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-02-03 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-02-03 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastMonth";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-01 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-01 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-31 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-31 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(30));
+ Assert.assertEquals(31, dateIntervals.size());
+
+ dateValue = "lastMonthBegin";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-01 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-01 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
+
+ dateValue = "lastMonthEnd";
+ dateIntervals = DependentUtils.getDateIntervalList(DateUtils.stringToDate("2019-02-10 07:00:00"), dateValue);
+ expect = new DateInterval(DateUtils.stringToDate("2019-01-31 00:00:00"),
+ DateUtils.getEndOfDay(DateUtils.stringToDate("2019-01-31 00:00:00")));
+ Assert.assertEquals(expect, dateIntervals.get(0));
+ Assert.assertEquals(1, dateIntervals.size());
}
@Test
@@ -197,4 +361,4 @@ public class DependentUtilsTest {
Assert.assertEquals(dateIntervals.get(30), di2);
}
-}
\ No newline at end of file
+}
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/PreconditionsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/PreconditionsTest.java
new file mode 100644
index 0000000000..dcb0e1370e
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/PreconditionsTest.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dolphinscheduler.common.utils;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+
+
+public class PreconditionsTest {
+ public static final Logger logger = LoggerFactory.getLogger(PreconditionsTest.class);
+
+ /**
+ * Test checkNotNull
+ */
+ @Test
+ public void testCheckNotNull() throws Exception {
+ String testReference = "test reference";
+ //test reference is not null
+ Assert.assertEquals(testReference,Preconditions.checkNotNull(testReference));
+ Assert.assertEquals(testReference,Preconditions.checkNotNull(testReference,"reference is null"));
+ Assert.assertEquals(testReference,Preconditions.checkNotNull(testReference,"%s is null",testReference));
+
+ //test reference is null
+ try {
+ Preconditions.checkNotNull(null);
+ } catch (NullPointerException ex) {
+ assertNull(ex.getMessage());
+ }
+
+ try {
+ Preconditions.checkNotNull("");
+ } catch (NullPointerException ex) {
+ assertNull(ex.getMessage());
+ }
+ //test reference is null ,expect contains errorMessage
+ try {
+ Preconditions.checkNotNull(null,"reference is null");
+ } catch (NullPointerException ex) {
+ assertThat(ex.getMessage(), containsString("reference is null"));
+ }
+
+ try {
+ Preconditions.checkNotNull("","reference is null");
+ } catch (NullPointerException ex) {
+ assertThat(ex.getMessage(), containsString("reference is null"));
+ }
+
+ //test reference is null ,expect contains errorMessageTemplate and errorMessageArgs
+ try {
+ Preconditions.checkNotNull(null,"%s is null",testReference);
+ } catch (NullPointerException ex) {
+ assertThat(ex.getMessage(), containsString(testReference + " is null"));
+ }
+
+ try {
+ Preconditions.checkNotNull("","%s is null",testReference);
+ } catch (NullPointerException ex) {
+ assertThat(ex.getMessage(), containsString(testReference + " is null"));
+ }
+ }
+
+ /**
+ * Test checkArgument
+ */
+ @Test
+ public void testCheckArgument() throws Exception {
+
+ int argument = 100;
+ //boolean condition is true
+ Preconditions.checkArgument(argument > 0 && argument < 200);
+
+ //boolean condition is false
+ try {
+ Preconditions.checkArgument(argument > 0 && argument < 50);
+ } catch (IllegalArgumentException ex) {
+ assertNull(ex.getMessage());
+ }
+
+ //boolean condition is false ,expect contains errorMessage
+ try {
+ Preconditions.checkArgument(argument > 300, "argument is error");
+ } catch (IllegalArgumentException ex) {
+ assertThat(ex.getMessage(), containsString("argument is error"));
+ }
+
+ //boolean condition is false,expect contains errorMessageTemplate and errorMessageArgs
+ try {
+ Preconditions.checkArgument(argument > 0 && argument < 99, "argument %s is error",argument);
+ } catch (IllegalArgumentException ex) {
+ assertThat(ex.getMessage(), containsString( "argument " + argument + " is error"));
+ }
+ }
+
+ /**
+ * Test checkState
+ */
+ @Test
+ public void testCheckState() throws Exception {
+ int state = 1;
+ //boolean condition is true
+ Preconditions.checkState(state == 1);
+ Preconditions.checkState(state > -1);
+
+ //boolean condition is false
+ try {
+ Preconditions.checkState(state > 2);
+ } catch (IllegalStateException ex) {
+ assertNull(ex.getMessage());
+ }
+
+ //boolean condition is false ,expect contains errorMessage
+ try {
+ Preconditions.checkState(state < 1, "state is error");
+ } catch (IllegalStateException ex) {
+ assertThat(ex.getMessage(), containsString("state is error"));
+ }
+
+ //boolean condition is false,expect contains errorMessageTemplate and errorMessageArgs
+ try {
+ Preconditions.checkState(state < -1 , "state %s is error",state);
+ } catch (IllegalStateException ex) {
+ assertThat(ex.getMessage(), containsString( "state " + state + " is error"));
+ }
+ }
+
+ /**
+ * Test checkElementIndex
+ */
+ @Test
+ public void testCheckElementIndex() throws Exception {
+ int index = 2;
+ int size = 30;
+
+ //boolean condition is true
+ Preconditions.checkElementIndex(index, size);
+
+ //boolean condition is false
+ try {
+ Preconditions.checkElementIndex(-1, 10);
+ } catch (IndexOutOfBoundsException ex) {
+ assertThat(ex.getMessage(), containsString("Index: -1, Size: 10"));
+ }
+
+ //boolean condition is false ,expect contains errorMessage
+ try {
+ Preconditions.checkElementIndex(100, 50, "index is greater than size");
+ } catch (IndexOutOfBoundsException ex) {
+ assertThat(ex.getMessage(), containsString("index is greater than size Index: 100, Size: 50"));
+ }
+ }
+}
diff --git a/dolphinscheduler-dao/pom.xml b/dolphinscheduler-dao/pom.xml
index af1cdb8b78..c994716517 100644
--- a/dolphinscheduler-dao/pom.xml
+++ b/dolphinscheduler-dao/pom.xml
@@ -108,14 +108,6 @@
commons-httpclientcommons-httpclient
-
- org.apache.commons
- commons-lang3
-
-
- commons-lang
- commons-lang
- com.alibaba
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
index 2f2314c91f..19dbf46a6b 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
@@ -17,9 +17,9 @@
package org.apache.dolphinscheduler.dao;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.ShowType;
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
index 66948951f6..ffb6febd66 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/ProcessDao.java
@@ -18,20 +18,19 @@ package org.apache.dolphinscheduler.dao;
import com.alibaba.fastjson.JSONObject;
import com.cronutils.model.Cron;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.*;
import org.apache.dolphinscheduler.common.model.DateInterval;
import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.queue.ITaskQueue;
-import org.apache.dolphinscheduler.common.queue.TaskQueueFactory;
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters;
+import org.apache.dolphinscheduler.common.utils.ArrayUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.IpUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.*;
import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
@@ -458,9 +457,12 @@ public class ProcessDao {
if(tenantId >= 0){
tenant = tenantMapper.queryById(tenantId);
}
- if(tenant == null){
+ if(null == tenant){
User user = userMapper.selectById(userId);
- tenant = tenantMapper.queryById(user.getTenantId());
+
+ if (null != user) {
+ tenant = tenantMapper.queryById(user.getTenantId());
+ }
}
return tenant;
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java
index 4e6b1df7e6..f7ba1054a5 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java
@@ -20,11 +20,11 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.TaskRecordStatus;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.TaskRecord;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java
index 33f6d2e24b..af9d9cd507 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java
@@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
-@Data
@TableName("t_ds_access_token")
public class AccessToken {
@@ -105,4 +103,45 @@ public class AccessToken {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ AccessToken that = (AccessToken) o;
+
+ if (id != that.id) return false;
+ if (userId != that.userId) return false;
+ if (token != null ? !token.equals(that.token) : that.token != null) return false;
+ if (userName != null ? !userName.equals(that.userName) : that.userName != null) return false;
+ if (expireTime != null ? !expireTime.equals(that.expireTime) : that.expireTime != null) return false;
+ if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
+ return updateTime != null ? updateTime.equals(that.updateTime) : that.updateTime == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id;
+ result = 31 * result + userId;
+ result = 31 * result + (token != null ? token.hashCode() : 0);
+ result = 31 * result + (userName != null ? userName.hashCode() : 0);
+ result = 31 * result + (expireTime != null ? expireTime.hashCode() : 0);
+ result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
+ result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "AccessToken{" +
+ "id=" + id +
+ ", userId=" + userId +
+ ", token='" + token + '\'' +
+ ", userName='" + userName + '\'' +
+ ", expireTime=" + expireTime +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ '}';
+ }
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java
index dac96e8695..d60a54269d 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java
@@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.ShowType;
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertGroup.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertGroup.java
index d5ecc04b69..80e4a99935 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertGroup.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertGroup.java
@@ -20,11 +20,9 @@ import org.apache.dolphinscheduler.common.enums.AlertType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
-@Data
@TableName("t_ds_alertgroup")
public class AlertGroup {
@@ -145,4 +143,16 @@ public class AlertGroup {
result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
return result;
}
+
+ @Override
+ public String toString() {
+ return "AlertGroup{" +
+ "id=" + id +
+ ", groupName='" + groupName + '\'' +
+ ", groupType=" + groupType +
+ ", description='" + description + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ '}';
+ }
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java
index 2d47b7874a..25667924ac 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Command.java
@@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import org.apache.dolphinscheduler.common.enums.*;
import java.util.Date;
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java
index 433fa2ebbf..236ae8f91e 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java
@@ -16,18 +16,14 @@
*/
package org.apache.dolphinscheduler.dao.entity;
-
-
import org.apache.dolphinscheduler.common.enums.DbType;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
-@Data
@TableName("t_ds_datasource")
public class DataSource {
/**
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
index d3de4123b0..cd0494ecc6 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
@@ -25,7 +25,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import lombok.Data;
import java.util.Date;
import java.util.List;
@@ -36,7 +35,6 @@ import java.util.stream.Collectors;
/**
* process definition
*/
-@Data
@TableName("t_ds_process_definition")
public class ProcessDefinition {
/**
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java
index 66a0d6c30a..f708e49e4f 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java
@@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import lombok.Data;
import org.apache.dolphinscheduler.common.enums.*;
import java.util.Date;
@@ -29,7 +28,6 @@ import java.util.Date;
/**
* process instance
*/
-@Data
@TableName("t_ds_process_instance")
public class ProcessInstance {
@@ -619,4 +617,98 @@ public class ProcessInstance {
", receiversCc='" + receiversCc + '\'' +
'}';
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ProcessInstance that = (ProcessInstance) o;
+
+ if (id != that.id) return false;
+ if (processDefinitionId != that.processDefinitionId) return false;
+ if (runTimes != that.runTimes) return false;
+ if (maxTryTimes != that.maxTryTimes) return false;
+ if (executorId != that.executorId) return false;
+ if (workerGroupId != that.workerGroupId) return false;
+ if (timeout != that.timeout) return false;
+ if (tenantId != that.tenantId) return false;
+ if (state != that.state) return false;
+ if (recovery != that.recovery) return false;
+ if (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null) return false;
+ if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false;
+ if (name != null ? !name.equals(that.name) : that.name != null) return false;
+ if (host != null ? !host.equals(that.host) : that.host != null) return false;
+ if (processDefinition != null ? !processDefinition.equals(that.processDefinition) : that.processDefinition != null)
+ return false;
+ if (commandType != that.commandType) return false;
+ if (commandParam != null ? !commandParam.equals(that.commandParam) : that.commandParam != null) return false;
+ if (taskDependType != that.taskDependType) return false;
+ if (failureStrategy != that.failureStrategy) return false;
+ if (warningType != that.warningType) return false;
+ if (warningGroupId != null ? !warningGroupId.equals(that.warningGroupId) : that.warningGroupId != null)
+ return false;
+ if (scheduleTime != null ? !scheduleTime.equals(that.scheduleTime) : that.scheduleTime != null) return false;
+ if (commandStartTime != null ? !commandStartTime.equals(that.commandStartTime) : that.commandStartTime != null)
+ return false;
+ if (globalParams != null ? !globalParams.equals(that.globalParams) : that.globalParams != null) return false;
+ if (processInstanceJson != null ? !processInstanceJson.equals(that.processInstanceJson) : that.processInstanceJson != null)
+ return false;
+ if (tenantCode != null ? !tenantCode.equals(that.tenantCode) : that.tenantCode != null) return false;
+ if (queue != null ? !queue.equals(that.queue) : that.queue != null) return false;
+ if (isSubProcess != that.isSubProcess) return false;
+ if (locations != null ? !locations.equals(that.locations) : that.locations != null) return false;
+ if (connects != null ? !connects.equals(that.connects) : that.connects != null) return false;
+ if (historyCmd != null ? !historyCmd.equals(that.historyCmd) : that.historyCmd != null) return false;
+ if (dependenceScheduleTimes != null ? !dependenceScheduleTimes.equals(that.dependenceScheduleTimes) : that.dependenceScheduleTimes != null)
+ return false;
+ if (duration != null ? !duration.equals(that.duration) : that.duration != null) return false;
+ if (processInstancePriority != that.processInstancePriority) return false;
+ if (workerGroupName != null ? !workerGroupName.equals(that.workerGroupName) : that.workerGroupName != null)
+ return false;
+ if (receivers != null ? !receivers.equals(that.receivers) : that.receivers != null) return false;
+ return receiversCc != null ? receiversCc.equals(that.receiversCc) : that.receiversCc == null;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id;
+ result = 31 * result + processDefinitionId;
+ result = 31 * result + (state != null ? state.hashCode() : 0);
+ result = 31 * result + (recovery != null ? recovery.hashCode() : 0);
+ result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
+ result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
+ result = 31 * result + runTimes;
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (host != null ? host.hashCode() : 0);
+ result = 31 * result + (processDefinition != null ? processDefinition.hashCode() : 0);
+ result = 31 * result + (commandType != null ? commandType.hashCode() : 0);
+ result = 31 * result + (commandParam != null ? commandParam.hashCode() : 0);
+ result = 31 * result + (taskDependType != null ? taskDependType.hashCode() : 0);
+ result = 31 * result + maxTryTimes;
+ result = 31 * result + (failureStrategy != null ? failureStrategy.hashCode() : 0);
+ result = 31 * result + (warningType != null ? warningType.hashCode() : 0);
+ result = 31 * result + (warningGroupId != null ? warningGroupId.hashCode() : 0);
+ result = 31 * result + (scheduleTime != null ? scheduleTime.hashCode() : 0);
+ result = 31 * result + (commandStartTime != null ? commandStartTime.hashCode() : 0);
+ result = 31 * result + (globalParams != null ? globalParams.hashCode() : 0);
+ result = 31 * result + (processInstanceJson != null ? processInstanceJson.hashCode() : 0);
+ result = 31 * result + executorId;
+ result = 31 * result + (tenantCode != null ? tenantCode.hashCode() : 0);
+ result = 31 * result + (queue != null ? queue.hashCode() : 0);
+ result = 31 * result + (isSubProcess != null ? isSubProcess.hashCode() : 0);
+ result = 31 * result + (locations != null ? locations.hashCode() : 0);
+ result = 31 * result + (connects != null ? connects.hashCode() : 0);
+ result = 31 * result + (historyCmd != null ? historyCmd.hashCode() : 0);
+ result = 31 * result + (dependenceScheduleTimes != null ? dependenceScheduleTimes.hashCode() : 0);
+ result = 31 * result + (duration != null ? duration.hashCode() : 0);
+ result = 31 * result + (processInstancePriority != null ? processInstancePriority.hashCode() : 0);
+ result = 31 * result + workerGroupId;
+ result = 31 * result + timeout;
+ result = 31 * result + tenantId;
+ result = 31 * result + (workerGroupName != null ? workerGroupName.hashCode() : 0);
+ result = 31 * result + (receivers != null ? receivers.hashCode() : 0);
+ result = 31 * result + (receiversCc != null ? receiversCc.hashCode() : 0);
+ return result;
+ }
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java
index c85a6b73e0..637d573b11 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java
@@ -19,12 +19,10 @@ package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
/**
* process instance map
*/
-@Data
@TableName("t_ds_relation_process_instance")
public class ProcessInstanceMap {
@@ -90,4 +88,26 @@ public class ProcessInstanceMap {
", processInstanceId=" + processInstanceId +
'}';
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ProcessInstanceMap that = (ProcessInstanceMap) o;
+
+ if (id != that.id) return false;
+ if (parentProcessInstanceId != that.parentProcessInstanceId) return false;
+ if (parentTaskInstanceId != that.parentTaskInstanceId) return false;
+ return processInstanceId == that.processInstanceId;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id;
+ result = 31 * result + parentProcessInstanceId;
+ result = 31 * result + parentTaskInstanceId;
+ result = 31 * result + processInstanceId;
+ return result;
+ }
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java
index 3385cd676c..feddb598f0 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java
@@ -20,14 +20,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
/**
* project
*/
-@Data
@TableName("t_ds_project")
public class Project {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Schedule.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Schedule.java
index 65ae4d8e12..cfda49df6e 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Schedule.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Schedule.java
@@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
@@ -32,7 +31,6 @@ import java.util.Date;
* schedule
*
*/
-@Data
@TableName("t_ds_schedules")
public class Schedule {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
index 3492fe5b17..2db1eda8f4 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java
@@ -26,14 +26,12 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
/**
* task instance
*/
-@Data
@TableName("t_ds_task_instance")
public class TaskInstance {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
index b6def18922..8849be0b83 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
@@ -22,14 +22,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
/**
* user
*/
-@Data
@TableName("t_ds_user")
public class User {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java
index 84742468b6..e86b32e075 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java
@@ -20,14 +20,12 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
/**
* user alert group
*/
-@Data
@TableName("t_ds_relation_user_alertgroup")
public class UserAlertGroup {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerGroup.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerGroup.java
index 5c4595b1cf..a732dbbe6e 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerGroup.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerGroup.java
@@ -19,14 +19,12 @@ package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
import java.util.Date;
/**
* worker group for task running
*/
-@Data
@TableName("t_ds_worker_group")
public class WorkerGroup {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
index 1dc4ad14e7..aed93038f5 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
@@ -17,14 +17,13 @@
package org.apache.dolphinscheduler.dao.upgrade;
import com.alibaba.druid.pool.DruidDataSource;
-import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.utils.ConnectionUtils;
import org.apache.dolphinscheduler.common.utils.SchemaUtils;
import org.apache.dolphinscheduler.common.utils.ScriptRunner;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.AbstractBaseDao;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -156,7 +155,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
try {
- conn.rollback();
+ if (null != conn) {
+ conn.rollback();
+ }
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
@@ -313,7 +314,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e);
} catch (SQLException e) {
try {
- conn.rollback();
+ if (null != conn) {
+ conn.rollback();
+ }
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
@@ -321,7 +324,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) {
try {
- conn.rollback();
+ if (null != conn) {
+ conn.rollback();
+ }
} catch (SQLException e1) {
logger.error(e1.getMessage(),e1);
}
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
index c4b312d608..26d0f1e8e2 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
@@ -24,9 +24,9 @@ import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
import org.apache.dolphinscheduler.common.process.ProcessDag;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessData;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,17 +78,17 @@ public class DagHelper {
List startNodeList = startNodeNameList;
if(taskDependType != TaskDependType.TASK_POST
- && startNodeList.size() == 0){
+ && CollectionUtils.isEmpty(startNodeList)){
logger.error("start node list is empty! cannot continue run the process ");
return destFlowNodeList;
}
List destTaskNodeList = new ArrayList<>();
List tmpTaskNodeList = new ArrayList<>();
if (taskDependType == TaskDependType.TASK_POST
- && recoveryNodeNameList.size() > 0) {
+ && CollectionUtils.isNotEmpty(recoveryNodeNameList)) {
startNodeList = recoveryNodeNameList;
}
- if (startNodeList == null || startNodeList.size() == 0) {
+ if (CollectionUtils.isEmpty(startNodeList)) {
// no special designation start nodes
tmpTaskNodeList = taskNodeList;
} else {
@@ -126,10 +126,8 @@ public class DagHelper {
List resultList = new ArrayList<>();
for (TaskNode taskNode : taskNodeList) {
List depList = taskNode.getDepList();
- if (depList != null) {
- if (depList.contains(startNode.getName())) {
- resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
- }
+ if (null != depList && null != startNode && depList.contains(startNode.getName())) {
+ resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
}
}
@@ -149,9 +147,12 @@ public class DagHelper {
List resultList = new ArrayList<>();
- List depList = startNode.getDepList();
- resultList.add(startNode);
- if (depList == null || depList.size() == 0) {
+ List depList = new ArrayList<>();
+ if (null != startNode) {
+ depList = startNode.getDepList();
+ resultList.add(startNode);
+ }
+ if (CollectionUtils.isEmpty(depList)) {
return resultList;
}
for (String depNodeName : depList) {
@@ -180,7 +181,10 @@ public class DagHelper {
TaskDependType depNodeType) throws Exception {
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
- List taskNodeList = processData.getTasks();
+ List taskNodeList = new ArrayList<>();
+ if (null != processData) {
+ taskNodeList = processData.getTasks();
+ }
List destTaskNodeList = generateFlowNodeListByStartNode(taskNodeList, startNodeNameList, recoveryNodeNameList, depNodeType);
if (destTaskNodeList.isEmpty()) {
return null;
@@ -201,7 +205,10 @@ public class DagHelper {
Map forbidTaskNodeMap = new ConcurrentHashMap<>();
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
- List taskNodeList = processData.getTasks();
+ List taskNodeList = new ArrayList<>();
+ if (null != processData) {
+ taskNodeList = processData.getTasks();
+ }
for(TaskNode node : taskNodeList){
if(node.isForbidden()){
forbidTaskNodeMap.putIfAbsent(node.getName(), node);
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/MysqlPerformance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/MysqlPerformance.java
index 019ef0cd72..40d12ab36f 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/MysqlPerformance.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/MysqlPerformance.java
@@ -17,12 +17,7 @@
package org.apache.dolphinscheduler.dao.utils;
-import org.apache.dolphinscheduler.common.enums.DbType;
-import org.apache.dolphinscheduler.common.enums.Flag;
-import org.apache.dolphinscheduler.dao.MonitorDBDao;
-import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.dolphinscheduler.dao.MonitorDBDao.VARIABLE_NAME;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -30,7 +25,12 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
-import static org.apache.dolphinscheduler.dao.MonitorDBDao.VARIABLE_NAME;
+import org.apache.dolphinscheduler.common.enums.DbType;
+import org.apache.dolphinscheduler.common.enums.Flag;
+import org.apache.dolphinscheduler.dao.MonitorDBDao;
+import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* mysql performance
@@ -55,26 +55,28 @@ public class MysqlPerformance extends BaseDBPerformance{
try{
pstmt = conn.createStatement();
- ResultSet rs1 = pstmt.executeQuery("show global variables");
- while(rs1.next()){
- if(rs1.getString(VARIABLE_NAME).toUpperCase().equals("MAX_CONNECTIONS")){
- monitorRecord.setMaxConnections( Long.parseLong(rs1.getString("value")));
+ try (ResultSet rs1 = pstmt.executeQuery("show global variables")) {
+ while(rs1.next()){
+ if(rs1.getString(VARIABLE_NAME).equalsIgnoreCase("MAX_CONNECTIONS")){
+ monitorRecord.setMaxConnections( Long.parseLong(rs1.getString("value")));
+ }
}
}
- ResultSet rs2 = pstmt.executeQuery("show global status");
- while(rs2.next()){
- if(rs2.getString(VARIABLE_NAME).toUpperCase().equals("MAX_USED_CONNECTIONS")){
- monitorRecord.setMaxUsedConnections(Long.parseLong(rs2.getString("value")));
- }else if(rs2.getString(VARIABLE_NAME).toUpperCase().equals("THREADS_CONNECTED")){
- monitorRecord.setThreadsConnections(Long.parseLong(rs2.getString("value")));
- }else if(rs2.getString(VARIABLE_NAME).toUpperCase().equals("THREADS_RUNNING")){
- monitorRecord.setThreadsRunningConnections(Long.parseLong(rs2.getString("value")));
+ try (ResultSet rs2 = pstmt.executeQuery("show global status")) {
+ while(rs2.next()){
+ if(rs2.getString(VARIABLE_NAME).equalsIgnoreCase("MAX_USED_CONNECTIONS")){
+ monitorRecord.setMaxUsedConnections(Long.parseLong(rs2.getString("value")));
+ }else if(rs2.getString(VARIABLE_NAME).equalsIgnoreCase("THREADS_CONNECTED")){
+ monitorRecord.setThreadsConnections(Long.parseLong(rs2.getString("value")));
+ }else if(rs2.getString(VARIABLE_NAME).equalsIgnoreCase("THREADS_RUNNING")){
+ monitorRecord.setThreadsRunningConnections(Long.parseLong(rs2.getString("value")));
+ }
}
}
}catch (Exception e) {
monitorRecord.setState(Flag.NO);
- logger.error("SQLException " + e);
+ logger.error("SQLException ", e);
}finally {
try {
if (pstmt != null) {
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
index d6471a9a9e..031fd00681 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PostgrePerformance.java
@@ -16,6 +16,12 @@
*/
package org.apache.dolphinscheduler.dao.utils;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Date;
+
import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.dao.MonitorDBDao;
@@ -23,12 +29,6 @@ import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Date;
-
/**
* postgresql performance
*/
@@ -50,26 +50,27 @@ public class PostgrePerformance extends BaseDBPerformance {
Statement pstmt= null;
try{
pstmt = conn.createStatement();
- ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;");
- while(rs1.next()){
- monitorRecord.setThreadsConnections(rs1.getInt("count"));
- break;
+
+ try (ResultSet rs1 = pstmt.executeQuery("select count(*) from pg_stat_activity;")) {
+ if(rs1.next()){
+ monitorRecord.setThreadsConnections(rs1.getInt("count"));
+ }
}
- ResultSet rs2 = pstmt.executeQuery("show max_connections");
- while(rs2.next()){
- monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
- break;
+ try (ResultSet rs2 = pstmt.executeQuery("show max_connections")) {
+ if(rs2.next()){
+ monitorRecord.setMaxConnections( rs2.getInt("max_connections"));
+ }
}
- ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';");
- while(rs3.next()){
- monitorRecord.setThreadsRunningConnections(rs3.getInt("count"));
- break;
+ try (ResultSet rs3 = pstmt.executeQuery("select count(*) from pg_stat_activity pg where pg.state = 'active';")) {
+ if(rs3.next()){
+ monitorRecord.setThreadsRunningConnections(rs3.getInt("count"));
+ }
}
}catch (Exception e) {
monitorRecord.setState(Flag.NO);
- logger.error("SQLException " + e);
+ logger.error("SQLException ", e);
}finally {
try {
if (pstmt != null) {
diff --git a/dolphinscheduler-rpc/pom.xml b/dolphinscheduler-rpc/pom.xml
index f0ac1a0e43..680a4a24c0 100644
--- a/dolphinscheduler-rpc/pom.xml
+++ b/dolphinscheduler-rpc/pom.xml
@@ -31,8 +31,8 @@
UTF-8
- 1.7
- 1.7
+ 1.8
+ 1.83.5.11.9.0
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
index 1f5b16a25a..e5b9daf6f0 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/MasterServer.java
@@ -16,7 +16,6 @@
*/
package org.apache.dolphinscheduler.server.master;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.IStoppable;
import org.apache.dolphinscheduler.common.thread.Stopper;
@@ -24,6 +23,7 @@ import org.apache.dolphinscheduler.common.thread.ThreadPoolExecutors;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerThread;
@@ -141,7 +141,7 @@ public class MasterServer implements IStoppable {
} catch (SchedulerException e1) {
logger.error("QuartzExecutors shutdown failed : " + e1.getMessage(), e1);
}
- logger.error("start Quartz failed : " + e.getMessage(), e);
+ logger.error("start Quartz failed", e);
}
@@ -183,7 +183,7 @@ public class MasterServer implements IStoppable {
//thread sleep 3 seconds for thread quitely stop
Thread.sleep(3000L);
}catch (Exception e){
- logger.warn("thread sleep exception:" + e.getMessage(), e);
+ logger.warn("thread sleep exception ", e);
}
try {
heartbeatMasterService.shutdownNow();
@@ -228,7 +228,7 @@ public class MasterServer implements IStoppable {
} catch (Exception e) {
- logger.error("master server stop exception : " + e.getMessage(), e);
+ logger.error("master server stop exception ", e);
System.exit(-1);
}
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterBaseTaskExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterBaseTaskExecThread.java
index 5c96757072..c1552c4621 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterBaseTaskExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterBaseTaskExecThread.java
@@ -140,7 +140,7 @@ public class MasterBaseTaskExecThread implements Callable {
}
Thread.sleep(commitRetryInterval);
} catch (Exception e) {
- logger.error("task commit to mysql and queue failed : " + e.getMessage(),e);
+ logger.error("task commit to mysql and queue failed",e);
}
retryTimes += 1;
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
index 3481b79caa..a91f8c17e6 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
@@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.server.master.runner;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.*;
import org.apache.dolphinscheduler.common.graph.DAG;
@@ -171,7 +170,7 @@ public class MasterExecThread implements Runnable {
executeProcess();
}
}catch (Exception e){
- logger.error("master exec thread exception: " + e.getMessage(), e);
+ logger.error("master exec thread exception", e);
logger.error("process execute failed, process id:{}", processInstance.getId());
processInstance.setState(ExecutionStatus.FAILURE);
processInstance.setEndTime(new Date());
@@ -356,7 +355,7 @@ public class MasterExecThread implements Runnable {
try {
FileUtils.deleteDirectory(new File(execLocalPath));
} catch (IOException e) {
- logger.error("delete exec dir failed : " + e.getMessage(), e);
+ logger.error("delete exec dir failed ", e);
}
}
}
@@ -734,7 +733,7 @@ public class MasterExecThread implements Runnable {
Date endTime = DateUtils.getScheduleDate(cmdParam.get(CMDPARAM_COMPLEMENT_DATA_END_DATE));
return processInstance.getScheduleTime().equals(endTime);
} catch (Exception e) {
- logger.error("complement end failed : " + e.getMessage(),e);
+ logger.error("complement end failed ",e);
return false;
}
}
@@ -1006,7 +1005,7 @@ public class MasterExecThread implements Runnable {
return task;
}
}catch (Exception e){
- logger.error("get recovery task instance failed : " + e.getMessage(),e);
+ logger.error("get recovery task instance failed ",e);
}
return null;
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java
index 5f594b3fa0..1d34bbd147 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerThread.java
@@ -134,7 +134,7 @@ public class MasterSchedulerThread implements Runnable {
}
}
}catch (Exception e){
- logger.error("master scheduler thread exception : " + e.getMessage(),e);
+ logger.error("master scheduler thread exception",e);
}finally{
AbstractZKClient.releaseMutex(mutex);
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java
index 7d10591e0d..1861e8a908 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java
@@ -137,7 +137,7 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
processInstance = processDao.findProcessInstanceById(processInstance.getId());
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
} catch (Exception e) {
- logger.error("exception: "+ e.getMessage(),e);
+ logger.error("exception",e);
if (processInstance != null) {
logger.error("wait task quit failed, instance id:{}, task id:{}",
processInstance.getId(), taskInstance.getId());
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/SubProcessTaskExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/SubProcessTaskExecThread.java
index 5ee5d01b7a..0026de7c25 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/SubProcessTaskExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/SubProcessTaskExecThread.java
@@ -81,9 +81,11 @@ public class SubProcessTaskExecThread extends MasterBaseTaskExecThread {
result = true;
}catch (Exception e){
- logger.error("exception: "+ e.getMessage(),e);
- logger.error("wait task quit failed, instance id:{}, task id:{}",
- processInstance.getId(), taskInstance.getId());
+ logger.error("exception: ",e);
+ if (null != taskInstance) {
+ logger.error("wait task quit failed, instance id:{}, task id:{}",
+ processInstance.getId(), taskInstance.getId());
+ }
}
return result;
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/monitor/AbstractMonitor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/monitor/AbstractMonitor.java
index ab30ce890f..15fef1e95d 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/monitor/AbstractMonitor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/monitor/AbstractMonitor.java
@@ -16,8 +16,8 @@
*/
package org.apache.dolphinscheduler.server.monitor;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/DruidConnectionProvider.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/DruidConnectionProvider.java
index 32932127f0..05100ac374 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/DruidConnectionProvider.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/DruidConnectionProvider.java
@@ -18,9 +18,9 @@ package org.apache.dolphinscheduler.server.quartz;
import com.alibaba.druid.pool.DruidDataSource;
import org.quartz.SchedulerException;
+import org.quartz.utils.ConnectionProvider;
import java.sql.Connection;
import java.sql.SQLException;
-import org.quartz.utils.ConnectionProvider;
/**
* druid connection provider
@@ -137,7 +137,7 @@ public class DruidConnectionProvider implements ConnectionProvider {
datasource.setDriverClassName(this.driver);
} catch (Exception e) {
try {
- throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), e);
+ throw new SchedulerException("Problem setting driver class name on datasource", e);
} catch (SchedulerException e1) {
}
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/QuartzExecutors.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/QuartzExecutors.java
index bb0f79897d..d4ad08faec 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/QuartzExecutors.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/quartz/QuartzExecutors.java
@@ -27,7 +27,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.Calendar;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -198,7 +197,7 @@ public class QuartzExecutors {
} catch (Exception e) {
logger.error("add job failed", e);
- throw new RuntimeException("add job failed:"+e.getMessage());
+ throw new RuntimeException("add job failed", e);
} finally {
lock.writeLock().unlock();
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/rpc/LogClient.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/rpc/LogClient.java
index 3f12ae75dd..1c6c97b88f 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/rpc/LogClient.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/rpc/LogClient.java
@@ -102,7 +102,7 @@ public class LogClient {
retStrInfo = blockingStub.rollViewLog(pathParameter);
return retStrInfo.getMsg();
} catch (StatusRuntimeException e) {
- logger.error("roll view log failed : " + e.getMessage(), e);
+ logger.error("roll view log failed", e);
return null;
}
}
@@ -122,7 +122,7 @@ public class LogClient {
retStrInfo = blockingStub.viewLog(pathParameter);
return retStrInfo.getMsg();
} catch (StatusRuntimeException e) {
- logger.error("view log failed : " + e.getMessage(), e);
+ logger.error("view log failed", e);
return null;
}
}
@@ -142,7 +142,7 @@ public class LogClient {
retByteInfo = blockingStub.getLogBytes(pathParameter);
return retByteInfo.getData().toByteArray();
} catch (StatusRuntimeException e) {
- logger.error("get log bytes failed : " + e.getMessage(), e);
+ logger.error("get log bytes failed ", e);
return null;
}
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
index 748c8f007e..0b621a9bb0 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
@@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.server.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.CommonUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.server.rpc.LogClient;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -308,7 +308,7 @@ public class ProcessUtils {
Runtime.getRuntime().exec(runCmd);
} catch (Exception e) {
- logger.error("kill application failed : " + e.getMessage(), e);
+ logger.error("kill application failed", e);
}
}
}
@@ -337,7 +337,7 @@ public class ProcessUtils {
killYarnJob(taskInstance);
} catch (Exception e) {
- logger.error("kill failed : " + e.getMessage(), e);
+ logger.error("kill task failed", e);
}
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/UDFUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/UDFUtils.java
index 937e35454d..5e2e535cdb 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/UDFUtils.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/UDFUtils.java
@@ -18,8 +18,8 @@ package org.apache.dolphinscheduler.server.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.text.MessageFormat;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java
index be8d3d12a0..2406a4da88 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java
@@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.server.worker.log;
import ch.qos.logback.classic.pattern.MessageConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.utils.SensitiveLogUtil;
import java.util.regex.Matcher;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
index ae67716da2..536fd0b0ca 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/FetchTaskThread.java
@@ -16,16 +16,12 @@
*/
package org.apache.dolphinscheduler.server.worker.runner;
-import org.apache.commons.lang3.StringUtils;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.queue.ITaskQueue;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
-import org.apache.dolphinscheduler.common.utils.CollectionUtils;
-import org.apache.dolphinscheduler.common.utils.FileUtils;
-import org.apache.dolphinscheduler.common.utils.OSUtils;
-import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
+import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.common.zk.AbstractZKClient;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
@@ -190,6 +186,10 @@ public class FetchTaskThread implements Runnable{
continue;
}
+ if(!checkWorkerGroup(taskInstance, OSUtils.getHost())){
+ continue;
+ }
+
Tenant tenant = processDao.getTenantForProcess(taskInstance.getProcessInstance().getTenantId(),
taskInstance.getProcessDefine().getUserId());
@@ -207,11 +207,6 @@ public class FetchTaskThread implements Runnable{
logger.info("worker fetch taskId : {} from queue ", taskInstId);
-
- if(!checkWorkerGroup(taskInstance, OSUtils.getHost())){
- continue;
- }
-
// local execute path
String execLocalPath = getExecLocalPath();
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
index 32a92d1b8f..715fda108e 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
@@ -20,11 +20,11 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.server.utils.LoggerUtils;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.io.*;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java
index 17413999e2..c1ff89d4cf 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java
@@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.server.worker.task;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.FileUtils;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/TaskManager.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/TaskManager.java
index ce27e1974c..310d9cad9a 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/TaskManager.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/TaskManager.java
@@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.server.worker.task;
import org.apache.dolphinscheduler.common.enums.TaskType;
+import org.apache.dolphinscheduler.common.utils.EnumUtils;
import org.apache.dolphinscheduler.server.worker.task.dependent.DependentTask;
import org.apache.dolphinscheduler.server.worker.task.flink.FlinkTask;
import org.apache.dolphinscheduler.server.worker.task.http.HttpTask;
@@ -27,7 +28,6 @@ import org.apache.dolphinscheduler.server.worker.task.python.PythonTask;
import org.apache.dolphinscheduler.server.worker.task.shell.ShellTask;
import org.apache.dolphinscheduler.server.worker.task.spark.SparkTask;
import org.apache.dolphinscheduler.server.worker.task.sql.SqlTask;
-import org.apache.commons.lang3.EnumUtils;
import org.slf4j.Logger;
/**
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/flink/FlinkTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/flink/FlinkTask.java
index 58ca74a204..0fa9e11ce5 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/flink/FlinkTask.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/flink/FlinkTask.java
@@ -21,12 +21,12 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.flink.FlinkParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.server.utils.FlinkArgsUtils;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractYarnTask;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.util.ArrayList;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java
index 39bcd922c8..97e6cb7bee 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java
@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.server.worker.task.http;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.Charsets;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.HttpMethod;
import org.apache.dolphinscheduler.common.enums.HttpParametersType;
@@ -30,6 +29,7 @@ import org.apache.dolphinscheduler.common.task.http.HttpParameters;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/mr/MapReduceTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/mr/MapReduceTask.java
index 4da3d2c656..b86ff9952e 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/mr/MapReduceTask.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/mr/MapReduceTask.java
@@ -23,10 +23,10 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.mr.MapreduceParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractYarnTask;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import java.util.ArrayList;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTask.java
index 34f7d13ca8..203c0fe146 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTask.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTask.java
@@ -16,13 +16,13 @@
*/
package org.apache.dolphinscheduler.server.worker.task.spark;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.enums.SparkVersion;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.spark.SparkParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.utils.SparkArgsUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractYarnTask;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
index 08a90c62ce..bacb3f22eb 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java
@@ -19,8 +19,6 @@ package org.apache.dolphinscheduler.server.worker.task.sql;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.EnumUtils;
import org.apache.dolphinscheduler.alert.utils.MailUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ShowType;
@@ -33,10 +31,7 @@ import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.sql.SqlBinds;
import org.apache.dolphinscheduler.common.task.sql.SqlParameters;
import org.apache.dolphinscheduler.common.task.sql.SqlType;
-import org.apache.dolphinscheduler.common.utils.CollectionUtils;
-import org.apache.dolphinscheduler.common.utils.CommonUtils;
-import org.apache.dolphinscheduler.common.utils.ParameterUtils;
-import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
+import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.DataSource;
@@ -124,6 +119,13 @@ public class SqlTask extends AbstractTask {
}
dataSource= processDao.findDataSourceById(sqlParameters.getDatasource());
+
+ if (null == dataSource){
+ logger.error("datasource not exists");
+ exitStatusCode = -1;
+ return;
+ }
+
logger.info("datasource name : {} , type : {} , desc : {} , user_id : {} , parameter : {}",
dataSource.getName(),
dataSource.getType(),
@@ -131,12 +133,6 @@ public class SqlTask extends AbstractTask {
dataSource.getUserId(),
dataSource.getConnectionParams());
- if (dataSource == null){
- logger.error("datasource not exists");
- exitStatusCode = -1;
- return;
- }
-
Connection con = null;
List createFuncs = null;
try {
@@ -182,7 +178,7 @@ public class SqlTask extends AbstractTask {
try {
con.close();
} catch (SQLException e) {
- throw e;
+ logger.error(e.getMessage(),e);
}
}
}
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTaskTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTaskTest.java
index b502e13bc6..a18e0b2a9d 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTaskTest.java
+++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/task/spark/SparkTaskTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.dolphinscheduler.server.worker.task.spark;
-import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.enums.SparkVersion;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.task.spark.SparkParameters;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.utils.SparkArgsUtils;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
diff --git a/dolphinscheduler-ui/pom.xml b/dolphinscheduler-ui/pom.xml
index 28f584f49a..3fd9aa6650 100644
--- a/dolphinscheduler-ui/pom.xml
+++ b/dolphinscheduler-ui/pom.xml
@@ -31,6 +31,7 @@
v12.12.06.11.3
+ src
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.js b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.js
index 11f22132c7..8225673ecd 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.js
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.js
@@ -177,8 +177,6 @@ Dag.prototype.backfill = function (arg) {
// Number of tree node levels
let countTree = getLeafCountTree(datas[0])
function getMaxFloor(treeData) {
- let floor = 0
- let v = this
let max = 0
function each (data, floor) {
data.forEach(e => {
@@ -224,9 +222,8 @@ Dag.prototype.backfill = function (arg) {
return []
}
function toLine(data){
- return data.reduce((arr, {id, name, targetarr, x, y, children = []}) =>
- arr.concat([{id, name, targetarr, x, y}], toLine(children)), [])
- return result;
+ return data.reduce((arrData, {id, name, targetarr, x, y, children = []}) =>
+ arrData.concat([{id, name, targetarr, x, y}], toLine(children)), [])
}
let listarr = toLine(datas);
let listarrs = toLine(datas)
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.scss b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.scss
index 7fdb5e64f2..237e6f5cd9 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.scss
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.scss
@@ -309,14 +309,15 @@ svg path:hover {
//min-width: calc(100% - 220px);
width: 8000px;
height: 5000px;
- position: relative;
svg:not(:root){
z-index: 11;
}
}
.jtk-demo-canvas {
+ position: relative;
height: 100%;
+ display: flex;
}
.jtk-bootstrap {
@@ -359,10 +360,6 @@ svg path:hover {
list-style-type: disc !important;
}
-.jtk-demo-canvas {
- display: flex;
-}
-
.canvas-wide {
padding-top: 10px;
margin-left: 0;
@@ -459,6 +456,12 @@ svg path:hover {
-webkit-transition: background-color 0.25s ease-in;
-moz-transition: background-color 0.25s ease-in;
transition: background-color 0.25s ease-in;
+ background-color: white;
+ opacity: 0.8;
+ padding: 0.3em;
+ border-radius: 0.5em;
+ border: 1px solid #346789;
+ cursor: pointer;
}
.aLabel.jtk-hover,
@@ -485,14 +488,6 @@ svg path:hover {
}
}
-.aLabel {
- background-color: white;
- opacity: 0.8;
- padding: 0.3em;
- border-radius: 0.5em;
- border: 1px solid #346789;
- cursor: pointer;
-}
.jtk-ep {
.ep {
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
index 8b1c353d41..feb756dabe 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue
@@ -58,7 +58,7 @@
{{name}}
-
+