status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
/* * 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 static java.nio.charset.StandardCharsets.UTF_8; import static com.fasterxml.jackson.databind.DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL; import static com.fasterxml.jackson.databind.MapperFeature.REQUIRE_SETTERS_FOR_GETTERS; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.spi.utils.StringUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.TimeZone; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.type.CollectionType; /** * json utils */ public class JSONUtils {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class); static { logger.info("init timezone: {}",TimeZone.getDefault()); } /** * can use static singleton, inject: just make sure to reuse! */ private static final ObjectMapper objectMapper = new ObjectMapper() .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true) .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true) .configure(REQUIRE_SETTERS_FOR_GETTERS, true) .setTimeZone(TimeZone.getDefault()) .setDateFormat(new SimpleDateFormat(Constants.YYYY_MM_DD_HH_MM_SS)); private JSONUtils() { throw new UnsupportedOperationException("Construct JSONUtils"); } public static ArrayNode createArrayNode() { return objectMapper.createArrayNode();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
} public static ObjectNode createObjectNode() { return objectMapper.createObjectNode(); } public static JsonNode toJsonNode(Object obj) { return objectMapper.valueToTree(obj); } /** * json representation of object * * @param object object * @param feature feature * @return object to json string */ public static String toJsonString(Object object, SerializationFeature feature) { try { ObjectWriter writer = objectMapper.writer(feature); return writer.writeValueAsString(object); } catch (Exception e) { logger.error("object to json exception!", e); } return null; } /** * This method deserializes the specified Json into an object of the specified class. It is not * suitable to use if the specified class is a generic type since it will not have the generic * type information because of the Type Erasure feature of Java. Therefore, this method should not * be used if the desired type is a generic type. Note that this method works fine if the any of * the fields of the specified object are generics, just the object itself should not be a * generic type.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* * @param json the string from which the object is to be deserialized * @param clazz the class of T * @param <T> T * @return an object of type T from the string * classOfT */ public static <T> T parseObject(String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) { return null; } try { return objectMapper.readValue(json, clazz); } catch (Exception e) { logger.error("parse object exception!", e); } return null; } /** * deserialize * * @param src byte array * @param clazz class * @param <T> deserialize type * @return deserialize type */ public static <T> T parseObject(byte[] src, Class<T> clazz) { if (src == null) { return null; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
String json = new String(src, UTF_8); return parseObject(json, clazz); } /** * json to list * * @param json json string * @param clazz class * @param <T> T * @return list */ public static <T> List<T> toList(String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) { return Collections.emptyList(); } try { CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, clazz); return objectMapper.readValue(json, listType); } catch (Exception e) { logger.error("parse list exception!", e); } return Collections.emptyList(); } /** * check json object valid * * @param json json * @return true if valid */ public static boolean checkJsonValid(String json) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
if (StringUtils.isEmpty(json)) { return false; } try { objectMapper.readTree(json); return true; } catch (IOException e) { logger.error("check json object valid exception!", e); } return false; } /** * Method for finding a JSON Object field with specified name in this * node or its child nodes, and returning value it has. * If no matching field is found in this node or its descendants, returns null. * * @param jsonNode json node * @param fieldName Name of field to look for * @return Value of first matching node found, if any; null if none */ public static String findValue(JsonNode jsonNode, String fieldName) { JsonNode node = jsonNode.findValue(fieldName); if (node == null) { return null; } return node.asText(); } /** * json to map * {@link #toMap(String, Class, Class)}
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* * @param json json * @return json to map */ public static Map<String, String> toMap(String json) { return parseObject(json, new TypeReference<Map<String, String>>() {}); } /** * json to map * * @param json json * @param classK classK * @param classV classV * @param <K> K * @param <V> V * @return to map */ public static <K, V> Map<K, V> toMap(String json, Class<K> classK, Class<V> classV) { if (StringUtils.isEmpty(json)) { return Collections.emptyMap(); } try { return objectMapper.readValue(json, new TypeReference<Map<K, V>>() { }); } catch (Exception e) { logger.error("json to map exception!", e); } return Collections.emptyMap(); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
* from the key-value generated json to get the str value no matter the real type of value * @param json the json str * @param nodeName key * @return the str value of key */ public static String getNodeString(String json, String nodeName) { try { JsonNode rootNode = objectMapper.readTree(json); JsonNode jsonNode = rootNode.findValue(nodeName); if (Objects.isNull(jsonNode)) { return ""; } return jsonNode.isTextual() ? jsonNode.asText() : jsonNode.toString(); } catch (JsonProcessingException e) { return ""; } } /** * json to object * * @param json json string * @param type type reference * @param <T> * @return return parse object */ public static <T> T parseObject(String json, TypeReference<T> type) { if (StringUtils.isEmpty(json)) { return null; } try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
return objectMapper.readValue(json, type); } catch (Exception e) { logger.error("json to map exception!", e); } return null; } /** * object to json string * * @param object object * @return json string */ public static String toJsonString(Object object) { try { return objectMapper.writeValueAsString(object); } catch (Exception e) { throw new RuntimeException("Object json deserialization exception.", e); } } /** * serialize to json byte * * @param obj object * @param <T> object type * @return byte array */ public static <T> byte[] toJsonByteArray(T obj) { if (obj == null) { return null; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
String json = ""; try { json = toJsonString(obj); } catch (Exception e) { logger.error("json serialize exception.", e); } return json.getBytes(UTF_8); } public static ObjectNode parseObject(String text) { try { if (text.isEmpty()) { return parseObject(text, ObjectNode.class); } else { return (ObjectNode) objectMapper.readTree(text); } } catch (Exception e) { throw new RuntimeException("String json deserialization exception.", e); } } public static ArrayNode parseArray(String text) { try { return (ArrayNode) objectMapper.readTree(text); } catch (Exception e) { throw new RuntimeException("Json deserialization exception.", e); } } /** * json serializer */ public static class JsonDataSerializer extends JsonSerializer<String> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
@Override public void serialize(String value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeRawValue(value); } } /** * json data deserializer */ public static class JsonDataDeserializer extends JsonDeserializer<String> { @Override public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); if (node instanceof TextNode) { return node.asText(); } else { return node.toString(); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
/* * 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.util.ArrayList;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.junit.Assert; import org.junit.Test; public class JSONUtilsTest { @Test public void createArrayNodeTest() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "[{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"},{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}]"; JsonNode jsonNode = JSONUtils.toJsonNode(property); ArrayNode arrayNode = JSONUtils.createArrayNode(); ArrayList<JsonNode> objects = new ArrayList<>(); objects.add(jsonNode); objects.add(jsonNode);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
ArrayNode jsonNodes = arrayNode.addAll(objects); String s = JSONUtils.toJsonString(jsonNodes); Assert.assertEquals(s, str); } @Test public void toJsonNodeTest() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "{\"prop\":\"ds\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}"; JsonNode jsonNodes = JSONUtils.toJsonNode(property); String s = JSONUtils.toJsonString(jsonNodes); Assert.assertEquals(s, str); } @Test public void createObjectNodeTest() { String jsonStr = "{\"a\":\"b\",\"b\":\"d\"}"; ObjectNode objectNode = JSONUtils.createObjectNode(); objectNode.put("a", "b"); objectNode.put("b", "d"); String s = JSONUtils.toJsonString(objectNode); Assert.assertEquals(s, jsonStr); } @Test public void toMap() { String jsonStr = "{\"id\":\"1001\",\"name\":\"Jobs\"}"; Map<String, String> models = JSONUtils.toMap(jsonStr); Assert.assertEquals("1001", models.get("id"));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
Assert.assertEquals("Jobs", models.get("name")); } @Test public void convert2Property() { Property property = new Property(); property.setProp("ds"); property.setDirect(Direct.IN); property.setType(DataType.VARCHAR); property.setValue("sssssss"); String str = "{\"direct\":\"IN\",\"prop\":\"ds\",\"type\":\"VARCHAR\",\"value\":\"sssssss\"}"; Property property1 = JSONUtils.parseObject(str, Property.class); Direct direct = property1.getDirect(); Assert.assertEquals(Direct.IN, direct); } @Test public void string2MapTest() { String str = list2String(); List<LinkedHashMap> maps = JSONUtils.toList(str, LinkedHashMap.class); Assert.assertEquals(1, maps.size()); Assert.assertEquals("mysql200", maps.get(0).get("mysql service name")); Assert.assertEquals("192.168.xx.xx", maps.get(0).get("mysql address")); Assert.assertEquals("3306", maps.get(0).get("port")); Assert.assertEquals("80", maps.get(0).get("no index of number")); Assert.assertEquals("190", maps.get(0).get("database client connections")); } public String list2String() { LinkedHashMap<String, String> map1 = new LinkedHashMap<>(); map1.put("mysql service name", "mysql200"); map1.put("mysql address", "192.168.xx.xx");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
map1.put("port", "3306"); map1.put("no index of number", "80"); map1.put("database client connections", "190"); List<LinkedHashMap<String, String>> maps = new ArrayList<>(); maps.add(0, map1); String resultJson = JSONUtils.toJsonString(maps); return resultJson; } @Test public void testParseObject() { Assert.assertNull(JSONUtils.parseObject("")); Assert.assertNull(JSONUtils.parseObject("foo", String.class)); } @Test public void testNodeString() { Assert.assertEquals("", JSONUtils.getNodeString("", "key")); Assert.assertEquals("", JSONUtils.getNodeString("abc", "key")); Assert.assertEquals("", JSONUtils.getNodeString("{\"bar\":\"foo\"}", "key")); Assert.assertEquals("foo", JSONUtils.getNodeString("{\"bar\":\"foo\"}", "bar")); Assert.assertEquals("[1,2,3]", JSONUtils.getNodeString("{\"bar\": [1,2,3]}", "bar")); Assert.assertEquals("{\"1\":\"2\",\"2\":3}", JSONUtils.getNodeString("{\"bar\": {\"1\":\"2\",\"2\":3}}", "bar")); } @Test public void testJsonByteArray() { String str = "foo"; byte[] serializeByte = JSONUtils.toJsonByteArray(str); String deserialize = JSONUtils.parseObject(serializeByte, String.class); Assert.assertEquals(str, deserialize); str = null; serializeByte = JSONUtils.toJsonByteArray(str);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
deserialize = JSONUtils.parseObject(serializeByte, String.class); Assert.assertNull(deserialize); } @Test public void testToList() { Assert.assertEquals(new ArrayList(), JSONUtils.toList("A1B2C3", null)); Assert.assertEquals(new ArrayList(), JSONUtils.toList("", null)); } @Test public void testCheckJsonValid() { Assert.assertTrue(JSONUtils.checkJsonValid("3")); Assert.assertFalse(JSONUtils.checkJsonValid("")); } @Test public void testFindValue() { Assert.assertNull(JSONUtils.findValue( new ArrayNode(new JsonNodeFactory(true)), null)); } @Test public void testToMap() { Map<String, String> map = new HashMap<>(); map.put("foo", "bar"); Assert.assertTrue(map.equals(JSONUtils.toMap( "{\n" + "\"foo\": \"bar\"\n" + "}"))); Assert.assertFalse(map.equals(JSONUtils.toMap( "{\n" + "\"bar\": \"foo\"\n" + "}"))); Assert.assertNull(JSONUtils.toMap("3")); Assert.assertNull(JSONUtils.toMap(null));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
String str = "{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"#!/bin/bash\\necho \\\"shell-1\\\"\"}"; Map<String, String> m = JSONUtils.toMap(str); Assert.assertNotNull(m); } @Test public void testToJsonString() { Map<String, Object> map = new HashMap<>(); map.put("foo", "bar"); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map)); Assert.assertEquals(String.valueOf((Object) null), JSONUtils.toJsonString(null)); Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJsonString(map, SerializationFeature.WRITE_NULL_MAP_VALUES)); } @Test public void parseObject() { String str = "{\"color\":\"yellow\",\"type\":\"renault\"}"; ObjectNode node = JSONUtils.parseObject(str); Assert.assertEquals("yellow", node.path("color").asText()); node.put("price", 100); Assert.assertEquals(100, node.path("price").asInt()); node.put("color", "red"); Assert.assertEquals("red", node.path("color").asText()); } @Test public void parseArray() { String str = "[{\"color\":\"yellow\",\"type\":\"renault\"}]"; ArrayNode node = JSONUtils.parseArray(str); Assert.assertEquals("yellow", node.path(0).path("color").asText());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,282
[Bug] [dolphinscheduler-common] JSONUtils tool class time zone problem reporting error
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened report error in mvn test,but not occur error when use Junit to run JSONUtilsTets.java file。 ``` @Test public void dateToString() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } ``` The dateToString and stringToDate methods get the following errors when running `mvn test` ``` [ERROR] Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest Tests run: 19, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.118 s <<< FAILURE! - in org.apache.dolphinscheduler.common.utils.JSONUtilsTest stringToDate(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.014 s <<< FAILURE! java.lang.AssertionError: expected:<Tue Feb 22 21:38:24 CST 2022> but was:<Tue Feb 22 13:38:24 CST 2022> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.stringToDate(JSONUtilsTest.java:280) [ERROR] dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! dateToString(org.apache.dolphinscheduler.common.utils.JSONUtilsTest) Time elapsed: 0.003 s <<< FAILURE! org.junit.ComparisonFailure: expected:<"2022-02-22 [05]:38:24"> but was:<"2022-02-22 [13]:38:24"> at org.apache.dolphinscheduler.common.utils.JSONUtilsTest.dateToString(JSONUtilsTest.java:269) ``` ### What you expected to happen use case passed ### How to reproduce OS Version : Any JDK Versin : Oracle JDK11 Run `mvn test -e ` in the terminal or press the button in IDEA ### Anything else I wrote a demo to show how to reproduce it easily without waiting a long time for mvn test to run. I will analyze why this problem occurs and submit a pull request. ``` import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtilsTest; import java.util.TimeZone; public class TimeZoneTest { public static void main(String[] args) { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); JSONUtils.createArrayNode();// This step is to load class and initialize JSONUtils's static code block new JSONUtilsTest().stringToDate(); new JSONUtilsTest().dateToString(); } } ``` ![image](https://user-images.githubusercontent.com/50058173/170871560-220da39a-6332-48bf-826a-0251ebf0e616.png) ![image](https://user-images.githubusercontent.com/50058173/170871585-f381b568-a0a1-4fde-b344-af5fa69d9ede.png) ![image](https://user-images.githubusercontent.com/50058173/170872251-592d43cd-8448-4abb-8d85-783b3578831c.png) The above one gives my demo and some source code screenshots. The reason for the bug is among them: - when using junit to execute use cases, each use case is isolated, and the JSONUtils class will not be shared among multiple use cases. In this case, `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")) `will not fail.Because the JSONUtils class is reinitialized once per use case - In the case of using` mvn test`, which is described in my demo, when the default time zone of the `TimeZone `class is set in other places through `TimeZone.setDefault`, the initialization of `JSONUtils` is carried out. At this time, `JSONUtils` final and static descriptors are modified parts The default time zone information in `TimeZone `will be loaded, and setting the `TimeZone `time zone via `TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))` in the future will not have any effect on JSONUtils. 上面个给出了我的demo和部分源码截图,bug出现的原因就在其中: - 当使用junit执行用例时,每个用例都是隔离的,此时多个用例之间不会共享JSONUtils类,这种情况下就不会出现TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))失效。因为每个用例都会重新初始化一次JSONUtils类 - 而在使用mvn test的情况中,也就是我demo中描述的那样,当在其他地方通过TimeZone.setDefault设置过TimeZone类默认时区后再进行JSONUtils的初始化,此时JSONUtils final 和static描述符修饰的部分就会加载TimeZone中默认的时区信息,而在以后再通过TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"))设置TimeZone时区并不会对JSONUtils产生任何影响。 ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! #10284 ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10282
https://github.com/apache/dolphinscheduler/pull/10284
ad2646ff1f7baa5d76d29023ced2c28a89b52f6b
062146eecd9ceabbd6d1fd32747372802749d6bd
2022-05-29T14:01:53Z
java
2022-06-17T03:08:38Z
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java
} @Test public void jsonDataDeserializerTest() { String a = "{\"conditionResult\":\"{\\\"successNode\\\":[\\\"\\\"],\\\"failedNode\\\":[\\\"\\\"]}\"," + "\"conditionsTask\":false,\"depList\":[],\"dependence\":\"{}\",\"forbidden\":false," + "\"id\":\"tasks-86823\",\"maxRetryTimes\":1,\"name\":\"shell test\"," + "\"params\":\"{\\\"resourceList\\\":[],\\\"localParams\\\":[],\\\"rawScript\\\":\\\"echo " + "'yyc'\\\"}\",\"preTasks\":\"[]\",\"retryInterval\":1,\"runFlag\":\"NORMAL\"," + "\"taskInstancePriority\":\"HIGHEST\",\"taskTimeoutParameter\":{\"enable\":false,\"interval\":0}," + "\"timeout\":\"{}\",\"type\":\"SHELL\",\"workerGroup\":\"default\"}"; TaskNode taskNode = JSONUtils.parseObject(a, TaskNode.class); Assert.assertTrue(true); } @Test public void dateToString() { String time = "2022-02-22 13:38:24"; Date date = DateUtils.stringToDate(time); String json = JSONUtils.toJsonString(date); Assert.assertEquals(json, "\"" + time + "\""); String errorFormatTime = "Tue Feb 22 03:50:00 UTC 2022"; Assert.assertNull(DateUtils.stringToDate(errorFormatTime)); } @Test public void stringToDate() { String json = "\"2022-02-22 13:38:24\""; Date date = JSONUtils.parseObject(json, Date.class); Assert.assertEquals(date, DateUtils.stringToDate("2022-02-22 13:38:24")); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
/* * 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
* limitations under the License. */ package org.apache.dolphinscheduler.dao.utils; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.model.TaskNodeRelation; import org.apache.dolphinscheduler.common.process.ProcessDag; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * dag tools */ public class DagHelper {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
private static final Logger logger = LoggerFactory.getLogger(DagHelper.class); /** * generate flow node relation list by task node list; * Edges that are not in the task Node List will not be added to the result * * @param taskNodeList taskNodeList * @return task node relation list */ public static List<TaskNodeRelation> generateRelationListByFlowNodes(List<TaskNode> taskNodeList) { List<TaskNodeRelation> nodeRelationList = new ArrayList<>(); for (TaskNode taskNode : taskNodeList) { String preTasks = taskNode.getPreTasks(); List<String> preTaskList = JSONUtils.toList(preTasks, String.class); if (preTaskList != null) { for (String depNodeCode : preTaskList) { if (null != findNodeByCode(taskNodeList, depNodeCode)) { nodeRelationList.add(new TaskNodeRelation(depNodeCode, Long.toString(taskNode.getCode()))); } } } } return nodeRelationList;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
} /** * generate task nodes needed by dag * * @param taskNodeList taskNodeList * @param startNodeNameList startNodeNameList * @param recoveryNodeCodeList recoveryNodeCodeList * @param taskDependType taskDependType * @return task node list */ public static List<TaskNode> generateFlowNodeListByStartNode(List<TaskNode> taskNodeList, List<String> startNodeNameList, List<String> recoveryNodeCodeList, TaskDependType taskDependType) { List<TaskNode> destFlowNodeList = new ArrayList<>(); List<String> startNodeList = startNodeNameList; if (taskDependType != TaskDependType.TASK_POST && CollectionUtils.isEmpty(startNodeList)) { logger.error("start node list is empty! cannot continue run the process "); return destFlowNodeList; } List<TaskNode> destTaskNodeList = new ArrayList<>(); List<TaskNode> tmpTaskNodeList = new ArrayList<>(); if (taskDependType == TaskDependType.TASK_POST && CollectionUtils.isNotEmpty(recoveryNodeCodeList)) { startNodeList = recoveryNodeCodeList; } if (CollectionUtils.isEmpty(startNodeList)) { tmpTaskNodeList = taskNodeList; } else { for (String startNodeCode : startNodeList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
TaskNode startNode = findNodeByCode(taskNodeList, startNodeCode); List<TaskNode> childNodeList = new ArrayList<>(); if (startNode == null) { logger.error("start node name [{}] is not in task node list [{}] ", startNodeCode, taskNodeList ); continue; } else if (TaskDependType.TASK_POST == taskDependType) { List<String> visitedNodeCodeList = new ArrayList<>(); childNodeList = getFlowNodeListPost(startNode, taskNodeList, visitedNodeCodeList); } else if (TaskDependType.TASK_PRE == taskDependType) { List<String> visitedNodeCodeList = new ArrayList<>(); childNodeList = getFlowNodeListPre(startNode, recoveryNodeCodeList, taskNodeList, visitedNodeCodeList); } else { childNodeList.add(startNode); } tmpTaskNodeList.addAll(childNodeList); } } for (TaskNode taskNode : tmpTaskNodeList) { if (null == findNodeByCode(destTaskNodeList, Long.toString(taskNode.getCode()))) { destTaskNodeList.add(taskNode); } } return destTaskNodeList; } /** * find all the nodes that depended on the start node *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
* @param startNode startNode * @param taskNodeList taskNodeList * @return task node list */ private static List<TaskNode> getFlowNodeListPost(TaskNode startNode, List<TaskNode> taskNodeList, List<String> visitedNodeCodeList) { List<TaskNode> resultList = new ArrayList<>(); for (TaskNode taskNode : taskNodeList) { List<String> depList = taskNode.getDepList(); if (null != depList && null != startNode && depList.contains(Long.toString(startNode.getCode())) && !visitedNodeCodeList.contains(Long.toString(taskNode.getCode()))) { resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList, visitedNodeCodeList)); } } if (null != startNode) { visitedNodeCodeList.add(Long.toString(startNode.getCode())); } resultList.add(startNode); return resultList; } /** * find all nodes that start nodes depend on. * * @param startNode startNode * @param recoveryNodeCodeList recoveryNodeCodeList * @param taskNodeList taskNodeList * @return task node list */ private static List<TaskNode> getFlowNodeListPre(TaskNode startNode, List<String> recoveryNodeCodeList, List<TaskNode> taskNodeList, List<String> visitedNodeCodeList) { List<TaskNode> resultList = new ArrayList<>(); List<String> depList = new ArrayList<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
if (null != startNode) { depList = startNode.getDepList(); resultList.add(startNode); } if (CollectionUtils.isEmpty(depList)) { return resultList; } for (String depNodeCode : depList) { TaskNode start = findNodeByCode(taskNodeList, depNodeCode); if (recoveryNodeCodeList.contains(depNodeCode)) { resultList.add(start); } else if (!visitedNodeCodeList.contains(depNodeCode)) { resultList.addAll(getFlowNodeListPre(start, recoveryNodeCodeList, taskNodeList, visitedNodeCodeList)); } } if (null != startNode) { visitedNodeCodeList.add(Long.toString(startNode.getCode())); } return resultList; } /** * generate dag by start nodes and recovery nodes * * @param totalTaskNodeList totalTaskNodeList * @param startNodeNameList startNodeNameList * @param recoveryNodeCodeList recoveryNodeCodeList * @param depNodeType depNodeType * @return process dag * @throws Exception if error throws Exception
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
*/ public static ProcessDag generateFlowDag(List<TaskNode> totalTaskNodeList, List<String> startNodeNameList, List<String> recoveryNodeCodeList, TaskDependType depNodeType) throws Exception { List<TaskNode> destTaskNodeList = generateFlowNodeListByStartNode(totalTaskNodeList, startNodeNameList, recoveryNodeCodeList, depNodeType); if (destTaskNodeList.isEmpty()) { return null; } List<TaskNodeRelation> taskNodeRelations = generateRelationListByFlowNodes(destTaskNodeList); ProcessDag processDag = new ProcessDag(); processDag.setEdges(taskNodeRelations); processDag.setNodes(destTaskNodeList); return processDag; } /** * find node by node name * * @param nodeDetails nodeDetails * @param nodeName nodeName * @return task node */ public static TaskNode findNodeByName(List<TaskNode> nodeDetails, String nodeName) { for (TaskNode taskNode : nodeDetails) { if (taskNode.getName().equals(nodeName)) { return taskNode; } } return null; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
/** * find node by node code * * @param nodeDetails nodeDetails * @param nodeCode nodeCode * @return task node */ public static TaskNode findNodeByCode(List<TaskNode> nodeDetails, String nodeCode) { for (TaskNode taskNode : nodeDetails) { if (Long.toString(taskNode.getCode()).equals(nodeCode)) { return taskNode; } } return null; } /** * the task can be submit when all the depends nodes are forbidden or complete * * @param taskNode taskNode * @param dag dag * @param completeTaskList completeTaskList * @return can submit */ public static boolean allDependsForbiddenOrEnd(TaskNode taskNode, DAG<String, TaskNode, TaskNodeRelation> dag, Map<String, TaskNode> skipTaskNodeList, Map<String, TaskInstance> completeTaskList) { List<String> dependList = taskNode.getDepList(); if (dependList == null) { return true;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
} for (String dependNodeCode : dependList) { TaskNode dependNode = dag.getNode(dependNodeCode); if (dependNode == null || completeTaskList.containsKey(dependNodeCode) || dependNode.isForbidden() || skipTaskNodeList.containsKey(dependNodeCode)) { continue; } else { return false; } } return true; } /** * parse the successor nodes of previous node. * this function parse the condition node to find the right branch. * also check all the depends nodes forbidden or complete * * @return successor nodes */ public static Set<String> parsePostNodes(String preNodeCode, Map<String, TaskNode> skipTaskNodeList, DAG<String, TaskNode, TaskNodeRelation> dag, Map<String, TaskInstance> completeTaskList) { Set<String> postNodeList = new HashSet<>(); Collection<String> startVertexes = new ArrayList<>(); if (preNodeCode == null) { startVertexes = dag.getBeginNode(); } else if (dag.getNode(preNodeCode).isConditionsTask()) { List<String> conditionTaskList = parseConditionTask(preNodeCode, skipTaskNodeList, dag, completeTaskList);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
startVertexes.addAll(conditionTaskList); } else if (dag.getNode(preNodeCode).isSwitchTask()) { List<String> conditionTaskList = parseSwitchTask(preNodeCode, skipTaskNodeList, dag, completeTaskList); startVertexes.addAll(conditionTaskList); } else { startVertexes = dag.getSubsequentNodes(preNodeCode); } for (String subsequent : startVertexes) { TaskNode taskNode = dag.getNode(subsequent); if (taskNode == null) { logger.error("taskNode {} is null, please check dag", subsequent); continue; } if (isTaskNodeNeedSkip(taskNode, skipTaskNodeList)) { setTaskNodeSkip(subsequent, dag, completeTaskList, skipTaskNodeList); continue; } if (!DagHelper.allDependsForbiddenOrEnd(taskNode, dag, skipTaskNodeList, completeTaskList)) { continue; } if (taskNode.isForbidden() || completeTaskList.containsKey(subsequent)) { postNodeList.addAll(parsePostNodes(subsequent, skipTaskNodeList, dag, completeTaskList)); continue; } postNodeList.add(subsequent); } return postNodeList; } /** * if all of the task dependence are skipped, skip it too.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
*/ private static boolean isTaskNodeNeedSkip(TaskNode taskNode, Map<String, TaskNode> skipTaskNodeList ) { if (CollectionUtils.isEmpty(taskNode.getDepList())) { return false; } for (String depNode : taskNode.getDepList()) { if (!skipTaskNodeList.containsKey(depNode)) { return false; } } return true; } /** * parse condition task find the branch process * set skip flag for another one. */ public static List<String> parseConditionTask(String nodeCode, Map<String, TaskNode> skipTaskNodeList, DAG<String, TaskNode, TaskNodeRelation> dag, Map<String, TaskInstance> completeTaskList) { List<String> conditionTaskList = new ArrayList<>(); TaskNode taskNode = dag.getNode(nodeCode); if (!taskNode.isConditionsTask()) { return conditionTaskList; } if (!completeTaskList.containsKey(nodeCode)) { return conditionTaskList; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
TaskInstance taskInstance = completeTaskList.get(nodeCode); ConditionsParameters conditionsParameters = JSONUtils.parseObject(taskNode.getConditionResult(), ConditionsParameters.class); List<String> skipNodeList = new ArrayList<>(); if (taskInstance.getState().typeIsSuccess()) { conditionTaskList = conditionsParameters.getSuccessNode(); skipNodeList = conditionsParameters.getFailedNode(); } else if (taskInstance.getState().typeIsFailure()) { conditionTaskList = conditionsParameters.getFailedNode(); skipNodeList = conditionsParameters.getSuccessNode(); } else { conditionTaskList.add(nodeCode); } for (String failedNode : skipNodeList) { setTaskNodeSkip(failedNode, dag, completeTaskList, skipTaskNodeList); } return conditionTaskList; } /** * parse condition task find the branch process * set skip flag for another one. * * @param nodeCode * @return */ public static List<String> parseSwitchTask(String nodeCode, Map<String, TaskNode> skipTaskNodeList, DAG<String, TaskNode, TaskNodeRelation> dag, Map<String, TaskInstance> completeTaskList) { List<String> conditionTaskList = new ArrayList<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
TaskNode taskNode = dag.getNode(nodeCode); if (!taskNode.isSwitchTask()) { return conditionTaskList; } if (!completeTaskList.containsKey(nodeCode)) { return conditionTaskList; } conditionTaskList = skipTaskNode4Switch(taskNode, skipTaskNodeList, completeTaskList, dag); return conditionTaskList; } private static List<String> skipTaskNode4Switch(TaskNode taskNode, Map<String, TaskNode> skipTaskNodeList, Map<String, TaskInstance> completeTaskList, DAG<String, TaskNode, TaskNodeRelation> dag) { SwitchParameters switchParameters = completeTaskList.get(Long.toString(taskNode.getCode())).getSwitchDependency(); int resultConditionLocation = switchParameters.getResultConditionLocation(); List<SwitchResultVo> conditionResultVoList = switchParameters.getDependTaskList(); List<String> switchTaskList = conditionResultVoList.get(resultConditionLocation).getNextNode(); if (CollectionUtils.isEmpty(switchTaskList)) { switchTaskList = new ArrayList<>(); } conditionResultVoList.remove(resultConditionLocation); for (SwitchResultVo info : conditionResultVoList) { if (CollectionUtils.isEmpty(info.getNextNode())) { continue; } setTaskNodeSkip(info.getNextNode().get(0), dag, completeTaskList, skipTaskNodeList); } return switchTaskList; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
* set task node and the post nodes skip flag */ private static void setTaskNodeSkip(String skipNodeCode, DAG<String, TaskNode, TaskNodeRelation> dag, Map<String, TaskInstance> completeTaskList, Map<String, TaskNode> skipTaskNodeList) { if (!dag.containsNode(skipNodeCode)) { return; } skipTaskNodeList.putIfAbsent(skipNodeCode, dag.getNode(skipNodeCode)); Collection<String> postNodeList = dag.getSubsequentNodes(skipNodeCode); for (String post : postNodeList) { TaskNode postNode = dag.getNode(post); if (isTaskNodeNeedSkip(postNode, skipTaskNodeList)) { setTaskNodeSkip(post, dag, completeTaskList, skipTaskNodeList); } } } /*** * build dag graph * @param processDag processDag * @return dag */ public static DAG<String, TaskNode, TaskNodeRelation> buildDagGraph(ProcessDag processDag) { DAG<String, TaskNode, TaskNodeRelation> dag = new DAG<>(); if (CollectionUtils.isNotEmpty(processDag.getNodes())) { for (TaskNode node : processDag.getNodes()) { dag.addNode(Long.toString(node.getCode()), node); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
} if (CollectionUtils.isNotEmpty(processDag.getEdges())) { for (TaskNodeRelation edge : processDag.getEdges()) { dag.addEdge(edge.getStartNode(), edge.getEndNode()); } } return dag; } /** * get process dag * * @param taskNodeList task node list * @return Process dag */ public static ProcessDag getProcessDag(List<TaskNode> taskNodeList) { List<TaskNodeRelation> taskNodeRelations = new ArrayList<>(); for (TaskNode taskNode : taskNodeList) { String preTasks = taskNode.getPreTasks(); List<String> preTasksList = JSONUtils.toList(preTasks, String.class); if (preTasksList != null) { for (String depNode : preTasksList) { taskNodeRelations.add(new TaskNodeRelation(depNode, Long.toString(taskNode.getCode()))); } } } ProcessDag processDag = new ProcessDag(); processDag.setEdges(taskNodeRelations);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
processDag.setNodes(taskNodeList); return processDag; } /** * get process dag * * @param taskNodeList task node list * @return Process dag */ public static ProcessDag getProcessDag(List<TaskNode> taskNodeList, List<ProcessTaskRelation> processTaskRelations) { Map<Long, TaskNode> taskNodeMap = new HashMap<>(); taskNodeList.forEach(taskNode -> { taskNodeMap.putIfAbsent(taskNode.getCode(), taskNode); }); List<TaskNodeRelation> taskNodeRelations = new ArrayList<>(); for (ProcessTaskRelation processTaskRelation : processTaskRelations) { long preTaskCode = processTaskRelation.getPreTaskCode(); long postTaskCode = processTaskRelation.getPostTaskCode(); if (processTaskRelation.getPreTaskCode() != 0 && taskNodeMap.containsKey(preTaskCode) && taskNodeMap.containsKey(postTaskCode)) { TaskNode preNode = taskNodeMap.get(preTaskCode); TaskNode postNode = taskNodeMap.get(postTaskCode); taskNodeRelations.add(new TaskNodeRelation(Long.toString(preNode.getCode()), Long.toString(postNode.getCode()))); } } ProcessDag processDag = new ProcessDag(); processDag.setEdges(taskNodeRelations); processDag.setNodes(taskNodeList); return processDag;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
} /** * is there have conditions after the parent node */ public static boolean haveConditionsAfterNode(String parentNodeCode, DAG<String, TaskNode, TaskNodeRelation> dag ) { return haveSubAfterNode(parentNodeCode, dag, TaskConstants.TASK_TYPE_CONDITIONS); } /** * is there have conditions after the parent node */ public static boolean haveConditionsAfterNode(String parentNodeCode, List<TaskNode> taskNodes) { if (CollectionUtils.isEmpty(taskNodes)) { return false; } for (TaskNode taskNode : taskNodes) { List<String> preTasksList = JSONUtils.toList(taskNode.getPreTasks(), String.class); if (preTasksList.contains(parentNodeCode) && taskNode.isConditionsTask()) { return true; } } return false; } /** * is there have blocking node after the parent node */ public static boolean haveBlockingAfterNode(String parentNodeCode, DAG<String,TaskNode,TaskNodeRelation> dag) { return haveSubAfterNode(parentNodeCode, dag, TaskConstants.TASK_TYPE_BLOCKING);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,476
[Bug] [Master] workflow instance never stop because conditional task has no downstream task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If condition have no downstream task, master will npe during workflow run.And workflow never stop. <img width="926" alt="image" src="https://user-images.githubusercontent.com/37766284/174033206-bc173d76-3e3d-4dfd-af4f-7864bc0fb43b.png"> <img width="1342" alt="image" src="https://user-images.githubusercontent.com/37766284/174033345-3cb9bbbe-7f9f-4f8a-9529-2bab659f606a.png"> ### What you expected to happen The workflow instance completed. ### How to reproduce <img width="637" alt="image" src="https://user-images.githubusercontent.com/37766284/174033843-f0ffbb23-a79b-4bef-8f93-ec4ad8f18d5f.png"> <img width="589" alt="image" src="https://user-images.githubusercontent.com/37766284/174034147-0092f7a8-d1bd-481d-9fc9-e16c7247bc36.png"> 1.create a condition task that have no downstream task. 2.run workflow. ### Anything else etc. ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10476
https://github.com/apache/dolphinscheduler/pull/10478
062146eecd9ceabbd6d1fd32747372802749d6bd
0dd6f4008e146097026626c6e1dd47820cdec6bd
2022-06-16T09:01:27Z
java
2022-06-17T05:40:11Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
} /** * is there have all node after the parent node */ public static boolean haveAllNodeAfterNode(String parentNodeCode, DAG<String,TaskNode,TaskNodeRelation> dag) { return haveSubAfterNode(parentNodeCode, dag, null); } /** * Whether there is a specified type of child node after the parent node */ public static boolean haveSubAfterNode(String parentNodeCode, DAG<String,TaskNode,TaskNodeRelation> dag, String filterNodeType) { Set<String> subsequentNodes = dag.getSubsequentNodes(parentNodeCode); if (CollectionUtils.isEmpty(subsequentNodes)) { return false; } if (StringUtils.isBlank(filterNodeType)){ return true; } for (String nodeName : subsequentNodes) { TaskNode taskNode = dag.getNode(nodeName); if (taskNode.getType().equalsIgnoreCase(filterNodeType)){ return true; } } return false; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinParameters.java
/* * 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.plugin.task.zeppelin; import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.Collections; import java.util.List; public class ZeppelinParameters extends AbstractParameters {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinParameters.java
/** * parameters for zeppelin client API * @see <a href="https://zeppelin.apache.org/docs/0.9.0/usage/zeppelin_sdk/client_api.html">Zeppelin_Client_API_Examples</a> */ private String noteId; private String paragraphId; private String parameters; @Override public boolean checkParameters() { return StringUtils.isNotEmpty(this.noteId) && StringUtils.isNotEmpty(this.paragraphId); } @Override public List<ResourceInfo> getResourceFilesList() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinParameters.java
return Collections.emptyList(); } public String getNoteId() { return noteId; } public void setNoteId(String noteId) { this.noteId = noteId; } public String getParagraphId() { return paragraphId; } public void setParagraphId(String paragraphId) { this.paragraphId = paragraphId; } public String getParameters() { return parameters; } public void setParameters(String parameters) { this.parameters = parameters; } @Override public String toString() { return "ZeppelinParameters{" + "noteId='" + noteId + '\'' + ", paragraphId='" + paragraphId + '\'' + ", parameters='" + parameters + '\'' + '}'; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java
/* * 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.plugin.task.zeppelin; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.JSONUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java
import org.apache.dolphinscheduler.spi.utils.PropertyUtils; import org.apache.zeppelin.client.ClientConfig; import org.apache.zeppelin.client.ParagraphResult; import org.apache.zeppelin.client.Status; import org.apache.zeppelin.client.ZeppelinClient; import java.util.HashMap; import java.util.Map; public class ZeppelinTask extends AbstractTaskExecutor { /** * taskExecutionContext */ private final TaskExecutionContext taskExecutionContext; /** * zeppelin parameters */ private ZeppelinParameters zeppelinParameters; /** * zeppelin api client */ private ZeppelinClient zClient; /** * constructor * * @param taskExecutionContext taskExecutionContext */ protected ZeppelinTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java
public void init() { final String taskParams = taskExecutionContext.getTaskParams(); logger.info("zeppelin task params:{}", taskParams); this.zeppelinParameters = JSONUtils.parseObject(taskParams, ZeppelinParameters.class); if (this.zeppelinParameters == null || !this.zeppelinParameters.checkParameters()) { throw new ZeppelinTaskException("zeppelin task params is not valid"); } this.zClient = getZeppelinClient(); } @Override public void handle() throws Exception { try { String noteId = this.zeppelinParameters.getNoteId(); String paragraphId = this.zeppelinParameters.getParagraphId(); String parameters = this.zeppelinParameters.getParameters(); Map<String, String> zeppelinParamsMap = new HashMap<>(); if (parameters != null) { ObjectMapper mapper = new ObjectMapper(); zeppelinParamsMap = mapper.readValue(parameters, Map.class); } ParagraphResult paragraphResult = this.zClient.executeParagraph(noteId, paragraphId, zeppelinParamsMap); String resultContent = paragraphResult.getResultInText(); Status status = paragraphResult.getStatus(); final int exitStatusCode = mapStatusToExitCode(status); setAppIds(String.format("%s-%s", noteId, paragraphId)); setExitStatusCode(exitStatusCode); logger.info("zeppelin task finished with results: {}", resultContent); } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java
setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE); logger.error("zeppelin task submit failed with error", e); } } /** * create zeppelin client from zeppelin config * * @return ZeppelinClient */ private ZeppelinClient getZeppelinClient() { final String zeppelinRestUrl = PropertyUtils.getString(TaskConstants.ZEPPELIN_REST_URL); ClientConfig clientConfig = new ClientConfig(zeppelinRestUrl); ZeppelinClient zClient = null; try { zClient = new ZeppelinClient(clientConfig); String zeppelinVersion = zClient.getVersion(); logger.info("zeppelin version: {}", zeppelinVersion); } catch (Exception e) { logger.error("some error"); } return zClient; } /** * map zeppelin task status to exitStatusCode * * @param status zeppelin job status * @return exitStatusCode */ private int mapStatusToExitCode(Status status) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java
switch (status) { case FINISHED: return TaskConstants.EXIT_CODE_SUCCESS; case ABORT: return TaskConstants.EXIT_CODE_KILL; default: return TaskConstants.EXIT_CODE_FAILURE; } } @Override public AbstractParameters getParameters() { return zeppelinParameters; } @Override public void cancelApplication(boolean status) throws Exception { super.cancelApplication(status); String noteId = this.zeppelinParameters.getNoteId(); String paragraphId = this.zeppelinParameters.getParagraphId(); logger.info("trying terminate zeppelin task, taskId: {}, noteId: {}, paragraphId: {}", this.taskExecutionContext.getTaskInstanceId(), noteId, paragraphId); this.zClient.cancelParagraph(noteId, paragraphId); logger.info("zeppelin task terminated, taskId: {}, noteId: {}, paragraphId: {}", this.taskExecutionContext.getTaskInstanceId(), noteId, paragraphId); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java
/* * 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.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java
* See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.plugin.task.zeppelin; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_SUCCESS; import static org.mockito.ArgumentMatchers.any; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.zeppelin.client.ParagraphResult; import org.apache.zeppelin.client.Status; import org.apache.zeppelin.client.ZeppelinClient; import org.junit.Assert; import org.junit.Before; 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.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; import java.util.Map; @RunWith(PowerMockRunner.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java
@PrepareForTest({ ZeppelinTask.class, ZeppelinClient.class, ObjectMapper.class, }) @PowerMockIgnore({"javax.*"}) public class ZeppelinTaskTest { private static final String MOCK_NOTE_ID = "2GYJR92R7"; private static final String MOCK_PARAGRAPH_ID = "paragraph_1648793472526_1771221396"; private static final String MOCK_PARAMETERS = "{\"key1\": \"value1\", \"key2\": \"value2\"}"; private final ObjectMapper mapper = new ObjectMapper(); private ZeppelinClient zClient; private ZeppelinTask zeppelinTask; private ParagraphResult paragraphResult; @Before public void before() throws Exception { String zeppelinParameters = buildZeppelinTaskParameters(); TaskExecutionContext taskExecutionContext = PowerMockito.mock(TaskExecutionContext.class); when(taskExecutionContext.getTaskParams()).thenReturn(zeppelinParameters); this.zeppelinTask = spy(new ZeppelinTask(taskExecutionContext)); this.zClient = mock(ZeppelinClient.class);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java
this.paragraphResult = mock(ParagraphResult.class); doReturn(this.zClient).when(this.zeppelinTask, "getZeppelinClient"); when(this.zClient.executeParagraph(any(), any(), any(Map.class))).thenReturn(this.paragraphResult); when(paragraphResult.getResultInText()).thenReturn("mock-zeppelin-paragraph-execution-result"); this.zeppelinTask.init(); } @Test public void testHandleWithParagraphExecutionSucess() throws Exception { when(this.paragraphResult.getStatus()).thenReturn(Status.FINISHED); this.zeppelinTask.handle(); Mockito.verify(this.zClient).executeParagraph(MOCK_NOTE_ID, MOCK_PARAGRAPH_ID, (Map<String, String>) mapper.readValue(MOCK_PARAMETERS, Map.class)); Mockito.verify(this.paragraphResult).getResultInText(); Mockito.verify(this.paragraphResult).getStatus(); Assert.assertEquals(EXIT_CODE_SUCCESS, this.zeppelinTask.getExitStatusCode()); } @Test public void testHandleWithParagraphExecutionAborted() throws Exception { when(this.paragraphResult.getStatus()).thenReturn(Status.ABORT); this.zeppelinTask.handle(); Mockito.verify(this.zClient).executeParagraph(MOCK_NOTE_ID, MOCK_PARAGRAPH_ID, (Map<String, String>) mapper.readValue(MOCK_PARAMETERS, Map.class)); Mockito.verify(this.paragraphResult).getResultInText(); Mockito.verify(this.paragraphResult).getStatus(); Assert.assertEquals(EXIT_CODE_KILL, this.zeppelinTask.getExitStatusCode()); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
9,798
[Feature][Task Plugin] Enable note-level task scheduling for zeppelin task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently `Zeppelin` task plugin only supports paragraph-level task scheduling because there is no `cancelNote` method in `Zeppelin Client Api` as mentioned here: https://github.com/apache/dolphinscheduler/pull/9327#issue-1190514486 * We should enable note-level task scheduling for `Zeppelin` task as soon as this PR is merged: https://github.com/apache/zeppelin/pull/4362 ### Use case * Users will be able to use Dolphin Scheduler to schedule both zeppelin notebook notes and paragraphs. ### Related issues related: #9201 ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/9798
https://github.com/apache/dolphinscheduler/pull/10434
2c227ab3849b50e2fac508c458a8b9b36a073159
4be3b877c3c143e2b5c58c017b641fd927c0dff5
2022-04-26T17:03:31Z
java
2022-06-18T05:34:24Z
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java
public void testHandleWithParagraphExecutionError() throws Exception { when(this.paragraphResult.getStatus()).thenReturn(Status.ERROR); this.zeppelinTask.handle(); Mockito.verify(this.zClient).executeParagraph(MOCK_NOTE_ID, MOCK_PARAGRAPH_ID, (Map<String, String>) mapper.readValue(MOCK_PARAMETERS, Map.class)); Mockito.verify(this.paragraphResult).getResultInText(); Mockito.verify(this.paragraphResult).getStatus(); Assert.assertEquals(EXIT_CODE_FAILURE, this.zeppelinTask.getExitStatusCode()); } @Test public void testHandleWithParagraphExecutionException() throws Exception { when(this.zClient.executeParagraph(any(), any(), any(Map.class))). thenThrow(new Exception("Something wrong happens from zeppelin side")); this.zeppelinTask.handle(); Mockito.verify(this.zClient).executeParagraph(MOCK_NOTE_ID, MOCK_PARAGRAPH_ID, (Map<String, String>) mapper.readValue(MOCK_PARAMETERS, Map.class)); Mockito.verify(this.paragraphResult, Mockito.times(0)).getResultInText(); Mockito.verify(this.paragraphResult, Mockito.times(0)).getStatus(); Assert.assertEquals(EXIT_CODE_FAILURE, this.zeppelinTask.getExitStatusCode()); } private String buildZeppelinTaskParameters() { ZeppelinParameters zeppelinParameters = new ZeppelinParameters(); zeppelinParameters.setNoteId(MOCK_NOTE_ID); zeppelinParameters.setParagraphId(MOCK_PARAGRAPH_ID); zeppelinParameters.setParameters(MOCK_PARAMETERS); return JSONUtils.toJsonString(zeppelinParameters); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterConstants.java
/* * 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.plugin.task.jupyter; public class JupyterConstants {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterConstants.java
private JupyterConstants() { throw new IllegalStateException("Utility class"); } /** * conda init */ public static final String CONDA_INIT = "source"; /** * conda activate */ public static final String CONDA_ACTIVATE = "conda activate"; /** * jointer to combine two command */ public static final String JOINTER = "&&"; /** * papermill */ public static final String PAPERMILL = "papermill";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterConstants.java
/** * Parameters to pass to the parameters cell. */ public static final String PARAMETERS = "--parameters"; /** * Name of kernel to run. */ public static final String KERNEL = "--kernel"; /** * The execution engine name to use in evaluating the notebook. */ public static final String ENGINE = "--engine"; /** * Time in seconds to wait for each cell before failing execution (default: forever) */ public static final String EXECUTION_TIMEOUT = "--execution-timeout"; /** * Time in seconds to wait for kernel to start. */ public static final String START_TIMEOUT = "--start-timeout"; /** * Insert the paths of input/output notebooks as PAPERMILL_INPUT_PATH/PAPERMILL_OUTPUT_PATH as notebook parameters. */ public static final String INJECT_PATHS = "--inject-paths"; /** * Flag for turning on the progress bar. */ public static final String PROGRESS_BAR = "--progress-bar"; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterParameters.java
/* * 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.plugin.task.jupyter; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; /** * jupyter parameters */ public class JupyterParameters extends AbstractParameters {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterParameters.java
/** * conda env name */ private String condaEnvName; /** * input note path */ private String inputNotePath; /** * output note path */ private String outputNotePath; /** * parameters to pass into jupyter note cells */ private String parameters; /** * jupyter kernel */ private String kernel;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterParameters.java
/** * the execution engine name to use in evaluating the notebook */ private String engine; /** * time in seconds to wait for each cell before failing execution (default: forever) */ private String executionTimeout; /** * time in seconds to wait for kernel to start */ private String startTimeout; /** * other arguments */ private String others; public String getCondaEnvName() { return condaEnvName; } public void setCondaEnvName(String condaEnvName) { this.condaEnvName = condaEnvName; } public String getInputNotePath() { return inputNotePath; } public void setInputNotePath(String inputNotePath) { this.inputNotePath = inputNotePath; } public String getOutputNotePath() { return outputNotePath;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterParameters.java
} public void setOutputNotePath(String outputNotePath) { this.outputNotePath = outputNotePath; } public String getParameters() { return parameters; } public void setParameters(String parameters) { this.parameters = parameters; } public String getKernel() { return kernel; } public void setKernel(String kernel) { this.kernel = kernel; } public String getEngine() { return engine; } public void setEngine(String engine) { this.engine = engine; } public String getExecutionTimeout() { return executionTimeout; } public void setExecutionTimeout(String executionTimeout) { this.executionTimeout = executionTimeout; } public String getStartTimeout() { return startTimeout;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterParameters.java
} public void setStartTimeout(String startTimeout) { this.startTimeout = startTimeout; } public String getOthers() { return others; } public void setOthers(String others) { this.others = others; } @Override public boolean checkParameters() { return condaEnvName != null && inputNotePath != null && outputNotePath != null; } @Override public String toString() { return "JupyterParameters{" + "condaEnvName='" + condaEnvName + '\'' + ", inputNotePath='" + inputNotePath + '\'' + ", outputNotePath='" + outputNotePath + '\'' + ", parameters='" + parameters + '\'' + ", kernel='" + kernel + '\'' + ", engine='" + engine + '\'' + ", executionTimeout=" + executionTimeout + ", startTimeout=" + startTimeout + ", others='" + others + '\'' + '}'; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
/* * 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
* * 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.plugin.task.jupyter; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; public class JupyterTask extends AbstractTaskExecutor {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
/** * jupyter parameters */ private JupyterParameters jupyterParameters; /** * taskExecutionContext */ private TaskExecutionContext taskExecutionContext; private ShellCommandExecutor shellCommandExecutor; public JupyterTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle, taskExecutionContext, logger); } @Override public void init() { logger.info("jupyter task params {}", taskExecutionContext.getTaskParams()); jupyterParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), JupyterParameters.class); if (null == jupyterParameters) { logger.error("jupyter params is null"); return; } if (!jupyterParameters.checkParameters()) { throw new RuntimeException("jupyter task params is not valid"); } } @Override
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
public void handle() throws Exception { try { TaskResponse response = shellCommandExecutor.run(buildCommand()); setExitStatusCode(response.getExitStatusCode()); setAppIds(response.getAppIds()); setProcessId(response.getProcessId()); } catch (Exception e) { logger.error("jupyter task execution failure", e); exitStatusCode = -1; throw e; } } /** * create command * * @return command */ protected String buildCommand() throws IOException { /** * papermill [OPTIONS] NOTEBOOK_PATH [OUTPUT_PATH] */ List<String> args = new ArrayList<>(); final String condaPath = PropertyUtils.getString(TaskConstants.CONDA_PATH); args.add(JupyterConstants.CONDA_INIT); args.add(condaPath); args.add(JupyterConstants.JOINTER); args.add(JupyterConstants.CONDA_ACTIVATE); args.add(jupyterParameters.getCondaEnvName()); args.add(JupyterConstants.JOINTER);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
args.add(JupyterConstants.PAPERMILL); args.add(jupyterParameters.getInputNotePath()); args.add(jupyterParameters.getOutputNotePath()); args.addAll(populateJupyterParameterization()); args.addAll(populateJupyterOptions()); Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext, getParameters()); if (MapUtils.isEmpty(paramsMap)) { paramsMap = new HashMap<>(); } if (MapUtils.isNotEmpty(taskExecutionContext.getParamsMap())) { paramsMap.putAll(taskExecutionContext.getParamsMap()); } String command = ParameterUtils.convertParameterPlaceholders(String.join(" ", args), ParamUtils.convert(paramsMap)); logger.info("jupyter task command: {}", command); return command; } /** * build jupyter parameterization * * @return argument list */ private List<String> populateJupyterParameterization() throws IOException { List<String> args = new ArrayList<>(); String parameters = jupyterParameters.getParameters(); if (StringUtils.isNotEmpty(parameters)) { ObjectMapper mapper = new ObjectMapper(); try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
Map<String, String> jupyterParamsMap = mapper.readValue(parameters, Map.class); for (String key : jupyterParamsMap.keySet()) { args.add(JupyterConstants.PARAMETERS); args.add(key); args.add(jupyterParamsMap.get(key)); } } catch (IOException e) { logger.error("fail to parse jupyter parameterization", e); throw e; } } return args; } /** * build jupyter options * * @return argument list */ private List<String> populateJupyterOptions() { List<String> args = new ArrayList<>(); String kernel = jupyterParameters.getKernel(); if (StringUtils.isNotEmpty(kernel)) { args.add(JupyterConstants.KERNEL); args.add(kernel); } String engine = jupyterParameters.getEngine(); if (StringUtils.isNotEmpty(engine)) { args.add(JupyterConstants.ENGINE); args.add(engine);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java
} String executionTimeout = jupyterParameters.getExecutionTimeout(); if (StringUtils.isNotEmpty(executionTimeout)) { args.add(JupyterConstants.EXECUTION_TIMEOUT); args.add(executionTimeout); } String startTimeout = jupyterParameters.getStartTimeout(); if (StringUtils.isNotEmpty(startTimeout)) { args.add(JupyterConstants.START_TIMEOUT); args.add(startTimeout); } String others = jupyterParameters.getOthers(); if (StringUtils.isNotEmpty(others)) { args.add(others); } args.add(JupyterConstants.INJECT_PATHS); args.add(JupyterConstants.PROGRESS_BAR); return args; } @Override public void cancelApplication(boolean cancelApplication) throws Exception { shellCommandExecutor.cancelApplication(); } @Override public AbstractParameters getParameters() { return jupyterParameters; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java
/* * 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.plugin.task.jupyter; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java
import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import static org.mockito.ArgumentMatchers.any; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) @PrepareForTest({ JSONUtils.class, PropertyUtils.class, }) @PowerMockIgnore({"javax.*"}) @SuppressStaticInitializationFor("org.apache.dolphinscheduler.spi.utils.PropertyUtils") public class JupyterTaskTest { @Test public void testBuildJupyterCommand() throws Exception { String parameters = buildJupyterCommand(); TaskExecutionContext taskExecutionContext = PowerMockito.mock(TaskExecutionContext.class); when(taskExecutionContext.getTaskParams()).thenReturn(parameters); PowerMockito.mockStatic(PropertyUtils.class); when(PropertyUtils.getString(any())).thenReturn("/opt/anaconda3/etc/profile.d/conda.sh"); JupyterTask jupyterTask = spy(new JupyterTask(taskExecutionContext)); jupyterTask.init(); Assert.assertEquals(jupyterTask.buildCommand(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,302
[Feature][Task Plugin] Enable users to switch and install conda env in jupyter task
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description * Currently users need to manually create conda env and install all libs on workers when using `jupyter task plugin`, which is not convenient with multiple workers. If workers do not have public ips, it will be more torturing. * By adding this feature, we could enable users to switch conda envs in jupyter task, something like switching interpreters in `PyCharm`. Users will upload their packed conda envs to `resource center`, and choose the one needed when setting up jupyter task. ![image](https://user-images.githubusercontent.com/34905992/171004364-5c9e7855-7906-4c3e-a656-74a64811c461.png) ### Use case * Already described above. ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10302
https://github.com/apache/dolphinscheduler/pull/10337
79ce5d78cd22e5d548bd3285e169ba51b1a83d26
64cee03fed1002770e552abbce451b699c252cdc
2022-05-30T13:48:10Z
java
2022-06-20T06:47:44Z
dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java
"source /opt/anaconda3/etc/profile.d/conda.sh && " + "conda activate jupyter-lab && " + "papermill " + "/test/input_note.ipynb " + "/test/output_note.ipynb " + "--parameters city Shanghai " + "--parameters factor 0.01 " + "--kernel python3 " + "--engine default_engine " + "--execution-timeout 10 " + "--start-timeout 3 " + "--version " + "--inject-paths " + "--progress-bar"); } private String buildJupyterCommand() { JupyterParameters jupyterParameters = new JupyterParameters(); jupyterParameters.setCondaEnvName("jupyter-lab"); jupyterParameters.setInputNotePath("/test/input_note.ipynb"); jupyterParameters.setOutputNotePath("/test/output_note.ipynb"); jupyterParameters.setParameters("{\"city\": \"Shanghai\", \"factor\": \"0.01\"}"); jupyterParameters.setKernel("python3"); jupyterParameters.setEngine("default_engine"); jupyterParameters.setExecutionTimeout("10"); jupyterParameters.setStartTimeout("3"); jupyterParameters.setOthers("--version"); return JSONUtils.toJsonString(jupyterParameters); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/storage/StorageOperate.java
/* * 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.storage; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ResUploadType; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.spi.enums.ResourceType; import java.io.IOException; import java.util.List; public interface StorageOperate { public static final String RESOURCE_UPLOAD_PATH = PropertyUtils.getString(Constants.RESOURCE_UPLOAD_PATH, "/dolphinscheduler"); /** * if the resource of tenant 's exist, the resource of folder will be created
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/storage/StorageOperate.java
* @param tenantCode * @throws Exception */ public void createTenantDirIfNotExists(String tenantCode) throws Exception; /** * get the resource directory of tenant * @param tenantCode * @return */ public String getResDir(String tenantCode); /** * return the udf directory of tenant * @param tenantCode * @return */ public String getUdfDir(String tenantCode); /** * create the directory that the path of tenant wanted to create * @param tenantCode * @param path * @return * @throws IOException */ public boolean mkdir(String tenantCode,String path) throws IOException; /** * get the path of the resource file * @param tenantCode * @param fullName * @return */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/storage/StorageOperate.java
public String getResourceFileName(String tenantCode, String fullName); /** * get the path of the file * @param resourceType * @param tenantCode * @param fileName * @return */ public String getFileName(ResourceType resourceType, String tenantCode, String fileName); /** * predicate if the resource of tenant exists * @param tenantCode * @param fileName * @return * @throws IOException */ public boolean exists(String tenantCode,String fileName) throws IOException; /** * delete the resource of filePath * todo if the filePath is the type of directory ,the files in the filePath need to be deleted at all * @param tenantCode * @param filePath * @param recursive * @return * @throws IOException */ public boolean delete(String tenantCode,String filePath, boolean recursive) throws IOException; /** * copy the file from srcPath to dstPath * @param srcPath
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/storage/StorageOperate.java
* @param dstPath * @param deleteSource if need to delete the file of srcPath * @param overwrite * @return * @throws IOException */ public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws IOException; /** * get the root path of the tenant with resourceType * @param resourceType * @param tenantCode * @return */ public String getDir(ResourceType resourceType, String tenantCode); /** * upload the local srcFile to dstPath * @param tenantCode * @param srcFile * @param dstPath * @param deleteSource * @param overwrite * @return * @throws IOException */ public boolean upload(String tenantCode,String srcFile, String dstPath, boolean deleteSource, boolean overwrite) throws IOException; /** * download the srcPath to local * @param tenantCode * @param srcFilePath the full path of the srcPath * @param dstFile
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/storage/StorageOperate.java
* @param deleteSource * @param overwrite * @throws IOException */ public void download(String tenantCode,String srcFilePath, String dstFile, boolean deleteSource, boolean overwrite)throws IOException; /** * vim the context of filePath * @param tenantCode * @param filePath * @param skipLineNums * @param limit * @return * @throws IOException */ public List<String> vimFile(String tenantCode, String filePath, int skipLineNums, int limit) throws IOException; /** * delete the files and directory of the tenant * * @param tenantCode * @throws Exception */ public void deleteTenant(String tenantCode) throws Exception; /** * return the storageType * * @return */ public ResUploadType returnStorageType(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
/* * 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.server.master.consumer; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.TaskExecuteRequestCommand; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.dispatch.ExecutorDispatcher; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException; import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventService; import org.apache.dolphinscheduler.service.exceptions.TaskPriorityQueueException; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.queue.TaskPriority; import org.apache.dolphinscheduler.service.queue.TaskPriorityQueue; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * TaskUpdateQueue consumer */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
public class TaskPriorityQueueConsumer extends Thread { /** * logger of TaskUpdateQueueConsumer */ private static final Logger logger = LoggerFactory.getLogger(TaskPriorityQueueConsumer.class); /** * taskUpdateQueue */ @Autowired private TaskPriorityQueue<TaskPriority> taskPriorityQueue; /** * processService
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
*/ @Autowired private ProcessService processService; /** * executor dispatcher */ @Autowired private ExecutorDispatcher dispatcher; /** * processInstance cache manager */ @Autowired private ProcessInstanceExecCacheManager processInstanceExecCacheManager; /** * master config */ @Autowired private MasterConfig masterConfig; /** * task response service */ @Autowired private TaskEventService taskEventService; /** * consumer thread pool */ private ThreadPoolExecutor consumerThreadPoolExecutor; @PostConstruct public void init() { this.consumerThreadPoolExecutor = (ThreadPoolExecutor) ThreadUtils.newDaemonFixedThreadExecutor("TaskUpdateQueueConsumerThread", masterConfig.getDispatchTaskNumber());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
super.start(); } @Override public void run() { int fetchTaskNum = masterConfig.getDispatchTaskNumber(); while (Stopper.isRunning()) { try { List<TaskPriority> failedDispatchTasks = this.batchDispatch(fetchTaskNum); if (CollectionUtils.isNotEmpty(failedDispatchTasks)) { TaskMetrics.incTaskDispatchFailed(failedDispatchTasks.size()); for (TaskPriority dispatchFailedTask : failedDispatchTasks) { taskPriorityQueue.put(dispatchFailedTask); } if (taskPriorityQueue.size() <= failedDispatchTasks.size()) { TimeUnit.MILLISECONDS.sleep(Constants.SLEEP_TIME_MILLIS); } } } catch (Exception e) { TaskMetrics.incTaskDispatchError(); logger.error("dispatcher task error", e); } } } /** * batch dispatch with thread pool */ public List<TaskPriority> batchDispatch(int fetchTaskNum) throws TaskPriorityQueueException, InterruptedException { List<TaskPriority> failedDispatchTasks = Collections.synchronizedList(new ArrayList<>());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
CountDownLatch latch = new CountDownLatch(fetchTaskNum); for (int i = 0; i < fetchTaskNum; i++) { TaskPriority taskPriority = taskPriorityQueue.poll(Constants.SLEEP_TIME_MILLIS, TimeUnit.MILLISECONDS); if (Objects.isNull(taskPriority)) { latch.countDown(); continue; } consumerThreadPoolExecutor.submit(() -> { try { boolean dispatchResult = this.dispatchTask(taskPriority); if (!dispatchResult) { failedDispatchTasks.add(taskPriority); } } finally { latch.countDown(); } }); } latch.await(); return failedDispatchTasks; } /** * Dispatch task to worker. * * @param taskPriority taskPriority * @return dispatch result, return true if dispatch success, return false if dispatch failed. */ protected boolean dispatchTask(TaskPriority taskPriority) { TaskMetrics.incTaskDispatch();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
boolean result = false; try { TaskExecutionContext context = taskPriority.getTaskExecutionContext(); ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER, context.getWorkerGroup()); if (isTaskNeedToCheck(taskPriority)) { if (taskInstanceIsFinalState(taskPriority.getTaskId())) { return true; } } result = dispatcher.dispatch(executionContext); if (result) { logger.info("Master success dispatch task to worker, taskInstanceId: {}", taskPriority.getTaskId()); addDispatchEvent(context, executionContext); } else { logger.info("Master failed to dispatch task to worker, taskInstanceId: {}", taskPriority.getTaskId()); } } catch (RuntimeException e) { logger.error("Master dispatch task to worker error: ", e); } catch (ExecuteException e) { logger.error("Master dispatch task to worker error: {}", e); } return result; } /** * add dispatch event */ private void addDispatchEvent(TaskExecutionContext context, ExecutionContext executionContext) { TaskEvent taskEvent = TaskEvent.newDispatchEvent(context.getProcessInstanceId(), context.getTaskInstanceId(), executionContext.getHost().getAddress()); taskEventService.addEvent(taskEvent);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java
} private Command toCommand(TaskExecutionContext taskExecutionContext) { TaskExecuteRequestCommand requestCommand = new TaskExecuteRequestCommand(); requestCommand.setTaskExecutionContext(JSONUtils.toJsonString(taskExecutionContext)); return requestCommand.convert2Command(); } /** * taskInstance is final state * success,failure,kill,stop,pause,threadwaiting is final state * * @param taskInstanceId taskInstanceId * @return taskInstance is final state */ public boolean taskInstanceIsFinalState(int taskInstanceId) { TaskInstance taskInstance = processService.findTaskInstanceById(taskInstanceId); return taskInstance.getState().typeIsFinished(); } /** * check if task need to check state, if true, refresh the checkpoint */ private boolean isTaskNeedToCheck(TaskPriority taskPriority) { long now = System.currentTimeMillis(); if (now - taskPriority.getCheckpoint() > Constants.SECOND_TIME_MILLIS) { taskPriority.setCheckpoint(now); return true; } return false; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
/* * 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.server.master.processor.queue; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.StateEventResponseCommand; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool; import java.util.ArrayList; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import io.netty.channel.Channel; /** * task manager */ @Component public class StateEventResponseService { /** * logger */ private final Logger logger = LoggerFactory.getLogger(StateEventResponseService.class); /** * attemptQueue */ private final BlockingQueue<StateEvent> eventQueue = new LinkedBlockingQueue<>(5000); /** * task response worker */ private Thread responseWorker; @Autowired private ProcessInstanceExecCacheManager processInstanceExecCacheManager; @Autowired private WorkflowExecuteThreadPool workflowExecuteThreadPool; @PostConstruct public void start() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
this.responseWorker = new StateEventResponseWorker(); this.responseWorker.setName("StateEventResponseWorker"); this.responseWorker.start(); } @PreDestroy public void stop() { this.responseWorker.interrupt(); if (!eventQueue.isEmpty()) { List<StateEvent> remainEvents = new ArrayList<>(eventQueue.size()); eventQueue.drainTo(remainEvents); for (StateEvent event : remainEvents) { this.persist(event); } } } /** * put task to attemptQueue */ public void addResponse(StateEvent stateEvent) { try { eventQueue.put(stateEvent); } catch (InterruptedException e) { logger.error("put state event : {} error :{}", stateEvent, e); Thread.currentThread().interrupt(); } } /** * task worker thread */ class StateEventResponseWorker extends Thread {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
@Override public void run() { while (Stopper.isRunning()) { try { StateEvent stateEvent = eventQueue.take(); persist(stateEvent); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } logger.info("StateEventResponseWorker stopped"); } } private void writeResponse(StateEvent stateEvent, ExecutionStatus status) { Channel channel = stateEvent.getChannel(); if (channel != null) { StateEventResponseCommand command = new StateEventResponseCommand(status.getCode(), stateEvent.getKey());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java
channel.writeAndFlush(command.convert2Command()); } } private void persist(StateEvent stateEvent) { try { if (!this.processInstanceExecCacheManager.contains(stateEvent.getProcessInstanceId())) { writeResponse(stateEvent, ExecutionStatus.FAILURE); return; } WorkflowExecuteRunnable workflowExecuteThread = this.processInstanceExecCacheManager.getByProcessInstanceId(stateEvent.getProcessInstanceId()); switch (stateEvent.getType()) { case TASK_STATE_CHANGE: workflowExecuteThread.refreshTaskInstance(stateEvent.getTaskInstanceId()); break; case PROCESS_STATE_CHANGE: workflowExecuteThread.refreshProcessInstance(stateEvent.getProcessInstanceId()); break; default: } workflowExecuteThreadPool.submitStateEvent(stateEvent); writeResponse(stateEvent, ExecutionStatus.SUCCESS); } catch (Exception e) { logger.error("persist event queue error, event: {}", stateEvent, e); } } public void addEvent2WorkflowExecute(StateEvent stateEvent) { workflowExecuteThreadPool.submitStateEvent(stateEvent); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEventService.java
/* * 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.server.master.processor.queue; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.thread.Stopper; import java.util.ArrayList; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEventService.java
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * task manager */ @Component public class TaskEventService { /** * logger */ private final Logger logger = LoggerFactory.getLogger(TaskEventService.class); /** * attemptQueue */ private final BlockingQueue<TaskEvent> eventQueue = new LinkedBlockingQueue<>(); /** * task event worker */ private Thread taskEventThread; private Thread taskEventHandlerThread; @Autowired private TaskExecuteThreadPool taskExecuteThreadPool; @PostConstruct public void start() { this.taskEventThread = new TaskEventThread(); this.taskEventThread.setName("TaskEventThread"); this.taskEventThread.start(); this.taskEventHandlerThread = new TaskEventHandlerThread(); this.taskEventHandlerThread.setName("TaskEventHandlerThread"); this.taskEventHandlerThread.start();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEventService.java
} @PreDestroy public void stop() { try { this.taskEventThread.interrupt(); this.taskEventHandlerThread.interrupt(); if (!eventQueue.isEmpty()) { List<TaskEvent> remainEvents = new ArrayList<>(eventQueue.size()); eventQueue.drainTo(remainEvents); for (TaskEvent taskEvent : remainEvents) { taskExecuteThreadPool.submitTaskEvent(taskEvent); } taskExecuteThreadPool.eventHandler(); } } catch (Exception e) { logger.error("stop error:", e); } } /** * add event * * @param taskEvent taskEvent */ public void addEvent(TaskEvent taskEvent) { taskExecuteThreadPool.submitTaskEvent(taskEvent); } /** * task worker thread */ class TaskEventThread extends Thread {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEventService.java
@Override public void run() { while (Stopper.isRunning()) { try { TaskEvent taskEvent = eventQueue.take(); taskExecuteThreadPool.submitTaskEvent(taskEvent); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } catch (Exception e) { logger.error("persist task error", e); } } logger.info("StateEventResponseWorker stopped"); } } /** * event handler thread */ class TaskEventHandlerThread extends Thread {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskEventService.java
@Override public void run() { logger.info("event handler thread started"); while (Stopper.isRunning()) { try { taskExecuteThreadPool.eventHandler(); TimeUnit.MILLISECONDS.sleep(Constants.SLEEP_TIME_MILLIS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } catch (Exception e) { logger.error("event handler thread error", e); } } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/EventExecuteService.java
/* * 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.server.master.runner; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class EventExecuteService extends Thread { private static final Logger logger = LoggerFactory.getLogger(EventExecuteService.class); @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/EventExecuteService.java
private ProcessInstanceExecCacheManager processInstanceExecCacheManager; /** * workflow exec service */ @Autowired private WorkflowExecuteThreadPool workflowExecuteThreadPool; @Override public synchronized void start() { super.setName("EventServiceStarted"); super.start(); } @Override public void run() { logger.info("Event service started"); while (Stopper.isRunning()) { try { eventHandler(); TimeUnit.MILLISECONDS.sleep(Constants.SLEEP_TIME_MILLIS_SHORT); } catch (Exception e) { logger.error("Event service thread error", e); } } } private void eventHandler() { for (WorkflowExecuteRunnable workflowExecuteThread : this.processInstanceExecCacheManager.getAll()) { workflowExecuteThreadPool.executeEvent(workflowExecuteThread); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/FailoverExecuteThread.java
/* * 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.server.master.runner; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.service.FailoverService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class FailoverExecuteThread extends Thread { private static final Logger logger = LoggerFactory.getLogger(FailoverExecuteThread.class); @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/FailoverExecuteThread.java
private MasterConfig masterConfig; /** * failover service */ @Autowired private FailoverService failoverService; @Override public synchronized void start() { super.setName("FailoverExecuteThread"); super.start(); } @Override public void run() { ThreadUtils.sleep((long) Constants.SLEEP_TIME_MILLIS * 10); logger.info("failover execute thread started"); while (Stopper.isRunning()) { try { failoverService.checkMasterFailover(); } catch (Exception e) { logger.error("failover execute error", e); } finally { ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS * masterConfig.getFailoverInterval() * 60); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java
/* * 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.server.master.runner; import org.apache.dolphinscheduler.common.Constants;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java
import org.apache.dolphinscheduler.common.enums.SlotCheckState; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.remote.NettyRemotingClient; import org.apache.dolphinscheduler.remote.config.NettyClientConfig; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.dispatch.executor.NettyExecutorManager; import org.apache.dolphinscheduler.server.master.metrics.MasterServerMetrics; import org.apache.dolphinscheduler.server.master.registry.ServerNodeManager; import org.apache.dolphinscheduler.service.alert.ProcessAlertManager; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.collections4.CollectionUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ThreadPoolExecutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Master scheduler thread, this thread will consume the commands from database and trigger processInstance executed. */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,413
[Bug] [Master] If an exception occurs during startup, the log will be flushed in an infinite loop
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened If an exception occurs during startup, the log will be flushed in an infinite loop, Hundreds of megabytes of logs are generated instantly ![image](https://user-images.githubusercontent.com/20675095/173209845-c64c9255-3dbd-4a0f-ab75-5a73c9b82af4.png) ![image](https://user-images.githubusercontent.com/20675095/173211004-81661eda-7caf-42cb-8156-5b4764abd628.png) ### What you expected to happen Start abnormal interrupt procedures, easy to troubleshoot problems ### How to reproduce An exception is thrown when the load bean is started ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10413
https://github.com/apache/dolphinscheduler/pull/10500
6e4b2e69927af70bccda5a2e70fe93d7b1a852e7
117f78ec4b0e2438082a3e25158492eca1b9b1be
2022-06-12T01:56:07Z
java
2022-06-20T14:35:06Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java
public class MasterSchedulerService extends Thread { /** * logger of MasterSchedulerService */ private static final Logger logger = LoggerFactory.getLogger(MasterSchedulerService.class); /** * dolphinscheduler database interface */ @Autowired private ProcessService processService; /** * master config */ @Autowired private MasterConfig masterConfig; /** * alert manager */ @Autowired private ProcessAlertManager processAlertManager; /** * netty remoting client */ private NettyRemotingClient nettyRemotingClient;