merge from dev
commit
714ae33e40
|
|
@ -96,7 +96,7 @@
|
|||
],
|
||||
"DOLPHIN_ALERT": [
|
||||
{
|
||||
"name": "DOLPHIN_DOLPHIN_ALERT_CHECK",
|
||||
"name": "DOLPHIN_ALERT_CHECK",
|
||||
"label": "check dolphin scheduler alert status",
|
||||
"description": "",
|
||||
"interval":10,
|
||||
|
|
@ -127,10 +127,10 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"DOLPHIN_ALERT": [
|
||||
"DOLPHIN_LOGGER": [
|
||||
{
|
||||
"name": "DOLPHIN_DOLPHIN_LOGGER_CHECK",
|
||||
"label": "check dolphin scheduler alert status",
|
||||
"name": "DOLPHIN_LOGGER_CHECK",
|
||||
"label": "check dolphin scheduler logger status",
|
||||
"description": "",
|
||||
"interval":10,
|
||||
"scope": "HOST",
|
||||
|
|
@ -161,4 +161,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,11 +66,6 @@
|
|||
<artifactId>commons-email</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.alert.template.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.apache.dolphinscheduler.alert.template.AlertTemplate;
|
||||
import org.apache.dolphinscheduler.alert.utils.Constants;
|
||||
import org.apache.dolphinscheduler.alert.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.enums.ShowType;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -108,18 +110,11 @@ public class DefaultHTMLTemplate implements AlertTemplate {
|
|||
private String getTextTypeMessage(String content,boolean showAll){
|
||||
|
||||
if (StringUtils.isNotEmpty(content)){
|
||||
List<String> list;
|
||||
try {
|
||||
list = JSONUtils.toList(content,String.class);
|
||||
}catch (Exception e){
|
||||
logger.error("json format exception",e);
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayNode list = JSONUtils.parseArray(content);
|
||||
StringBuilder contents = new StringBuilder(100);
|
||||
for (String str : list){
|
||||
for (JsonNode jsonNode : list){
|
||||
contents.append(Constants.TR);
|
||||
contents.append(Constants.TD).append(str).append(Constants.TD_END);
|
||||
contents.append(Constants.TD).append(jsonNode.toString()).append(Constants.TD_END);
|
||||
contents.append(Constants.TR_END);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
|
|
@ -129,7 +129,7 @@ public class DingTalkUtils {
|
|||
textContent.put("content", txt);
|
||||
items.put("text", textContent);
|
||||
|
||||
return JSON.toJSONString(items);
|
||||
return JSONUtils.toJsonString(items);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ package org.apache.dolphinscheduler.alert.utils;
|
|||
|
||||
import org.apache.dolphinscheduler.common.enums.ShowType;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import org.apache.dolphinscheduler.plugin.model.AlertData;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
|
|
@ -64,14 +63,15 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* get Enterprise WeChat is enable
|
||||
*
|
||||
* @return isEnable
|
||||
*/
|
||||
public static boolean isEnable(){
|
||||
public static boolean isEnable() {
|
||||
Boolean isEnable = null;
|
||||
try {
|
||||
isEnable = PropertyUtils.getBoolean(Constants.ENTERPRISE_WECHAT_ENABLE);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
if (isEnable == null) {
|
||||
return false;
|
||||
|
|
@ -81,6 +81,7 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* get Enterprise WeChat token info
|
||||
*
|
||||
* @return token string info
|
||||
* @throws IOException the IOException
|
||||
*/
|
||||
|
|
@ -99,10 +100,12 @@ public class EnterpriseWeChatUtils {
|
|||
response.close();
|
||||
}
|
||||
|
||||
Map<String, Object> map = JSON.parseObject(resp,
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
return map.get("access_token").toString();
|
||||
Map<String, String> map = JSONUtils.toMap(resp);
|
||||
if (map != null) {
|
||||
return map.get("access_token");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
httpClient.close();
|
||||
}
|
||||
|
|
@ -110,9 +113,10 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* make team single Enterprise WeChat message
|
||||
*
|
||||
* @param toParty the toParty
|
||||
* @param agentId the agentId
|
||||
* @param msg the msg
|
||||
* @param msg the msg
|
||||
* @return Enterprise WeChat send message
|
||||
*/
|
||||
public static String makeTeamSendMsg(String toParty, String agentId, String msg) {
|
||||
|
|
@ -123,9 +127,10 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* make team multi Enterprise WeChat message
|
||||
*
|
||||
* @param toParty the toParty
|
||||
* @param agentId the agentId
|
||||
* @param msg the msg
|
||||
* @param msg the msg
|
||||
* @return Enterprise WeChat send message
|
||||
*/
|
||||
public static String makeTeamSendMsg(Collection<String> toParty, String agentId, String msg) {
|
||||
|
|
@ -137,9 +142,10 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* make team single user message
|
||||
* @param toUser the toUser
|
||||
*
|
||||
* @param toUser the toUser
|
||||
* @param agentId the agentId
|
||||
* @param msg the msg
|
||||
* @param msg the msg
|
||||
* @return Enterprise WeChat send message
|
||||
*/
|
||||
public static String makeUserSendMsg(String toUser, String agentId, String msg) {
|
||||
|
|
@ -150,9 +156,10 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* make team multi user message
|
||||
* @param toUser the toUser
|
||||
*
|
||||
* @param toUser the toUser
|
||||
* @param agentId the agentId
|
||||
* @param msg the msg
|
||||
* @param msg the msg
|
||||
* @return Enterprise WeChat send message
|
||||
*/
|
||||
public static String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) {
|
||||
|
|
@ -164,9 +171,10 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* send Enterprise WeChat
|
||||
*
|
||||
* @param charset the charset
|
||||
* @param data the data
|
||||
* @param token the token
|
||||
* @param data the data
|
||||
* @param token the token
|
||||
* @return Enterprise WeChat resp, demo: {"errcode":0,"errmsg":"ok","invaliduser":""}
|
||||
* @throws IOException the IOException
|
||||
*/
|
||||
|
|
@ -196,21 +204,22 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* convert table to markdown style
|
||||
* @param title the title
|
||||
*
|
||||
* @param title the title
|
||||
* @param content the content
|
||||
* @return markdown table content
|
||||
*/
|
||||
public static String markdownTable(String title,String content){
|
||||
public static String markdownTable(String title, String content) {
|
||||
List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
|
||||
StringBuilder contents = new StringBuilder(200);
|
||||
|
||||
if (null != mapItemsList) {
|
||||
for (LinkedHashMap mapItems : mapItemsList){
|
||||
for (LinkedHashMap mapItems : mapItemsList) {
|
||||
Set<Map.Entry<String, String>> entries = mapItems.entrySet();
|
||||
Iterator<Map.Entry<String, String>> iterator = entries.iterator();
|
||||
StringBuilder t = new StringBuilder(String.format("`%s`%s",title,Constants.MARKDOWN_ENTER));
|
||||
StringBuilder t = new StringBuilder(String.format("`%s`%s", title, Constants.MARKDOWN_ENTER));
|
||||
|
||||
while (iterator.hasNext()){
|
||||
while (iterator.hasNext()) {
|
||||
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
t.append(Constants.MARKDOWN_QUOTE);
|
||||
|
|
@ -225,23 +234,24 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* convert text to markdown style
|
||||
* @param title the title
|
||||
*
|
||||
* @param title the title
|
||||
* @param content the content
|
||||
* @return markdown text
|
||||
*/
|
||||
public static String markdownText(String title,String content){
|
||||
if (StringUtils.isNotEmpty(content)){
|
||||
public static String markdownText(String title, String content) {
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
List<String> list;
|
||||
try {
|
||||
list = JSONUtils.toList(content,String.class);
|
||||
}catch (Exception e){
|
||||
logger.error("json format exception",e);
|
||||
list = JSONUtils.toList(content, String.class);
|
||||
} catch (Exception e) {
|
||||
logger.error("json format exception", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder contents = new StringBuilder(100);
|
||||
contents.append(String.format("`%s`%n",title));
|
||||
for (String str : list){
|
||||
contents.append(String.format("`%s`%n", title));
|
||||
for (String str : list) {
|
||||
contents.append(Constants.MARKDOWN_QUOTE);
|
||||
contents.append(str);
|
||||
contents.append(Constants.MARKDOWN_ENTER);
|
||||
|
|
@ -255,14 +265,15 @@ public class EnterpriseWeChatUtils {
|
|||
|
||||
/**
|
||||
* Determine the mardown style based on the show type of the alert
|
||||
*
|
||||
* @return the markdown alert table/text
|
||||
*/
|
||||
public static String markdownByAlert(AlertData alert){
|
||||
public static String markdownByAlert(AlertData alert) {
|
||||
String result = "";
|
||||
if (alert.getShowType().equals(ShowType.TABLE.getDescp())) {
|
||||
result = markdownTable(alert.getTitle(),alert.getContent());
|
||||
}else if(alert.getShowType().equals(ShowType.TEXT.getDescp())){
|
||||
result = markdownText(alert.getTitle(),alert.getContent());
|
||||
result = markdownTable(alert.getTitle(), alert.getContent());
|
||||
} else if (alert.getShowType().equals(ShowType.TEXT.getDescp())) {
|
||||
result = markdownText(alert.getTitle(), alert.getContent());
|
||||
}
|
||||
return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
/**
|
||||
* excel utils
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* json utils
|
||||
*/
|
||||
public class JSONUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class);
|
||||
|
||||
/**
|
||||
* object to json string
|
||||
* @param object the object to be converted to json
|
||||
* @return json string
|
||||
*/
|
||||
public static String toJsonString(Object object) {
|
||||
try{
|
||||
return JSON.toJSONString(object,false);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Json deserialization exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* json to list
|
||||
*
|
||||
* @param json the json
|
||||
* @param clazz c
|
||||
* @param <T> the generic clazz
|
||||
* @return the result list or empty list
|
||||
*/
|
||||
public static <T> List<T> toList(String json, Class<T> clazz) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
return JSON.parseArray(json, clazz);
|
||||
} catch (Exception e) {
|
||||
logger.error("JSONArray.parseArray exception!",e);
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.alert.template.impl;
|
||||
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.alert.utils.Constants;
|
||||
import org.apache.dolphinscheduler.alert.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.enums.ShowType;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,10 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
|
|
@ -67,7 +64,7 @@ public class DingTalkUtilsTest {
|
|||
// logger.info(PropertyUtils.getString(Constants.DINGTALK_WEBHOOK));
|
||||
// String rsp = DingTalkUtils.sendDingTalkMsg(msgTosend, Constants.UTF_8);
|
||||
// logger.info("send msg result:{}",rsp);
|
||||
// String errmsg = JSON.parseObject(rsp).getString("errmsg");
|
||||
// String errmsg = JSONUtils.parseObject(rsp).getString("errmsg");
|
||||
// Assert.assertEquals("ok", errmsg);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.dolphinscheduler.common.enums.AlertType;
|
||||
import org.apache.dolphinscheduler.common.enums.ShowType;
|
||||
import org.apache.dolphinscheduler.dao.entity.Alert;
|
||||
import org.apache.dolphinscheduler.plugin.model.AlertData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
|
|
@ -34,6 +32,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
/**
|
||||
* Please manually modify the configuration file before testing.
|
||||
|
|
@ -206,7 +205,7 @@ public class EnterpriseWeChatUtilsTest {
|
|||
// String msg = EnterpriseWeChatUtils.makeTeamSendMsg(partyId, agentId, "hello world");
|
||||
// String resp = EnterpriseWeChatUtils.sendEnterpriseWeChat("utf-8", msg, token);
|
||||
//
|
||||
// String errmsg = JSON.parseObject(resp).getString("errmsg");
|
||||
// String errmsg = JSONUtils.parseObject(resp).getString("errmsg");
|
||||
// Assert.assertEquals("ok",errmsg);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
|
|
@ -221,7 +220,7 @@ public class EnterpriseWeChatUtilsTest {
|
|||
// String msg = EnterpriseWeChatUtils.makeTeamSendMsg(listPartyId, agentId, "hello world");
|
||||
// String resp = EnterpriseWeChatUtils.sendEnterpriseWeChat("utf-8", msg, token);
|
||||
//
|
||||
// String errmsg = JSON.parseObject(resp).getString("errmsg");
|
||||
// String errmsg = JSONUtils.parseObject(resp).getString("errmsg");
|
||||
// Assert.assertEquals("ok",errmsg);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
|
|
@ -248,7 +247,7 @@ public class EnterpriseWeChatUtilsTest {
|
|||
//
|
||||
// String resp = EnterpriseWeChatUtils.sendEnterpriseWeChat("utf-8", msg, token);
|
||||
//
|
||||
// String errmsg = JSON.parseObject(resp).getString("errmsg");
|
||||
// String errmsg = JSONUtils.parseObject(resp).getString("errmsg");
|
||||
// Assert.assertEquals("ok",errmsg);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
|
|
@ -263,7 +262,7 @@ public class EnterpriseWeChatUtilsTest {
|
|||
// String msg = EnterpriseWeChatUtils.makeUserSendMsg(listUserId, agentId, "hello world");
|
||||
// String resp = EnterpriseWeChatUtils.sendEnterpriseWeChat("utf-8", msg, token);
|
||||
//
|
||||
// String errmsg = JSON.parseObject(resp).getString("errmsg");
|
||||
// String errmsg = JSONUtils.parseObject(resp).getString("errmsg");
|
||||
// Assert.assertEquals("ok",errmsg);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.alert.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JSONUtilsTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JSONUtilsTest.class);
|
||||
|
||||
public List<LinkedHashMap<String, Object>> list = new ArrayList<>();
|
||||
|
||||
public String expected = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
//Define expected json string
|
||||
expected = "[{\"mysql service name\":\"mysql200\",\"mysql address\":\"192.168.xx.xx\",\"port\":\"3306\",\"no index of number\":\"80\",\"database client connections\":\"190\"}]";
|
||||
|
||||
//Initial map
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("mysql service name","mysql200");
|
||||
map.put("mysql address","192.168.xx.xx");
|
||||
map.put("port","3306");
|
||||
map.put("no index of number","80");
|
||||
map.put("database client connections","190");
|
||||
|
||||
//Add map into list
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test toJsonString
|
||||
*/
|
||||
@Test
|
||||
public void testToJsonString() {
|
||||
|
||||
//Invoke toJsonString
|
||||
String result = JSONUtils.toJsonString(list);
|
||||
logger.info(result);
|
||||
|
||||
//Equal result with expected string
|
||||
assertEquals(result,expected);
|
||||
|
||||
//If param is null, then return null string
|
||||
result = JSONUtils.toJsonString(null);
|
||||
logger.info(result);
|
||||
|
||||
assertEquals("null", result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test toList
|
||||
*/
|
||||
@Test
|
||||
public void testToList() {
|
||||
|
||||
//Invoke toList
|
||||
List<LinkedHashMap> result = JSONUtils.toList(expected ,LinkedHashMap.class);
|
||||
//Equal list size=1
|
||||
assertEquals(1,result.size());
|
||||
|
||||
//Transform entity to LinkedHashMap<String, Object>
|
||||
LinkedHashMap<String, Object> entity = result.get(0);
|
||||
|
||||
//Equal expected values
|
||||
assertEquals("mysql200",entity.get("mysql service name"));
|
||||
assertEquals("192.168.xx.xx", entity.get("mysql address"));
|
||||
assertEquals("3306", entity.get("port"));
|
||||
assertEquals("80", entity.get("no index of number"));
|
||||
assertEquals("190", entity.get("database client connections"));
|
||||
|
||||
//If param is null, then return empty list
|
||||
result = JSONUtils.toList(null ,LinkedHashMap.class);
|
||||
assertNotNull(result);
|
||||
assertTrue(result.isEmpty());
|
||||
|
||||
//If param is incorrect, then return empty list and log error message
|
||||
result = JSONUtils.toList("}{" ,LinkedHashMap.class);
|
||||
assertNotNull(result);
|
||||
assertTrue(result.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -86,11 +86,6 @@
|
|||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
|
|
|
|||
|
|
@ -16,13 +16,17 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* schedule parameters
|
||||
*/
|
||||
public class ScheduleParam {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
private String crontab;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.dto.gantt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -41,16 +43,19 @@ public class Task {
|
|||
/**
|
||||
* task execution date
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date executionDate;
|
||||
|
||||
/**
|
||||
* task iso start
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date isoStart;
|
||||
|
||||
/**
|
||||
* task iso end
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date isoEnd;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.apache.dolphinscheduler.api.dto.resources;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.apache.dolphinscheduler.common.enums.ResourceType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -26,7 +25,7 @@ import java.util.List;
|
|||
/**
|
||||
* resource component
|
||||
*/
|
||||
@JSONType(orders={"id","pid","name","fullName","description","isDirctory","children","type"})
|
||||
@JsonPropertyOrder({"id","pid","name","fullName","description","isDirctory","children","type"})
|
||||
public abstract class ResourceComponent {
|
||||
public ResourceComponent() {
|
||||
}
|
||||
|
|
@ -46,17 +45,14 @@ public abstract class ResourceComponent {
|
|||
/**
|
||||
* id
|
||||
*/
|
||||
@JSONField(ordinal = 1)
|
||||
protected int id;
|
||||
/**
|
||||
* parent id
|
||||
*/
|
||||
@JSONField(ordinal = 2)
|
||||
protected int pid;
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
@JSONField(ordinal = 3)
|
||||
protected String name;
|
||||
/**
|
||||
* current directory
|
||||
|
|
@ -65,32 +61,26 @@ public abstract class ResourceComponent {
|
|||
/**
|
||||
* full name
|
||||
*/
|
||||
@JSONField(ordinal = 4)
|
||||
protected String fullName;
|
||||
/**
|
||||
* description
|
||||
*/
|
||||
@JSONField(ordinal = 5)
|
||||
protected String description;
|
||||
/**
|
||||
* is directory
|
||||
*/
|
||||
@JSONField(ordinal = 6)
|
||||
protected boolean isDirctory;
|
||||
/**
|
||||
* id value
|
||||
*/
|
||||
@JSONField(ordinal = 7)
|
||||
protected String idValue;
|
||||
/**
|
||||
* resoruce type
|
||||
*/
|
||||
@JSONField(ordinal = 8)
|
||||
protected ResourceType type;
|
||||
/**
|
||||
* children
|
||||
*/
|
||||
@JSONField(ordinal = 8)
|
||||
protected List<ResourceComponent> children = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.dto.treeview;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -42,11 +44,13 @@ public class Instance {
|
|||
/**
|
||||
* node start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* node end time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ public enum Status {
|
|||
DATA_IS_NOT_VALID(50017,"data {0} not valid", "数据[{0}]无效"),
|
||||
DATA_IS_NULL(50018,"data {0} is null", "数据[{0}]不能为空"),
|
||||
PROCESS_NODE_HAS_CYCLE(50019,"process node has cycle", "流程节点间存在循环依赖"),
|
||||
PROCESS_NODE_S_PARAMETER_INVALID(50020,"process node %s parameter invalid", "流程节点[%s]参数无效"),
|
||||
PROCESS_NODE_S_PARAMETER_INVALID(50020,"process node {0} parameter invalid", "流程节点[{0}]参数无效"),
|
||||
PROCESS_DEFINE_STATE_ONLINE(50021, "process definition {0} is already on line", "工作流定义[{0}]已上线"),
|
||||
DELETE_PROCESS_DEFINE_BY_ID_ERROR(50022,"delete process definition by id error", "删除工作流定义错误"),
|
||||
SCHEDULE_CRON_STATE_ONLINE(50023,"the status of schedule {0} is already on line", "调度配置[{0}]已上线"),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ 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.common.utils.*;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
|
||||
import org.apache.dolphinscheduler.dao.utils.DagHelper;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
|
|
@ -29,7 +27,7 @@ import org.apache.dolphinscheduler.common.Constants;
|
|||
import org.apache.dolphinscheduler.common.enums.DbConnectType;
|
||||
import org.apache.dolphinscheduler.common.enums.DbType;
|
||||
import org.apache.dolphinscheduler.common.utils.CommonUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.dao.datasource.*;
|
||||
import org.apache.dolphinscheduler.dao.entity.DataSource;
|
||||
import org.apache.dolphinscheduler.dao.entity.Resource;
|
||||
|
|
@ -161,15 +159,15 @@ public class DataSourceService extends BaseService{
|
|||
return result;
|
||||
}
|
||||
//check password,if the password is not updated, set to the old password.
|
||||
JSONObject paramObject = JSON.parseObject(parameter);
|
||||
String password = paramObject.getString(Constants.PASSWORD);
|
||||
ObjectNode paramObject = JSONUtils.parseObject(parameter);
|
||||
String password = paramObject.path(Constants.PASSWORD).asText();
|
||||
if (StringUtils.isBlank(password)) {
|
||||
String oldConnectionParams = dataSource.getConnectionParams();
|
||||
JSONObject oldParams = JSON.parseObject(oldConnectionParams);
|
||||
paramObject.put(Constants.PASSWORD, oldParams.getString(Constants.PASSWORD));
|
||||
ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams);
|
||||
paramObject.put(Constants.PASSWORD, oldParams.path(Constants.PASSWORD).asText());
|
||||
}
|
||||
// connectionParams json
|
||||
String connectionParams = paramObject.toJSONString();
|
||||
String connectionParams = paramObject.toString();
|
||||
|
||||
Boolean isConnection = checkConnection(type, connectionParams);
|
||||
if (!isConnection) {
|
||||
|
|
@ -327,9 +325,9 @@ public class DataSourceService extends BaseService{
|
|||
for (DataSource dataSource : dataSourceList) {
|
||||
|
||||
String connectionParams = dataSource.getConnectionParams();
|
||||
JSONObject object = JSON.parseObject(connectionParams);
|
||||
ObjectNode object = JSONUtils.parseObject(connectionParams);
|
||||
object.put(Constants.PASSWORD, Constants.XXXXXX);
|
||||
dataSource.setConnectionParams(JSONUtils.toJson(object));
|
||||
dataSource.setConnectionParams(object.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -391,11 +389,11 @@ public class DataSourceService extends BaseService{
|
|||
try {
|
||||
switch (dbType) {
|
||||
case POSTGRESQL:
|
||||
datasource = JSON.parseObject(parameter, PostgreDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, PostgreDataSource.class);
|
||||
Class.forName(Constants.ORG_POSTGRESQL_DRIVER);
|
||||
break;
|
||||
case MYSQL:
|
||||
datasource = JSON.parseObject(parameter, MySQLDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, MySQLDataSource.class);
|
||||
Class.forName(Constants.COM_MYSQL_JDBC_DRIVER);
|
||||
break;
|
||||
case HIVE:
|
||||
|
|
@ -410,26 +408,26 @@ public class DataSourceService extends BaseService{
|
|||
getString(org.apache.dolphinscheduler.common.Constants.LOGIN_USER_KEY_TAB_PATH));
|
||||
}
|
||||
if (dbType == DbType.HIVE){
|
||||
datasource = JSON.parseObject(parameter, HiveDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, HiveDataSource.class);
|
||||
}else if (dbType == DbType.SPARK){
|
||||
datasource = JSON.parseObject(parameter, SparkDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, SparkDataSource.class);
|
||||
}
|
||||
Class.forName(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER);
|
||||
break;
|
||||
case CLICKHOUSE:
|
||||
datasource = JSON.parseObject(parameter, ClickHouseDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, ClickHouseDataSource.class);
|
||||
Class.forName(Constants.COM_CLICKHOUSE_JDBC_DRIVER);
|
||||
break;
|
||||
case ORACLE:
|
||||
datasource = JSON.parseObject(parameter, OracleDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, OracleDataSource.class);
|
||||
Class.forName(Constants.COM_ORACLE_JDBC_DRIVER);
|
||||
break;
|
||||
case SQLSERVER:
|
||||
datasource = JSON.parseObject(parameter, SQLServerDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, SQLServerDataSource.class);
|
||||
Class.forName(Constants.COM_SQLSERVER_JDBC_DRIVER);
|
||||
break;
|
||||
case DB2:
|
||||
datasource = JSON.parseObject(parameter, DB2ServerDataSource.class);
|
||||
datasource = JSONUtils.parseObject(parameter, DB2ServerDataSource.class);
|
||||
Class.forName(Constants.COM_DB2_JDBC_DRIVER);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -524,6 +522,8 @@ public class DataSourceService extends BaseService{
|
|||
separator = ";";
|
||||
}
|
||||
|
||||
Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(6);
|
||||
parameterMap.put(TYPE, connectType);
|
||||
parameterMap.put(Constants.ADDRESS, address);
|
||||
parameterMap.put(Constants.DATABASE, database);
|
||||
parameterMap.put(Constants.JDBC_URL, jdbcUrl);
|
||||
|
|
@ -534,8 +534,7 @@ public class DataSourceService extends BaseService{
|
|||
parameterMap.put(Constants.PRINCIPAL,principal);
|
||||
}
|
||||
if (other != null && !"".equals(other)) {
|
||||
LinkedHashMap<String, String> map = JSON.parseObject(other, new TypeReference<LinkedHashMap<String, String>>() {
|
||||
});
|
||||
Map<String, String> map = JSONUtils.toMap(other);
|
||||
if (map.size() > 0) {
|
||||
StringBuilder otherSb = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry: map.entrySet()) {
|
||||
|
|
@ -550,9 +549,9 @@ public class DataSourceService extends BaseService{
|
|||
}
|
||||
|
||||
if(logger.isDebugEnabled()){
|
||||
logger.info("parameters map-----" + JSON.toJSONString(parameterMap));
|
||||
logger.info("parameters map:{}", JSONUtils.toJsonString(parameterMap));
|
||||
}
|
||||
return JSON.toJSONString(parameterMap);
|
||||
return JSONUtils.toJsonString(parameterMap);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.dolphinscheduler.common.enums.*;
|
|||
import org.apache.dolphinscheduler.common.model.Server;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.*;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||
|
|
@ -509,7 +509,7 @@ public class ExecutorService extends BaseService{
|
|||
if(warningType != null){
|
||||
command.setWarningType(warningType);
|
||||
}
|
||||
command.setCommandParam(JSONUtils.toJson(cmdParam));
|
||||
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
|
||||
command.setExecutorId(executorId);
|
||||
command.setWarningGroupId(warningGroupId);
|
||||
command.setProcessInstancePriority(processInstancePriority);
|
||||
|
|
@ -532,7 +532,7 @@ public class ExecutorService extends BaseService{
|
|||
if(runMode == RunMode.RUN_MODE_SERIAL){
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start));
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(end));
|
||||
command.setCommandParam(JSONUtils.toJson(cmdParam));
|
||||
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
|
||||
return processService.createCommand(command);
|
||||
}else if (runMode == RunMode.RUN_MODE_PARALLEL){
|
||||
List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionId(processDefineId);
|
||||
|
|
@ -547,7 +547,7 @@ public class ExecutorService extends BaseService{
|
|||
for (Date date : listDate) {
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(date));
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(date));
|
||||
command.setCommandParam(JSONUtils.toJson(cmdParam));
|
||||
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
|
||||
processService.createCommand(command);
|
||||
}
|
||||
return listDate.size();
|
||||
|
|
@ -558,7 +558,7 @@ public class ExecutorService extends BaseService{
|
|||
runCunt += 1;
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start));
|
||||
cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(start));
|
||||
command.setCommandParam(JSONUtils.toJson(cmdParam));
|
||||
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
|
||||
processService.createCommand(command);
|
||||
start = DateUtils.getSomeDay(start, 1);
|
||||
}
|
||||
|
|
@ -570,7 +570,7 @@ public class ExecutorService extends BaseService{
|
|||
processDefineId, schedule);
|
||||
}
|
||||
}else{
|
||||
command.setCommandParam(JSONUtils.toJson(cmdParam));
|
||||
command.setCommandParam(JSONUtils.toJsonString(cmdParam));
|
||||
return processService.createCommand(command);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
|
@ -636,7 +635,7 @@ public class ProcessDefinitionService extends BaseDAGService {
|
|||
try {
|
||||
out = response.getOutputStream();
|
||||
buff = new BufferedOutputStream(out);
|
||||
buff.write(JSON.toJSONString(processDefinitionList).getBytes(StandardCharsets.UTF_8));
|
||||
buff.write(JSONUtils.toJsonString(processDefinitionList).getBytes(StandardCharsets.UTF_8));
|
||||
buff.flush();
|
||||
buff.close();
|
||||
} catch (IOException e) {
|
||||
|
|
@ -756,7 +755,7 @@ public class ProcessDefinitionService extends BaseDAGService {
|
|||
public Map<String, Object> importProcessDefinition(User loginUser, MultipartFile file, String currentProjectName) {
|
||||
Map<String, Object> result = new HashMap<>(5);
|
||||
String processMetaJson = FileUtils.file2String(file);
|
||||
List<ProcessMeta> processMetaList = JSON.parseArray(processMetaJson, ProcessMeta.class);
|
||||
List<ProcessMeta> processMetaList = JSONUtils.toList(processMetaJson, ProcessMeta.class);
|
||||
|
||||
//check file content
|
||||
if (CollectionUtils.isEmpty(processMetaList)) {
|
||||
|
|
@ -1340,9 +1339,9 @@ public class ProcessDefinitionService extends BaseDAGService {
|
|||
*/
|
||||
if (taskInstance.getTaskType().equals(TaskType.SUB_PROCESS.name())) {
|
||||
String taskJson = taskInstance.getTaskJson();
|
||||
taskNode = JSON.parseObject(taskJson, TaskNode.class);
|
||||
subProcessId = Integer.parseInt(JSON.parseObject(
|
||||
taskNode.getParams()).getString(CMDPARAM_SUB_PROCESS_DEFINE_ID));
|
||||
taskNode = JSONUtils.parseObject(taskJson, TaskNode.class);
|
||||
subProcessId = Integer.parseInt(JSONUtils.parseObject(
|
||||
taskNode.getParams()).path(CMDPARAM_SUB_PROCESS_DEFINE_ID).asText());
|
||||
}
|
||||
treeViewDto.getInstances().add(new Instance(taskInstance.getId(), taskInstance.getName(), taskInstance.getTaskType(), taskInstance.getState().toString()
|
||||
, taskInstance.getStartTime(), taskInstance.getEndTime(), taskInstance.getHost(), DateUtils.format2Readable(endTime.getTime() - startTime.getTime()), subProcessId));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.dolphinscheduler.api.dto.gantt.GanttDto;
|
||||
import org.apache.dolphinscheduler.api.dto.gantt.Task;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
|
|
@ -33,11 +34,11 @@ import org.apache.dolphinscheduler.common.model.TaskNodeRelation;
|
|||
import org.apache.dolphinscheduler.common.process.Property;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.placeholder.BusinessTimeUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.dolphinscheduler.dao.entity.*;
|
||||
import org.apache.dolphinscheduler.dao.mapper.*;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
|
||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -49,6 +50,7 @@ import java.io.BufferedReader;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -242,7 +244,7 @@ public class ProcessInstanceService extends BaseDAGService {
|
|||
if(logResult.getCode() == Status.SUCCESS.ordinal()){
|
||||
String log = (String) logResult.getData();
|
||||
Map<String, DependResult> resultMap = parseLogForDependentResult(log);
|
||||
taskInstance.setDependentResult(JSONUtils.toJson(resultMap));
|
||||
taskInstance.setDependentResult(JSONUtils.toJsonString(resultMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -380,7 +382,7 @@ public class ProcessInstanceService extends BaseDAGService {
|
|||
return result;
|
||||
}
|
||||
|
||||
originDefParams = JSONUtils.toJson(processData.getGlobalParams());
|
||||
originDefParams = JSONUtils.toJsonString(processData.getGlobalParams());
|
||||
List<Property> globalParamList = processData.getGlobalParams();
|
||||
Map<String, String> globalParamMap = globalParamList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
|
||||
globalParams = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList,
|
||||
|
|
@ -530,16 +532,16 @@ public class ProcessInstanceService extends BaseDAGService {
|
|||
List<Property> globalParams = new ArrayList<>();
|
||||
|
||||
if (userDefinedParams != null && userDefinedParams.length() > 0) {
|
||||
globalParams = JSON.parseArray(userDefinedParams, Property.class);
|
||||
globalParams = JSONUtils.toList(userDefinedParams, Property.class);
|
||||
}
|
||||
|
||||
|
||||
List<TaskNode> taskNodeList = workflowData.getTasks();
|
||||
|
||||
// global param string
|
||||
String globalParamStr = JSONUtils.toJson(globalParams);
|
||||
String globalParamStr = JSONUtils.toJsonString(globalParams);
|
||||
globalParamStr = ParameterUtils.convertParameterPlaceholders(globalParamStr, timeParams);
|
||||
globalParams = JSON.parseArray(globalParamStr, Property.class);
|
||||
globalParams = JSONUtils.toList(globalParamStr, Property.class);
|
||||
for (Property property : globalParams) {
|
||||
timeParams.put(property.getProp(), property.getValue());
|
||||
}
|
||||
|
|
@ -552,7 +554,8 @@ public class ProcessInstanceService extends BaseDAGService {
|
|||
String localParams = map.get(LOCAL_PARAMS);
|
||||
if (localParams != null && !localParams.isEmpty()) {
|
||||
localParams = ParameterUtils.convertParameterPlaceholders(localParams, timeParams);
|
||||
List<Property> localParamsList = JSON.parseArray(localParams, Property.class);
|
||||
List<Property> localParamsList = JSONUtils.toList(localParams, Property.class);
|
||||
|
||||
Map<String,Object> localParamsMap = new HashMap<>();
|
||||
localParamsMap.put("taskType",taskNode.getType());
|
||||
localParamsMap.put("localParamsList",localParamsList);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.apache.commons.collections.BeanMap;
|
||||
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
||||
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
|
||||
|
|
@ -557,7 +556,6 @@ public class ResourcesService extends BaseService {
|
|||
}
|
||||
List<Resource> allResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal(),0);
|
||||
Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList);
|
||||
//JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(resourceTreeVisitor.visit().getChildren(), SerializerFeature.SortField));
|
||||
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
|
||||
putMsg(result,Status.SUCCESS);
|
||||
|
||||
|
|
@ -1154,8 +1152,9 @@ public class ResourcesService extends BaseService {
|
|||
}
|
||||
List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId);
|
||||
Visitor visitor = new ResourceTreeVisitor(authedResources);
|
||||
logger.info(JSON.toJSONString(visitor.visit(), SerializerFeature.SortField));
|
||||
String jsonTreeStr = JSON.toJSONString(visitor.visit().getChildren(), SerializerFeature.SortField);
|
||||
String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
|
||||
logger.info(visit);
|
||||
String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
|
||||
logger.info(jsonTreeStr);
|
||||
result.put(Constants.DATA_LIST, visitor.visit().getChildren());
|
||||
putMsg(result,Status.SUCCESS);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.dolphinscheduler.common.Constants;
|
|||
import org.apache.dolphinscheduler.common.enums.*;
|
||||
import org.apache.dolphinscheduler.common.model.Server;
|
||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
|
||||
import org.apache.dolphinscheduler.dao.entity.Project;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.api.utils;
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.task.AbstractParameters;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.TaskParametersUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.dolphinscheduler.common.enums.TaskType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
|
||||
import org.apache.dolphinscheduler.dao.entity.Project;
|
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.AlertType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
|
|||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.WarningType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,12 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.ResourceType;
|
||||
import org.apache.dolphinscheduler.common.enums.UdfType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -55,7 +54,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -79,7 +78,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -282,7 +281,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -304,7 +303,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -325,7 +324,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -345,7 +344,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -366,7 +365,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -387,7 +386,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -407,7 +406,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -428,7 +427,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
@ -447,7 +446,7 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
result.getCode().equals(Status.SUCCESS.getCode());
|
||||
JSONObject object = (JSONObject) JSON.parse(mvcResult.getResponse().getContentAsString());
|
||||
ObjectNode object = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
|||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.WarningType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.api.controller;
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.api.service;
|
|||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.DbConnectType;
|
||||
import org.apache.dolphinscheduler.common.enums.DbType;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import org.apache.dolphinscheduler.dao.entity.DataSource;
|
||||
|
|
@ -97,4 +98,12 @@ public class DataSourceServiceTest {
|
|||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildParameter(){
|
||||
String param = dataSourceService.buildParameter("","", DbType.ORACLE, "192.168.9.1","1521","im"
|
||||
,"","test","test", DbConnectType.ORACLE_SERVICE_NAME,"");
|
||||
String expected = "{\"type\":\"ORACLE_SERVICE_NAME\",\"address\":\"jdbc:oracle:thin:@//192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:oracle:thin:@//192.168.9.1:1521/im\",\"user\":\"test\",\"password\":\"test\"}";
|
||||
Assert.assertEquals(expected, param);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ import org.apache.dolphinscheduler.common.Constants;
|
|||
import org.apache.dolphinscheduler.common.enums.*;
|
||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.FileUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.dao.entity.*;
|
||||
import org.apache.dolphinscheduler.dao.mapper.*;
|
||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||
|
|
@ -521,7 +521,6 @@ public class ProcessDefinitionServiceTest {
|
|||
@Test
|
||||
public void testExportProcessMetaDataStr() {
|
||||
Mockito.when(scheduleMapper.queryByProcessDefinitionId(46)).thenReturn(getSchedulerList());
|
||||
|
||||
ProcessDefinition processDefinition = getProcessDefinition();
|
||||
processDefinition.setProcessDefinitionJson(sqlDependentJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.api.service;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.avro.generic.GenericData;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.apache.dolphinscheduler.common.task.shell.ShellParameters;
|
|||
import org.apache.dolphinscheduler.common.task.spark.SparkParameters;
|
||||
import org.apache.dolphinscheduler.common.task.sql.SqlParameters;
|
||||
import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.TaskParametersUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.api.utils.exportprocess;
|
|||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.json.JSONException;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.api.utils.exportprocess;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.json.JSONException;
|
||||
import org.junit.Test;
|
||||
|
|
|
|||
|
|
@ -36,11 +36,7 @@
|
|||
<groupId>org.apache.dolphinscheduler</groupId>
|
||||
<artifactId>dolphinscheduler-plugin-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.dolphinscheduler.common.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
|
||||
public enum SqoopJobType {
|
||||
CUSTOM(0, "CUSTOM"),
|
||||
TEMPLATE(1, "TEMPLATE");
|
||||
|
||||
SqoopJobType(int code, String descp){
|
||||
this.code = code;
|
||||
this.descp = descp;
|
||||
}
|
||||
|
||||
@EnumValue
|
||||
private final int code;
|
||||
private final String descp;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescp() {
|
||||
return descp;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -23,9 +25,9 @@ import java.util.Objects;
|
|||
* date interval class
|
||||
*/
|
||||
public class DateInterval {
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
public DateInterval(Date beginTime, Date endTime){
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
package org.apache.dolphinscheduler.common.model;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -52,11 +54,13 @@ public class Server {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* laster heart beat time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastHeartbeatTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.TaskType;
|
||||
import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
|
@ -200,7 +199,7 @@ public class TaskNode {
|
|||
|
||||
public void setDepList(List<String> depList) throws JsonProcessingException {
|
||||
this.depList = depList;
|
||||
this.preTasks = JSONUtils.toJson(depList);
|
||||
this.preTasks = JSONUtils.toJsonString(depList);
|
||||
}
|
||||
|
||||
public String getLoc() {
|
||||
|
|
@ -300,7 +299,7 @@ public class TaskNode {
|
|||
if(StringUtils.isNotEmpty(this.getTimeout())){
|
||||
String formatStr = String.format("%s,%s", TaskTimeoutStrategy.WARN.name(), TaskTimeoutStrategy.FAILED.name());
|
||||
String taskTimeout = this.getTimeout().replace(formatStr,TaskTimeoutStrategy.WARNFAILED.name());
|
||||
return JSON.parseObject(taskTimeout,TaskTimeoutParameter.class);
|
||||
return JSONUtils.parseObject(taskTimeout,TaskTimeoutParameter.class);
|
||||
}
|
||||
return new TaskTimeoutParameter(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ public class FlinkParameters extends AbstractParameters {
|
|||
*/
|
||||
private String others;
|
||||
|
||||
/**
|
||||
* flink version
|
||||
*/
|
||||
private String flinkVersion;
|
||||
|
||||
/**
|
||||
* program type
|
||||
* 0 JAVA,1 SCALA,2 PYTHON
|
||||
|
|
@ -200,6 +205,14 @@ public class FlinkParameters extends AbstractParameters {
|
|||
this.programType = programType;
|
||||
}
|
||||
|
||||
public String getFlinkVersion() {
|
||||
return flinkVersion;
|
||||
}
|
||||
|
||||
public void setFlinkVersion(String flinkVersion) {
|
||||
this.flinkVersion = flinkVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkParameters() {
|
||||
return mainJar != null && programType != null;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,17 @@ public class HttpParameters extends AbstractParameters {
|
|||
private String condition;
|
||||
|
||||
|
||||
/**
|
||||
* Connect Timeout
|
||||
* Unit: ms
|
||||
*/
|
||||
private int connectTimeout ;
|
||||
|
||||
/**
|
||||
* Socket Timeout
|
||||
* Unit: ms
|
||||
*/
|
||||
private int socketTimeout ;
|
||||
|
||||
@Override
|
||||
public boolean checkParameters() {
|
||||
|
|
@ -106,4 +117,20 @@ public class HttpParameters extends AbstractParameters {
|
|||
public void setCondition(String condition) {
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public int getConnectTimeout() {
|
||||
return connectTimeout;
|
||||
}
|
||||
|
||||
public void setConnectTimeout(int connectTimeout) {
|
||||
this.connectTimeout = connectTimeout;
|
||||
}
|
||||
|
||||
public int getSocketTimeout() {
|
||||
return socketTimeout;
|
||||
}
|
||||
|
||||
public void setSocketTimeout(int socketTimeout) {
|
||||
this.socketTimeout = socketTimeout;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.task.sqoop;
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.SqoopJobType;
|
||||
import org.apache.dolphinscheduler.common.process.Property;
|
||||
import org.apache.dolphinscheduler.common.process.ResourceInfo;
|
||||
import org.apache.dolphinscheduler.common.task.AbstractParameters;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
|
|
@ -28,6 +30,23 @@ import java.util.List;
|
|||
*/
|
||||
public class SqoopParameters extends AbstractParameters {
|
||||
|
||||
/**
|
||||
* sqoop job type:
|
||||
* CUSTOM - custom sqoop job
|
||||
* TEMPLATE - sqoop template job
|
||||
*/
|
||||
private String jobType;
|
||||
|
||||
/**
|
||||
* customJob eq 1, use customShell
|
||||
*/
|
||||
private String customShell;
|
||||
|
||||
/**
|
||||
* sqoop job name - map-reduce job name
|
||||
*/
|
||||
private String jobName;
|
||||
|
||||
/**
|
||||
* model type
|
||||
*/
|
||||
|
|
@ -53,6 +72,16 @@ public class SqoopParameters extends AbstractParameters {
|
|||
*/
|
||||
private String targetParams;
|
||||
|
||||
/**
|
||||
* hadoop custom param for sqoop job
|
||||
*/
|
||||
private List<Property> hadoopCustomParams;
|
||||
|
||||
/**
|
||||
* sqoop advanced param
|
||||
*/
|
||||
private List<Property> sqoopAdvancedParams;
|
||||
|
||||
public String getModelType() {
|
||||
return modelType;
|
||||
}
|
||||
|
|
@ -101,18 +130,74 @@ public class SqoopParameters extends AbstractParameters {
|
|||
this.targetParams = targetParams;
|
||||
}
|
||||
|
||||
public String getJobType() {
|
||||
return jobType;
|
||||
}
|
||||
|
||||
public void setJobType(String jobType) {
|
||||
this.jobType = jobType;
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getCustomShell() {
|
||||
return customShell;
|
||||
}
|
||||
|
||||
public void setCustomShell(String customShell) {
|
||||
this.customShell = customShell;
|
||||
}
|
||||
|
||||
public List<Property> getHadoopCustomParams() {
|
||||
return hadoopCustomParams;
|
||||
}
|
||||
|
||||
public void setHadoopCustomParams(List<Property> hadoopCustomParams) {
|
||||
this.hadoopCustomParams = hadoopCustomParams;
|
||||
}
|
||||
|
||||
public List<Property> getSqoopAdvancedParams() {
|
||||
return sqoopAdvancedParams;
|
||||
}
|
||||
|
||||
public void setSqoopAdvancedParams(List<Property> sqoopAdvancedParams) {
|
||||
this.sqoopAdvancedParams = sqoopAdvancedParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkParameters() {
|
||||
return StringUtils.isNotEmpty(modelType)&&
|
||||
concurrency != 0 &&
|
||||
StringUtils.isNotEmpty(sourceType)&&
|
||||
StringUtils.isNotEmpty(targetType)&&
|
||||
StringUtils.isNotEmpty(sourceParams)&&
|
||||
StringUtils.isNotEmpty(targetParams);
|
||||
|
||||
boolean sqoopParamsCheck = false;
|
||||
|
||||
if (StringUtils.isEmpty(jobType)) {
|
||||
return sqoopParamsCheck;
|
||||
}
|
||||
|
||||
if (SqoopJobType.TEMPLATE.getDescp().equals(jobType)) {
|
||||
sqoopParamsCheck = StringUtils.isEmpty(customShell) &&
|
||||
StringUtils.isNotEmpty(modelType) &&
|
||||
StringUtils.isNotEmpty(jobName) &&
|
||||
concurrency != 0 &&
|
||||
StringUtils.isNotEmpty(sourceType) &&
|
||||
StringUtils.isNotEmpty(targetType) &&
|
||||
StringUtils.isNotEmpty(sourceParams) &&
|
||||
StringUtils.isNotEmpty(targetParams);
|
||||
} else if (SqoopJobType.CUSTOM.getDescp().equals(jobType)) {
|
||||
sqoopParamsCheck = StringUtils.isNotEmpty(customShell) &&
|
||||
StringUtils.isEmpty(jobName);
|
||||
}
|
||||
|
||||
return sqoopParamsCheck;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceInfo> getResourceFilesList() {
|
||||
return new ArrayList<>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class TargetMysqlParameter {
|
|||
this.preQuery = preQuery;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
public boolean getIsUpdate() {
|
||||
return isUpdate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
|
@ -28,8 +26,8 @@ import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
|||
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
||||
import org.apache.dolphinscheduler.common.enums.ResourceType;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.*;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.*;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.yarn.client.cli.RMAdminCLI;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -408,9 +406,8 @@ public class HadoopUtils implements Closeable {
|
|||
*
|
||||
* @param applicationId application id
|
||||
* @return the return may be null or there may be other parse exceptions
|
||||
* @throws JSONException json exception
|
||||
*/
|
||||
public ExecutionStatus getApplicationStatus(String applicationId) throws JSONException {
|
||||
public ExecutionStatus getApplicationStatus(String applicationId) {
|
||||
if (StringUtils.isEmpty(applicationId)) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -421,15 +418,18 @@ public class HadoopUtils implements Closeable {
|
|||
|
||||
String responseContent = HttpUtils.get(applicationUrl);
|
||||
if (responseContent != null) {
|
||||
JSONObject jsonObject = JSON.parseObject(responseContent);
|
||||
result = jsonObject.getJSONObject("app").getString("finalStatus");
|
||||
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
||||
result = jsonObject.path("app").path("finalStatus").asText();
|
||||
} else {
|
||||
//may be in job history
|
||||
String jobHistoryUrl = getJobHistoryUrl(applicationId);
|
||||
logger.info("jobHistoryUrl={}", jobHistoryUrl);
|
||||
responseContent = HttpUtils.get(jobHistoryUrl);
|
||||
JSONObject jsonObject = JSONObject.parseObject(responseContent);
|
||||
result = jsonObject.getJSONObject("job").getString("state");
|
||||
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
||||
if (!jsonObject.has("job")){
|
||||
return ExecutionStatus.FAILURE;
|
||||
}
|
||||
result = jsonObject.path("job").path("state").asText();
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
|
|
@ -469,6 +469,7 @@ public class HadoopUtils implements Closeable {
|
|||
* hdfs resource dir
|
||||
*
|
||||
* @param tenantCode tenant code
|
||||
* @param resourceType resource type
|
||||
* @return hdfs resource dir
|
||||
*/
|
||||
public static String getHdfsDir(ResourceType resourceType, String tenantCode) {
|
||||
|
|
@ -669,10 +670,13 @@ public class HadoopUtils implements Closeable {
|
|||
return null;
|
||||
}
|
||||
//to json
|
||||
JSONObject jsonObject = JSON.parseObject(retStr);
|
||||
ObjectNode jsonObject = JSONUtils.parseObject(retStr);
|
||||
|
||||
//get ResourceManager state
|
||||
return jsonObject.getJSONObject("clusterInfo").getString("haState");
|
||||
if (!jsonObject.has("clusterInfo")){
|
||||
return null;
|
||||
}
|
||||
return jsonObject.get("clusterInfo").path("haState").asText();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,34 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
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
|
||||
|
|
@ -50,15 +66,30 @@ public class JSONUtils {
|
|||
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true).setTimeZone(TimeZone.getDefault());
|
||||
}
|
||||
|
||||
|
||||
public static ArrayNode createArrayNode() {
|
||||
return objectMapper.createArrayNode();
|
||||
}
|
||||
|
||||
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 toJson(Object object) {
|
||||
public static String toJsonString(Object object, SerializationFeature feature) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(object);
|
||||
ObjectWriter writer = objectMapper.writer(feature);
|
||||
return writer.writeValueAsString(object);
|
||||
} catch (Exception e) {
|
||||
logger.error("object to json exception!", e);
|
||||
}
|
||||
|
|
@ -66,7 +97,6 @@ public class JSONUtils {
|
|||
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
|
||||
|
|
@ -94,7 +124,6 @@ public class JSONUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* json to list
|
||||
*
|
||||
|
|
@ -105,16 +134,18 @@ public class JSONUtils {
|
|||
*/
|
||||
public static <T> List<T> toList(String json, Class<T> clazz) {
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return objectMapper.readValue(json, new TypeReference<List<T>>() {
|
||||
});
|
||||
} catch (Exception e) {
|
||||
logger.error("JSONArray.parseArray exception!", e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -259,7 +290,11 @@ public class JSONUtils {
|
|||
@Override
|
||||
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||
JsonNode node = p.getCodec().readTree(p);
|
||||
return node.toString();
|
||||
if (node instanceof TextNode) {
|
||||
return node.asText();
|
||||
} else {
|
||||
return node.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,12 @@ public class OSUtils {
|
|||
private static final SystemInfo SI = new SystemInfo();
|
||||
public static final String TWO_DECIMAL = "0.00";
|
||||
|
||||
/**
|
||||
* return -1 when the function can not get hardware env info
|
||||
* e.g {@link OSUtils#loadAverage()} {@link OSUtils#cpuUsage()}
|
||||
*/
|
||||
public static final double NEGATIVE_ONE = -1;
|
||||
|
||||
private static HardwareAbstractionLayer hal = SI.getHardware();
|
||||
|
||||
private OSUtils() {}
|
||||
|
|
@ -118,9 +124,11 @@ public class OSUtils {
|
|||
*/
|
||||
public static double loadAverage() {
|
||||
double loadAverage = hal.getProcessor().getSystemLoadAverage();
|
||||
if (Double.isNaN(loadAverage)) {
|
||||
return NEGATIVE_ONE;
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
|
||||
|
||||
df.setRoundingMode(RoundingMode.HALF_UP);
|
||||
return Double.parseDouble(df.format(loadAverage));
|
||||
}
|
||||
|
|
@ -133,10 +141,12 @@ public class OSUtils {
|
|||
public static double cpuUsage() {
|
||||
CentralProcessor processor = hal.getProcessor();
|
||||
double cpuUsage = processor.getSystemCpuLoad();
|
||||
if (Double.isNaN(cpuUsage)) {
|
||||
return NEGATIVE_ONE;
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
|
||||
df.setRoundingMode(RoundingMode.HALF_UP);
|
||||
|
||||
return Double.parseDouble(df.format(cpuUsage));
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +403,6 @@ public class OSUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* whether is macOS
|
||||
* @return true if mac
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.CommandType;
|
||||
import org.apache.dolphinscheduler.common.enums.DataType;
|
||||
|
|
@ -24,8 +25,6 @@ import org.apache.dolphinscheduler.common.process.Property;
|
|||
import org.apache.dolphinscheduler.common.utils.placeholder.BusinessTimeUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.placeholder.PlaceholderUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.placeholder.TimePlaceholderUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -196,7 +195,7 @@ public class ParameterUtils {
|
|||
property.setValue(val);
|
||||
}
|
||||
}
|
||||
return JSONUtils.toJson(globalParamList);
|
||||
return JSONUtils.toJsonString(globalParamList);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class ResInfo {
|
|||
*/
|
||||
public static String getResInfoJson(double cpuUsage , double memoryUsage,double loadAverage){
|
||||
ResInfo resInfo = new ResInfo(cpuUsage,memoryUsage,loadAverage);
|
||||
return JSONUtils.toJson(resInfo);
|
||||
return JSONUtils.toJsonString(resInfo);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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.task;
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.HttpCheckCondition;
|
||||
import org.apache.dolphinscheduler.common.enums.HttpMethod;
|
||||
import org.apache.dolphinscheduler.common.task.http.HttpParameters;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* http parameter
|
||||
*/
|
||||
public class HttpParametersTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerator(){
|
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," +
|
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}";
|
||||
HttpParameters httpParameters = JSONUtils.parseObject(paramData, HttpParameters.class);
|
||||
|
||||
|
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() );
|
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout());
|
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl());
|
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod());
|
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition());
|
||||
Assert.assertEquals("",httpParameters.getCondition());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCheckParameters(){
|
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," +
|
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}";
|
||||
HttpParameters httpParameters = JSONUtils.parseObject(paramData, HttpParameters.class);
|
||||
|
||||
Assert.assertTrue( httpParameters.checkParameters());
|
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() );
|
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout());
|
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl());
|
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod());
|
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition());
|
||||
Assert.assertEquals("",httpParameters.getCondition());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCheckValues() {
|
||||
String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," +
|
||||
"\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}";
|
||||
HttpParameters httpParameters = JSONUtils.parseObject(paramData, HttpParameters.class);
|
||||
|
||||
Assert.assertTrue( httpParameters.checkParameters());
|
||||
Assert.assertEquals(10000,httpParameters.getConnectTimeout() );
|
||||
Assert.assertEquals(10000,httpParameters.getSocketTimeout());
|
||||
Assert.assertEquals("https://www.baidu.com/",httpParameters.getUrl());
|
||||
Assert.assertEquals(HttpMethod.GET,httpParameters.getHttpMethod());
|
||||
Assert.assertEquals(HttpCheckCondition.STATUS_CODE_DEFAULT,httpParameters.getHttpCheckCondition());
|
||||
Assert.assertEquals("",httpParameters.getCondition());
|
||||
Assert.assertEquals(0,httpParameters.getLocalParametersMap().size());
|
||||
Assert.assertEquals(0,httpParameters.getResourceFilesList().size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -16,8 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -37,8 +36,8 @@ public class HttpUtilsTest {
|
|||
//success
|
||||
String result = HttpUtils.get("https://github.com/manifest.json");
|
||||
Assert.assertNotNull(result);
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
Assert.assertEquals("GitHub", jsonObject.getString("name"));
|
||||
ObjectNode jsonObject = JSONUtils.parseObject(result);
|
||||
Assert.assertEquals("GitHub", jsonObject.path("name").asText());
|
||||
|
||||
result = HttpUtils.get("https://123.333.111.33/ccc");
|
||||
Assert.assertNull(result);
|
||||
|
|
|
|||
|
|
@ -16,16 +16,11 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.apache.dolphinscheduler.common.enums.DataType;
|
||||
import org.apache.dolphinscheduler.common.enums.Direct;
|
||||
import org.apache.dolphinscheduler.common.process.Property;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -33,36 +28,89 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.DataType;
|
||||
import org.apache.dolphinscheduler.common.enums.Direct;
|
||||
import org.apache.dolphinscheduler.common.model.TaskNode;
|
||||
import org.apache.dolphinscheduler.common.process.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);
|
||||
|
||||
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);
|
||||
Map<String, String> models = JSONUtils.toMap(jsonStr);
|
||||
Assert.assertEquals("1001", models.get("id"));
|
||||
Assert.assertEquals("Jobs", models.get("name"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convert2Property(){
|
||||
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 = JSON.parseObject(str, Property.class);
|
||||
Property property1 = JSONUtils.parseObject(str, Property.class);
|
||||
Direct direct = property1.getDirect();
|
||||
Assert.assertEquals(Direct.IN, direct);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void String2MapTest(){
|
||||
public void String2MapTest() {
|
||||
String str = list2String();
|
||||
|
||||
List<LinkedHashMap> maps = JSONUtils.toList(str,
|
||||
|
|
@ -76,34 +124,24 @@ public class JSONUtilsTest {
|
|||
Assert.assertEquals("190", maps.get(0).get("database client connections"));
|
||||
}
|
||||
|
||||
public String list2String(){
|
||||
public String list2String() {
|
||||
|
||||
LinkedHashMap<String, String> map1 = new LinkedHashMap<>();
|
||||
map1.put("mysql service name","mysql200");
|
||||
map1.put("mysql address","192.168.xx.xx");
|
||||
map1.put("port","3306");
|
||||
map1.put("no index of number","80");
|
||||
map1.put("database client connections","190");
|
||||
map1.put("mysql service name", "mysql200");
|
||||
map1.put("mysql address", "192.168.xx.xx");
|
||||
map1.put("port", "3306");
|
||||
map1.put("no index of number", "80");
|
||||
map1.put("database client connections", "190");
|
||||
|
||||
List<LinkedHashMap<String, String>> maps = new ArrayList<>();
|
||||
maps.add(0,map1);
|
||||
String resultJson = JSONUtils.toJson(maps);
|
||||
maps.add(0, map1);
|
||||
String resultJson = JSONUtils.toJsonString(maps);
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToJson() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("foo","bar");
|
||||
|
||||
Assert.assertEquals("{\"foo\":\"bar\"}", JSONUtils.toJson(map));
|
||||
Assert.assertEquals(
|
||||
String.valueOf((Object) null), JSONUtils.toJson(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseObject() {
|
||||
Assert.assertNull(JSONUtils.parseObject("", null));
|
||||
Assert.assertNull(JSONUtils.parseObject(""));
|
||||
Assert.assertNull(JSONUtils.parseObject("foo", String.class));
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +168,7 @@ public class JSONUtilsTest {
|
|||
@Test
|
||||
public void testToMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("foo","bar");
|
||||
map.put("foo", "bar");
|
||||
|
||||
Assert.assertTrue(map.equals(JSONUtils.toMap(
|
||||
"{\n" + "\"foo\": \"bar\"\n" + "}")));
|
||||
|
|
@ -157,6 +195,9 @@ public class JSONUtilsTest {
|
|||
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
|
||||
|
|
@ -181,4 +222,19 @@ public class JSONUtilsTest {
|
|||
Assert.assertEquals("yellow", node.path(0).path("color").asText());
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,15 +41,15 @@ public class OSUtilsTest {
|
|||
public void testOSMetric(){
|
||||
if (!OSUtils.isWindows()) {
|
||||
double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize();
|
||||
Assert.assertTrue(availablePhysicalMemorySize > 0.0f);
|
||||
Assert.assertTrue(availablePhysicalMemorySize >= 0.0d);
|
||||
double totalMemorySize = OSUtils.totalMemorySize();
|
||||
Assert.assertTrue(totalMemorySize > 0.0f);
|
||||
Assert.assertTrue(totalMemorySize >= 0.0d);
|
||||
double loadAverage = OSUtils.loadAverage();
|
||||
logger.info("loadAverage {}", loadAverage);
|
||||
double memoryUsage = OSUtils.memoryUsage();
|
||||
Assert.assertTrue(memoryUsage > 0.0f);
|
||||
Assert.assertTrue(memoryUsage >= 0.0d);
|
||||
double cpuUsage = OSUtils.cpuUsage();
|
||||
Assert.assertTrue(cpuUsage > 0.0f);
|
||||
Assert.assertTrue(cpuUsage >= 0.0d || cpuUsage == -1.0d);
|
||||
} else {
|
||||
// TODO window ut
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.apache.dolphinscheduler.common.enums.CommandType;
|
||||
import org.apache.dolphinscheduler.common.enums.DataType;
|
||||
|
|
@ -27,7 +26,9 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_TIME;
|
||||
import static org.apache.dolphinscheduler.common.utils.placeholder.TimePlaceholderUtils.replacePlaceholders;
|
||||
|
||||
|
|
@ -91,13 +92,13 @@ public class ParameterUtilsTest {
|
|||
globalParamList.add(property);
|
||||
|
||||
String result2 = ParameterUtils.curingGlobalParams(null,globalParamList,CommandType.START_CURRENT_TASK_PROCESS,scheduleTime);
|
||||
Assert.assertEquals(result2, JSONUtils.toJson(globalParamList));
|
||||
Assert.assertEquals(result2, JSONUtils.toJsonString(globalParamList));
|
||||
|
||||
String result3 = ParameterUtils.curingGlobalParams(globalParamMap,globalParamList,CommandType.START_CURRENT_TASK_PROCESS,null);
|
||||
Assert.assertEquals(result3, JSONUtils.toJson(globalParamList));
|
||||
Assert.assertEquals(result3, JSONUtils.toJsonString(globalParamList));
|
||||
|
||||
String result4 = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, CommandType.START_CURRENT_TASK_PROCESS, scheduleTime);
|
||||
Assert.assertEquals(result4, JSONUtils.toJson(globalParamList));
|
||||
Assert.assertEquals(result4, JSONUtils.toJsonString(globalParamList));
|
||||
|
||||
//test var $ startsWith
|
||||
globalParamMap.put("bizDate","${system.biz.date}");
|
||||
|
|
@ -113,7 +114,7 @@ public class ParameterUtilsTest {
|
|||
globalParamList.add(property4);
|
||||
|
||||
String result5 = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, CommandType.START_CURRENT_TASK_PROCESS, scheduleTime);
|
||||
Assert.assertEquals(result5, JSONUtils.toJson(globalParamList));
|
||||
Assert.assertEquals(result5, JSONUtils.toJsonString(globalParamList));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -122,12 +122,6 @@
|
|||
<artifactId>commons-httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.cronutils</groupId>
|
||||
<artifactId>cron-utils</artifactId>
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public abstract class BaseDataSource {
|
|||
* append database
|
||||
* @param jdbcUrl jdbc url
|
||||
*/
|
||||
private void appendDatabase(StringBuilder jdbcUrl) {
|
||||
protected void appendDatabase(StringBuilder jdbcUrl) {
|
||||
if (dbTypeSelector() == DbType.SQLSERVER) {
|
||||
jdbcUrl.append(";databaseName=").append(getDatabase());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.dao.datasource;
|
|||
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.enums.DbType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,19 @@ public class OracleDataSource extends BaseDataSource {
|
|||
return Constants.COM_ORACLE_JDBC_DRIVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* append service name or SID
|
||||
*/
|
||||
@Override
|
||||
protected void appendDatabase(StringBuilder jdbcUrl) {
|
||||
if (getConnectType() == DbConnectType.ORACLE_SID) {
|
||||
jdbcUrl.append(":");
|
||||
} else {
|
||||
jdbcUrl.append("/");
|
||||
}
|
||||
jdbcUrl.append(getDatabase());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db type
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.CycleEnum;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -31,10 +32,12 @@ public class CycleDependency {
|
|||
/**
|
||||
* last schedule time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastScheduleTime;
|
||||
/**
|
||||
* expiration time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date expirationTime;
|
||||
/**
|
||||
* cycle enum
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
|
@ -66,11 +67,13 @@ public class DataSource {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public DataSource() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -78,11 +79,13 @@ public class ErrorCommand {
|
|||
/**
|
||||
* schedule time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date scheduleTime;
|
||||
|
||||
/**
|
||||
* start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
|
|
@ -93,6 +96,7 @@ public class ErrorCommand {
|
|||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.DbType;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ public class MonitorRecord {
|
|||
/**
|
||||
* start date
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date date;
|
||||
|
||||
public Flag getState() {
|
||||
|
|
|
|||
|
|
@ -16,16 +16,18 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
import org.apache.dolphinscheduler.common.process.Property;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
import org.apache.dolphinscheduler.common.process.Property;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -37,10 +39,11 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@TableName("t_ds_process_definition")
|
||||
public class ProcessDefinition {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value="id", type=IdType.AUTO)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private int id;
|
||||
|
||||
/**
|
||||
|
|
@ -81,23 +84,25 @@ public class ProcessDefinition {
|
|||
/**
|
||||
* user defined parameter list
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
@TableField(exist = false)
|
||||
private List<Property> globalParamList;
|
||||
|
||||
/**
|
||||
* user define parameter map
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
private Map<String,String> globalParamMap;
|
||||
@TableField(exist = false)
|
||||
private Map<String, String> globalParamMap;
|
||||
|
||||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
|
@ -145,7 +150,7 @@ public class ProcessDefinition {
|
|||
/**
|
||||
* schedule release state : online/offline
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
@TableField(exist = false)
|
||||
private ReleaseState scheduleReleaseState;
|
||||
|
||||
/**
|
||||
|
|
@ -271,7 +276,11 @@ public class ProcessDefinition {
|
|||
}
|
||||
|
||||
public void setGlobalParams(String globalParams) {
|
||||
this.globalParamList = JSON.parseArray(globalParams, Property.class);
|
||||
if (globalParams == null){
|
||||
this.globalParamList = new ArrayList<>();
|
||||
}else {
|
||||
this.globalParamList = JSONUtils.toList(globalParams, Property.class);
|
||||
}
|
||||
this.globalParams = globalParams;
|
||||
}
|
||||
|
||||
|
|
@ -280,15 +289,13 @@ public class ProcessDefinition {
|
|||
}
|
||||
|
||||
public void setGlobalParamList(List<Property> globalParamList) {
|
||||
this.globalParams = JSON.toJSONString(globalParamList);
|
||||
this.globalParams = JSONUtils.toJsonString(globalParamList);
|
||||
this.globalParamList = globalParamList;
|
||||
}
|
||||
|
||||
public Map<String, String> getGlobalParamMap() {
|
||||
List<Property> propList;
|
||||
|
||||
if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) {
|
||||
propList = JSON.parseArray(globalParams, Property.class);
|
||||
List<Property> propList = JSONUtils.toList(globalParams,Property.class);
|
||||
globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -52,11 +53,13 @@ public class ProcessInstance {
|
|||
/**
|
||||
* start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* end time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
|
|
@ -117,11 +120,13 @@ public class ProcessInstance {
|
|||
/**
|
||||
* schedule time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date scheduleTime;
|
||||
|
||||
/**
|
||||
* command start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date commandStartTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -45,10 +46,12 @@ public class Queue {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.ResourceType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
|
@ -80,11 +81,13 @@ public class Resource {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public Resource() {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -52,11 +53,13 @@ public class ResourcesUser {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
|
|
@ -62,11 +63,13 @@ public class Schedule {
|
|||
/**
|
||||
* schedule start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* schedule end time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
|
|
@ -87,11 +90,13 @@ public class Schedule {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ public class Session {
|
|||
/**
|
||||
* last login time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastLoginTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@
|
|||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.TaskType;
|
||||
import org.apache.dolphinscheduler.common.model.TaskNode;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
|
@ -84,16 +85,19 @@ public class TaskInstance implements Serializable {
|
|||
/**
|
||||
* task submit time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date submitTime;
|
||||
|
||||
/**
|
||||
* task start time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* task end time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -46,11 +48,13 @@ public class TaskRecord {
|
|||
/**
|
||||
* start date
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* end date
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
|
@ -71,10 +72,12 @@ public class Tenant {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -52,11 +53,13 @@ public class UDFUser {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.UdfType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
|
@ -81,11 +82,13 @@ public class UdfFunc {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
|
@ -104,11 +105,13 @@ public class User {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
|
@ -61,11 +62,13 @@ public class UserAlertGroup {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* update time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -29,8 +33,9 @@ public class WorkerGroup {
|
|||
|
||||
private List<String> ipList;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.dolphinscheduler.dao.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class WorkerServer {
|
||||
|
|
@ -49,11 +51,13 @@ public class WorkerServer {
|
|||
/**
|
||||
* create time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* last heart beat time
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date lastHeartbeatTime;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ 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.CollectionUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.*;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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.dao.datasource;
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.DbConnectType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OracleDataSourceTest {
|
||||
|
||||
@Test
|
||||
public void testGetOracleJdbcUrl() {
|
||||
OracleDataSource oracleDataSource = new OracleDataSource();
|
||||
oracleDataSource.setType(DbConnectType.ORACLE_SERVICE_NAME);
|
||||
oracleDataSource.setAddress("jdbc:oracle:thin:@//127.0.0.1:1521");
|
||||
oracleDataSource.setDatabase("test");
|
||||
oracleDataSource.setPassword("123456");
|
||||
oracleDataSource.setUser("test");
|
||||
Assert.assertEquals("jdbc:oracle:thin:@//127.0.0.1:1521/test", oracleDataSource.getJdbcUrl());
|
||||
//set fake principal
|
||||
oracleDataSource.setPrincipal("fake principal");
|
||||
Assert.assertEquals("jdbc:oracle:thin:@//127.0.0.1:1521/test", oracleDataSource.getJdbcUrl());
|
||||
//set fake other
|
||||
oracleDataSource.setOther("charset=UTF-8");
|
||||
Assert.assertEquals("jdbc:oracle:thin:@//127.0.0.1:1521/test?charset=UTF-8", oracleDataSource.getJdbcUrl());
|
||||
|
||||
OracleDataSource oracleDataSource2 = new OracleDataSource();
|
||||
oracleDataSource2.setAddress("jdbc:oracle:thin:@127.0.0.1:1521");
|
||||
oracleDataSource2.setDatabase("orcl");
|
||||
oracleDataSource2.setPassword("123456");
|
||||
oracleDataSource2.setUser("test");
|
||||
oracleDataSource2.setType(DbConnectType.ORACLE_SID);
|
||||
Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl", oracleDataSource2.getJdbcUrl());
|
||||
//set fake principal
|
||||
oracleDataSource2.setPrincipal("fake principal");
|
||||
Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl", oracleDataSource2.getJdbcUrl());
|
||||
//set fake other
|
||||
oracleDataSource2.setOther("charset=UTF-8");
|
||||
Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl?charset=UTF-8", oracleDataSource2.getJdbcUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppendDatabase() {
|
||||
OracleDataSource oracleDataSource = new OracleDataSource();
|
||||
oracleDataSource.setAddress("jdbc:oracle:thin:@//127.0.0.1:1521");
|
||||
oracleDataSource.setDatabase("test");
|
||||
oracleDataSource.setType(DbConnectType.ORACLE_SERVICE_NAME);
|
||||
StringBuilder jdbcUrl = new StringBuilder(oracleDataSource.getAddress());
|
||||
oracleDataSource.appendDatabase(jdbcUrl);
|
||||
Assert.assertEquals("jdbc:oracle:thin:@//127.0.0.1:1521/test", jdbcUrl.toString());
|
||||
|
||||
OracleDataSource oracleDataSource2 = new OracleDataSource();
|
||||
oracleDataSource2.setAddress("jdbc:oracle:thin:@127.0.0.1:1521");
|
||||
oracleDataSource2.setDatabase("orcl");
|
||||
oracleDataSource2.setType(DbConnectType.ORACLE_SID);
|
||||
StringBuilder jdbcUrl2 = new StringBuilder(oracleDataSource2.getAddress());
|
||||
oracleDataSource2.appendDatabase(jdbcUrl2);
|
||||
Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl", jdbcUrl2.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.dao.entity;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ProcessDefinitionTest {
|
||||
|
||||
/**
|
||||
* task instance sub process
|
||||
*/
|
||||
@Test
|
||||
public void getGlobalParamMapTest() {
|
||||
ProcessDefinition taskInstance = new ProcessDefinition();
|
||||
|
||||
//sub process
|
||||
taskInstance.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
|
||||
|
||||
taskInstance.getGlobalParamMap();
|
||||
Assert.assertEquals("{selenium_global_parameters_1=selenium_global_parameters_value_1}",taskInstance.getGlobalParamMap().toString());
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +69,8 @@ public class ProcessDefinitionMapperTest {
|
|||
processDefinition.setUserId(101);
|
||||
processDefinition.setUpdateTime(new Date());
|
||||
processDefinition.setCreateTime(new Date());
|
||||
// processDefinition.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
|
||||
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
return processDefinition;
|
||||
}
|
||||
|
|
@ -159,6 +161,8 @@ public class ProcessDefinitionMapperTest {
|
|||
processDefinition.setCreateTime(new Date());
|
||||
processDefinition.setTenantId(tenant.getId());
|
||||
processDefinition.setUserId(user.getId());
|
||||
// processDefinition.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
|
||||
//
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
|
||||
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getId(), "def 1");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ 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.common.utils.*;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||
import org.junit.Assert;
|
||||
|
|
|
|||
|
|
@ -253,7 +253,6 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
|
|||
datanucleus-rdbms 4.1.7: https://mvnrepository.com/artifact/org.datanucleus/datanucleus-rdbms/4.1.7, Apache 2.0
|
||||
derby 10.14.2.0: https://github.com/apache/derby, Apache 2.0
|
||||
druid 1.1.14: https://mvnrepository.com/artifact/com.alibaba/druid/1.1.14, Apache 2.0
|
||||
fastjson 1.2.61: https://mvnrepository.com/artifact/com.alibaba/fastjson/1.2.61, Apache 2.0
|
||||
gson 2.8.5: https://github.com/google/gson, Apache 2.0
|
||||
guava 20.0: https://mvnrepository.com/artifact/com.google.guava/guava/20.0, Apache 2.0
|
||||
guice 3.0: https://mvnrepository.com/artifact/com.google.inject/guice/3.0, Apache 2.0
|
||||
|
|
@ -321,7 +320,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
|
|||
joda-time 2.10.1: https://github.com/JodaOrg/joda-time, Apache 2.0
|
||||
jpam 1.1: https://mvnrepository.com/artifact/net.sf.jpam/jpam/1.1, Apache 2.0
|
||||
jsqlparser 2.1: https://github.com/JSQLParser/JSqlParser, Apache 2.0 or LGPL 2.1
|
||||
jsp-api-2.1 6.1.14: https://mvnrepository.com/artifact/org.mortbay.jetty/jsp-api-2.1/6.1.14, Apache 2.0
|
||||
jsp-api-2.1 6.1.14: https://mvnrepository.com/artifact/org.mortbay.jetty/jsp-api-2.1/6.1.14, Apache 2.0
|
||||
jsr305 3.0.0: https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305, Apache 2.0
|
||||
libfb303 0.9.3: https://mvnrepository.com/artifact/org.apache.thrift/libfb303/0.9.3, Apache 2.0
|
||||
libthrift 0.9.3: https://mvnrepository.com/artifact/org.apache.thrift/libthrift/0.9.3, Apache 2.0
|
||||
|
|
@ -426,7 +425,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
|
|||
jersey-json 1.9: https://mvnrepository.com/artifact/com.sun.jersey/jersey-json/1.9, CDDL 1.1 and GPL 1.1
|
||||
jersey-server 1.9: https://mvnrepository.com/artifact/com.sun.jersey/jersey-server/1.9, CDDL 1.1 and GPL 1.1
|
||||
jsp-2.1 6.1.14 https://mvnrepository.com/artifact/org.mortbay.jetty/jsp-2.1/6.1.14, CDDL 1.0
|
||||
|
||||
|
||||
jta 1.1: https://mvnrepository.com/artifact/javax.transaction/jta/1.1, CDDL 1.0
|
||||
transaction-api 1.1: https://mvnrepository.com/artifact/javax.transaction/transaction-api/1.1, CDDL 1.0
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue