Skip to content

Commit cd5a3a9

Browse files
committed
[DSIP-87] Remove cache configuration of task
1 parent f57acab commit cd5a3a9

File tree

74 files changed

+242
-784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+242
-784
lines changed

docs/docs/en/faq.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -752,20 +752,4 @@ start API server. If you want disabled when Python gateway service you could cha
752752

753753
---
754754

755-
## Q:How to determine whether a task has been cached when the cache is executed, that is, how to determine whether a task can use the running result of another task?
756-
757-
A: For the task identified as `Cache Execution`, when the task starts, a cache key will be generated, and the key is composed of the following fields and hashed:
758-
759-
- task definition: the id of the task definition corresponding to the task instance
760-
- task version: the version of the task definition corresponding to the task instance
761-
- task input parameters: including the parameters passed in by the upstream node and the global parameter, the parameters referenced by the parameter list of the task definition and the parameters used by the task definition using `${}`
762-
- environment configuration: the actual configuration content of the environment configuration under the environment name, that is, the actual configuration content in the `security` - `environment management`
763-
764-
If the task with cache identification runs, it will find whether there is data with the same cache key in the database,
765-
766-
- If there is, copy the task instance and update the corresponding data
767-
- If not, the task runs as usual, and the task instance data is stored in the cache when the task is completed
768-
769-
If you do not need to cache, you can right-click the node to run `Clear cache` in the workflow instance to clear the cache, which will clear the cache data of the current input parameters under this version.
770-
771755
We will collect more FAQ later

docs/docs/en/guide/task/appendix.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ DolphinScheduler task plugins share some common default parameters. Each type of
88
|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
99
| Node Name | The name of the task. Node names within the same workflow must be unique. |
1010
| Run Flag | Indicating whether to schedule the task. If you do not need to execute the task, you can turn on the `Prohibition execution` switch. |
11-
| Cache Execution | Indicating whether this node needs to be cached. If it is cached, the same identifier (same task version, same task definition, same parameter input) task is cached. When the task has been cached, it will not be executed again, and the result will be reused directly. |
1211
| Description | Describing the function of this node. |
1312
| Task Priority | When the number of the worker threads is insufficient, the worker executes task according to the priority. When two tasks have the same priority, the worker will execute them in `first come first served` fashion. |
1413
| Worker Group | Machines which execute the tasks. If you choose `default`, scheduler will send the task to a random worker. |

dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/resources/workflow-json/test.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"taskParamList" : [ ],
5454
"taskParamMap" : null,
5555
"flag" : "YES",
56-
"isCache" : "NO",
5756
"taskPriority" : "MEDIUM",
5857
"userName" : null,
5958
"projectName" : null,

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919

2020
import static org.apache.dolphinscheduler.api.enums.Status.FORCE_TASK_SUCCESS_ERROR;
2121
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR;
22-
import static org.apache.dolphinscheduler.api.enums.Status.REMOVE_TASK_INSTANCE_CACHE_ERROR;
2322
import static org.apache.dolphinscheduler.api.enums.Status.TASK_SAVEPOINT_ERROR;
2423
import static org.apache.dolphinscheduler.api.enums.Status.TASK_STOP_ERROR;
2524

2625
import org.apache.dolphinscheduler.api.audit.OperatorLog;
2726
import org.apache.dolphinscheduler.api.audit.enums.AuditType;
28-
import org.apache.dolphinscheduler.api.dto.taskInstance.TaskInstanceRemoveCacheResponse;
2927
import org.apache.dolphinscheduler.api.exceptions.ApiException;
3028
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
3129
import org.apache.dolphinscheduler.api.utils.Result;
@@ -37,7 +35,6 @@
3735

