This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new c070752674 [Improvement-18056] Remove unused code in service module
(#18112)
c070752674 is described below
commit c070752674d6f99ce8bf36530b16b8d3fcf5fd3a
Author: xiangzihao <[email protected]>
AuthorDate: Wed Apr 1 15:32:42 2026 +0800
[Improvement-18056] Remove unused code in service module (#18112)
---
.../service/alert/WorkflowAlertManager.java | 62 ------------------
.../service/bean/SpringApplicationContext.java | 9 ---
.../service/expand/CuringParamsService.java | 12 ----
.../service/expand/CuringParamsServiceImpl.java | 28 --------
.../service/alert/WorkflowAlertManagerTest.java | 74 ----------------------
.../expand/CuringParamsServiceImplTest.java | 42 ------------
6 files changed, 227 deletions(-)
diff --git
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManager.java
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManager.java
index bbe3ec3b07..2a907c48dc 100644
---
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManager.java
+++
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManager.java
@@ -136,68 +136,6 @@ public class WorkflowAlertManager {
return res;
}
- /**
- * getting worker fault tolerant content
- *
- * @param workflowInstance workflow instance
- * @param toleranceTaskList tolerance task list
- * @return worker tolerance content
- */
- private String getWorkerToleranceContent(WorkflowInstance
workflowInstance, List<TaskInstance> toleranceTaskList) {
-
- List<WorkflowAlertContent> toleranceTaskInstanceList = new
ArrayList<>();
-
- WorkflowDefinitionLog workflowDefinitionLog = workflowDefinitionLogDao
-
.queryByDefinitionCodeAndVersion(workflowInstance.getWorkflowDefinitionCode(),
- workflowInstance.getWorkflowDefinitionVersion());
- String modifyBy = "";
- if (workflowDefinitionLog != null) {
- User operator =
userDao.queryById(workflowDefinitionLog.getOperator());
- modifyBy = operator == null ? "" : operator.getUserName();
- }
-
- for (TaskInstance taskInstance : toleranceTaskList) {
- WorkflowAlertContent workflowAlertContent =
WorkflowAlertContent.builder()
- .workflowInstanceId(workflowInstance.getId())
-
.workflowDefinitionCode(workflowInstance.getWorkflowDefinitionCode())
- .workflowInstanceName(workflowInstance.getName())
- .modifyBy(modifyBy)
- .taskCode(taskInstance.getTaskCode())
- .taskName(taskInstance.getName())
- .taskHost(taskInstance.getHost())
-
.taskPriority(taskInstance.getTaskInstancePriority().getDescp())
- .retryTimes(taskInstance.getRetryTimes())
- .build();
- toleranceTaskInstanceList.add(workflowAlertContent);
- }
- return JSONUtils.toJsonString(toleranceTaskInstanceList);
- }
-
- /**
- * send worker alert fault tolerance
- *
- * @param workflowInstance workflow instance
- * @param toleranceTaskList tolerance task list
- */
- public void sendAlertWorkerToleranceFault(WorkflowInstance
workflowInstance, List<TaskInstance> toleranceTaskList) {
- try {
- Alert alert = new Alert();
- alert.setTitle("worker fault tolerance");
- String content = getWorkerToleranceContent(workflowInstance,
toleranceTaskList);
- alert.setContent(content);
- alert.setWarningType(WarningType.FAILURE);
- alert.setCreateTime(new Date());
- alert.setAlertGroupId(
- workflowInstance.getWarningGroupId() == null ? 1 :
workflowInstance.getWarningGroupId());
- alert.setAlertType(AlertType.FAULT_TOLERANCE_WARNING);
- alertDao.addAlert(alert);
-
- } catch (Exception e) {
- log.error("send alert failed:{} ", e.getMessage());
- }
-
- }
-
/**
* send workflow instance alert
*
diff --git
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/bean/SpringApplicationContext.java
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/bean/SpringApplicationContext.java
index 14d82b416e..50d0f835f7 100644
---
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/bean/SpringApplicationContext.java
+++
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/bean/SpringApplicationContext.java
@@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.service.bean;
import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.AbstractApplicationContext;
@@ -45,12 +44,4 @@ public class SpringApplicationContext implements
ApplicationContextAware, AutoCl
public static <T> T getBean(Class<T> requiredType) {
return applicationContext.getBean(requiredType);
}
-
- public static <T> T getBean(Class<T> requiredType, T defaultValue) {
- try {
- return applicationContext.getBean(requiredType);
- } catch (NoSuchBeanDefinitionException e) {
- return defaultValue;
- }
- }
}
diff --git
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsService.java
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsService.java
index 0bdf5468b8..4b7b72f573 100644
---
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsService.java
+++
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsService.java
@@ -27,8 +27,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
-import javax.annotation.Nullable;
-
import lombok.NonNull;
public interface CuringParamsService {
@@ -70,16 +68,6 @@ public interface CuringParamsService {
String projectName,
String
workflowDefinitionName);
- /**
- * Parse workflow star parameter
- */
- Map<String, Property> parseWorkflowStartParam(@Nullable Map<String,
String> cmdParam);
-
- /**
- * Parse workflow father parameter
- */
- Map<String, Property> parseWorkflowFatherParam(@Nullable Map<String,
String> cmdParam);
-
/**
* preBuildBusinessParams
* @param workflowInstance
diff --git
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java
index 583532d558..8a68b7579f 100644
---
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java
+++
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java
@@ -28,7 +28,6 @@ import static
org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETE
import static
org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_WORKFLOW_DEFINITION_NAME;
import static
org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_WORKFLOW_INSTANCE_ID;
-import org.apache.dolphinscheduler.common.constants.CommandKeyConstants;
import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.constants.DateConstants;
import org.apache.dolphinscheduler.common.enums.CommandType;
@@ -47,7 +46,6 @@ import
org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters
import org.apache.dolphinscheduler.plugin.task.api.utils.GlobalParameterUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
-import org.apache.dolphinscheduler.plugin.task.api.utils.PropertyUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.VarPoolUtils;
import org.apache.dolphinscheduler.service.exceptions.ServiceException;
@@ -64,8 +62,6 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
-import javax.annotation.Nullable;
-
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
@@ -138,30 +134,6 @@ public class CuringParamsServiceImpl implements
CuringParamsService {
return GlobalParameterUtils.serializeGlobalParameter(globalParamList);
}
- @Override
- public Map<String, Property> parseWorkflowStartParam(@Nullable Map<String,
String> cmdParam) {
- if (cmdParam == null ||
!cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_START_PARAMS)) {
- return new HashMap<>();
- }
- String startParamJson =
cmdParam.get(CommandKeyConstants.CMD_PARAM_START_PARAMS);
- List<Property> propertyList =
PropertyUtils.startParamsTransformPropertyList(startParamJson);
- if (CollectionUtils.isEmpty(propertyList)) {
- return new HashMap<>();
- }
- return
propertyList.stream().collect(Collectors.toMap(Property::getProp,
Function.identity()));
- }
-
- @Override
- public Map<String, Property> parseWorkflowFatherParam(@Nullable
Map<String, String> cmdParam) {
- if (cmdParam == null ||
!cmdParam.containsKey(CommandKeyConstants.CMD_PARAM_FATHER_PARAMS)) {
- return new HashMap<>();
- }
- String startParamJson =
cmdParam.get(CommandKeyConstants.CMD_PARAM_FATHER_PARAMS);
- Map<String, String> startParamMap = JSONUtils.toMap(startParamJson);
- return
startParamMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
- entry -> new Property(entry.getKey(), Direct.IN,
DataType.VARCHAR, entry.getValue())));
- }
-
/**
* Prepares the final map of task execution parameters by merging
parameters from multiple sources
* in a well-defined priority order. The resulting map is guaranteed to
contain only valid entries:
diff --git
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManagerTest.java
b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManagerTest.java
deleted file mode 100644
index 5d5449fb3e..0000000000
---
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/WorkflowAlertManagerTest.java
+++ /dev/null
@@ -1,74 +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.service.alert;
-
-import org.apache.dolphinscheduler.dao.AlertDao;
-import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
-import org.apache.dolphinscheduler.dao.mapper.UserMapper;
-import org.apache.dolphinscheduler.dao.mapper.WorkflowDefinitionLogMapper;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ProcessAlertManager Test
- */
-@ExtendWith(MockitoExtension.class)
-public class WorkflowAlertManagerTest {
-
- private static final Logger logger =
LoggerFactory.getLogger(WorkflowAlertManagerTest.class);
-
- @InjectMocks
- WorkflowAlertManager workflowAlertManager = new WorkflowAlertManager();
-
- @Mock
- private AlertDao alertDao;
-
- @Mock
- private WorkflowDefinitionLogMapper workflowDefinitionLogMapper;
-
- @Mock
- private UserMapper userMapper;
-
- /**
- * send worker alert fault tolerance
- */
- @Test
- public void sendWarningWorkerToleranceFaultTest() {
- WorkflowInstance workflowInstance = new WorkflowInstance();
- workflowInstance.setName("test");
-
- TaskInstance taskInstance = new TaskInstance();
- taskInstance.setName("test-task-1");
- taskInstance.setHost("127.0.0.1");
- taskInstance.setRetryTimes(3);
- List<TaskInstance> taskInstanceList = new ArrayList<>();
- taskInstanceList.add(taskInstance);
-
- workflowAlertManager.sendAlertWorkerToleranceFault(workflowInstance,
taskInstanceList);
- }
-}
diff --git
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImplTest.java
b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImplTest.java
index bdd2008d89..1f0beb349e 100644
---
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImplTest.java
+++
b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImplTest.java
@@ -232,48 +232,6 @@ public class CuringParamsServiceImplTest {
String.valueOf(workflowDefinition.getCode()));
}
- @Test
- public void testParseWorkflowStartParam() {
- Map<String, Property> result;
- // empty cmd param
- Map<String, String> startParamMap = new HashMap<>();
- result =
curingParamsServiceImpl.parseWorkflowStartParam(startParamMap);
- Assertions.assertTrue(MapUtils.isEmpty(result));
-
- // without key
- startParamMap.put("testStartParam", "$[yyyyMMdd]");
- result =
curingParamsServiceImpl.parseWorkflowStartParam(startParamMap);
- Assertions.assertTrue(MapUtils.isEmpty(result));
-
- startParamMap.put("StartParams", "{\"param1\":\"11111\",
\"param2\":\"22222\"}");
- result =
curingParamsServiceImpl.parseWorkflowStartParam(startParamMap);
- Assertions.assertTrue(MapUtils.isNotEmpty(result));
- Assertions.assertEquals(2, result.keySet().size());
- Assertions.assertEquals("11111", result.get("param1").getValue());
- Assertions.assertEquals("22222", result.get("param2").getValue());
- }
-
- @Test
- public void testParseWorkflowFatherParam() {
- Map<String, Property> result;
- // empty cmd param
- Map<String, String> startParamMap = new HashMap<>();
- result =
curingParamsServiceImpl.parseWorkflowFatherParam(startParamMap);
- Assertions.assertTrue(MapUtils.isEmpty(result));
-
- // without key
- startParamMap.put("testfatherParams", "$[yyyyMMdd]");
- result =
curingParamsServiceImpl.parseWorkflowFatherParam(startParamMap);
- Assertions.assertTrue(MapUtils.isEmpty(result));
-
- startParamMap.put("fatherParams", "{\"param1\":\"11111\",
\"param2\":\"22222\"}");
- result =
curingParamsServiceImpl.parseWorkflowFatherParam(startParamMap);
- Assertions.assertTrue(MapUtils.isNotEmpty(result));
- Assertions.assertEquals(2, result.keySet().size());
- Assertions.assertEquals("11111", result.get("param1").getValue());
- Assertions.assertEquals("22222", result.get("param2").getValue());
- }
-
@Test
public void testParseGlobalParamsMap() throws Exception {
WorkflowInstance workflowInstance = new WorkflowInstance();