提交 24120a46 编写于 作者: S simon824

fix the bad code smell

上级 cfecfb79
...@@ -20,7 +20,6 @@ import org.apache.dolphinscheduler.common.enums.ShowType; ...@@ -20,7 +20,6 @@ import org.apache.dolphinscheduler.common.enums.ShowType;
import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.common.utils.*; import org.apache.dolphinscheduler.common.utils.*;
import com.google.common.reflect.TypeToken;
import org.apache.dolphinscheduler.plugin.model.AlertData; import org.apache.dolphinscheduler.plugin.model.AlertData;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
......
...@@ -539,7 +539,7 @@ public class DataSourceService extends BaseService{ ...@@ -539,7 +539,7 @@ public class DataSourceService extends BaseService{
} }
if(logger.isDebugEnabled()){ if(logger.isDebugEnabled()){
logger.info("parameters map-----" + JSONUtils.toJsonString(parameterMap)); logger.info("parameters map:{}", JSONUtils.toJsonString(parameterMap));
} }
return JSONUtils.toJsonString(parameterMap); return JSONUtils.toJsonString(parameterMap);
......
...@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service; ...@@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
......
...@@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.api.service; ...@@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto;
import org.apache.dolphinscheduler.api.dto.gantt.Task; import org.apache.dolphinscheduler.api.dto.gantt.Task;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
...@@ -554,8 +553,7 @@ public class ProcessInstanceService extends BaseDAGService { ...@@ -554,8 +553,7 @@ public class ProcessInstanceService extends BaseDAGService {
String localParams = map.get(LOCAL_PARAMS); String localParams = map.get(LOCAL_PARAMS);
if (localParams != null && !localParams.isEmpty()) { if (localParams != null && !localParams.isEmpty()) {
localParams = ParameterUtils.convertParameterPlaceholders(localParams, timeParams); localParams = ParameterUtils.convertParameterPlaceholders(localParams, timeParams);
List<Property> localParamsList = new ArrayList<>(); List<Property> localParamsList = JSONUtils.toList(localParams, Property.class);
localParamsList = JSONUtils.toList(localParams, Property.class);
Map<String,Object> localParamsMap = new HashMap<>(); Map<String,Object> localParamsMap = new HashMap<>();
localParamsMap.put("taskType",taskNode.getType()); localParamsMap.put("taskType",taskNode.getType());
......
...@@ -543,7 +543,6 @@ public class ResourcesService extends BaseService { ...@@ -543,7 +543,6 @@ public class ResourcesService extends BaseService {
} }
List<Resource> allResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal(),0); List<Resource> allResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal(),0);
Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList);
//JSONArray jsonArray = JSONUtils.toList(JSONUtils.toJsonString(resourceTreeVisitor.visit().getChildren(), SerializerFeature.SortField));
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
putMsg(result,Status.SUCCESS); putMsg(result,Status.SUCCESS);
...@@ -1127,7 +1126,8 @@ public class ResourcesService extends BaseService { ...@@ -1127,7 +1126,8 @@ public class ResourcesService extends BaseService {
} }
List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId); List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId);
Visitor visitor = new ResourceTreeVisitor(authedResources); Visitor visitor = new ResourceTreeVisitor(authedResources);
logger.info(JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)); 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); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
logger.info(jsonTreeStr); logger.info(jsonTreeStr);
result.put(Constants.DATA_LIST, visitor.visit().getChildren()); result.put(Constants.DATA_LIST, visitor.visit().getChildren());
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
*/ */
package org.apache.dolphinscheduler.common.utils; package org.apache.dolphinscheduler.common.utils;
import com.fasterxml.jackson.core.io.JsonEOFException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
...@@ -408,7 +409,7 @@ public class HadoopUtils implements Closeable { ...@@ -408,7 +409,7 @@ public class HadoopUtils implements Closeable {
* @param applicationId application id * @param applicationId application id
* @return the return may be null or there may be other parse exceptions * @return the return may be null or there may be other parse exceptions
*/ */
public ExecutionStatus getApplicationStatus(String applicationId) throws NullPointerException { public ExecutionStatus getApplicationStatus(String applicationId) {
if (StringUtils.isEmpty(applicationId)) { if (StringUtils.isEmpty(applicationId)) {
return null; return null;
} }
...@@ -428,7 +429,7 @@ public class HadoopUtils implements Closeable { ...@@ -428,7 +429,7 @@ public class HadoopUtils implements Closeable {
responseContent = HttpUtils.get(jobHistoryUrl); responseContent = HttpUtils.get(jobHistoryUrl);
ObjectNode jsonObject = JSONUtils.parseObject(responseContent); ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
if (!jsonObject.has("job")){ if (!jsonObject.has("job")){
throw new NullPointerException(); return ExecutionStatus.FAILURE;
} }
result = jsonObject.path("job").path("state").asText(); result = jsonObject.path("job").path("state").asText();
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.dao.entity; package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.dolphinscheduler.common.enums.AlertType; import org.apache.dolphinscheduler.common.enums.AlertType;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
......
...@@ -22,21 +22,16 @@ import com.baomidou.mybatisplus.annotation.TableId; ...@@ -22,21 +22,16 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.utils.*; import org.apache.dolphinscheduler.common.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
...@@ -44,7 +39,6 @@ import java.util.stream.Stream; ...@@ -44,7 +39,6 @@ import java.util.stream.Stream;
*/ */
@TableName("t_ds_process_definition") @TableName("t_ds_process_definition")
public class ProcessDefinition { public class ProcessDefinition {
private static final Logger logger = LoggerFactory.getLogger(ProcessDefinition.class);
/** /**
* id * id
...@@ -300,10 +294,8 @@ public class ProcessDefinition { ...@@ -300,10 +294,8 @@ public class ProcessDefinition {
} }
public Map<String, String> getGlobalParamMap() { public Map<String, String> getGlobalParamMap() {
List<Property> propList = new ArrayList<> ();
if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) { if (globalParamMap == null && StringUtils.isNotEmpty(globalParams)) {
propList = JSONUtils.toList(globalParams,Property.class); List<Property> propList = JSONUtils.toList(globalParams,Property.class);
globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); globalParamMap = propList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
} }
......
...@@ -32,7 +32,7 @@ public class ProcessDefinitionTest { ...@@ -32,7 +32,7 @@ public class ProcessDefinitionTest {
taskInstance.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]"); taskInstance.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
taskInstance.getGlobalParamMap(); taskInstance.getGlobalParamMap();
Assert.assertEquals(taskInstance.getGlobalParamMap().toString(),"{selenium_global_parameters_1=selenium_global_parameters_value_1}"); Assert.assertEquals("{selenium_global_parameters_1=selenium_global_parameters_value_1}",taskInstance.getGlobalParamMap().toString());
......
...@@ -31,6 +31,9 @@ public class JsonSerializer { ...@@ -31,6 +31,9 @@ public class JsonSerializer {
private static final ObjectMapper objectMapper = new ObjectMapper(); private static final ObjectMapper objectMapper = new ObjectMapper();
private static final Logger logger = LoggerFactory.getLogger(JsonSerializer.class); private static final Logger logger = LoggerFactory.getLogger(JsonSerializer.class);
private JsonSerializer(){
}
/** /**
* serialize to byte * serialize to byte
* *
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
*/ */
package org.apache.dolphinscheduler.server.worker.runner; package org.apache.dolphinscheduler.server.worker.runner;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.dolphinscheduler.common.utils.*; import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
...@@ -25,7 +24,6 @@ import org.apache.dolphinscheduler.common.model.TaskNode; ...@@ -25,7 +24,6 @@ import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter; import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter;
import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand; import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext; import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService;
......
...@@ -223,7 +223,7 @@ public class DataxTask extends AbstractTask { ...@@ -223,7 +223,7 @@ public class DataxTask extends AbstractTask {
* @return collection of datax job config JSONObject * @return collection of datax job config JSONObject
* @throws SQLException if error throws SQLException * @throws SQLException if error throws SQLException
*/ */
private List<ObjectNode> buildDataxJobContentJson() throws SQLException { private List<ObjectNode> buildDataxJobContentJson() {
DataxTaskExecutionContext dataxTaskExecutionContext = taskExecutionContext.getDataxTaskExecutionContext(); DataxTaskExecutionContext dataxTaskExecutionContext = taskExecutionContext.getDataxTaskExecutionContext();
...@@ -304,8 +304,8 @@ public class DataxTask extends AbstractTask { ...@@ -304,8 +304,8 @@ public class DataxTask extends AbstractTask {
List<ObjectNode> contentList = new ArrayList<>(); List<ObjectNode> contentList = new ArrayList<>();
ObjectNode content = JSONUtils.createObjectNode(); ObjectNode content = JSONUtils.createObjectNode();
content.put("reader", reader); content.put("reader", reader.toString());
content.put("writer", writer); content.put("writer", reader.toString());
contentList.add(content); contentList.add(content);
return contentList; return contentList;
...@@ -335,8 +335,8 @@ public class DataxTask extends AbstractTask { ...@@ -335,8 +335,8 @@ public class DataxTask extends AbstractTask {
errorLimit.put("percentage", 0); errorLimit.put("percentage", 0);
ObjectNode setting = JSONUtils.createObjectNode(); ObjectNode setting = JSONUtils.createObjectNode();
setting.put("speed", speed); setting.put("speed", speed.toString());
setting.put("errorLimit", errorLimit); setting.put("errorLimit", errorLimit.toString());
return setting; return setting;
} }
......
...@@ -269,16 +269,17 @@ public class SqlTask extends AbstractTask { ...@@ -269,16 +269,17 @@ public class SqlTask extends AbstractTask {
resultJSONArray.add(mapOfColValues); resultJSONArray.add(mapOfColValues);
rowCount++; rowCount++;
} }
logger.debug("execute sql : {}", JSONUtils.toJsonString(resultJSONArray, SerializationFeature.WRITE_NULL_MAP_VALUES)); String result = JSONUtils.toJsonString(resultJSONArray);
logger.debug("execute sql : {}", result);
// if there is a result set // if there is a result set
if (!resultJSONArray.isEmpty(null) ) { if (!resultJSONArray.isEmpty(null) ) {
if (StringUtils.isNotEmpty(sqlParameters.getTitle())) { if (StringUtils.isNotEmpty(sqlParameters.getTitle())) {
sendAttachment(sqlParameters.getTitle(), sendAttachment(sqlParameters.getTitle(),
JSONUtils.toJsonString(resultJSONArray, SerializationFeature.WRITE_NULL_MAP_VALUES)); JSONUtils.toJsonString(resultJSONArray));
}else{ }else{
sendAttachment(taskExecutionContext.getTaskName() + " query resultsets ", sendAttachment(taskExecutionContext.getTaskName() + " query resultsets ",
JSONUtils.toJsonString(resultJSONArray, SerializationFeature.WRITE_NULL_MAP_VALUES)); JSONUtils.toJsonString(resultJSONArray));
} }
} }
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.service.process; package org.apache.dolphinscheduler.service.process;
import com.cronutils.model.Cron; import com.cronutils.model.Cron;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
...@@ -37,7 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -37,7 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册