3836
import org.springframework.beans.factory.annotation.Autowired;
3937
import org.springframework.http.HttpStatus;
40-
import org.springframework.web.bind.annotation.DeleteMapping;
4138
import org.springframework.web.bind.annotation.GetMapping;
4239
import org.springframework.web.bind.annotation.PathVariable;
4340
import org.springframework.web.bind.annotation.PostMapping;
@@ -202,24 +199,4 @@ public Result<Object> stopTask(@Parameter(hidden = true) @RequestAttribute(value
202199
return taskInstanceService.stopTask(loginUser, projectCode, id);
203200
}
204201

205-
/**
206-
* remove task instance cache
207-
*
208-
* @param loginUser login user
209-
* @param projectCode project code
210-
* @param id task instance id
211-
* @return the result code and msg
212-
*/
213-
@Operation(summary = "remove-task-instance-cache", description = "REMOVE_TASK_INSTANCE_CACHE")
214-
@Parameters({
215-
@Parameter(name = "id", description = "TASK_INSTANCE_ID", required = true, schema = @Schema(implementation = int.class, example = "12"))
216-
})
217-
@DeleteMapping(value = "/{id}/remove-cache")
218-
@ResponseStatus(HttpStatus.OK)
219-
@ApiException(REMOVE_TASK_INSTANCE_CACHE_ERROR)
220-
public TaskInstanceRemoveCacheResponse removeTaskInstanceCache(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
221-
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
222-
@PathVariable(value = "id") Integer id) {
223-
return taskInstanceService.removeTaskInstanceCache(loginUser, projectCode, id);
224-
}
225202
}

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/taskInstance/TaskInstanceRemoveCacheResponse.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ public enum Status {
314314
"资源文件已授权其他用户[{0}],后缀不允许修改"),
315315
RESOURCE_HAS_FOLDER(20018, "There are files or folders in the current directory:{0}", "当前目录下有文件或文件夹[{0}]"),
316316

317-
REMOVE_TASK_INSTANCE_CACHE_ERROR(20019, "remove task instance cache error", "删除任务实例缓存错误"),
318-
319317
ILLEGAL_RESOURCE_PATH(20020, "Resource file [{0}] is illegal", "非法的资源路径[{0}]"),
320318

321319
USER_NO_OPERATION_PERM(30001, "user has no operation privilege", "当前用户没有操作权限"),
@@ -520,7 +518,6 @@ public enum Status {
520518
CLOSE_TASK_GROUP_ERROR(130011, "close task group error", "关闭任务组错误"),
521519
START_TASK_GROUP_ERROR(130012, "start task group error", "启动任务组错误"),
522520
QUERY_TASK_GROUP_QUEUE_LIST_ERROR(130013, "query task group queue list error", "查询任务组队列列表错误"),
523-
TASK_GROUP_CACHE_START_FAILED(130014, "cache start failed", "任务组相关的缓存启动失败"),
524521
ENVIRONMENT_WORKER_GROUPS_IS_INVALID(130015, "environment worker groups is invalid format", "环境关联的工作组参数解析错误"),
525522
UPDATE_ENVIRONMENT_WORKER_GROUP_RELATION_ERROR(130016,
526523
"You can't modify the worker group, because the worker group [{0}] and this environment [{1}] already be used in the task [{2}]",

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.dolphinscheduler.api.service;
1919

20-
import org.apache.dolphinscheduler.api.dto.taskInstance.TaskInstanceRemoveCacheResponse;
2120
import org.apache.dolphinscheduler.api.utils.Result;
2221
import org.apache.dolphinscheduler.common.enums.TaskExecuteType;
2322
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
@@ -101,14 +100,5 @@ void forceTaskSuccess(User loginUser,
101100
*/
102101
TaskInstance queryTaskInstanceById(User loginUser, long projectCode, Long taskInstanceId);
103102

104-
/**
105-
* remove task instance cache
106-
* @param loginUser
107-
* @param projectCode
108-
* @param taskInstanceId
109-
* @return
110-
*/
111-
TaskInstanceRemoveCacheResponse removeTaskInstanceCache(User loginUser, long projectCode, Integer taskInstanceId);
112-
113103
void deleteByWorkflowInstanceId(Integer workflowInstanceId);
114104
}

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
package org.apache.dolphinscheduler.api.service.impl;
1919

2020
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.FORCED_SUCCESS;
21-
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.INSTANCE_UPDATE;
2221
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_INSTANCE;
2322

24-
import org.apache.dolphinscheduler.api.dto.taskInstance.TaskInstanceRemoveCacheResponse;
2523
import org.apache.dolphinscheduler.api.enums.Status;
2624
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
2725
import org.apache.dolphinscheduler.api.service.ProjectService;
@@ -43,7 +41,6 @@
4341
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
4442
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
4543
import org.apache.dolphinscheduler.dao.repository.WorkflowInstanceDao;
46-
import org.apache.dolphinscheduler.dao.utils.TaskCacheUtils;
4744
import org.apache.dolphinscheduler.extract.base.client.Clients;
4845
import org.apache.dolphinscheduler.extract.common.ILogService;
4946
import org.apache.dolphinscheduler.extract.worker.IPhysicalTaskExecutorOperator;
@@ -56,7 +53,6 @@
5653
import org.apache.dolphinscheduler.task.executor.operations.TaskExecutorKillResponse;
5754

5855
import org.apache.commons.lang3.StringUtils;
59-
import org.apache.commons.lang3.tuple.Pair;
6056

6157
import java.util.Date;
6258
import java.util.HashSet;
@@ -325,31 +321,6 @@ public TaskInstance queryTaskInstanceById(User loginUser, long projectCode, Long
325321
return taskInstance;
326322
}
327323

328-
@Override
329-
public TaskInstanceRemoveCacheResponse removeTaskInstanceCache(User loginUser, long projectCode,
330-
Integer taskInstanceId) {
331-
Result result = new Result();
332-
333-
Project project = projectMapper.queryByCode(projectCode);
334-
projectService.checkProjectAndAuthThrowException(loginUser, project, INSTANCE_UPDATE);
335-
336-
TaskInstance taskInstance = taskInstanceMapper.selectById(taskInstanceId);
337-
if (taskInstance == null) {
338-
log.error("Task definition can not be found, projectCode:{}, taskInstanceId:{}.", projectCode,
339-
taskInstanceId);
340-
putMsg(result, Status.TASK_INSTANCE_NOT_FOUND);
341-
return new TaskInstanceRemoveCacheResponse(result);
342-
}
343-
String tagCacheKey = taskInstance.getCacheKey();
344-
Pair<Integer, String> taskIdAndCacheKey = TaskCacheUtils.revertCacheKey(tagCacheKey);
345-
String cacheKey = taskIdAndCacheKey.getRight();
346-
if (StringUtils.isNotEmpty(cacheKey)) {
347-
taskInstanceDao.clearCacheByCacheKey(cacheKey);
348-
}
349-
putMsg(result, Status.SUCCESS);
350-
return new TaskInstanceRemoveCacheResponse(result, cacheKey);
351-
}
352-
353324
@Override
354325
public void deleteByWorkflowInstanceId(Integer workflowInstanceId) {
355326
List<TaskInstance> needToDeleteTaskInstances =

dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static org.mockito.Mockito.doThrow;
2727
import static org.mockito.Mockito.when;
2828

29-
import org.apache.dolphinscheduler.api.dto.taskInstance.TaskInstanceRemoveCacheResponse;
3029
import org.apache.dolphinscheduler.api.enums.Status;
3130
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
3231
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
@@ -410,29 +409,4 @@ public void testForceTaskSuccess_withTaskInstanceNotFinished() {
410409
() -> taskInstanceService.forceTaskSuccess(user, task.getProjectCode(), task.getId()));
411410
}
412411

413-
@Test
414-
public void testRemoveTaskInstanceCache() {
415-
User user = getAdminUser();
416-
long projectCode = 1L;
417-
Project project = getProject(projectCode);
418-
int taskId = 1;
419-
TaskInstance task = getTaskInstance();
420-
String cacheKey = "950311f3597f9198976cd3fd69e208e5b9ba6750";
421-
task.setCacheKey(cacheKey);
422-
423-
when(projectMapper.queryByCode(projectCode)).thenReturn(project);
424-
when(taskInstanceMapper.selectById(1)).thenReturn(task);
425-
when(taskInstanceDao.queryByCacheKey(cacheKey)).thenReturn(task, null);
426-
when(taskInstanceDao.updateById(task)).thenReturn(true);
427-
428-
TaskInstanceRemoveCacheResponse response =
429-
taskInstanceService.removeTaskInstanceCache(user, projectCode, taskId);
430-
Assertions.assertEquals(Status.SUCCESS.getCode(), response.getCode());
431-
432-
when(taskInstanceMapper.selectById(1)).thenReturn(null);
433-
TaskInstanceRemoveCacheResponse responseNotFoundTask =
434-
taskInstanceService.removeTaskInstanceCache(user, projectCode, taskId);
435-
Assertions.assertEquals(Status.TASK_INSTANCE_NOT_FOUND.getCode(), responseNotFoundTask.getCode());
436-
437-
}
438412
}

dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/Flag.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
* have_arr_variables
2727
* have_map_variables
2828
* have_alert
29-
* is_cache
3029
*/
3130
public enum Flag {
3231

0 commit comments

Comments
 (0)