diff --git a/dolphinscheduler-api/pom.xml b/dolphinscheduler-api/pom.xml index b0de6fcff4..8fcb948292 100644 --- a/dolphinscheduler-api/pom.xml +++ b/dolphinscheduler-api/pom.xml @@ -45,6 +45,11 @@ ${project.version} + + org.apache.dolphinscheduler + dolphinscheduler-task-all + + org.apache.dolphinscheduler dolphinscheduler-ui-next diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java index f458da89df..971c76f35f 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java @@ -17,10 +17,10 @@ package org.apache.dolphinscheduler.api.controller; -import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_BY_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ACCESS_TOKEN_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ACCESS_TOKEN_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GENERATE_TOKEN_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_BY_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ACCESS_TOKEN_ERROR; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java index c888ff76fa..dafb21af67 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java @@ -34,11 +34,10 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.ProcessInstanceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessTaskRelationController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessTaskRelationController.java index 8c1d3d7ac5..13e68bcfdf 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessTaskRelationController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessTaskRelationController.java @@ -21,7 +21,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROCESS_TASK_R import static org.apache.dolphinscheduler.api.enums.Status.DATA_IS_NOT_VALID; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_EDGE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TASK_PROCESS_RELATION_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.MOVE_PROCESS_TASK_RELATION_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_PROCESS_RELATION_ERROR; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java index 22e582204d..0eff931c7f 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectController.java @@ -17,12 +17,12 @@ package org.apache.dolphinscheduler.api.controller; -import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_USER; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.LOGIN_USER_QUERY_PROJECT_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_AND_USER_CREATED_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_PROJECT; +import static org.apache.dolphinscheduler.api.enums.Status.QUERY_AUTHORIZED_USER; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_PROJECT_DETAILS_BY_CODE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_UNAUTHORIZED_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROJECT_ERROR; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskDefinitionController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskDefinitionController.java index 9e59c3932c..a5d1b2f762 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskDefinitionController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskDefinitionController.java @@ -34,7 +34,6 @@ import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.dao.entity.User; @@ -53,6 +52,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import org.apache.commons.lang3.StringUtils; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -60,8 +61,6 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import springfox.documentation.annotations.ApiIgnore; -import org.apache.commons.lang3.StringUtils; - /** * task definition controller */ @@ -344,7 +343,7 @@ public class TaskDefinitionController extends BaseController { @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam(value = "searchWorkflowName", required = false) String searchWorkflowName, @RequestParam(value = "searchTaskName", required = false) String searchTaskName, - @RequestParam(value = "taskType", required = false) TaskType taskType, + @RequestParam(value = "taskType", required = false) String taskType, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { Result result = checkPageParams(pageNo, pageSize); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskGroupController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskGroupController.java index 79c61b59b3..68fc4bdd06 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskGroupController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskGroupController.java @@ -17,10 +17,13 @@ package org.apache.dolphinscheduler.api.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; +import static org.apache.dolphinscheduler.api.enums.Status.CLOSE_TASK_GROUP_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.CREATE_TASK_GROUP_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_LIST_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_QUEUE_LIST_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.START_TASK_GROUP_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TASK_GROUP_ERROR; + import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.TaskGroupQueueService; @@ -29,6 +32,11 @@ import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.dao.entity.User; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; @@ -42,16 +50,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; -import java.util.Map; - -import static org.apache.dolphinscheduler.api.enums.Status.CLOSE_TASK_GROUP_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.CREATE_TASK_GROUP_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_LIST_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_GROUP_QUEUE_LIST_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.START_TASK_GROUP_ERROR; -import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TASK_GROUP_ERROR; - - /** * task group controller */ diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java index 35ad434f4e..e007c55807 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java @@ -25,9 +25,9 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Map; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java index fc1c00d2f4..949e0292e7 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UiPluginController.java @@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java index da48ca763f..313958b22b 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.api.controller; -import static org.apache.dolphinscheduler.api.enums.Status.REVOKE_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_USER_BY_ID_ERROR; @@ -27,6 +26,7 @@ import static org.apache.dolphinscheduler.api.enums.Status.GRANT_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_RESOURCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GRANT_UDF_FUNCTION_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_USER_LIST_PAGING_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.REVOKE_PROJECT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_USER_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.USER_LIST_ERROR; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/CommandStateCount.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/CommandStateCount.java index d116e46578..5e6a518173 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/CommandStateCount.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/CommandStateCount.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto; import org.apache.dolphinscheduler.common.enums.CommandType; @@ -28,6 +29,7 @@ public class CommandStateCount { private CommandType commandState; public CommandStateCount(){} + public CommandStateCount(int errorCount, int normalCount, CommandType commandState) { this.errorCount = errorCount; this.normalCount = normalCount; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/DefineUserDto.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/DefineUserDto.java index 2f0167d003..dddc0a7560 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/DefineUserDto.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/DefineUserDto.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto; import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser; @@ -31,7 +32,7 @@ public class DefineUserDto { public DefineUserDto(List defineGroupByUsers) { - for(DefinitionGroupByUser define : defineGroupByUsers){ + for (DefinitionGroupByUser define : defineGroupByUsers) { count += define.getCount(); } this.userList = defineGroupByUsers; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ScheduleParam.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ScheduleParam.java index d2f13ed052..a3c4f08d8a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ScheduleParam.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/ScheduleParam.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.dto; import java.util.Date; - /** * schedule parameters */ diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskCountDto.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskCountDto.java index 41c7abba85..96082aab45 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskCountDto.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskCountDto.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Arrays; import java.util.List; @@ -39,7 +40,6 @@ public class TaskCountDto { */ private List taskCountDtos; - public TaskCountDto(List taskInstanceStateCounts) { countTaskDtos(taskInstanceStateCounts); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskStateCount.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskStateCount.java index 460ea7da4b..2fe5e9ec23 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskStateCount.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/TaskStateCount.java @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; /** * task state count @@ -31,7 +32,6 @@ public class TaskStateCount { this.count = count; } - public int getCount() { return count; } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/gantt/Task.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/gantt/Task.java index ac27e153ba..07243db3fd 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/gantt/Task.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/gantt/Task.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.api.dto.gantt; +package org.apache.dolphinscheduler.api.dto.gantt; import java.util.Date; import java.util.LinkedList; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/Directory.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/Directory.java index 2d06e1b6ef..c6147696ec 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/Directory.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/Directory.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto.resources; /** * directory */ -public class Directory extends ResourceComponent{ +public class Directory extends ResourceComponent { @Override public boolean isDirctory() { diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/visitor/Visitor.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/visitor/Visitor.java index b2ef79c398..defbed13bb 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/visitor/Visitor.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/visitor/Visitor.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.dto.resources.visitor; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/treeview/Instance.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/treeview/Instance.java index 9f636711df..d714fd291e 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/treeview/Instance.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/treeview/Instance.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.dto.treeview; import java.util.Date; - /** * Instance */ @@ -97,7 +96,6 @@ public class Instance { this(id, name, code, type, state, startTime, endTime, host, duration, 0); } - public int getId() { return id; } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/ExecuteType.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/ExecuteType.java index f4dac5aecd..bfac404582 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/ExecuteType.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/ExecuteType.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.enums; /** @@ -21,7 +22,6 @@ package org.apache.dolphinscheduler.api.enums; */ public enum ExecuteType { - /** * operation type * 1 repeat running @@ -32,10 +32,9 @@ public enum ExecuteType { */ NONE, REPEAT_RUNNING, RECOVER_SUSPENDED_PROCESS, START_FAILURE_TASK_PROCESS, STOP, PAUSE; - - public static ExecuteType getEnum(int value){ + public static ExecuteType getEnum(int value) { for (ExecuteType e: ExecuteType.values()) { - if(e.ordinal() == value) { + if (e.ordinal() == value) { return e; } } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiException.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiException.java index 3c094f5294..8cdf2b81f8 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiException.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiException.java @@ -14,16 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.exceptions; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + import org.apache.dolphinscheduler.api.enums.Status; import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - /** * controller exception annotation */ diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandler.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandler.java index b90a4bde7e..84d1abc337 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandler.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandler.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.exceptions; import org.apache.dolphinscheduler.api.enums.Status; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java index 5e25696f00..faa93ee07a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java @@ -42,6 +42,7 @@ public interface AlertGroupService { * @return one alert group */ Map queryAlertGroupById(User loginUser, Integer id); + /** * paging query alarm group list * diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java index 073e1f3818..4b2ad72a3c 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java @@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.utils.Result; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.io.IOException; import java.util.List; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskDefinitionService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskDefinitionService.java index 962e60a15a..5d2ba85b02 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskDefinitionService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskDefinitionService.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.dao.entity.User; import java.util.Map; @@ -178,7 +177,7 @@ public interface TaskDefinitionService { long projectCode, String searchWorkflowName, String searchTaskName, - TaskType taskType, + String taskType, Integer pageNo, Integer pageSize); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java index 73e3a489a5..0d16022799 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java @@ -18,8 +18,8 @@ package org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.utils.Result; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Map; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkFlowLineageService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkFlowLineageService.java index 64ea0033aa..f4c32b68f6 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkFlowLineageService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkFlowLineageService.java @@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.api.service; import java.util.Map; -import java.util.Set; /** * work flow lineage service diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java index 9fd9bbfc3d..daa3d4a3ef 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.api.service.impl; -import org.apache.commons.lang3.StringUtils; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.AccessTokenService; import org.apache.dolphinscheduler.api.utils.PageInfo; @@ -30,6 +29,8 @@ import org.apache.dolphinscheduler.dao.entity.AccessToken; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; +import org.apache.commons.lang3.StringUtils; + import java.util.Date; import java.util.HashMap; import java.util.List; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java index c0dada657a..b4cf3f8ae6 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java @@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.api.service.DataAnalysisService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.TriFunction; @@ -40,6 +39,7 @@ 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.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DqRuleServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DqRuleServiceImpl.java index 5cc2f81c5f..8b39b2c8c5 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DqRuleServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DqRuleServiceImpl.java @@ -40,6 +40,7 @@ import org.apache.dolphinscheduler.dao.mapper.DqRuleExecuteSqlMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleInputEntryMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleMapper; import org.apache.dolphinscheduler.dao.utils.DqRuleUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.params.base.FormType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; @@ -51,7 +52,6 @@ import org.apache.dolphinscheduler.spi.params.group.GroupParamsProps; import org.apache.dolphinscheduler.spi.params.input.InputParam; import org.apache.dolphinscheduler.spi.params.input.InputParamProps; import org.apache.dolphinscheduler.spi.params.select.SelectParam; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.apache.commons.collections4.CollectionUtils; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java index 6dc8ab72f4..a14ac46124 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java @@ -24,7 +24,6 @@ import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; -import org.apache.commons.beanutils.BeanUtils; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ExecutorService; @@ -34,7 +33,6 @@ import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; import org.apache.dolphinscheduler.common.enums.CycleEnum; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; @@ -58,11 +56,13 @@ import org.apache.dolphinscheduler.dao.entity.User; 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.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index 9f1b343814..682a6f6624 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -19,6 +19,8 @@ package org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMPLEX_TASK_TYPES; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SQL; import org.apache.dolphinscheduler.api.dto.DagDataSchedule; import org.apache.dolphinscheduler.api.dto.ScheduleParam; @@ -41,16 +43,13 @@ import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; 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.task.sql.SqlParameters; -import org.apache.dolphinscheduler.common.task.sql.SqlType; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; @@ -82,11 +81,14 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.SqlType; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.hadoop.fs.Stat; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -185,6 +187,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro @Autowired private DataSourceMapper dataSourceMapper; + @Autowired + private TaskPluginManager taskPluginManager; + /** * create process definition * @@ -298,7 +303,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro return result; } for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { - if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionLog)) { + + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskDefinitionLog.getTaskType()) + .taskParams(taskDefinitionLog.getTaskParams()) + .dependence(taskDefinitionLog.getDependence()) + .build())) { logger.error("task definition {} parameter invalid", taskDefinitionLog.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); return result; @@ -1085,7 +1095,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro sqlParameters.setLocalParams(Collections.emptyList()); taskDefinition.setTaskParams(JSONUtils.toJsonString(sqlParameters)); taskDefinition.setCode(CodeGenerateUtils.getInstance().genCode()); - taskDefinition.setTaskType(TaskType.SQL.getDesc()); + taskDefinition.setTaskType(TASK_TYPE_SQL); taskDefinition.setFailRetryTimes(0); taskDefinition.setFailRetryInterval(0); taskDefinition.setTimeoutFlag(TimeoutFlag.CLOSE); @@ -1287,7 +1297,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro // check whether the process definition json is normal for (TaskNode taskNode : taskNodes) { - if (!CheckUtils.checkTaskNodeParameters(taskNode)) { + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskNode.getType()) + .taskParams(taskNode.getTaskParams()) + .dependence(taskNode.getDependence()) + .switchResult(taskNode.getSwitchResult()) + .build())) { logger.error("task node {} parameter invalid", taskNode.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskNode.getName()); return result; @@ -1650,10 +1665,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro List taskDefinitionLogs = processService.genTaskDefineList(processTaskRelations); Map taskCodeMap = new HashMap<>(); for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { - if (TaskType.CONDITIONS.getDesc().equals(taskDefinitionLog.getTaskType()) - || TaskType.SWITCH.getDesc().equals(taskDefinitionLog.getTaskType()) - || TaskType.SUB_PROCESS.getDesc().equals(taskDefinitionLog.getTaskType()) - || TaskType.DEPENDENT.getDesc().equals(taskDefinitionLog.getTaskType())) { + if (COMPLEX_TASK_TYPES.contains(taskDefinitionLog.getTaskType())) { putMsg(result, Status.NOT_SUPPORT_COPY_TASK_TYPE, taskDefinitionLog.getTaskType()); return; } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java index da10458777..902b3a495c 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java @@ -23,6 +23,7 @@ import static org.apache.dolphinscheduler.common.Constants.GLOBAL_PARAMS; import static org.apache.dolphinscheduler.common.Constants.LOCAL_PARAMS; import static org.apache.dolphinscheduler.common.Constants.PROCESS_INSTANCE_STATE; import static org.apache.dolphinscheduler.common.Constants.TASK_LIST; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; import org.apache.dolphinscheduler.api.dto.gantt.Task; @@ -34,18 +35,13 @@ import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProcessInstanceService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.UsersService; -import org.apache.dolphinscheduler.api.utils.CheckUtils; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; -import org.apache.dolphinscheduler.common.enums.TaskType; 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.Property; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils; @@ -67,7 +63,12 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; @@ -145,6 +146,9 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce @Autowired TaskDefinitionMapper taskDefinitionMapper; + @Autowired + private TaskPluginManager taskPluginManager; + /** * return top n SUCCESS process instance order by running time which started between startTime and endTime */ @@ -336,7 +340,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce */ private void addDependResultForTaskList(List taskInstanceList) throws IOException { for (TaskInstance taskInstance : taskInstanceList) { - if (TaskType.DEPENDENT.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { + if (TASK_TYPE_DEPENDENT.equalsIgnoreCase(taskInstance.getTaskType())) { Result logResult = loggerService.queryLog( taskInstance.getId(), Constants.LOG_QUERY_SKIP_LINE_NUMBER, Constants.LOG_QUERY_LIMIT); if (logResult.getCode() == Status.SUCCESS.ordinal()) { @@ -476,7 +480,11 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce return result; } for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { - if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionLog)) { + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskDefinitionLog.getTaskType()) + .taskParams(taskDefinitionLog.getTaskParams()) + .dependence(taskDefinitionLog.getDependence()) + .build())) { putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); return result; } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java index 27855edd89..3cf41f820a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java @@ -17,13 +17,16 @@ package org.apache.dolphinscheduler.api.service.impl; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; + import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ProcessTaskRelationService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ConditionType; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; @@ -228,9 +231,9 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P } updateProcessDefiniteVersion(loginUser, result, processDefinition); updateRelation(loginUser, result, processDefinition, processTaskRelationList); - if (TaskType.CONDITIONS.getDesc().equals(taskDefinition.getTaskType()) - || TaskType.DEPENDENT.getDesc().equals(taskDefinition.getTaskType()) - || TaskType.SUB_PROCESS.getDesc().equals(taskDefinition.getTaskType())) { + if (TASK_TYPE_CONDITIONS.equals(taskDefinition.getTaskType()) + || TASK_TYPE_DEPENDENT.equals(taskDefinition.getTaskType()) + || TASK_TYPE_SUB_PROCESS.equals(taskDefinition.getTaskType())) { int deleteTaskDefinition = taskDefinitionMapper.deleteByCode(taskCode); if (0 == deleteTaskDefinition) { putMsg(result, Status.DELETE_TASK_DEFINE_BY_CODE_ERROR); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java index f5ba6296ba..c7a9c887be 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService; -import org.apache.dolphinscheduler.api.utils.CheckUtils; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; @@ -29,7 +28,6 @@ import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.ConditionType; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.common.utils.JSONUtils; @@ -46,8 +44,10 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.service.permission.PermissionCheck; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -103,6 +103,9 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe @Autowired private ProcessService processService; + @Autowired + private TaskPluginManager taskPluginManager; + /** * create task definition * @@ -129,7 +132,11 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe return result; } for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { - if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionLog)) { + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskDefinitionLog.getTaskType()) + .taskParams(taskDefinitionLog.getTaskParams()) + .dependence(taskDefinitionLog.getDependence()) + .build())) { logger.error("task definition {} parameter invalid", taskDefinitionLog.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName()); return result; @@ -186,7 +193,11 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj); return result; } - if (!CheckUtils.checkTaskDefinitionParameters(taskDefinition)) { + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskDefinition.getTaskType()) + .taskParams(taskDefinition.getTaskParams()) + .dependence(taskDefinition.getDependence()) + .build())) { logger.error("task definition {} parameter invalid", taskDefinition.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinition.getName()); return result; @@ -411,7 +422,11 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj); return null; } - if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionToUpdate)) { + if (!taskPluginManager.checkTaskParameters(ParametersNode.builder() + .taskType(taskDefinitionToUpdate.getTaskType()) + .taskParams(taskDefinitionToUpdate.getTaskParams()) + .dependence(taskDefinitionToUpdate.getDependence()) + .build())) { logger.error("task definition {} parameter invalid", taskDefinitionToUpdate.getName()); putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionToUpdate.getName()); return null; @@ -643,7 +658,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe long projectCode, String searchWorkflowName, String searchTaskName, - TaskType taskType, + String taskType, Integer pageNo, Integer pageSize) { Result result = new Result(); @@ -657,7 +672,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe } Page page = new Page<>(pageNo, pageSize); IPage taskMainInfoIPage = taskDefinitionMapper.queryDefineListPaging(page, projectCode, searchWorkflowName, - searchTaskName, taskType == null ? StringUtils.EMPTY : taskType.getDesc()); + searchTaskName, taskType == null ? StringUtils.EMPTY : taskType); List records = taskMainInfoIPage.getRecords(); if (!records.isEmpty()) { Map taskMainInfoMap = new HashMap<>(); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java index b07f18a1a2..2ea46a0fc5 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskGroupQueueServiceImpl.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.api.service.impl; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.TaskGroupQueueService; @@ -29,14 +27,18 @@ import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * task group queue service diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java index e25cde6bc2..cfcd95d88c 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java @@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.Project; @@ -35,6 +34,7 @@ import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.Date; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java index eb3c5b08a5..08b3d221be 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java @@ -17,13 +17,11 @@ package org.apache.dolphinscheduler.api.service.impl; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; + import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.WorkFlowLineageService; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessLineage; @@ -35,6 +33,9 @@ import org.apache.dolphinscheduler.dao.entity.WorkFlowRelation; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.WorkFlowLineageMapper; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; @@ -201,7 +202,7 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF List taskDefinitionLogs = taskDefinitionLogMapper.queryByTaskDefinitions(taskDefinitionList); for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { if (taskDefinitionLog.getProjectCode() == projectCode) { - if (taskDefinitionLog.getTaskType().equals(TaskType.DEPENDENT.getDesc())) { + if (taskDefinitionLog.getTaskType().equals(TASK_TYPE_DEPENDENT)) { DependentParameters dependentParameters = JSONUtils.parseObject(taskDefinitionLog.getDependence(), DependentParameters.class); if (dependentParameters != null) { List dependTaskList = dependentParameters.getDependTaskList(); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java index 05adaa577e..540ec1b2ca 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java @@ -23,7 +23,6 @@ import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.NodeType; -import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.WorkerGroup; diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java index 2e84a14680..a8d225ddc0 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/CheckUtils.java @@ -14,19 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.utils; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.task.AbstractParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; -import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.commons.lang.StringUtils; -import org.hibernate.validator.internal.constraintvalidators.bv.EmailValidator; import java.text.MessageFormat; import java.time.ZoneId; @@ -34,6 +29,7 @@ import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; +import org.hibernate.validator.internal.constraintvalidators.bv.EmailValidator; /** * check utils @@ -136,49 +132,6 @@ public class CheckUtils { } } - /** - * check task node parameter - * - * @param taskNode TaskNode - * @return true if task node parameters are valid, otherwise return false - */ - public static boolean checkTaskNodeParameters(TaskNode taskNode) { - AbstractParameters abstractParameters; - String taskType = taskNode.getType(); - if (taskType == null) { - return false; - } - if (TaskType.DEPENDENT.getDesc().equalsIgnoreCase(taskType)) { - abstractParameters = TaskParametersUtils.getParameters(taskType.toUpperCase(), taskNode.getDependence()); - } else if (TaskType.SWITCH.getDesc().equalsIgnoreCase(taskType)) { - abstractParameters = TaskParametersUtils.getParameters(taskType.toUpperCase(), taskNode.getSwitchResult()); - } else { - abstractParameters = TaskParametersUtils.getParameters(taskType.toUpperCase(), taskNode.getTaskParams()); - } - - if (abstractParameters != null) { - return abstractParameters.checkParameters(); - } - - return false; - } - - public static boolean checkTaskDefinitionParameters(TaskDefinition taskDefinition) { - AbstractParameters abstractParameters; - String taskType = taskDefinition.getTaskType(); - if (TaskType.DEPENDENT.getDesc().equalsIgnoreCase(taskType)) { - abstractParameters = TaskParametersUtils.getParameters(taskType.toUpperCase(), taskDefinition.getDependence()); - } else { - abstractParameters = TaskParametersUtils.getParameters(taskType.toUpperCase(), taskDefinition.getTaskParams()); - } - - if (abstractParameters != null) { - return abstractParameters.checkParameters(); - } - - return false; - } - /** * regex check * diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java index 62e64acec5..9408ce133e 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java @@ -23,7 +23,6 @@ import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.SessionService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ProfileType; import org.apache.dolphinscheduler.dao.DaoConfiguration; import org.apache.dolphinscheduler.dao.entity.User; @@ -44,9 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java index 7eb1c847a0..11987ce606 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java @@ -35,7 +35,6 @@ import java.util.Date; import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceControllerTest.java index f34d1ee9fb..6aa8d2bc80 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceControllerTest.java @@ -17,13 +17,24 @@ package org.apache.dolphinscheduler.api.controller; -import com.google.common.collect.ImmutableMap; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.User; + import org.junit.Test; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; @@ -31,13 +42,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.google.common.collect.ImmutableMap; /** * alert plugin instance controller test diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataQualityControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataQualityControllerTest.java index 541a95c8df..3b285a6206 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataQualityControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataQualityControllerTest.java @@ -28,7 +28,7 @@ import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.DqRule; import org.apache.dolphinscheduler.dao.entity.User; -import org.apache.dolphinscheduler.spi.task.dq.enums.RuleType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.RuleType; import java.text.MessageFormat; import java.util.ArrayList; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java index 7862e0a960..b7c9c0af90 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java @@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ProcessInstanceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java index 02df499cb6..e58234f25f 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java @@ -31,10 +31,10 @@ import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/ExecuteTypeTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/ExecuteTypeTest.java index a69b51c555..70fb568b84 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/ExecuteTypeTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/ExecuteTypeTest.java @@ -14,10 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.api.enums; +import static org.junit.Assert.assertEquals; + import org.junit.Test; -import static org.junit.Assert.*; public class ExecuteTypeTest { diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java index aed7161e56..040221fb6c 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java @@ -27,7 +27,6 @@ import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.DataAnalysisServiceImpl; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.CommandCount; @@ -41,6 +40,7 @@ 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.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import java.text.MessageFormat; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java index cd3493646c..a3b07fa2d0 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.api.service; -import org.apache.commons.collections.CollectionUtils; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.DataSourceServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; @@ -41,6 +40,8 @@ import org.apache.dolphinscheduler.spi.enums.DbConnectType; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; +import org.apache.commons.collections.CollectionUtils; + import java.sql.Connection; import java.util.ArrayList; import java.util.Collections; @@ -370,7 +371,10 @@ public class DataSourceServiceTest { hiveDataSourceParamDTO.setLoginUserKeytabUsername("test2/hdfs-mycluster@ESZ.COM"); connectionParam = DataSourceUtils.buildConnectionParams(hiveDataSourceParamDTO); - expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:hive2://192.168.9.1:10000\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:hive2://192.168.9.1:10000/im\",\"driverClassName\":\"org.apache.hive.jdbc.HiveDriver\",\"validationQuery\":\"select 1\",\"principal\":\"hive/hdfs-mycluster@ESZ.COM\",\"javaSecurityKrb5Conf\":\"/opt/krb5.conf\",\"loginUserKeytabUsername\":\"test2/hdfs-mycluster@ESZ.COM\",\"loginUserKeytabPath\":\"/opt/hdfs.headless.keytab\"}"; + expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:hive2://192.168.9.1:10000\",\"database\":\"im\"," + + "\"jdbcUrl\":\"jdbc:hive2://192.168.9.1:10000/im\",\"driverClassName\":\"org.apache.hive.jdbc.HiveDriver\",\"validationQuery\":\"select 1\"," + + "\"principal\":\"hive/hdfs-mycluster@ESZ.COM\",\"javaSecurityKrb5Conf\":\"/opt/krb5.conf\",\"loginUserKeytabUsername\":\"test2/hdfs-mycluster@ESZ.COM\"," + + "\"loginUserKeytabPath\":\"/opt/hdfs.headless.keytab\"}"; Assert.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java index b300a707cd..8417ae09ce 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java @@ -30,7 +30,7 @@ import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.DqExecuteResult; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DqExecuteResultMapper; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqTaskState; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java index 069edca0c1..0162262f20 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java @@ -37,13 +37,13 @@ import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleExecuteSqlMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleInputEntryMapper; import org.apache.dolphinscheduler.dao.mapper.DqRuleMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.RuleType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ValueType; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.params.base.FormType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.dq.enums.InputType; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.RuleType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ValueType; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java index 2e4c92f14a..cc6fc86e25 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.api.service; -import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; -import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -30,13 +28,10 @@ import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode; 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.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; @@ -46,6 +41,7 @@ import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.ArrayList; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/LoggerServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/LoggerServiceTest.java index bc46d248be..840f38c141 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/LoggerServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/LoggerServiceTest.java @@ -187,7 +187,6 @@ public class LoggerServiceTest { loggerService.getLogBytes(loginUser, projectCode, 1); } - @After public void close() { this.loggerService.close(); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java index 4950c69173..53337524db 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java @@ -27,10 +27,7 @@ import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.model.TaskNode; @@ -54,7 +51,10 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import java.io.IOException; import java.text.MessageFormat; @@ -118,6 +118,9 @@ public class ProcessInstanceServiceTest { @Mock TaskDefinitionMapper taskDefinitionMapper; + @Mock + TaskPluginManager taskPluginManager; + private String shellJson = "[{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":123456789," + "\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":\"{}\"},{\"name\":\"\",\"preTaskCode\":123456789," + "\"preTaskVersion\":1,\"postTaskCode\":123451234,\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":\"{}\"}]"; @@ -130,16 +133,16 @@ public class ProcessInstanceServiceTest { + ":[\"\"],\"failedNode\":[\"\"]},\"dependence\":{}},\"flag\":\"NORMAL\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\"," + "\"failRetryTimes\":\"0\",\"failRetryInterval\":\"1\",\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":\"\",\"timeout\":null,\"delayTime\":\"0\"}]"; - private String taskRelationJson = "[{\"name\":\"\",\"preTaskCode\":4254865123776,\"preTaskVersion\":1,\"postTaskCode\":4254862762304,\"postTaskVersion\":1,\"conditionType\":0," + - "\"conditionParams\":{}},{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":4254865123776,\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":{}}]"; + private String taskRelationJson = "[{\"name\":\"\",\"preTaskCode\":4254865123776,\"preTaskVersion\":1,\"postTaskCode\":4254862762304,\"postTaskVersion\":1,\"conditionType\":0," + + "\"conditionParams\":{}},{\"name\":\"\",\"preTaskCode\":0,\"preTaskVersion\":0,\"postTaskCode\":4254865123776,\"postTaskVersion\":1,\"conditionType\":0,\"conditionParams\":{}}]"; - private String taskDefinitionJson = "[{\"code\":4254862762304,\"name\":\"test1\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\",\"taskParams\":{\"resourceList\":[]," + - "\"localParams\":[],\"rawScript\":\"echo 1\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{},\"switchResult\":{}},\"flag\":\"YES\"," + - "\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":null,\"timeout\":0," + - "\"environmentCode\":-1},{\"code\":4254865123776,\"name\":\"test2\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\",\"taskParams\":{\"resourceList\":[]," + - "\"localParams\":[],\"rawScript\":\"echo 2\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{},\"switchResult\":{}},\"flag\":\"YES\"," + - "\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":\"WARN\",\"timeout\":0," + - "\"environmentCode\":-1}]"; + private String taskDefinitionJson = "[{\"code\":4254862762304,\"name\":\"test1\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\",\"taskParams\":{\"resourceList\":[]," + + "\"localParams\":[],\"rawScript\":\"echo 1\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{},\"switchResult\":{}},\"flag\":\"YES\"," + + "\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":null,\"timeout\":0," + + "\"environmentCode\":-1},{\"code\":4254865123776,\"name\":\"test2\",\"version\":1,\"description\":\"\",\"delayTime\":0,\"taskType\":\"SHELL\",\"taskParams\":{\"resourceList\":[]," + + "\"localParams\":[],\"rawScript\":\"echo 2\",\"dependence\":{},\"conditionResult\":{\"successNode\":[],\"failedNode\":[]},\"waitStartTimeout\":{},\"switchResult\":{}},\"flag\":\"YES\"," + + "\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeoutNotifyStrategy\":\"WARN\",\"timeout\":0," + + "\"environmentCode\":-1}]"; @Test public void testQueryProcessInstanceList() { @@ -310,7 +313,7 @@ public class ProcessInstanceServiceTest { ProcessInstance processInstance = getProcessInstance(); processInstance.setState(ExecutionStatus.SUCCESS); TaskInstance taskInstance = new TaskInstance(); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); List taskInstanceList = new ArrayList<>(); taskInstanceList.add(taskInstance); Result res = new Result(); @@ -361,7 +364,7 @@ public class ProcessInstanceServiceTest { //task not sub process TaskInstance taskInstance = getTaskInstance(); - taskInstance.setTaskType(TaskType.HTTP.getDesc()); + taskInstance.setTaskType("HTTP"); taskInstance.setProcessInstanceId(1); putMsg(result, Status.SUCCESS, projectCode); when(processService.findTaskInstanceById(1)).thenReturn(taskInstance); @@ -373,7 +376,7 @@ public class ProcessInstanceServiceTest { //sub process not exist TaskInstance subTask = getTaskInstance(); - subTask.setTaskType(TaskType.SUB_PROCESS.getDesc()); + subTask.setTaskType("SUB_PROCESS"); subTask.setProcessInstanceId(1); putMsg(result, Status.SUCCESS, projectCode); when(processService.findTaskInstanceById(subTask.getId())).thenReturn(subTask); @@ -442,6 +445,7 @@ public class ProcessInstanceServiceTest { List taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); when(processDefinitionService.checkProcessNodeList(taskRelationJson, taskDefinitionLogs)).thenReturn(result); putMsg(result, Status.SUCCESS, projectCode); + when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); Map processInstanceFinishRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, taskRelationJson, taskDefinitionJson,"2020-02-21 00:00:00", true, "", "", 0, "root"); Assert.assertEquals(Status.SUCCESS, processInstanceFinishRes.get(Constants.STATUS)); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessTaskRelationServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessTaskRelationServiceTest.java index f21de2aed4..dca48d99b9 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessTaskRelationServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessTaskRelationServiceTest.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.ProcessTaskRelationServiceImpl; import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; @@ -251,7 +250,7 @@ public class ProcessTaskRelationServiceTest { taskDefinition.setProjectCode(1L); taskDefinition.setCode(1L); taskDefinition.setVersion(1); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); return taskDefinition; } @@ -476,7 +475,7 @@ public class ProcessTaskRelationServiceTest { Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(getProcessDefinition()); Mockito.when(taskDefinitionMapper.queryByCode(taskCode)).thenReturn(getTaskDefinition()); TaskDefinition taskDefinition = new TaskDefinition(); - taskDefinition.setTaskType(TaskType.CONDITIONS.getDesc()); + taskDefinition.setTaskType("CONDITIONS"); Mockito.when(taskDefinitionMapper.queryByCode(taskCode)).thenReturn(taskDefinition); List processTaskRelationList = Lists.newArrayList(); ProcessTaskRelation processTaskRelation = new ProcessTaskRelation(); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java index 266f95efd0..9aade5555c 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskDefinitionServiceImplTest.java @@ -22,9 +22,7 @@ import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.api.service.impl.TaskDefinitionServiceImpl; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.UserType; -import org.apache.dolphinscheduler.common.task.shell.ShellParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; @@ -34,7 +32,9 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; +import org.apache.dolphinscheduler.plugin.task.shell.ShellParameters; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import java.text.MessageFormat; import java.util.ArrayList; @@ -74,6 +74,9 @@ public class TaskDefinitionServiceImplTest { @Mock private ProcessTaskRelationMapper processTaskRelationMapper; + @Mock + private TaskPluginManager taskPluginManager; + @Test public void createTaskDefinition() { long projectCode = 1L; @@ -98,6 +101,7 @@ public class TaskDefinitionServiceImplTest { + "\"timeoutNotifyStrategy\":0,\"timeout\":0,\"delayTime\":0,\"resourceIds\":\"\"}]"; List taskDefinitions = JSONUtils.toList(createTaskDefinitionJson, TaskDefinitionLog.class); Mockito.when(processService.saveTaskDefine(loginUser, projectCode, taskDefinitions, Boolean.TRUE)).thenReturn(1); + Mockito.when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); Map relation = taskDefinitionService .createTaskDefinition(loginUser, projectCode, createTaskDefinitionJson); Assert.assertEquals(Status.SUCCESS, relation.get(Constants.STATUS)); @@ -132,6 +136,7 @@ public class TaskDefinitionServiceImplTest { Mockito.when(taskDefinitionMapper.updateById(Mockito.any(TaskDefinitionLog.class))).thenReturn(1); Mockito.when(taskDefinitionLogMapper.insert(Mockito.any(TaskDefinitionLog.class))).thenReturn(1); Mockito.when(taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode)).thenReturn(1); + Mockito.when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); result = taskDefinitionService.updateTaskDefinition(loginUser, projectCode, taskCode, taskDefinitionJson); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @@ -247,7 +252,7 @@ public class TaskDefinitionServiceImplTest { taskDefinition.setProjectCode(1L); taskDefinition.setCode(1L); taskDefinition.setVersion(1); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); return taskDefinition; } @@ -313,7 +318,7 @@ public class TaskDefinitionServiceImplTest { taskDefinition.setCode(taskCode); String params = "{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"echo 1\",\"conditionResult\":{\"successNode\":[\"\"],\"failedNode\":[\"\"]},\"dependence\":{}}"; taskDefinition.setTaskParams(params); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); Mockito.when(taskDefinitionMapper.queryByCode(taskCode)).thenReturn(taskDefinition); TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog(taskDefinition); Mockito.when(taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, taskDefinition.getVersion())).thenReturn(taskDefinitionLog); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java index 5977b5ca64..106e9918c9 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java @@ -27,7 +27,6 @@ import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.api.service.impl.TaskInstanceServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; @@ -38,6 +37,7 @@ import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import java.text.MessageFormat; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java index e87e759b8e..1f1fdb0571 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/CheckUtilsTest.java @@ -23,22 +23,6 @@ import static org.junit.Assert.assertTrue; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ProgramType; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.datax.DataxParameters; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.task.flink.FlinkParameters; -import org.apache.dolphinscheduler.common.task.http.HttpParameters; -import org.apache.dolphinscheduler.common.task.mr.MapReduceParameters; -import org.apache.dolphinscheduler.common.task.procedure.ProcedureParameters; -import org.apache.dolphinscheduler.common.task.python.PythonParameters; -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 java.util.Map; @@ -108,142 +92,4 @@ public class CheckUtilsTest { assertTrue(CheckUtils.checkPhone("17362537263")); } - @Test - public void testCheckTaskNodeParameters() { - TaskNode taskNode = new TaskNode(); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - taskNode.setType("unKnown"); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - taskNode.setParams("unKnown"); - taskNode.setType("unKnown"); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - taskNode.setParams("unKnown"); - taskNode.setType(null); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - // sub SubProcessParameters - SubProcessParameters subProcessParameters = new SubProcessParameters(); - taskNode.setParams(JSONUtils.toJsonString(subProcessParameters)); - taskNode.setType(TaskType.SUB_PROCESS.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - subProcessParameters.setProcessDefinitionCode(1234L); - taskNode.setParams(JSONUtils.toJsonString(subProcessParameters)); - taskNode.setType(TaskType.SUB_PROCESS.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // ShellParameters - ShellParameters shellParameters = new ShellParameters(); - taskNode.setParams(JSONUtils.toJsonString(shellParameters)); - taskNode.setType(TaskType.SHELL.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - shellParameters.setRawScript(""); - taskNode.setParams(JSONUtils.toJsonString(shellParameters)); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - shellParameters.setRawScript("sss"); - taskNode.setParams(JSONUtils.toJsonString(shellParameters)); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // ProcedureParameters - ProcedureParameters procedureParameters = new ProcedureParameters(); - taskNode.setParams(JSONUtils.toJsonString(procedureParameters)); - taskNode.setType(TaskType.PROCEDURE.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - procedureParameters.setDatasource(1); - procedureParameters.setType("xx"); - procedureParameters.setMethod("yy"); - taskNode.setParams(JSONUtils.toJsonString(procedureParameters)); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // SqlParameters - SqlParameters sqlParameters = new SqlParameters(); - taskNode.setParams(JSONUtils.toJsonString(sqlParameters)); - taskNode.setType(TaskType.SQL.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - sqlParameters.setDatasource(1); - sqlParameters.setType("xx"); - sqlParameters.setSql("yy"); - taskNode.setParams(JSONUtils.toJsonString(sqlParameters)); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // MapReduceParameters - MapReduceParameters mapreduceParameters = new MapReduceParameters(); - taskNode.setParams(JSONUtils.toJsonString(mapreduceParameters)); - taskNode.setType(TaskType.MR.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - - ResourceInfo resourceInfoMapreduce = new ResourceInfo(); - resourceInfoMapreduce.setId(1); - resourceInfoMapreduce.setRes(""); - mapreduceParameters.setMainJar(resourceInfoMapreduce); - mapreduceParameters.setProgramType(ProgramType.JAVA); - taskNode.setParams(JSONUtils.toJsonString(mapreduceParameters)); - taskNode.setType(TaskType.MR.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // SparkParameters - SparkParameters sparkParameters = new SparkParameters(); - taskNode.setParams(JSONUtils.toJsonString(sparkParameters)); - taskNode.setType(TaskType.SPARK.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - sparkParameters.setMainJar(new ResourceInfo()); - sparkParameters.setProgramType(ProgramType.SCALA); - sparkParameters.setSparkVersion("1.1.1"); - taskNode.setParams(JSONUtils.toJsonString(sparkParameters)); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // PythonParameters - PythonParameters pythonParameters = new PythonParameters(); - taskNode.setParams(JSONUtils.toJsonString(pythonParameters)); - taskNode.setType(TaskType.PYTHON.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - pythonParameters.setRawScript("ss"); - taskNode.setParams(JSONUtils.toJsonString(pythonParameters)); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // DependentParameters - DependentParameters dependentParameters = new DependentParameters(); - taskNode.setDependence(JSONUtils.toJsonString(dependentParameters)); - taskNode.setType(TaskType.DEPENDENT.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // FlinkParameters - FlinkParameters flinkParameters = new FlinkParameters(); - taskNode.setParams(JSONUtils.toJsonString(flinkParameters)); - taskNode.setType(TaskType.FLINK.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - flinkParameters.setMainJar(new ResourceInfo()); - flinkParameters.setProgramType(ProgramType.JAVA); - taskNode.setParams(JSONUtils.toJsonString(flinkParameters)); - taskNode.setType(TaskType.FLINK.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // HTTP - HttpParameters httpParameters = new HttpParameters(); - taskNode.setParams(JSONUtils.toJsonString(httpParameters)); - taskNode.setType(TaskType.HTTP.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - httpParameters.setUrl("httpUrl"); - taskNode.setParams(JSONUtils.toJsonString(httpParameters)); - taskNode.setType(TaskType.HTTP.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - - // DataxParameters - DataxParameters dataxParameters = new DataxParameters(); - taskNode.setParams(JSONUtils.toJsonString(dataxParameters)); - taskNode.setType(TaskType.DATAX.getDesc()); - assertFalse(CheckUtils.checkTaskNodeParameters(taskNode)); - dataxParameters.setCustomConfig(0); - dataxParameters.setDataSource(111); - dataxParameters.setDataTarget(333); - dataxParameters.setSql(TaskType.SQL.getDesc()); - dataxParameters.setTargetTable("tar"); - taskNode.setParams(JSONUtils.toJsonString(dataxParameters)); - taskNode.setType(TaskType.DATAX.getDesc()); - assertTrue(CheckUtils.checkTaskNodeParameters(taskNode)); - } - } diff --git a/dolphinscheduler-common/pom.xml b/dolphinscheduler-common/pom.xml index 33756af27d..e0e36ad818 100644 --- a/dolphinscheduler-common/pom.xml +++ b/dolphinscheduler-common/pom.xml @@ -34,6 +34,11 @@ dolphinscheduler-spi + + org.apache.dolphinscheduler + dolphinscheduler-task-api + + org.apache.httpcomponents httpclient diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java index aa13eec513..1bec093456 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.common; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/Direct.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/Direct.java deleted file mode 100644 index f9a761a4e8..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/Direct.java +++ /dev/null @@ -1,28 +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.common.enums; - -/** - * parameter of stored procedure - */ -public enum Direct { - /** - * 0 in; 1 out; - */ - IN,OUT -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/StateEvent.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/StateEvent.java index 7cc806a8a5..54c7835f0b 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/StateEvent.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/StateEvent.java @@ -17,6 +17,8 @@ package org.apache.dolphinscheduler.common.enums; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; + import io.netty.channel.Channel; /** diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskStateType.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskStateType.java index a730fa84c3..f544b41c36 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskStateType.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskStateType.java @@ -17,6 +17,8 @@ package org.apache.dolphinscheduler.common.enums; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; + /** * type of task state */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskType.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskType.java deleted file mode 100644 index 1462d1c489..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskType.java +++ /dev/null @@ -1,84 +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.common.enums; - -import com.baomidou.mybatisplus.annotation.EnumValue; - -/** - * task node type - */ -public enum TaskType { - /** - * 0 SHELL - * 1 SQL - * 2 SUB_PROCESS - * 3 PROCEDURE - * 4 MR - * 5 SPARK - * 6 PYTHON - * 7 DEPENDENT - * 8 FLINK - * 9 HTTP - * 10 DATAX - * 11 CONDITIONS - * 12 SQOOP - * 13 SEATUNNEL - * 14 SWITCH - * 15 PIGEON - * 16 DATA_QUALITY - * 17 EMR - * 18 BLOCKING - */ - SHELL(0, "SHELL"), - SQL(1, "SQL"), - SUB_PROCESS(2, "SUB_PROCESS"), - PROCEDURE(3, "PROCEDURE"), - MR(4, "MR"), - SPARK(5, "SPARK"), - PYTHON(6, "PYTHON"), - DEPENDENT(7, "DEPENDENT"), - FLINK(8, "FLINK"), - HTTP(9, "HTTP"), - DATAX(10, "DATAX"), - CONDITIONS(11, "CONDITIONS"), - SQOOP(12, "SQOOP"), - SEATUNNEL(13, "SEATUNNEL"), - SWITCH(14, "SWITCH"), - PIGEON(15, "PIGEON"), - DATA_QUALITY(16, "DATA_QUALITY"), - EMR(17, "EMR"), - BLOCKING(18, "BLOCKING"); - ; - - TaskType(int code, String desc) { - this.code = code; - this.desc = desc; - } - - @EnumValue - private final int code; - private final String desc; - - public int getCode() { - return code; - } - - public String getDesc() { - return desc; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/Server.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/Server.java index 29a055dbff..4bd4648e93 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/Server.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/Server.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.common.model; import java.util.Date; - /** * server */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java index 30ee7fb64b..5a12fb6dc7 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java @@ -17,12 +17,15 @@ package org.apache.dolphinscheduler.common.model; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SWITCH; + import com.fasterxml.jackson.core.type.TypeReference; 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.plugin.task.api.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.parameters.TaskTimeoutParameter; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; @@ -387,11 +390,11 @@ public class TaskNode { } public boolean isConditionsTask() { - return TaskType.CONDITIONS.getDesc().equalsIgnoreCase(this.getType()); + return TASK_TYPE_CONDITIONS.equalsIgnoreCase(this.getType()); } public boolean isSwitchTask() { - return TaskType.SWITCH.toString().equalsIgnoreCase(this.getType()); + return TASK_TYPE_SWITCH.equalsIgnoreCase(this.getType()); } public List getPreTaskNodeList() { @@ -399,7 +402,7 @@ public class TaskNode { } public boolean isBlockingTask() { - return TaskType.BLOCKING.getDesc().equalsIgnoreCase(this.getType()); + return TASK_TYPE_BLOCKING.equalsIgnoreCase(this.getType()); } public void setPreTaskNodeList(List preTaskNodeList) { diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/WorkerServerModel.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/WorkerServerModel.java index 45241e68b5..a1f7b479d3 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/WorkerServerModel.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/WorkerServerModel.java @@ -20,7 +20,6 @@ package org.apache.dolphinscheduler.common.model; import java.util.Date; import java.util.Set; - /** * server */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/Property.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/Property.java deleted file mode 100644 index 2f9556e578..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/Property.java +++ /dev/null @@ -1,140 +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.common.process; - -import org.apache.dolphinscheduler.common.enums.DataType; -import org.apache.dolphinscheduler.common.enums.Direct; - -import java.io.Serializable; -import java.util.Objects; - -public class Property implements Serializable { - /** - * key - */ - private String prop; - - /** - * input/output - */ - private Direct direct; - - /** - * data type - */ - private DataType type; - - /** - * value - */ - private String value; - - public Property() { - } - - public Property(String prop,Direct direct,DataType type,String value) { - this.prop = prop; - this.direct = direct; - this.type = type; - this.value = value; - } - - /** - * getter method - * - * @return the prop - * @see Property#prop - */ - public String getProp() { - return prop; - } - - /** - * setter method - * - * @param prop the prop to set - * @see Property#prop - */ - public void setProp(String prop) { - this.prop = prop; - } - - /** - * getter method - * - * @return the value - * @see Property#value - */ - public String getValue() { - return value; - } - - /** - * setter method - * - * @param value the value to set - * @see Property#value - */ - public void setValue(String value) { - this.value = value; - } - - public Direct getDirect() { - return direct; - } - - public void setDirect(Direct direct) { - this.direct = direct; - } - - public DataType getType() { - return type; - } - - public void setType(DataType type) { - this.type = type; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Property property = (Property) o; - return Objects.equals(prop, property.prop) - && Objects.equals(value, property.value); - } - - @Override - public int hashCode() { - return Objects.hash(prop, value); - } - - @Override - public String toString() { - return "Property{" - + "prop='" + prop + '\'' - + ", direct=" + direct - + ", type=" + type - + ", value='" + value + '\'' - + '}'; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/ResourceInfo.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/ResourceInfo.java deleted file mode 100644 index adc86b2f1c..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/process/ResourceInfo.java +++ /dev/null @@ -1,63 +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.common.process; - -/** - * resource info - */ -public class ResourceInfo { - /** - * res id of the resource that was uploaded - */ - private int id; - - private String res; - - /** - * full name of the resource that was uploaded - */ - private String resourceName; - - public ResourceInfo() { - // do nothing, void constructor - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getRes() { - return res; - } - - public void setRes(String res) { - this.res = res; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/shell/AbstractShell.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/shell/AbstractShell.java index 63e43a9f78..c2f63cce14 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/shell/AbstractShell.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/shell/AbstractShell.java @@ -17,9 +17,6 @@ package org.apache.dolphinscheduler.common.shell; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -31,6 +28,9 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * A base class for running a Unix command. * diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/AbstractParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/AbstractParameters.java deleted file mode 100644 index 4886e52c29..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/AbstractParameters.java +++ /dev/null @@ -1,181 +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.common.task; - -import org.apache.dolphinscheduler.common.enums.Direct; -import org.apache.dolphinscheduler.common.process.Property; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.utils.JSONUtils; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; - -/** - * job params related class - */ -public abstract class AbstractParameters implements IParameters { - - @Override - public abstract boolean checkParameters(); - - @Override - public abstract List getResourceFilesList(); - - /** - * local parameters - */ - public List localParams; - - /** - * var pool - */ - public List varPool; - - /** - * get local parameters list - * - * @return Property list - */ - public List getLocalParams() { - return localParams; - } - - public void setLocalParams(List localParams) { - this.localParams = localParams; - } - - /** - * get local parameters map - * - * @return parameters map - */ - public Map getLocalParametersMap() { - if (localParams != null) { - Map localParametersMaps = new LinkedHashMap<>(); - - for (Property property : localParams) { - localParametersMaps.put(property.getProp(), property); - } - return localParametersMaps; - } - return null; - } - - /** - * get varPool map - * - * @return parameters map - */ - public Map getVarPoolMap() { - if (varPool != null) { - Map varPoolMap = new LinkedHashMap<>(); - for (Property property : varPool) { - varPoolMap.put(property.getProp(), property); - } - return varPoolMap; - } - return null; - } - - public List getVarPool() { - return varPool; - } - - public void setVarPool(String varPool) { - if (StringUtils.isEmpty(varPool)) { - this.varPool = new ArrayList<>(); - } else { - this.varPool = JSONUtils.toList(varPool, Property.class); - } - } - - public void dealOutParam(String result) { - if (CollectionUtils.isEmpty(localParams)) { - return; - } - List outProperty = getOutProperty(localParams); - if (CollectionUtils.isEmpty(outProperty)) { - return; - } - if (StringUtils.isEmpty(result)) { - varPool.addAll(outProperty); - return; - } - Map taskResult = getMapByString(result); - if (taskResult == null || taskResult.size() == 0) { - return; - } - for (Property info : outProperty) { - info.setValue(taskResult.get(info.getProp())); - varPool.add(info); - } - } - - public List getOutProperty(List params) { - if (CollectionUtils.isEmpty(params)) { - return new ArrayList<>(); - } - List result = new ArrayList<>(); - for (Property info : params) { - if (info.getDirect() == Direct.OUT) { - result.add(info); - } - } - return result; - } - - public List> getListMapByString(String json) { - List> allParams = new ArrayList<>(); - ArrayNode paramsByJson = JSONUtils.parseArray(json); - Iterator listIterator = paramsByJson.iterator(); - while (listIterator.hasNext()) { - Map param = JSONUtils.parseObject(listIterator.next().toString(), new TypeReference>() {}); - allParams.add(param); - } - return allParams; - } - - /** - * shell's result format is key=value$VarPool$key=value$VarPool$ - * @param result - * @return - */ - public static Map getMapByString(String result) { - String[] formatResult = result.split("\\$VarPool\\$"); - Map format = new HashMap<>(); - for (String info : formatResult) { - if (!StringUtils.isEmpty(info) && info.contains("=")) { - String[] keyValue = info.split("="); - format.put(keyValue[0], keyValue[1]); - } - } - return format; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/datax/DataxParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/datax/DataxParameters.java deleted file mode 100755 index 29fbeafa64..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/datax/DataxParameters.java +++ /dev/null @@ -1,252 +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.common.task.datax; - -import org.apache.dolphinscheduler.common.enums.Flag; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * DataX parameter - */ -public class DataxParameters extends AbstractParameters { - - /** - * if custom json config,eg 0, 1 - */ - private int customConfig; - - /** - * if customConfig eq 1 ,then json is usable - */ - private String json; - - /** - * data source type,eg MYSQL, POSTGRES ... - */ - private String dsType; - - /** - * datasource id - */ - private int dataSource; - - /** - * data target type,eg MYSQL, POSTGRES ... - */ - private String dtType; - - /** - * datatarget id - */ - private int dataTarget; - - /** - * sql - */ - private String sql; - - /** - * target table - */ - private String targetTable; - - /** - * Pre Statements - */ - private List preStatements; - - /** - * Post Statements - */ - private List postStatements; - - /** - * speed byte num - */ - private int jobSpeedByte; - - /** - * speed record count - */ - private int jobSpeedRecord; - - /** - * Xms memory - */ - private int xms; - - /** - * Xmx memory - */ - private int xmx; - - public int getCustomConfig() { - return customConfig; - } - - public void setCustomConfig(int customConfig) { - this.customConfig = customConfig; - } - - public String getJson() { - return json; - } - - public void setJson(String json) { - this.json = json; - } - - public String getDsType() { - return dsType; - } - - public void setDsType(String dsType) { - this.dsType = dsType; - } - - public int getDataSource() { - return dataSource; - } - - public void setDataSource(int dataSource) { - this.dataSource = dataSource; - } - - public String getDtType() { - return dtType; - } - - public void setDtType(String dtType) { - this.dtType = dtType; - } - - public int getDataTarget() { - return dataTarget; - } - - public void setDataTarget(int dataTarget) { - this.dataTarget = dataTarget; - } - - public String getSql() { - return sql; - } - - public void setSql(String sql) { - this.sql = sql; - } - - public String getTargetTable() { - return targetTable; - } - - public void setTargetTable(String targetTable) { - this.targetTable = targetTable; - } - - public List getPreStatements() { - return preStatements; - } - - public void setPreStatements(List preStatements) { - this.preStatements = preStatements; - } - - public List getPostStatements() { - return postStatements; - } - - public void setPostStatements(List postStatements) { - this.postStatements = postStatements; - } - - public int getJobSpeedByte() { - return jobSpeedByte; - } - - public void setJobSpeedByte(int jobSpeedByte) { - this.jobSpeedByte = jobSpeedByte; - } - - public int getJobSpeedRecord() { - return jobSpeedRecord; - } - - public void setJobSpeedRecord(int jobSpeedRecord) { - this.jobSpeedRecord = jobSpeedRecord; - } - - public int getXms() { - return xms; - } - - public void setXms(int xms) { - this.xms = xms; - } - - public int getXmx() { - return xmx; - } - - public void setXmx(int xmx) { - this.xmx = xmx; - } - - @Override - public boolean checkParameters() { - if (customConfig == Flag.NO.ordinal()) { - return dataSource != 0 - && dataTarget != 0 - && !StringUtils.isEmpty(sql) - && !StringUtils.isEmpty(targetTable); - } else { - return !StringUtils.isEmpty(json); - } - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - - @Override - public String toString() { - return "DataxParameters{" - + "customConfig=" + customConfig - + ", json='" + json + '\'' - + ", dsType='" + dsType + '\'' - + ", dataSource=" + dataSource - + ", dtType='" + dtType + '\'' - + ", dataTarget=" + dataTarget - + ", sql='" + sql + '\'' - + ", targetTable='" + targetTable + '\'' - + ", preStatements=" + preStatements - + ", postStatements=" + postStatements - + ", jobSpeedByte=" + jobSpeedByte - + ", jobSpeedRecord=" + jobSpeedRecord - + ", xms=" + xms - + ", xmx=" + xmx - + '}'; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dq/DataQualityParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dq/DataQualityParameters.java deleted file mode 100644 index db4baddeee..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dq/DataQualityParameters.java +++ /dev/null @@ -1,103 +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.common.task.dq; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.common.task.spark.SparkParameters; - -import org.apache.commons.collections.MapUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * DataQualityParameters - */ -public class DataQualityParameters extends AbstractParameters { - - private static final Logger logger = LoggerFactory.getLogger(DataQualityParameters.class); - - /** - * rule id - */ - private int ruleId; - /** - * rule input entry value map - */ - private Map ruleInputParameter; - /** - * spark parameters - */ - private SparkParameters sparkParameters; - - public int getRuleId() { - return ruleId; - } - - public void setRuleId(int ruleId) { - this.ruleId = ruleId; - } - - public Map getRuleInputParameter() { - return ruleInputParameter; - } - - public void setRuleInputParameter(Map ruleInputParameter) { - this.ruleInputParameter = ruleInputParameter; - } - - /** - * In this function ,we need more detailed check every parameter, - * if the parameter is non-conformant will return false - * @return boolean result - */ - @Override - public boolean checkParameters() { - - if (ruleId == 0) { - logger.error("rule id is null"); - return false; - } - - if (MapUtils.isEmpty(ruleInputParameter)) { - logger.error("rule input parameter is empty"); - return false; - } - - return sparkParameters != null; - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - - public SparkParameters getSparkParameters() { - return sparkParameters; - } - - public void setSparkParameters(SparkParameters sparkParameters) { - this.sparkParameters = sparkParameters; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/emr/EmrParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/emr/EmrParameters.java deleted file mode 100644 index d15c5c19c7..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/emr/EmrParameters.java +++ /dev/null @@ -1,59 +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.common.task.emr; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.utils.StringUtils; - -import java.util.Collections; -import java.util.List; - -public class EmrParameters extends AbstractParameters { - /** - * job flow define in json format - */ - private String jobFlowDefineJson; - - @Override - public boolean checkParameters() { - return StringUtils.isNotEmpty(jobFlowDefineJson); - } - - - @Override - public List getResourceFilesList() { - return Collections.emptyList(); - } - - - public String getJobFlowDefineJson() { - return jobFlowDefineJson; - } - - public void setJobFlowDefineJson(String jobFlowDefineJson) { - this.jobFlowDefineJson = jobFlowDefineJson; - } - - @Override - public String toString() { - return "EmrParameters{" + - "jobFlowDefineJson='" + jobFlowDefineJson + '\'' + - '}'; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/flink/FlinkParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/flink/FlinkParameters.java deleted file mode 100644 index 76d68c0460..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/flink/FlinkParameters.java +++ /dev/null @@ -1,241 +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.common.task.flink; - -import org.apache.dolphinscheduler.common.enums.ProgramType; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.ArrayList; -import java.util.List; - -/** - * flink parameters - */ -public class FlinkParameters extends AbstractParameters { - - /** - * major jar - */ - private ResourceInfo mainJar; - - /** - * major class - */ - private String mainClass; - - /** - * deploy mode yarn-cluster yarn-local - */ - private String deployMode; - - /** - * arguments - */ - private String mainArgs; - - /** - * slot count - */ - private int slot; - - /** - * parallelism - */ - private int parallelism; - - /** - * yarn application name - */ - private String appName; - - /** - * taskManager count - */ - private int taskManager; - - /** - * job manager memory - */ - private String jobManagerMemory; - - /** - * task manager memory - */ - private String taskManagerMemory; - - /** - * resource list - */ - private List resourceList = new ArrayList<>(); - - /** - * The YARN queue to submit to - */ - private String queue; - - /** - * other arguments - */ - private String others; - - /** - * flink version - */ - private String flinkVersion; - - /** - * program type - * 0 JAVA,1 SCALA,2 PYTHON - */ - private ProgramType programType; - - public ResourceInfo getMainJar() { - return mainJar; - } - - public void setMainJar(ResourceInfo mainJar) { - this.mainJar = mainJar; - } - - public String getMainClass() { - return mainClass; - } - - public void setMainClass(String mainClass) { - this.mainClass = mainClass; - } - - public String getDeployMode() { - return deployMode; - } - - public void setDeployMode(String deployMode) { - this.deployMode = deployMode; - } - - public String getMainArgs() { - return mainArgs; - } - - public void setMainArgs(String mainArgs) { - this.mainArgs = mainArgs; - } - - public int getSlot() { - return slot; - } - - public void setSlot(int slot) { - this.slot = slot; - } - - public int getParallelism() { - return parallelism; - } - - public void setParallelism(int parallelism) { - this.parallelism = parallelism; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public int getTaskManager() { - return taskManager; - } - - public void setTaskManager(int taskManager) { - this.taskManager = taskManager; - } - - public String getJobManagerMemory() { - return jobManagerMemory; - } - - public void setJobManagerMemory(String jobManagerMemory) { - this.jobManagerMemory = jobManagerMemory; - } - - public String getTaskManagerMemory() { - return taskManagerMemory; - } - - public void setTaskManagerMemory(String taskManagerMemory) { - this.taskManagerMemory = taskManagerMemory; - } - - public String getQueue() { - return queue; - } - - public void setQueue(String queue) { - this.queue = queue; - } - - public List getResourceList() { - return resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - public String getOthers() { - return others; - } - - public void setOthers(String others) { - this.others = others; - } - - public ProgramType getProgramType() { - return programType; - } - - public void setProgramType(ProgramType programType) { - 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; - } - - @Override - public List getResourceFilesList() { - if (mainJar != null && !resourceList.contains(mainJar)) { - resourceList.add(mainJar); - } - return resourceList; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/http/HttpParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/http/HttpParameters.java deleted file mode 100644 index df2c26846b..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/http/HttpParameters.java +++ /dev/null @@ -1,138 +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.common.task.http; - -import org.apache.dolphinscheduler.common.enums.HttpCheckCondition; -import org.apache.dolphinscheduler.common.enums.HttpMethod; -import org.apache.dolphinscheduler.common.process.HttpProperty; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * http parameter - */ -public class HttpParameters extends AbstractParameters { - /** - * url - */ - private String url; - - /** - * httpMethod - */ - private HttpMethod httpMethod; - - /** - * http params - */ - private List httpParams; - - /** - * httpCheckCondition - */ - private HttpCheckCondition httpCheckCondition = HttpCheckCondition.STATUS_CODE_DEFAULT; - - /** - * condition - */ - private String condition; - - - /** - * Connect Timeout - * Unit: ms - */ - private int connectTimeout; - - /** - * Socket Timeout - * Unit: ms - */ - private int socketTimeout; - - @Override - public boolean checkParameters() { - return !StringUtils.isEmpty(url); - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public HttpMethod getHttpMethod() { - return httpMethod; - } - - public void setHttpMethod(HttpMethod httpMethod) { - this.httpMethod = httpMethod; - } - - public List getHttpParams() { - return httpParams; - } - - public void setHttpParams(List httpParams) { - this.httpParams = httpParams; - } - - public HttpCheckCondition getHttpCheckCondition() { - return httpCheckCondition; - } - - public void setHttpCheckCondition(HttpCheckCondition httpCheckCondition) { - this.httpCheckCondition = httpCheckCondition; - } - - public String getCondition() { - return condition; - } - - 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; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/mr/MapReduceParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/mr/MapReduceParameters.java deleted file mode 100644 index e9b54a3bb1..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/mr/MapReduceParameters.java +++ /dev/null @@ -1,160 +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.common.task.mr; - -import org.apache.dolphinscheduler.common.enums.ProgramType; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.ArrayList; -import java.util.List; - -/** - * mapreduce parameters - */ -public class MapReduceParameters extends AbstractParameters { - - /** - * major jar - */ - private ResourceInfo mainJar; - - /** - * major class - */ - private String mainClass; - - /** - * arguments - */ - private String mainArgs; - - /** - * other arguments - */ - private String others; - - /** - * app name - */ - private String appName; - - /** - * queue - */ - private String queue; - - /** - * resource list - */ - private List resourceList = new ArrayList<>(); - - /** - * program type - * 0 JAVA,1 SCALA,2 PYTHON - */ - private ProgramType programType; - - public String getMainClass() { - return mainClass; - } - - public void setMainClass(String mainClass) { - this.mainClass = mainClass; - } - - public String getMainArgs() { - return mainArgs; - } - - public void setMainArgs(String mainArgs) { - this.mainArgs = mainArgs; - } - - public String getOthers() { - return others; - } - - public void setOthers(String others) { - this.others = others; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getQueue() { - return queue; - } - - public void setQueue(String queue) { - this.queue = queue; - } - - public List getResourceList() { - return this.resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - public void setMainJar(ResourceInfo mainJar) { - this.mainJar = mainJar; - } - - public ResourceInfo getMainJar() { - return mainJar; - } - - public ProgramType getProgramType() { - return programType; - } - - public void setProgramType(ProgramType programType) { - this.programType = programType; - } - - @Override - public boolean checkParameters() { - return this.mainJar != null && this.programType != null; - } - - @Override - public List getResourceFilesList() { - if (mainJar != null && !resourceList.contains(mainJar)) { - resourceList.add(mainJar); - } - - return resourceList; - } - - @Override - public String toString() { - return "mainJar= " + mainJar - + "mainClass=" + mainClass - + "mainArgs=" + mainArgs - + "queue=" + queue - + "other mainArgs=" + others - ; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/procedure/ProcedureParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/procedure/ProcedureParameters.java deleted file mode 100644 index d35b05d2b7..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/procedure/ProcedureParameters.java +++ /dev/null @@ -1,90 +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.common.task.procedure; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * procedure parameter - */ -public class ProcedureParameters extends AbstractParameters { - - /** - * data source type,eg MYSQL, POSTGRES, HIVE ... - */ - private String type; - - /** - * data source id - */ - private int datasource; - - /** - * procedure name - */ - private String method; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public int getDatasource() { - return datasource; - } - - public void setDatasource(int datasource) { - this.datasource = datasource; - } - - public String getMethod() { - return method; - } - - public void setMethod(String method) { - this.method = method; - } - - @Override - public boolean checkParameters() { - return datasource != 0 && !StringUtils.isEmpty(type) && !StringUtils.isEmpty(method); - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - - @Override - public String toString() { - return "ProcessdureParam{" - + "type='" + type + '\'' - + ", datasource=" + datasource - + ", method='" + method + '\'' - + '}'; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/python/PythonParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/python/PythonParameters.java deleted file mode 100644 index 48c5e31dbb..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/python/PythonParameters.java +++ /dev/null @@ -1,61 +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.common.task.python; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.List; - -public class PythonParameters extends AbstractParameters { - /** - * origin python script - */ - private String rawScript; - - /** - * resource list - */ - private List resourceList; - - public String getRawScript() { - return rawScript; - } - - public void setRawScript(String rawScript) { - this.rawScript = rawScript; - } - - public List getResourceList() { - return resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - @Override - public boolean checkParameters() { - return rawScript != null && !rawScript.isEmpty(); - } - - @Override - public List getResourceFilesList() { - return this.resourceList; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/shell/ShellParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/shell/ShellParameters.java deleted file mode 100644 index 7388cd35da..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/shell/ShellParameters.java +++ /dev/null @@ -1,65 +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.common.task.shell; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.List; - -/** - * shell parameters - */ -public class ShellParameters extends AbstractParameters { - /** - * shell script - */ - private String rawScript; - - /** - * resource list - */ - private List resourceList; - - public String getRawScript() { - return rawScript; - } - - public void setRawScript(String rawScript) { - this.rawScript = rawScript; - } - - public List getResourceList() { - return resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - @Override - public boolean checkParameters() { - return rawScript != null && !rawScript.isEmpty(); - } - - @Override - public List getResourceFilesList() { - return resourceList; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/spark/SparkParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/spark/SparkParameters.java deleted file mode 100644 index 947f09e9b6..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/spark/SparkParameters.java +++ /dev/null @@ -1,242 +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.common.task.spark; - -import org.apache.dolphinscheduler.common.enums.ProgramType; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.ArrayList; -import java.util.List; - -/** - * spark parameters - */ -public class SparkParameters extends AbstractParameters { - - /** - * main jar - */ - private ResourceInfo mainJar; - - /** - * main class - */ - private String mainClass; - - /** - * deploy mode - */ - private String deployMode; - - /** - * arguments - */ - private String mainArgs; - - /** - * driver-cores Number of cores used by the driver, only in cluster mode - */ - private int driverCores; - - /** - * driver-memory Memory for driver - */ - - private String driverMemory; - - /** - * num-executors Number of executors to launch - */ - private int numExecutors; - - /** - * executor-cores Number of cores per executor - */ - private int executorCores; - - /** - * Memory per executor - */ - private String executorMemory; - - /** - * app name - */ - private String appName; - - /** - * The YARN queue to submit to - */ - private String queue; - - /** - * other arguments - */ - private String others; - - /** - * program type - * 0 JAVA,1 SCALA,2 PYTHON - */ - private ProgramType programType; - - /** - * spark version - */ - private String sparkVersion; - - /** - * resource list - */ - private List resourceList = new ArrayList<>(); - - public ResourceInfo getMainJar() { - return mainJar; - } - - public void setMainJar(ResourceInfo mainJar) { - this.mainJar = mainJar; - } - - public String getMainClass() { - return mainClass; - } - - public void setMainClass(String mainClass) { - this.mainClass = mainClass; - } - - public String getDeployMode() { - return deployMode; - } - - public void setDeployMode(String deployMode) { - this.deployMode = deployMode; - } - - public String getMainArgs() { - return mainArgs; - } - - public void setMainArgs(String mainArgs) { - this.mainArgs = mainArgs; - } - - public int getDriverCores() { - return driverCores; - } - - public void setDriverCores(int driverCores) { - this.driverCores = driverCores; - } - - public String getDriverMemory() { - return driverMemory; - } - - public void setDriverMemory(String driverMemory) { - this.driverMemory = driverMemory; - } - - public int getNumExecutors() { - return numExecutors; - } - - public void setNumExecutors(int numExecutors) { - this.numExecutors = numExecutors; - } - - public int getExecutorCores() { - return executorCores; - } - - public void setExecutorCores(int executorCores) { - this.executorCores = executorCores; - } - - public String getExecutorMemory() { - return executorMemory; - } - - public void setExecutorMemory(String executorMemory) { - this.executorMemory = executorMemory; - } - - public String getAppName() { - return appName; - } - - public void setAppName(String appName) { - this.appName = appName; - } - - public String getQueue() { - return queue; - } - - public void setQueue(String queue) { - this.queue = queue; - } - - public String getOthers() { - return others; - } - - public void setOthers(String others) { - this.others = others; - } - - public List getResourceList() { - return resourceList; - } - - public void setResourceList(List resourceList) { - this.resourceList = resourceList; - } - - public ProgramType getProgramType() { - return programType; - } - - public void setProgramType(ProgramType programType) { - this.programType = programType; - } - - public String getSparkVersion() { - return sparkVersion; - } - - public void setSparkVersion(String sparkVersion) { - this.sparkVersion = sparkVersion; - } - - @Override - public boolean checkParameters() { - return mainJar != null && programType != null; - } - - @Override - public List getResourceFilesList() { - if (mainJar != null && !resourceList.contains(mainJar)) { - resourceList.add(mainJar); - } - return resourceList; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlBinds.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlBinds.java deleted file mode 100644 index 2d68af891e..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlBinds.java +++ /dev/null @@ -1,43 +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.common.task.sql; - -import org.apache.dolphinscheduler.common.process.Property; - -import java.util.Map; - -/** - * Used to contains both prepared sql string and its to-be-bind parameters - */ -public class SqlBinds { - private final String sql; - private final Map paramsMap; - - public SqlBinds(String sql, Map paramsMap) { - this.sql = sql; - this.paramsMap = paramsMap; - } - - public String getSql() { - return sql; - } - - public Map getParamsMap() { - return paramsMap; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlParameters.java deleted file mode 100644 index bd3825d131..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlParameters.java +++ /dev/null @@ -1,295 +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.common.task.sql; - -import org.apache.dolphinscheduler.common.enums.DataType; -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.JSONUtils; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Sql/Hql parameter - */ -public class SqlParameters extends AbstractParameters { - /** - * data source type,eg MYSQL, POSTGRES, HIVE ... - */ - private String type; - - /** - * datasource id - */ - private int datasource; - - /** - * sql - */ - private String sql; - - /** - * sql type - * 0 query - * 1 NON_QUERY - */ - private int sqlType; - - /** - * send email - */ - private Boolean sendEmail; - - /** - * display rows - */ - private int displayRows; - - /** - * udf list - */ - private String udfs; - /** - * show type - * 0 TABLE - * 1 TEXT - * 2 attachment - * 3 TABLE+attachment - */ - private String showType; - /** - * SQL connection parameters - */ - private String connParams; - /** - * Pre Statements - */ - private List preStatements; - /** - * Post Statements - */ - private List postStatements; - - /** - * groupId - */ - private int groupId; - /** - * title - */ - private String title; - - private int limit; - - public int getLimit() { - return limit; - } - - public void setLimit(int limit) { - this.limit = limit; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public int getDatasource() { - return datasource; - } - - public void setDatasource(int datasource) { - this.datasource = datasource; - } - - public String getSql() { - return sql; - } - - public void setSql(String sql) { - this.sql = sql; - } - - public String getUdfs() { - return udfs; - } - - public void setUdfs(String udfs) { - this.udfs = udfs; - } - - public int getSqlType() { - return sqlType; - } - - public void setSqlType(int sqlType) { - this.sqlType = sqlType; - } - - public Boolean getSendEmail() { - return sendEmail; - } - - public void setSendEmail(Boolean sendEmail) { - this.sendEmail = sendEmail; - } - - public int getDisplayRows() { - return displayRows; - } - - public void setDisplayRows(int displayRows) { - this.displayRows = displayRows; - } - - public String getShowType() { - return showType; - } - - public void setShowType(String showType) { - this.showType = showType; - } - - public String getConnParams() { - return connParams; - } - - public void setConnParams(String connParams) { - this.connParams = connParams; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getPreStatements() { - return preStatements; - } - - public void setPreStatements(List preStatements) { - this.preStatements = preStatements; - } - - public List getPostStatements() { - return postStatements; - } - - public void setPostStatements(List postStatements) { - this.postStatements = postStatements; - } - - public int getGroupId() { - return groupId; - } - - public void setGroupId(int groupId) { - this.groupId = groupId; - } - - @Override - public boolean checkParameters() { - return datasource != 0 && !StringUtils.isEmpty(type) && !StringUtils.isEmpty(sql); - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - - @Override - public void dealOutParam(String result) { - if (CollectionUtils.isEmpty(localParams)) { - return; - } - List outProperty = getOutProperty(localParams); - if (CollectionUtils.isEmpty(outProperty)) { - return; - } - if (StringUtils.isEmpty(result)) { - varPool.addAll(outProperty); - return; - } - List> sqlResult = getListMapByString(result); - if (CollectionUtils.isEmpty(sqlResult)) { - return; - } - //if sql return more than one line - if (sqlResult.size() > 1) { - Map> sqlResultFormat = new HashMap<>(); - //init sqlResultFormat - Set keySet = sqlResult.get(0).keySet(); - for (String key : keySet) { - sqlResultFormat.put(key, new ArrayList<>()); - } - for (Map info : sqlResult) { - info.forEach((key, value) -> { - sqlResultFormat.get(key).add(value); - }); - } - for (Property info : outProperty) { - if (info.getType() == DataType.LIST) { - info.setValue(JSONUtils.toJsonString(sqlResultFormat.get(info.getProp()))); - varPool.add(info); - } - } - } else { - //result only one line - Map firstRow = sqlResult.get(0); - for (Property info : outProperty) { - info.setValue(String.valueOf(firstRow.get(info.getProp()))); - varPool.add(info); - } - } - - } - - @Override - public String toString() { - return "SqlParameters{" - + "type='" + type + '\'' - + ", datasource=" + datasource - + ", sql='" + sql + '\'' - + ", sqlType=" + sqlType - + ", sendEmail=" + sendEmail - + ", displayRows=" + displayRows - + ", limit=" + limit - + ", udfs='" + udfs + '\'' - + ", showType='" + showType + '\'' - + ", connParams='" + connParams + '\'' - + ", groupId='" + groupId + '\'' - + ", title='" + title + '\'' - + ", preStatements=" + preStatements - + ", postStatements=" + postStatements - + '}'; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/SqoopParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/SqoopParameters.java deleted file mode 100644 index feea0fb389..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/SqoopParameters.java +++ /dev/null @@ -1,205 +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.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.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * sqoop parameters - */ -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 - */ - private String modelType; - /** - * concurrency - */ - private int concurrency; - /** - * source type - */ - private String sourceType; - /** - * target type - */ - private String targetType; - /** - * source params - */ - private String sourceParams; - /** - * target params - */ - private String targetParams; - - /** - * hadoop custom param for sqoop job - */ - private List hadoopCustomParams; - - /** - * sqoop advanced param - */ - private List sqoopAdvancedParams; - - public String getModelType() { - return modelType; - } - - public void setModelType(String modelType) { - this.modelType = modelType; - } - - public int getConcurrency() { - return concurrency; - } - - public void setConcurrency(int concurrency) { - this.concurrency = concurrency; - } - - public String getSourceType() { - return sourceType; - } - - public void setSourceType(String sourceType) { - this.sourceType = sourceType; - } - - public String getTargetType() { - return targetType; - } - - public void setTargetType(String targetType) { - this.targetType = targetType; - } - - public String getSourceParams() { - return sourceParams; - } - - public void setSourceParams(String sourceParams) { - this.sourceParams = sourceParams; - } - - public String getTargetParams() { - return targetParams; - } - - public void setTargetParams(String targetParams) { - 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 getHadoopCustomParams() { - return hadoopCustomParams; - } - - public void setHadoopCustomParams(List hadoopCustomParams) { - this.hadoopCustomParams = hadoopCustomParams; - } - - public List getSqoopAdvancedParams() { - return sqoopAdvancedParams; - } - - public void setSqoopAdvancedParams(List sqoopAdvancedParams) { - this.sqoopAdvancedParams = sqoopAdvancedParams; - } - - @Override - public boolean checkParameters() { - - boolean sqoopParamsCheck = false; - - if (StringUtils.isEmpty(jobType)) { - return sqoopParamsCheck; - } - - if (SqoopJobType.TEMPLATE.getDescp().equals(jobType)) { - sqoopParamsCheck = StringUtils.isEmpty(customShell) - && !StringUtils.isEmpty(modelType) - && !StringUtils.isEmpty(jobName) - && concurrency != 0 - && !StringUtils.isEmpty(sourceType) - && !StringUtils.isEmpty(targetType) - && !StringUtils.isEmpty(sourceParams) - && !StringUtils.isEmpty(targetParams); - } else if (SqoopJobType.CUSTOM.getDescp().equals(jobType)) { - sqoopParamsCheck = !StringUtils.isEmpty(customShell) - && StringUtils.isEmpty(jobName); - } - - return sqoopParamsCheck; - } - - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHdfsParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHdfsParameter.java deleted file mode 100644 index 5346ca6073..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHdfsParameter.java +++ /dev/null @@ -1,37 +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.common.task.sqoop.sources; - -/** - * source hdfs parameter - */ -public class SourceHdfsParameter { - - /** - * export dir - */ - private String exportDir; - - public String getExportDir() { - return exportDir; - } - - public void setExportDir(String exportDir) { - this.exportDir = exportDir; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHiveParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHiveParameter.java deleted file mode 100644 index b7bc97ae2f..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceHiveParameter.java +++ /dev/null @@ -1,73 +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.common.task.sqoop.sources; - -/** - * source hive parameter - */ -public class SourceHiveParameter { - - /** - * hive database - */ - private String hiveDatabase; - /** - * hive table - */ - private String hiveTable; - /** - * hive partition key - */ - private String hivePartitionKey; - /** - * hive partition value - */ - private String hivePartitionValue; - - public String getHiveDatabase() { - return hiveDatabase; - } - - public void setHiveDatabase(String hiveDatabase) { - this.hiveDatabase = hiveDatabase; - } - - public String getHiveTable() { - return hiveTable; - } - - public void setHiveTable(String hiveTable) { - this.hiveTable = hiveTable; - } - - public String getHivePartitionKey() { - return hivePartitionKey; - } - - public void setHivePartitionKey(String hivePartitionKey) { - this.hivePartitionKey = hivePartitionKey; - } - - public String getHivePartitionValue() { - return hivePartitionValue; - } - - public void setHivePartitionValue(String hivePartitionValue) { - this.hivePartitionValue = hivePartitionValue; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceMysqlParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceMysqlParameter.java deleted file mode 100644 index 9e5e81b311..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/sources/SourceMysqlParameter.java +++ /dev/null @@ -1,137 +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.common.task.sqoop.sources; - -import org.apache.dolphinscheduler.common.process.Property; - -import java.util.List; - -/** - * source mysql parameter - */ -public class SourceMysqlParameter { - - /** - * src datasource - */ - private int srcDatasource; - /** - * src table - */ - private String srcTable; - /** - * src query type - */ - private int srcQueryType; - /** - * src query sql - */ - private String srcQuerySql; - /** - * src column type - */ - private int srcColumnType; - /** - * src columns - */ - private String srcColumns; - /** - * src condition list - */ - private List srcConditionList; - /** - * map column hive - */ - private List mapColumnHive; - /** - * map column java - */ - private List mapColumnJava; - - public int getSrcDatasource() { - return srcDatasource; - } - - public void setSrcDatasource(int srcDatasource) { - this.srcDatasource = srcDatasource; - } - - public String getSrcTable() { - return srcTable; - } - - public void setSrcTable(String srcTable) { - this.srcTable = srcTable; - } - - public int getSrcQueryType() { - return srcQueryType; - } - - public void setSrcQueryType(int srcQueryType) { - this.srcQueryType = srcQueryType; - } - - public String getSrcQuerySql() { - return srcQuerySql; - } - - public void setSrcQuerySql(String srcQuerySql) { - this.srcQuerySql = srcQuerySql; - } - - public int getSrcColumnType() { - return srcColumnType; - } - - public void setSrcColumnType(int srcColumnType) { - this.srcColumnType = srcColumnType; - } - - public String getSrcColumns() { - return srcColumns; - } - - public void setSrcColumns(String srcColumns) { - this.srcColumns = srcColumns; - } - - public List getSrcConditionList() { - return srcConditionList; - } - - public void setSrcConditionList(List srcConditionList) { - this.srcConditionList = srcConditionList; - } - - public List getMapColumnHive() { - return mapColumnHive; - } - - public void setMapColumnHive(List mapColumnHive) { - this.mapColumnHive = mapColumnHive; - } - - public List getMapColumnJava() { - return mapColumnJava; - } - - public void setMapColumnJava(List mapColumnJava) { - this.mapColumnJava = mapColumnJava; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHdfsParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHdfsParameter.java deleted file mode 100644 index e60a123f00..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHdfsParameter.java +++ /dev/null @@ -1,98 +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.common.task.sqoop.targets; - -/** - * target hdfs parameter - */ -public class TargetHdfsParameter { - - /** - * target dir - */ - private String targetPath; - /** - * delete target dir - */ - private boolean deleteTargetDir; - /** - * file type - */ - private String fileType; - /** - * compression codec - */ - private String compressionCodec; - /** - * fields terminated - */ - private String fieldsTerminated; - /** - * lines terminated - */ - private String linesTerminated; - - public String getTargetPath() { - return targetPath; - } - - public void setTargetPath(String targetPath) { - this.targetPath = targetPath; - } - - public boolean isDeleteTargetDir() { - return deleteTargetDir; - } - - public void setDeleteTargetDir(boolean deleteTargetDir) { - this.deleteTargetDir = deleteTargetDir; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public String getCompressionCodec() { - return compressionCodec; - } - - public void setCompressionCodec(String compressionCodec) { - this.compressionCodec = compressionCodec; - } - - public String getFieldsTerminated() { - return fieldsTerminated; - } - - public void setFieldsTerminated(String fieldsTerminated) { - this.fieldsTerminated = fieldsTerminated; - } - - public String getLinesTerminated() { - return linesTerminated; - } - - public void setLinesTerminated(String linesTerminated) { - this.linesTerminated = linesTerminated; - } - -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHiveParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHiveParameter.java deleted file mode 100644 index eba17ee107..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetHiveParameter.java +++ /dev/null @@ -1,121 +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.common.task.sqoop.targets; - -/** - * target hive parameter - */ -public class TargetHiveParameter { - - /** - * hive database - */ - private String hiveDatabase; - /** - * hive table - */ - private String hiveTable; - /** - * create hive table - */ - private boolean createHiveTable; - /** - * drop delimiter - */ - private boolean dropDelimiter; - /** - * hive overwrite - */ - private boolean hiveOverWrite; - /** - * replace delimiter - */ - private String replaceDelimiter; - /** - * hive partition key - */ - private String hivePartitionKey; - /** - * hive partition value - */ - private String hivePartitionValue; - - public String getHiveDatabase() { - return hiveDatabase; - } - - public void setHiveDatabase(String hiveDatabase) { - this.hiveDatabase = hiveDatabase; - } - - public String getHiveTable() { - return hiveTable; - } - - public void setHiveTable(String hiveTable) { - this.hiveTable = hiveTable; - } - - public boolean isCreateHiveTable() { - return createHiveTable; - } - - public void setCreateHiveTable(boolean createHiveTable) { - this.createHiveTable = createHiveTable; - } - - public boolean isDropDelimiter() { - return dropDelimiter; - } - - public void setDropDelimiter(boolean dropDelimiter) { - this.dropDelimiter = dropDelimiter; - } - - public boolean isHiveOverWrite() { - return hiveOverWrite; - } - - public void setHiveOverWrite(boolean hiveOverWrite) { - this.hiveOverWrite = hiveOverWrite; - } - - public String getReplaceDelimiter() { - return replaceDelimiter; - } - - public void setReplaceDelimiter(String replaceDelimiter) { - this.replaceDelimiter = replaceDelimiter; - } - - public String getHivePartitionKey() { - return hivePartitionKey; - } - - public void setHivePartitionKey(String hivePartitionKey) { - this.hivePartitionKey = hivePartitionKey; - } - - public String getHivePartitionValue() { - return hivePartitionValue; - } - - public void setHivePartitionValue(String hivePartitionValue) { - this.hivePartitionValue = hivePartitionValue; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetMysqlParameter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetMysqlParameter.java deleted file mode 100644 index b16c77cb1c..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sqoop/targets/TargetMysqlParameter.java +++ /dev/null @@ -1,133 +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.common.task.sqoop.targets; - -/** - * target mysql parameter - */ -public class TargetMysqlParameter { - - /** - * target datasource - */ - private int targetDatasource; - /** - * target table - */ - private String targetTable; - /** - * target columns - */ - private String targetColumns; - /** - * fields terminated - */ - private String fieldsTerminated; - /** - * lines terminated - */ - private String linesTerminated; - /** - * pre query - */ - private String preQuery; - /** - * is update - */ - private boolean isUpdate; - /** - * target update key - */ - private String targetUpdateKey; - /** - * target update mode - */ - private String targetUpdateMode; - - public int getTargetDatasource() { - return targetDatasource; - } - - public void setTargetDatasource(int targetDatasource) { - this.targetDatasource = targetDatasource; - } - - public String getTargetTable() { - return targetTable; - } - - public void setTargetTable(String targetTable) { - this.targetTable = targetTable; - } - - public String getTargetColumns() { - return targetColumns; - } - - public void setTargetColumns(String targetColumns) { - this.targetColumns = targetColumns; - } - - public String getFieldsTerminated() { - return fieldsTerminated; - } - - public void setFieldsTerminated(String fieldsTerminated) { - this.fieldsTerminated = fieldsTerminated; - } - - public String getLinesTerminated() { - return linesTerminated; - } - - public void setLinesTerminated(String linesTerminated) { - this.linesTerminated = linesTerminated; - } - - public String getPreQuery() { - return preQuery; - } - - public void setPreQuery(String preQuery) { - this.preQuery = preQuery; - } - - public boolean getIsUpdate() { - return isUpdate; - } - - public void setUpdate(boolean update) { - isUpdate = update; - } - - public String getTargetUpdateKey() { - return targetUpdateKey; - } - - public void setTargetUpdateKey(String targetUpdateKey) { - this.targetUpdateKey = targetUpdateKey; - } - - public String getTargetUpdateMode() { - return targetUpdateMode; - } - - public void setTargetUpdateMode(String targetUpdateMode) { - this.targetUpdateMode = targetUpdateMode; - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/tis/PigeonCommonParameters.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/tis/PigeonCommonParameters.java deleted file mode 100644 index 6606cc13e9..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/tis/PigeonCommonParameters.java +++ /dev/null @@ -1,58 +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.common.task.tis; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.utils.StringUtils; - -import java.util.Collections; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * TIS parameter - */ -public class PigeonCommonParameters extends AbstractParameters { - - private static final Logger logger = LoggerFactory.getLogger(PigeonCommonParameters.class); - /** - * TIS target job name - */ - private String jobName; - - public String getTargetJobName() { - return jobName; - } - - public void setTargetJobName(String jobName) { - this.jobName = jobName; - } - - @Override - public boolean checkParameters() { - return StringUtils.isNotBlank(this.jobName); - } - - @Override - public List getResourceFilesList() { - return Collections.emptyList(); - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java index a48ed1f29d..0ac3b5db01 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/CollectionUtils.java @@ -23,7 +23,6 @@ import org.apache.commons.beanutils.BeanMap; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java index aab69e0929..189cbbf040 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java @@ -20,9 +20,9 @@ package org.apache.dolphinscheduler.common.utils; import static org.apache.dolphinscheduler.common.Constants.RESOURCE_UPLOAD_PATH; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.ResUploadType; import org.apache.dolphinscheduler.common.exception.BaseException; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.io.IOUtils; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java index 23d0f44636..92875e8991 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java @@ -28,7 +28,6 @@ import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.io.IOException; -import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java index 0d7055e60c..8dd4969494 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java @@ -18,7 +18,7 @@ package org.apache.dolphinscheduler.common.utils; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.spi.task.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import java.io.BufferedReader; import java.io.FileInputStream; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java index ed109f77b3..66a59f1668 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ParameterUtils.java @@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.common.utils; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -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.dolphinscheduler.plugin.task.api.model.Property; import org.apache.commons.lang.StringUtils; @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -152,7 +153,7 @@ public class ParameterUtils { */ public static Map convert(Map paramsMap) { Map map = new HashMap<>(); - Iterator> iter = paramsMap.entrySet().iterator(); + Iterator> iter = paramsMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry en = iter.next(); map.put(en.getKey(), en.getValue().getValue()); diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtils.java deleted file mode 100644 index e47654411b..0000000000 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtils.java +++ /dev/null @@ -1,106 +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.common.utils; - -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.common.task.blocking.BlockingParameters; -import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters; -import org.apache.dolphinscheduler.common.task.datax.DataxParameters; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.task.dq.DataQualityParameters; -import org.apache.dolphinscheduler.common.task.emr.EmrParameters; -import org.apache.dolphinscheduler.common.task.flink.FlinkParameters; -import org.apache.dolphinscheduler.common.task.http.HttpParameters; -import org.apache.dolphinscheduler.common.task.mr.MapReduceParameters; -import org.apache.dolphinscheduler.common.task.procedure.ProcedureParameters; -import org.apache.dolphinscheduler.common.task.python.PythonParameters; -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.sqoop.SqoopParameters; -import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; -import org.apache.dolphinscheduler.common.task.tis.PigeonCommonParameters; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * task parameters utils - */ -public class TaskParametersUtils { - - private static final Logger logger = LoggerFactory.getLogger(TaskParametersUtils.class); - - private TaskParametersUtils() { - throw new UnsupportedOperationException("Construct TaskParametersUtils"); - } - - /** - * get task parameters - * - * @param taskType task type - * @param parameter parameter - * @return task parameters - */ - public static AbstractParameters getParameters(String taskType, String parameter) { - switch (taskType) { - case "SUB_PROCESS": - return JSONUtils.parseObject(parameter, SubProcessParameters.class); - case "SHELL": - case "SEATUNNEL": - return JSONUtils.parseObject(parameter, ShellParameters.class); - case "PROCEDURE": - return JSONUtils.parseObject(parameter, ProcedureParameters.class); - case "SQL": - return JSONUtils.parseObject(parameter, SqlParameters.class); - case "MR": - return JSONUtils.parseObject(parameter, MapReduceParameters.class); - case "SPARK": - return JSONUtils.parseObject(parameter, SparkParameters.class); - case "PYTHON": - return JSONUtils.parseObject(parameter, PythonParameters.class); - case "DEPENDENT": - return JSONUtils.parseObject(parameter, DependentParameters.class); - case "FLINK": - return JSONUtils.parseObject(parameter, FlinkParameters.class); - case "HTTP": - return JSONUtils.parseObject(parameter, HttpParameters.class); - case "DATAX": - return JSONUtils.parseObject(parameter, DataxParameters.class); - case "CONDITIONS": - return JSONUtils.parseObject(parameter, ConditionsParameters.class); - case "SQOOP": - return JSONUtils.parseObject(parameter, SqoopParameters.class); - case "DATA_QUALITY": - return JSONUtils.parseObject(parameter, DataQualityParameters.class); - case "SWITCH": - return JSONUtils.parseObject(parameter, SwitchParameters.class); - case "BLOCKING": - return JSONUtils.parseObject(parameter, BlockingParameters.class); - case "PIGEON": - return JSONUtils.parseObject(parameter, PigeonCommonParameters.class); - case "EMR": - return JSONUtils.parseObject(parameter, EmrParameters.class); - default: - logger.error("not support task type: {}", taskType); - return null; - } - - } -} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java index dc2c8cfe0f..23de2d1753 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/BusinessTimeUtils.java @@ -17,6 +17,12 @@ package org.apache.dolphinscheduler.common.utils.placeholder; +import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_DATE; +import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_TIME; +import static org.apache.dolphinscheduler.common.utils.DateUtils.format; + +import static org.apache.commons.lang.time.DateUtils.addDays; + import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; @@ -24,12 +30,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_DATE; -import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_TIME; -import static org.apache.dolphinscheduler.common.utils.DateUtils.format; -import static org.apache.commons.lang.time.DateUtils.addDays; - - /** * business time utils */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/PlaceholderUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/PlaceholderUtils.java index 39b59a04d6..217aa75063 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/PlaceholderUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/placeholder/PlaceholderUtils.java @@ -14,13 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.common.utils.placeholder; +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; - /** * placeholder utils */ @@ -39,7 +40,6 @@ public class PlaceholderUtils { public static final String PLACEHOLDER_SUFFIX = "}"; - /** * Replaces all placeholders of format {@code ${name}} with the value returned * from the supplied {@link PropertyPlaceholderHelper.PlaceholderResolver}. @@ -94,11 +94,10 @@ public class PlaceholderUtils { try { return paramsMap.get(placeholderName); } catch (Exception ex) { - logger.error("resolve placeholder '{}' in [ {} ]" , placeholderName, value, ex); + logger.error("resolve placeholder '{}' in [ {} ]", placeholderName, value, ex); return null; } } } - } diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/ConstantsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/ConstantsTest.java index 3f2c3016ba..dec8b4e2da 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/ConstantsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/ConstantsTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.common; import org.apache.commons.lang.SystemUtils; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataQualityParameterTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataQualityParameterTest.java deleted file mode 100644 index f402209add..0000000000 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataQualityParameterTest.java +++ /dev/null @@ -1,132 +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.common.task; - -import org.apache.dolphinscheduler.common.task.dq.DataQualityParameters; -import org.apache.dolphinscheduler.common.task.spark.SparkParameters; -import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; -import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.params.base.TriggerType; -import org.apache.dolphinscheduler.spi.params.base.Validate; -import org.apache.dolphinscheduler.spi.params.input.InputParam; -import org.apache.dolphinscheduler.spi.params.input.InputParamProps; -import org.apache.dolphinscheduler.spi.params.select.SelectParam; -import org.apache.dolphinscheduler.spi.params.select.SelectParamProps; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * DataQualityParameterTest - */ -public class DataQualityParameterTest { - - private DataQualityParameters dataQualityParameters = null; - - @Before - public void before() { - dataQualityParameters = new DataQualityParameters(); - dataQualityParameters.setRuleId(1); - dataQualityParameters.setSparkParameters(new SparkParameters()); - } - - @Test - public void testCheckParameterNormal() { - - Map inputParameterValue = new HashMap<>(); - inputParameterValue.put("src_connector_type","JDBC"); - inputParameterValue.put("src_datasource_id","1"); - inputParameterValue.put("src_table","test1"); - inputParameterValue.put("src_filter","date=2012-10-05"); - inputParameterValue.put("src_field","id"); - - inputParameterValue.put("rule_type","1"); - inputParameterValue.put("process_definition_id","1"); - inputParameterValue.put("task_instance_id","1"); - inputParameterValue.put("check_type","1"); - inputParameterValue.put("threshold","1000"); - inputParameterValue.put("create_time","2012-10-05"); - inputParameterValue.put("update_time","2012-10-05"); - - dataQualityParameters.setRuleInputParameter(inputParameterValue); - - Assert.assertTrue(dataQualityParameters.checkParameters()); - } - - @Test - public void testRuleInputParameter() { - String formCreateJson = "[{\"field\":\"src_connector_type\",\"name\":\"源数据类型\"," - + "\"props\":{\"disabled\":false,\"multiple\":false,\"size\":\"small\"}," - + "\"type\":\"select\",\"title\":\"源数据类型\",\"value\":\"JDBC\"," - + "\"options\":[{\"label\":\"HIVE\",\"value\":\"HIVE\",\"disabled\":false}," - + "{\"label\":\"JDBC\",\"value\":\"JDBC\",\"disabled\":false}]}," - + "{\"props\":{\"disabled\":false,\"rows\":0,\"placeholder\":\"Please enter source table name\"," - + "\"size\":\"small\"},\"field\":\"src_table\",\"name\":\"源数据表\"," - + "\"type\":\"input\",\"title\":\"源数据表\",\"validate\":[{\"required\":true,\"type\":\"string\"," - + "\"trigger\":\"blur\"}]}]"; - - List pluginParamsList = new ArrayList<>(); - SelectParamProps selectParamProps = new SelectParamProps(); - selectParamProps.setMultiple(false); - selectParamProps.setDisabled(false); - selectParamProps.setSize("small"); - - SelectParam srcConnectorType = SelectParam.newBuilder("src_connector_type","源数据类型") - .setProps(selectParamProps) - .addOptions(new ParamsOptions("HIVE","HIVE",false)) - .addOptions(new ParamsOptions("JDBC","JDBC",false)) - .setValue("JDBC") - .build(); - - InputParamProps inputParamProps = new InputParamProps(); - inputParamProps.setPlaceholder("Please enter source table name"); - inputParamProps.setDisabled(false); - inputParamProps.setSize("small"); - inputParamProps.setRows(0); - - InputParam srcTable = InputParam.newBuilder("src_table","源数据表") - .setProps(inputParamProps) - .addValidate(Validate.newBuilder().setType("string").setRequired(true).setTrigger(TriggerType.BLUR.getTriggerType()).build()) - .build(); - - pluginParamsList.add(srcConnectorType); - pluginParamsList.add(srcTable); - - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - String result = null; - - try { - result = mapper.writeValueAsString(pluginParamsList); - } catch (JsonProcessingException e) { - Assert.fail(); - } - - Assert.assertEquals(formCreateJson,result); - } -} diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java index 1135442b1f..b32640c189 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/JSONUtilsTest.java @@ -17,10 +17,10 @@ package org.apache.dolphinscheduler.common.utils; -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.apache.dolphinscheduler.plugin.task.api.enums.DataType; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClientTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClientTest.java index 9911961ac0..b3017166f2 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClientTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClientTest.java @@ -14,9 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.common.utils; import org.apache.dolphinscheduler.common.Constants; + import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java index cf629ca631..d897696fca 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.common.utils; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/ParameterUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/ParameterUtilsTest.java index 9ebfd69430..aff76fb785 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/ParameterUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/ParameterUtilsTest.java @@ -21,10 +21,10 @@ import static org.apache.dolphinscheduler.common.utils.placeholder.TimePlacehold import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.DataType; -import org.apache.dolphinscheduler.common.enums.Direct; -import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.placeholder.PlaceholderUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.text.ParseException; import java.util.ArrayList; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtilsTest.java deleted file mode 100644 index 5fd35f327b..0000000000 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/TaskParametersUtilsTest.java +++ /dev/null @@ -1,40 +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.common.utils; - -import org.apache.dolphinscheduler.common.enums.TaskType; - -import org.junit.Assert; -import org.junit.Test; - -public class TaskParametersUtilsTest { - - @Test - public void testGetParameters() { - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.SHELL.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.SQL.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.SUB_PROCESS.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.PROCEDURE.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.MR.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.SPARK.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.PYTHON.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.DEPENDENT.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.FLINK.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.HTTP.getDesc(), "{}")); - Assert.assertNotNull(TaskParametersUtils.getParameters(TaskType.PIGEON.getDesc(), "{}")); - } -} diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/MonitorDBDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/MonitorDBDao.java index a5d3ae29d8..f71e1b6266 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/MonitorDBDao.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/MonitorDBDao.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao; import org.apache.dolphinscheduler.dao.entity.MonitorRecord; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java index 516e16ad42..d477972ff1 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java @@ -73,7 +73,7 @@ public class SpringConnectionFactory { sqlSessionFactoryBean.setTypeAliasesPackage("org.apache.dolphinscheduler.dao.entity"); ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); sqlSessionFactoryBean.setMapperLocations(resolver.getResources("org/apache/dolphinscheduler/dao/mapper/*Mapper.xml")); - sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.*.enums"); + sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.**.enums"); sqlSessionFactoryBean.setDatabaseIdProvider(databaseIdProvider()); return sqlSessionFactoryBean.getObject(); } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java index 66aab3c559..56f976173b 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AccessToken.java @@ -14,15 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; +import java.util.Date; + 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 java.util.Date; - @TableName("t_ds_access_token") public class AccessToken { /** @@ -162,14 +163,14 @@ public class AccessToken { @Override public String toString() { - return "AccessToken{" + - "id=" + id + - ", userId=" + userId + - ", token='" + token + '\'' + - ", userName='" + userName + '\'' + - ", expireTime=" + expireTime + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; + return "AccessToken{" + + "id=" + id + + ", userId=" + userId + + ", token='" + token + '\'' + + ", userName='" + userName + '\'' + + ", expireTime=" + expireTime + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + '}'; } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CommandCount.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CommandCount.java index df99b54dbe..9dc04c6d6a 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CommandCount.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CommandCount.java @@ -14,14 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.entity; +package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.CommandType; public class CommandCount { - /** * execution state */ @@ -32,7 +31,6 @@ public class CommandCount { */ private int count; - public CommandType getCommandType() { return commandType; } @@ -76,9 +74,9 @@ public class CommandCount { @Override public String toString() { - return "CommandCount{" + - "commandType=" + commandType + - ", count=" + count + - '}'; + return "CommandCount{" + + "commandType=" + commandType + + ", count=" + count + + '}'; } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CycleDependency.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CycleDependency.java index e7ad38b6ea..02f9dbd75d 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CycleDependency.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/CycleDependency.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.CycleEnum; @@ -41,7 +42,6 @@ public class CycleDependency { */ private CycleEnum cycleEnum; - public CycleDependency(int processDefineId, Date lastScheduleTime, Date expirationTime, CycleEnum cycleEnum) { this.processDefineId = processDefineId; this.lastScheduleTime = lastScheduleTime; @@ -83,11 +83,11 @@ public class CycleDependency { @Override public String toString() { - return "CycleDependency{" + - "processDefineId=" + processDefineId + - ", lastScheduleTime=" + lastScheduleTime + - ", expirationTime=" + expirationTime + - ", cycleEnum=" + cycleEnum + - '}'; + return "CycleDependency{" + + "processDefineId=" + processDefineId + + ", lastScheduleTime=" + lastScheduleTime + + ", expirationTime=" + expirationTime + + ", cycleEnum=" + cycleEnum + + '}'; } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java index 39f62c8ddb..68120cafe8 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DataSource.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.spi.enums.DbType; @@ -27,167 +28,165 @@ import com.baomidou.mybatisplus.annotation.TableName; @TableName("t_ds_datasource") public class DataSource { - /** - * id - */ - @TableId(value="id", type=IdType.AUTO) - private int id; - - /** - * user id - */ - private int userId; - - /** - * user name - */ - @TableField(exist = false) - private String userName; - - /** - * data source name - */ - private String name; - - /** - * note - */ - private String note; - - /** - * data source type - */ - private DbType type; - - /** - * connection parameters - */ - private String connectionParams; - - /** - * create time - */ - private Date createTime; - - /** - * update time - */ - private Date updateTime; - - public DataSource() { - } - - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getUserId() { - return userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } - - public DbType getType() { - return type; - } - - public void setType(DbType type) { - this.type = type; - } - - public String getConnectionParams() { - return connectionParams; - } - - public void setConnectionParams(String connectionParams) { - this.connectionParams = connectionParams; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - - @Override - public String toString() { - return "DataSource{" + - "id=" + id + - ", userId=" + userId + - ", userName='" + userName + '\'' + - ", name='" + name + '\'' + - ", note='" + note + '\'' + - ", type=" + type + - ", connectionParams='" + connectionParams + '\'' + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; - } + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * user id + */ + private int userId; + + /** + * user name + */ + @TableField(exist = false) + private String userName; + + /** + * data source name + */ + private String name; + + /** + * note + */ + private String note; + + /** + * data source type + */ + private DbType type; + + /** + * connection parameters + */ + private String connectionParams; + + /** + * create time + */ + private Date createTime; + + /** + * update time + */ + private Date updateTime; + + public DataSource() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public String getUserName() { + return userName; } - if (o == null || getClass() != o.getClass()) { - return false; + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; } - DataSource that = (DataSource) o; + public String getNote() { + return note; + } - if (id != that.id) { - return false; + public void setNote(String note) { + this.note = note; } - return name.equals(that.name); - } + public DbType getType() { + return type; + } - @Override - public int hashCode() { - int result = id; - result = 31 * result + name.hashCode(); - return result; - } + public void setType(DbType type) { + this.type = type; + } + + public String getConnectionParams() { + return connectionParams; + } + + public void setConnectionParams(String connectionParams) { + this.connectionParams = connectionParams; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "DataSource{" + + "id=" + id + + ", userId=" + userId + + ", userName='" + userName + '\'' + + ", name='" + name + '\'' + + ", note='" + note + '\'' + + ", type=" + type + + ", connectionParams='" + connectionParams + '\'' + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DataSource that = (DataSource) o; + + if (id != that.id) { + return false; + } + return name.equals(that.name); + + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + name.hashCode(); + return result; + } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java index 805f075bfb..6f18d0c9ee 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java @@ -14,108 +14,108 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; +import java.util.Date; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; - /** * data source user relation */ @TableName("t_ds_relation_datasource_user") public class DatasourceUser { - /** - * id - */ - @TableId(value="id", type=IdType.AUTO) - private int id; - - /** - * user id - */ - private int userId; - - /** - * data source id - */ - private int datasourceId; - - /** - * permission - */ - private int perm; - /** - * create time - */ - private Date createTime; - - /** - * update time - */ - private Date updateTime; - - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getUserId() { - return userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public int getDatasourceId() { - return datasourceId; - } - - public void setDatasourceId(int datasourceId) { - this.datasourceId = datasourceId; - } - - public int getPerm() { - return perm; - } - - public void setPerm(int perm) { - this.perm = perm; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - @Override - public String toString() { - return "DatasourceUser{" + - "id=" + id + - ", userId=" + userId + - ", datasourceId=" + datasourceId + - ", perm=" + perm + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; - } + /** + * id + */ + @TableId(value = "id", type = IdType.AUTO) + private int id; + + /** + * user id + */ + private int userId; + + /** + * data source id + */ + private int datasourceId; + + /** + * permission + */ + private int perm; + /** + * create time + */ + private Date createTime; + + /** + * update time + */ + private Date updateTime; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getUserId() { + return userId; + } + + public void setUserId(int userId) { + this.userId = userId; + } + + public int getDatasourceId() { + return datasourceId; + } + + public void setDatasourceId(int datasourceId) { + this.datasourceId = datasourceId; + } + + public int getPerm() { + return perm; + } + + public void setPerm(int perm) { + this.perm = perm; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public String toString() { + return "DatasourceUser{" + + "id=" + id + + ", userId=" + userId + + ", datasourceId=" + datasourceId + + ", perm=" + perm + + ", createTime=" + createTime + + ", updateTime=" + updateTime + + '}'; + } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DefinitionGroupByUser.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DefinitionGroupByUser.java index 12f1a5fbe4..bd20386fb0 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DefinitionGroupByUser.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DefinitionGroupByUser.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; /** diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java index 3952b40b23..109a6f7e2b 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DependentProcessDefinition.java @@ -19,10 +19,10 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CycleEnum; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import java.util.List; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleExecuteSql.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleExecuteSql.java index dfffe09e4c..d349b63f34 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleExecuteSql.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleExecuteSql.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.dao.entity; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; import java.io.Serializable; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleInputEntry.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleInputEntry.java index 5e7c259148..63659f5688 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleInputEntry.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DqRuleInputEntry.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.dao.entity; -import org.apache.dolphinscheduler.spi.task.dq.enums.InputType; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ValueType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ValueType; import java.io.Serializable; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/EnvironmentWorkerGroupRelation.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/EnvironmentWorkerGroupRelation.java index feb4a7aac5..14bce3959f 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/EnvironmentWorkerGroupRelation.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/EnvironmentWorkerGroupRelation.java @@ -17,12 +17,12 @@ package org.apache.dolphinscheduler.dao.entity; +import java.util.Date; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import java.util.Date; - /** * EnvironmentWorkerGroupRelation */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ExecuteStatusCount.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ExecuteStatusCount.java index 0e877a60f8..4452156b55 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ExecuteStatusCount.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ExecuteStatusCount.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.entity; +package org.apache.dolphinscheduler.dao.entity; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; /** * count execute state @@ -53,9 +53,9 @@ public class ExecuteStatusCount { @Override public String toString() { - return "ExecuteStatusCount{" + - "state=" + state + - ", count=" + count + - '}'; + return "ExecuteStatusCount{" + + "state=" + state + + ", count=" + count + + '}'; } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/K8s.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/K8s.java index 2cddf171e2..9f2ef2ff77 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/K8s.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/K8s.java @@ -56,7 +56,6 @@ public class K8s { @TableField("update_time") private Date updateTime; - public K8s() { } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/MonitorRecord.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/MonitorRecord.java index af458d88e2..80cd06d528 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/MonitorRecord.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/MonitorRecord.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.Flag; @@ -21,7 +22,6 @@ import org.apache.dolphinscheduler.spi.enums.DbType; import java.util.Date; - /** * monitor record for database */ @@ -109,15 +109,15 @@ public class MonitorRecord { @Override public String toString() { - return "MonitorRecord{" + - "state=" + state + - ", dbType=" + dbType + - ", maxConnections=" + maxConnections + - ", maxUsedConnections=" + maxUsedConnections + - ", threadsConnections=" + threadsConnections + - ", threadsRunningConnections=" + threadsRunningConnections + - ", date=" + date + - '}'; + return "MonitorRecord{" + + "state=" + state + + ", dbType=" + dbType + + ", maxConnections=" + maxConnections + + ", maxUsedConnections=" + maxUsedConnections + + ", threadsConnections=" + threadsConnections + + ", threadsRunningConnections=" + threadsRunningConnections + + ", date=" + date + + '}'; } public DbType getDbType() { diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessAlertContent.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessAlertContent.java index 3688ba1b08..fc7129a2f6 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessAlertContent.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessAlertContent.java @@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.AlertEvent; import org.apache.dolphinscheduler.common.enums.AlertWarnLevel; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.io.Serializable; import java.util.Date; @@ -148,6 +148,7 @@ public class ProcessAlertContent implements Serializable { this.projectId = projectId; return this; } + public Builder projectCode(Long projectCode) { this.projectCode = projectCode; return this; @@ -167,6 +168,7 @@ public class ProcessAlertContent implements Serializable { this.processId = processId; return this; } + public Builder processDefinitionCode(Long processDefinitionCode) { this.processDefinitionCode = processDefinitionCode; return this; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessData.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessData.java index e9a6d994e8..005f8cb51d 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessData.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessData.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.CollectionUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.util.List; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java index c0c98d1fd1..f68ad065b3 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java @@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ReleaseState; -import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java index 41fde2456e..8f639efc07 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstance.java @@ -18,13 +18,13 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.utils.DateUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java index 58e5411563..4cd2186f18 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessInstanceMap.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import com.baomidou.mybatisplus.annotation.IdType; @@ -29,7 +30,7 @@ public class ProcessInstanceMap { /** * id */ - @TableId(value="id", type=IdType.AUTO) + @TableId(value = "id", type = IdType.AUTO) private int id; /** @@ -81,12 +82,12 @@ public class ProcessInstanceMap { @Override public String toString() { - return "ProcessInstanceMap{" + - "id=" + id + - ", parentProcessInstanceId=" + parentProcessInstanceId + - ", parentTaskInstanceId=" + parentTaskInstanceId + - ", processInstanceId=" + processInstanceId + - '}'; + return "ProcessInstanceMap{" + + "id=" + id + + ", parentProcessInstanceId=" + parentProcessInstanceId + + ", parentTaskInstanceId=" + parentTaskInstanceId + + ", processInstanceId=" + processInstanceId + + '}'; } @Override diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java index 82e5cd7a8f..2a41c01306 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Project.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java index 37722f3c79..bf959b493b 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectUser.java @@ -14,21 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; +import java.util.Date; + 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 java.util.Date; - @TableName("t_ds_relation_project_user") public class ProjectUser { /** * id */ - @TableId(value="id", type=IdType.AUTO) + @TableId(value = "id", type = IdType.AUTO) private int id; @TableField("user_id") diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskAlertContent.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskAlertContent.java index 3b79844643..f8e361e9ed 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskAlertContent.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskAlertContent.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.dao.entity; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.io.Serializable; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java index d78c46a688..7ebc415617 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java @@ -20,10 +20,10 @@ package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.commons.lang.StringUtils; @@ -475,6 +475,7 @@ public class TaskDefinition { && taskGroupId == that.taskGroupId && taskGroupPriority == that.taskGroupPriority; } + @Override public String toString() { return "TaskDefinition{" diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskGroupQueue.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskGroupQueue.java index e2e211c159..6399f12ada 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskGroupQueue.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskGroupQueue.java @@ -17,15 +17,16 @@ package org.apache.dolphinscheduler.dao.entity; -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 org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import java.io.Serializable; import java.util.Date; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + /** * Task Group Queue */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java index d48ad66d19..6ab0c340f1 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskInstance.java @@ -18,16 +18,20 @@ package org.apache.dolphinscheduler.dao.entity; import static org.apache.dolphinscheduler.common.Constants.SEC_2_MINUTES_TIME_UNIT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SWITCH; import org.apache.dolphinscheduler.common.Constants; -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.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import java.io.Serializable; import java.util.Date; @@ -579,23 +583,23 @@ public class TaskInstance implements Serializable { } public boolean isSubProcess() { - return TaskType.SUB_PROCESS.getDesc().equalsIgnoreCase(this.taskType); + return TASK_TYPE_SUB_PROCESS.equalsIgnoreCase(this.taskType); } public boolean isDependTask() { - return TaskType.DEPENDENT.getDesc().equalsIgnoreCase(this.taskType); + return TASK_TYPE_DEPENDENT.equalsIgnoreCase(this.taskType); } public boolean isConditionsTask() { - return TaskType.CONDITIONS.getDesc().equalsIgnoreCase(this.taskType); + return TASK_TYPE_CONDITIONS.equalsIgnoreCase(this.taskType); } public boolean isSwitchTask() { - return TaskType.SWITCH.getDesc().equalsIgnoreCase(this.taskType); + return TASK_TYPE_SWITCH.equalsIgnoreCase(this.taskType); } public boolean isBlockingTask() { - return TaskType.BLOCKING.getDesc().equalsIgnoreCase(this.taskType); + return TASK_TYPE_BLOCKING.equalsIgnoreCase(this.taskType); } /** diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskMainInfo.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskMainInfo.java index fef401e35a..6fefd47990 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskMainInfo.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskMainInfo.java @@ -22,7 +22,6 @@ import org.apache.dolphinscheduler.common.enums.ReleaseState; import java.util.Date; import java.util.Map; - /** * task main info */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskRecord.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskRecord.java index 2247b38aee..5cfa095cec 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskRecord.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskRecord.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.entity; +package org.apache.dolphinscheduler.dao.entity; import java.util.Date; @@ -234,9 +234,9 @@ public class TaskRecord { } @Override - public String toString(){ + public String toString() { return "task record, id:" + id - +" proc id:" + procId + + " proc id:" + procId + " proc name:" + procName + " proc date: " + procDate + " start date:" + startTime diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java index 153bf353ff..c0e61fffd7 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.entity; +package org.apache.dolphinscheduler.dao.entity; import org.apache.dolphinscheduler.common.enums.UserType; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkFlowLineage.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkFlowLineage.java index b3fc56c3e7..68b63141c5 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkFlowLineage.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkFlowLineage.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerServer.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerServer.java index f536c90aa7..3fbbf71f74 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerServer.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/WorkerServer.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.entity; +package org.apache.dolphinscheduler.dao.entity; import java.util.Date; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.java index 3c73a56bbf..602af602d5 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.java @@ -21,12 +21,12 @@ import org.apache.dolphinscheduler.dao.entity.AccessToken; import org.apache.ibatis.annotations.Param; +import java.util.List; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import java.util.List; - /** * accesstoken mapper interface */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java index 22913845c3..c1e30fdfb5 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java @@ -14,18 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.mapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; +package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.CommandCount; + import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + /** * command mapper interface */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java index bfb0640386..15b5a3db0f 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java @@ -14,15 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.DataSource; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; + import org.apache.ibatis.annotations.Param; import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; + /** * datasource mapper interface */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.java index 28a89c6fc1..df51ebe33e 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapper.java @@ -14,12 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.DatasourceUser; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; + import org.apache.ibatis.annotations.Param; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + /** * datasource user realtion mapper interface */ @@ -40,5 +43,4 @@ public interface DataSourceUserMapper extends BaseMapper { */ int deleteByDatasourceId(@Param("datasourceId") int datasourceId); - } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java index c814260783..acd9ce79cb 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java @@ -14,16 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.CommandCount; import org.apache.dolphinscheduler.dao.entity.ErrorCommand; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; + import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + /** * error command mapper interface */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.java index 0e5a38140f..0397d37154 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapper.java @@ -14,14 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + /** * process instance map mapper interface */ diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java index 6bfb4cfd37..bc4ea7caca 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.ibatis.annotations.Param; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.java index b6947210be..b5496c438d 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapper.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.ProjectUser; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapper.java index 6fe80bda99..d12ad9d0d2 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapper.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.dao.mapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.dolphinscheduler.dao.entity.TaskGroup; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * the Dao interfaces of task group diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.java index 24938e4f8d..5fda409432 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.dao.mapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; @@ -27,6 +26,7 @@ import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * the Dao interfaces of task group queue diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java index 17c4672a28..a79a07ca27 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java @@ -17,10 +17,10 @@ package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.ibatis.annotations.Param; diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.java index b7351f4b49..85cf4833ae 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapper.java @@ -41,7 +41,7 @@ public interface UdfFuncMapper extends BaseMapper { * @param funcNames funcNames * @return udf function list */ - List queryUdfByIdStr(@Param("ids") int[] ids, + List queryUdfByIdStr(@Param("ids") Integer[] ids, @Param("funcNames") String funcNames); /** diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BaseDBPerformance.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BaseDBPerformance.java index a26af6713f..4ba722d245 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BaseDBPerformance.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BaseDBPerformance.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.utils; import org.apache.dolphinscheduler.dao.entity.MonitorRecord; @@ -25,7 +26,6 @@ import java.sql.Connection; */ public abstract class BaseDBPerformance { - /** * return the current database performance * @param conn connection diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BeanContext.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BeanContext.java index 6767c3d6db..4bf4dbdb83 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BeanContext.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/BeanContext.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.utils; +package org.apache.dolphinscheduler.dao.utils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; @@ -26,10 +26,10 @@ import org.springframework.stereotype.Component; * bean context */ @Component - public class BeanContext implements ApplicationContextAware { +public class BeanContext implements ApplicationContextAware { private static ApplicationContext applicationContext; - public static ApplicationContext getApplicationContext(){ + public static ApplicationContext getApplicationContext() { return applicationContext; } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java index 4c190413c4..0531791423 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java @@ -22,12 +22,12 @@ 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.task.conditions.ConditionsParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchResultVo; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import org.apache.commons.collections.CollectionUtils; diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java index 951311672a..ca0a447f9a 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; import org.junit.Assert; @@ -34,7 +35,5 @@ public class ProcessDefinitionTest { taskInstance.getGlobalParamMap(); Assert.assertEquals("{selenium_global_parameters_1=selenium_global_parameters_value_1}",taskInstance.getGlobalParamMap().toString()); - - } } diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java index 9e938bbf67..33c5cc9568 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/TaskInstanceTest.java @@ -14,15 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.entity; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; + import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import java.util.ArrayList; import java.util.List; @@ -40,19 +43,19 @@ public class TaskInstanceTest { TaskInstance taskInstance = new TaskInstance(); //sub process - taskInstance.setTaskType(TaskType.SUB_PROCESS.getDesc()); + taskInstance.setTaskType(TASK_TYPE_SUB_PROCESS); Assert.assertTrue(taskInstance.isSubProcess()); //not sub process - taskInstance.setTaskType(TaskType.HTTP.getDesc()); + taskInstance.setTaskType("HTTP"); Assert.assertFalse(taskInstance.isSubProcess()); //sub process - taskInstance.setTaskType(TaskType.CONDITIONS.getDesc()); + taskInstance.setTaskType(TASK_TYPE_CONDITIONS); Assert.assertTrue(taskInstance.isConditionsTask()); //sub process - taskInstance.setTaskType(TaskType.DEPENDENT.getDesc()); + taskInstance.setTaskType(TASK_TYPE_DEPENDENT); Assert.assertTrue(taskInstance.isDependTask()); } diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java index 3910d297cd..aa1c42e144 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import static org.hamcrest.MatcherAssert.assertThat; @@ -186,7 +187,6 @@ public class AccessTokenMapperTest extends BaseDaoTest { assertNull(resultAccessToken); } - /** * create accessTokens * diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java index 301dd9ca42..949bf7bbd5 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java @@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.dao.mapper; import static java.util.stream.Collectors.toList; + import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java index 1f267c70cd..35146a9ade 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceUserMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.BaseDaoTest; @@ -52,7 +53,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest { * test update */ @Test - public void testUpdate(){ + public void testUpdate() { //insertOne DatasourceUser dataSourceUser = insertOne(); //update @@ -65,7 +66,7 @@ public class DataSourceUserMapperTest extends BaseDaoTest { * test delete */ @Test - public void testDelete(){ + public void testDelete() { DatasourceUser dataSourceUser = insertOne(); int delete = dataSourceUserMapper.deleteById(dataSourceUser.getId()); diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java index 264e734918..27c9467109 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapperTest.java @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.dao.mapper; +package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.dao.BaseDaoTest; @@ -42,7 +42,7 @@ public class ErrorCommandMapperTest extends BaseDaoTest { * insert * @return ErrorCommand */ - private ErrorCommand insertOne(){ + private ErrorCommand insertOne() { //insertOne ErrorCommand errorCommand = new ErrorCommand(); errorCommand.setId(10101); @@ -76,7 +76,6 @@ public class ErrorCommandMapperTest extends BaseDaoTest { errorCommand.setProcessDefinitionCode(processDefinition.getCode()); errorCommandMapper.updateById(errorCommand); - List commandCounts = errorCommandMapper.countCommandState( null, null, diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java index a05ff25d27..e01e4731a4 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.BaseDaoTest; @@ -49,7 +50,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest { * test update */ @Test - public void testUpdate(){ + public void testUpdate() { //insertOne ProcessInstanceMap processInstanceMap = insertOne(); //update @@ -62,7 +63,7 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest { * test delete */ @Test - public void testDelete(){ + public void testDelete() { ProcessInstanceMap processInstanceMap = insertOne(); int delete = processInstanceMapMapper.deleteById(processInstanceMap.getId()); Assert.assertEquals(1, delete); @@ -89,11 +90,8 @@ public class ProcessInstanceMapMapperTest extends BaseDaoTest { processInstanceMap.setParentProcessInstanceId(100); processInstanceMapMapper.updateById(processInstanceMap); - } - - /** * test delete by parent process instance id */ diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java index 8159c65f86..c5f2d28ce1 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapperTest.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.dao.BaseDaoTest; @@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Project; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Date; import java.util.List; @@ -155,7 +156,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { @Test public void testQueryProcessInstanceListPaging() { - int[] stateArray = new int[]{ ExecutionStatus.RUNNING_EXECUTION.ordinal(), ExecutionStatus.SUCCESS.ordinal()}; @@ -176,7 +176,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { processInstanceMapper.updateById(processInstance); - Page page = new Page(1, 3); IPage processInstanceIPage = processInstanceMapper.queryProcessInstanceListPaging( @@ -226,7 +225,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { @Test public void testUpdateProcessInstanceByState() { - ProcessInstance processInstance = insertOne(); processInstance.setState(ExecutionStatus.RUNNING_EXECUTION); @@ -268,7 +266,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { List executeStatusCounts = processInstanceMapper.countInstanceStateByProjectCodes(null, null, projectCodes); - Assert.assertNotEquals(executeStatusCounts.size(), 0); projectMapper.deleteById(project.getId()); @@ -284,7 +281,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { ProcessInstance processInstance = insertOne(); ProcessInstance processInstance1 = insertOne(); - List processInstances = processInstanceMapper.queryByProcessDefineCode(processInstance.getProcessDefinitionCode(), 1); Assert.assertEquals(1, processInstances.size()); @@ -351,7 +347,6 @@ public class ProcessInstanceMapperTest extends BaseDaoTest { } - /** * test whether it is in descending order by running duration */ diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java index 7c3c80f52c..7bf8ffb47d 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.BaseDaoTest; diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java index 9a562790ee..53a9a20614 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectUserMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import static org.hamcrest.MatcherAssert.assertThat; @@ -52,7 +53,7 @@ public class ProjectUserMapperTest extends BaseDaoTest { * test update */ @Test - public void testUpdate(){ + public void testUpdate() { //insertOne ProjectUser projectUser = insertOne(); projectUser.setCreateTime(new Date()); @@ -65,7 +66,7 @@ public class ProjectUserMapperTest extends BaseDaoTest { * test delete */ @Test - public void testDelete(){ + public void testDelete() { ProjectUser projectUserMap = insertOne(); int delete = projectUserMapper.deleteById(projectUserMap.getId()); Assert.assertEquals(delete, 1); diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java index c7e694f9bc..f61813be3a 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapperTest.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; @@ -44,7 +43,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest { taskDefinition.setCode(888888L); taskDefinition.setName("unit-test"); taskDefinition.setProjectCode(1L); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(userId); taskDefinition.setEnvironmentCode(1L); taskDefinition.setWorkerGroup("default"); @@ -83,7 +82,7 @@ public class TaskDefinitionLogMapperTest extends BaseDaoTest { taskDefinition.setCode(888888L); taskDefinition.setName("unit-test"); taskDefinition.setProjectCode(1L); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(1); taskDefinition.setResourceIds("1"); taskDefinition.setVersion(1); diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java index b2fc8d3b15..03131c0b8c 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapperTest.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.entity.DefinitionGroupByUser; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; @@ -48,7 +47,7 @@ public class TaskDefinitionMapperTest extends BaseDaoTest { taskDefinition.setCode(888888L); taskDefinition.setName("unit-test"); taskDefinition.setProjectCode(1L); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(userId); taskDefinition.setResourceIds("1"); taskDefinition.setWorkerGroup("default"); diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java index aaa7b54d7b..731f6689fa 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupMapperTest.java @@ -24,7 +24,6 @@ import java.util.Date; import org.junit.Assert; import org.junit.Test; -import org.mockito.Mock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java index 0cbd532023..af203d2626 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapperTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; -import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; public class TaskGroupQueueMapperTest extends BaseDaoTest { diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java index 6a799e429d..4bcdab8550 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapperTest.java @@ -17,14 +17,13 @@ package org.apache.dolphinscheduler.dao.mapper; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Date; import java.util.List; @@ -64,7 +63,7 @@ public class TaskInstanceMapperTest extends BaseDaoTest { */ private TaskInstance insertTaskInstance(int processInstanceId) { //insertOne - return insertTaskInstance(processInstanceId, TaskType.SHELL.getDesc()); + return insertTaskInstance(processInstanceId, "SHELL"); } /** @@ -314,7 +313,6 @@ public class TaskInstanceMapperTest extends BaseDaoTest { Assert.assertEquals(countTask, 0); Assert.assertEquals(countTask2, 0); - } /** @@ -336,7 +334,6 @@ public class TaskInstanceMapperTest extends BaseDaoTest { processDefinitionMapper.insert(definition); taskInstanceMapper.updateById(task); - List count = taskInstanceMapper.countTaskInstanceStateByProjectCodes( null, null, new Long[]{definition.getProjectCode()} diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java index 9d5be633a1..474d5319a1 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java @@ -195,7 +195,7 @@ public class UdfFuncMapperTest extends BaseDaoTest { UdfFunc udfFunc = insertOne(); //insertOne UdfFunc udfFunc1 = insertOne(); - int[] idArray = new int[]{udfFunc.getId(), udfFunc1.getId()}; + Integer[] idArray = new Integer[]{udfFunc.getId(), udfFunc1.getId()}; //queryUdfByIdStr List udfFuncList = udfFuncMapper.queryUdfByIdStr(idArray, ""); Assert.assertNotEquals(udfFuncList.size(), 0); diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java index 3350e5ae60..eb949066ea 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/WorkFlowLineageMapperTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.common.enums.FailureStrategy; diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/DagHelperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/DagHelperTest.java index 8df92dd0ad..31178a5487 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/DagHelperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/utils/DagHelperTest.java @@ -17,19 +17,20 @@ package org.apache.dolphinscheduler.dao.utils; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; + import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.TaskDependType; -import org.apache.dolphinscheduler.common.enums.TaskType; 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.task.switchtask.SwitchParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchResultVo; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessData; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import java.io.IOException; import java.util.ArrayList; @@ -208,7 +209,7 @@ public class DagHelperTest { completeTaskList.put("2", new TaskInstance()); completeTaskList.put("4", new TaskInstance()); TaskNode node3 = dag.getNode("3"); - node3.setType(TaskType.CONDITIONS.getDesc()); + node3.setType(TASK_TYPE_CONDITIONS); node3.setConditionResult("{\n" + " \"successNode\": [5\n" @@ -292,14 +293,14 @@ public class DagHelperTest { node1.setId("1"); node1.setName("1"); node1.setCode(1); - node1.setType(TaskType.SHELL.getDesc()); + node1.setType("SHELL"); taskNodeList.add(node1); TaskNode node2 = new TaskNode(); node2.setId("2"); node2.setName("2"); node2.setCode(2); - node2.setType(TaskType.SHELL.getDesc()); + node2.setType("SHELL"); List dep2 = new ArrayList<>(); dep2.add("1"); node2.setPreTasks(JSONUtils.toJsonString(dep2)); @@ -309,14 +310,14 @@ public class DagHelperTest { node4.setId("4"); node4.setName("4"); node4.setCode(4); - node4.setType(TaskType.SHELL.getDesc()); + node4.setType("SHELL"); taskNodeList.add(node4); TaskNode node3 = new TaskNode(); node3.setId("3"); node3.setName("3"); node3.setCode(3); - node3.setType(TaskType.SHELL.getDesc()); + node3.setType("SHELL"); List dep3 = new ArrayList<>(); dep3.add("2"); dep3.add("4"); @@ -327,7 +328,7 @@ public class DagHelperTest { node5.setId("5"); node5.setName("5"); node5.setCode(5); - node5.setType(TaskType.SHELL.getDesc()); + node5.setType("SHELL"); List dep5 = new ArrayList<>(); dep5.add("3"); dep5.add("8"); @@ -338,7 +339,7 @@ public class DagHelperTest { node6.setId("6"); node6.setName("6"); node6.setCode(6); - node6.setType(TaskType.SHELL.getDesc()); + node6.setType("SHELL"); List dep6 = new ArrayList<>(); dep6.add("3"); node6.setPreTasks(JSONUtils.toJsonString(dep6)); @@ -348,7 +349,7 @@ public class DagHelperTest { node7.setId("7"); node7.setName("7"); node7.setCode(7); - node7.setType(TaskType.SHELL.getDesc()); + node7.setType("SHELL"); List dep7 = new ArrayList<>(); dep7.add("5"); node7.setPreTasks(JSONUtils.toJsonString(dep7)); @@ -358,7 +359,7 @@ public class DagHelperTest { node8.setId("8"); node8.setName("8"); node8.setCode(8); - node8.setType(TaskType.SHELL.getDesc()); + node8.setType("SHELL"); List dep8 = new ArrayList<>(); dep8.add("2"); node8.setPreTasks(JSONUtils.toJsonString(dep8)); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml index 27c24e1ac7..51a162b0c6 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/pom.xml @@ -35,6 +35,12 @@ provided + + org.apache.dolphinscheduler + dolphinscheduler-task-api + provided + + commons-io commons-io diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtils.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtils.java index 00004281b7..45d5cd2d8f 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtils.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtils.java @@ -17,18 +17,18 @@ package org.apache.dolphinscheduler.plugin.datasource.api.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATA_QUALITY_JAR_NAME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.HADOOP_SECURITY_AUTHENTICATION; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.KERBEROS; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.LOGIN_USER_KEY_TAB_PATH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.LOGIN_USER_KEY_TAB_USERNAME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.RESOURCE_STORAGE_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DATA_QUALITY_JAR_NAME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.HADOOP_SECURITY_AUTHENTICATION; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.JAVA_SECURITY_KRB5_CONF; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.KERBEROS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LOGIN_USER_KEY_TAB_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LOGIN_USER_KEY_TAB_USERNAME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RESOURCE_STORAGE_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RESOURCE_UPLOAD_PATH; import org.apache.dolphinscheduler.spi.enums.ResUploadType; -import org.apache.dolphinscheduler.spi.task.TaskConstants; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -141,7 +141,7 @@ public class CommonUtils { * @return data hdfs path */ public static String getHdfsDataBasePath() { - String resourceUploadPath = PropertyUtils.getString(TaskConstants.RESOURCE_UPLOAD_PATH, "/dolphinscheduler"); + String resourceUploadPath = PropertyUtils.getString(RESOURCE_UPLOAD_PATH, "/dolphinscheduler"); if ("/".equals(resourceUploadPath)) { // if basepath is configured to /, the generated url may be //default/resources (with extra leading /) return ""; diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/PasswordUtils.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/PasswordUtils.java index 9bf2f96735..71c436eb5e 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/PasswordUtils.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/PasswordUtils.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.datasource.api.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATASOURCE_ENCRYPTION_ENABLE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATASOURCE_ENCRYPTION_SALT; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATASOURCE_ENCRYPTION_SALT_DEFAULT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DATASOURCE_ENCRYPTION_ENABLE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DATASOURCE_ENCRYPTION_SALT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DATASOURCE_ENCRYPTION_SALT_DEFAULT; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java index fc4f675472..63534dfc70 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java @@ -17,12 +17,14 @@ package org.apache.dolphinscheduler.plugin.datasource.api.datasource; -import org.junit.Test; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; import java.util.HashMap; import java.util.Map; -import static org.mockito.Mockito.*; +import org.junit.Test; public class AbstractDataSourceProcessorTest { diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java index 61f78ba634..7be1a8acb7 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.plugin.datasource.api.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATASOURCE_ENCRYPTION_ENABLE; +import static org.apache.dolphinscheduler.spi.utils.Constants.DATASOURCE_ENCRYPTION_ENABLE; import org.apache.dolphinscheduler.spi.utils.Constants; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; @@ -97,7 +97,7 @@ public class CommonUtilsTest { PowerMockito.mockStatic(PropertyUtils.class); PowerMockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false)).thenReturn(Boolean.TRUE); - PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "true"); + PropertyUtils.setValue(DATASOURCE_ENCRYPTION_ENABLE, "true"); PowerMockito.mockStatic(PasswordUtils.class); PowerMockito.when(PasswordUtils.decodePassword("bnVsbE1USXpORFUy")).thenReturn("123456"); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/pom.xml b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/pom.xml index b9eb8890bd..6f15a84553 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/pom.xml +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/pom.xml @@ -36,6 +36,11 @@ dolphinscheduler-spi provided + + org.apache.dolphinscheduler + dolphinscheduler-task-api + provided + org.apache.hadoop diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java index c888fa407f..68edf02a9a 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.datasource.hive; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.JAVA_SECURITY_KRB5_CONF; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE; import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient; import org.apache.dolphinscheduler.plugin.datasource.api.provider.JDBCDataSourceProvider; diff --git a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java index cbaa036e21..06f76676b8 100644 --- a/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java +++ b/dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/TaskInstanceTab.java @@ -17,6 +17,7 @@ * under the License. * */ + package org.apache.dolphinscheduler.e2e.pages.project.workflow; import lombok.Getter; diff --git a/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogFilterTest.java b/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogFilterTest.java index 8905315bd3..34c939d7ce 100644 --- a/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogFilterTest.java +++ b/dolphinscheduler-log-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogFilterTest.java @@ -21,8 +21,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; import ch.qos.logback.classic.spi.LoggerContextVO; import ch.qos.logback.core.spi.FilterReply; -import org.apache.dolphinscheduler.common.utils.LoggerUtils; -import org.apache.dolphinscheduler.spi.task.TaskConstants; + +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.junit.Assert; import org.junit.Test; diff --git a/dolphinscheduler-master/pom.xml b/dolphinscheduler-master/pom.xml index 1851637b10..3033c3f519 100644 --- a/dolphinscheduler-master/pom.xml +++ b/dolphinscheduler-master/pom.xml @@ -47,6 +47,12 @@ org.apache.dolphinscheduler dolphinscheduler-server + + + org.apache.dolphinscheduler + dolphinscheduler-task-all + + org.springframework.boot spring-boot-starter-cache diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java index 538617e4d8..93aac17c66 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/builder/TaskExecutionContextBuilder.java @@ -19,18 +19,15 @@ package org.apache.dolphinscheduler.server.builder; import static org.apache.dolphinscheduler.common.Constants.SEC_2_MINUTES_TIME_UNIT; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.ProcedureTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SqoopTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; /** * TaskExecutionContext builder @@ -109,58 +106,13 @@ public class TaskExecutionContextBuilder { return this; } - /** - * build SQLTask related info - * - * @param sqlTaskExecutionContext sqlTaskExecutionContext - * @return TaskExecutionContextBuilder - */ - public TaskExecutionContextBuilder buildSQLTaskRelatedInfo(SQLTaskExecutionContext sqlTaskExecutionContext) { - taskExecutionContext.setSqlTaskExecutionContext(sqlTaskExecutionContext); - return this; - } - - /** - * build DataxTask related info - * - * @param dataxTaskExecutionContext dataxTaskExecutionContext - * @return TaskExecutionContextBuilder - */ - public TaskExecutionContextBuilder buildDataxTaskRelatedInfo(DataxTaskExecutionContext dataxTaskExecutionContext) { - taskExecutionContext.setDataxTaskExecutionContext(dataxTaskExecutionContext); - return this; - } - - /** - * build procedureTask related info - * - * @param procedureTaskExecutionContext procedureTaskExecutionContext - * @return TaskExecutionContextBuilder - */ - public TaskExecutionContextBuilder buildProcedureTaskRelatedInfo(ProcedureTaskExecutionContext procedureTaskExecutionContext) { - taskExecutionContext.setProcedureTaskExecutionContext(procedureTaskExecutionContext); - return this; - } - - /** - * build sqoopTask related info - * - * @param sqoopTaskExecutionContext sqoopTaskExecutionContext - * @return TaskExecutionContextBuilder - */ - public TaskExecutionContextBuilder buildSqoopTaskRelatedInfo(SqoopTaskExecutionContext sqoopTaskExecutionContext) { - taskExecutionContext.setSqoopTaskExecutionContext(sqoopTaskExecutionContext); + public TaskExecutionContextBuilder buildDataQualityTaskExecutionContext(DataQualityTaskExecutionContext dataQualityTaskExecutionContext) { + taskExecutionContext.setDataQualityTaskExecutionContext(dataQualityTaskExecutionContext); return this; } - /** - * build DataQualityTask related info - * - * @param dataQualityTaskExecutionContext dataQualityTaskExecutionContext - * @return TaskExecutionContextBuilder - */ - public TaskExecutionContextBuilder buildDataQualityTaskRelatedInfo(DataQualityTaskExecutionContext dataQualityTaskExecutionContext) { - taskExecutionContext.setDataQualityTaskExecutionContext(dataQualityTaskExecutionContext); + public TaskExecutionContextBuilder buildResourceParametersInfo(ResourceParametersHelper parametersHelper) { + taskExecutionContext.setResourceParametersHelper(parametersHelper); return this; } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java index c65195c4ce..7c158add39 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumer.java @@ -21,6 +21,9 @@ import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.remote.command.Command; +import org.apache.dolphinscheduler.remote.command.TaskExecuteRequestCommand; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.dispatch.ExecutorDispatcher; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; @@ -30,7 +33,7 @@ import org.apache.dolphinscheduler.service.exceptions.TaskPriorityQueueException import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.queue.TaskPriority; import org.apache.dolphinscheduler.service.queue.TaskPriorityQueue; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; import java.util.Collections; @@ -155,7 +158,7 @@ public class TaskPriorityQueueConsumer extends Thread { boolean result = false; try { TaskExecutionContext context = taskPriority.getTaskExecutionContext(); - ExecutionContext executionContext = new ExecutionContext(context.toCommand(), ExecutorType.WORKER, context.getWorkerGroup()); + ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER, context.getWorkerGroup()); if (isTaskNeedToCheck(taskPriority)) { if (taskInstanceIsFinalState(taskPriority.getTaskId())) { @@ -171,6 +174,12 @@ public class TaskPriorityQueueConsumer extends Thread { return result; } + private Command toCommand(TaskExecutionContext taskExecutionContext) { + TaskExecuteRequestCommand requestCommand = new TaskExecuteRequestCommand(); + requestCommand.setTaskExecutionContext(JSONUtils.toJsonString(taskExecutionContext)); + return requestCommand.convert2Command(); + } + /** * taskInstance is final state * success,failure,kill,stop,pause,threadwaiting is final state diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java index bd53ad621a..7c94144af8 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcher.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.server.master.dispatch; - import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; @@ -60,7 +59,7 @@ public class ExecutorDispatcher implements InitializingBean { /** * constructor */ - public ExecutorDispatcher(){ + public ExecutorDispatcher() { this.executorManagers = new ConcurrentHashMap<>(); } @@ -76,7 +75,7 @@ public class ExecutorDispatcher implements InitializingBean { * get executor manager */ ExecutorManager executorManager = this.executorManagers.get(context.getExecutorType()); - if(executorManager == null){ + if (executorManager == null) { throw new ExecuteException("no ExecutorManager for type : " + context.getExecutorType()); } @@ -117,7 +116,7 @@ public class ExecutorDispatcher implements InitializingBean { * @param type executor type * @param executorManager executorManager */ - public void register(ExecutorType type, ExecutorManager executorManager){ + public void register(ExecutorType type, ExecutorManager executorManager) { executorManagers.put(type, executorManager); } } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java index fd673ca678..b3fba87870 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/context/ExecutionContext.java @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master.dispatch.context; +import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; -import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP; - /** * execution context */ @@ -48,7 +48,6 @@ public class ExecutionContext { */ private String workerGroup; - public ExecutionContext(Command command, ExecutorType executorType) { this(command, executorType, DEFAULT_WORKER_GROUP); } @@ -71,8 +70,7 @@ public class ExecutionContext { this.workerGroup = workerGroup; } - - public String getWorkerGroup(){ + public String getWorkerGroup() { return this.workerGroup; } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/enums/ExecutorType.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/enums/ExecutorType.java index 03be62e701..0f1a79011b 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/enums/ExecutorType.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/enums/ExecutorType.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master.dispatch.enums; /** diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/exceptions/ExecuteException.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/exceptions/ExecuteException.java index eaf614c023..abc70e4035 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/exceptions/ExecuteException.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/exceptions/ExecuteException.java @@ -20,23 +20,20 @@ package org.apache.dolphinscheduler.server.master.dispatch.exceptions; /** * execute exception */ -public class ExecuteException extends Exception{ +public class ExecuteException extends Exception { public ExecuteException() { super(); } - public ExecuteException(String message) { super(message); } - public ExecuteException(String message, Throwable cause) { super(message, cause); } - public ExecuteException(Throwable cause) { super(cause); } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/AbstractExecutorManager.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/AbstractExecutorManager.java index d6a7720db6..41b1837e5d 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/AbstractExecutorManager.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/AbstractExecutorManager.java @@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteExce /** * abstract executor manager */ -public abstract class AbstractExecutorManager implements ExecutorManager{ +public abstract class AbstractExecutorManager implements ExecutorManager { /** * before execute , add time monitor , timeout diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java index 521d0c45aa..0e5333bf1c 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManager.java @@ -49,7 +49,7 @@ import org.springframework.stereotype.Service; * netty executor manager */ @Service -public class NettyExecutorManager extends AbstractExecutorManager{ +public class NettyExecutorManager extends AbstractExecutorManager { private final Logger logger = LoggerFactory.getLogger(NettyExecutorManager.class); @@ -76,13 +76,13 @@ public class NettyExecutorManager extends AbstractExecutorManager{ /** * constructor */ - public NettyExecutorManager(){ + public NettyExecutorManager() { final NettyClientConfig clientConfig = new NettyClientConfig(); this.nettyRemotingClient = new NettyRemotingClient(clientConfig); } @PostConstruct - public void init(){ + public void init() { this.nettyRemotingClient.registerProcessor(CommandType.TASK_EXECUTE_RESPONSE, taskResponseProcessor); this.nettyRemotingClient.registerProcessor(CommandType.TASK_EXECUTE_ACK, taskAckProcessor); this.nettyRemotingClient.registerProcessor(CommandType.TASK_KILL_RESPONSE, taskKillResponseProcessor); @@ -182,13 +182,13 @@ public class NettyExecutorManager extends AbstractExecutorManager{ * @param context context * @return nodes */ - private Set getAllNodes(ExecutionContext context){ + private Set getAllNodes(ExecutionContext context) { Set nodes = Collections.emptySet(); /** * executor type */ ExecutorType executorType = context.getExecutorType(); - switch (executorType){ + switch (executorType) { case WORKER: nodes = serverNodeManager.getWorkerGroupNodes(context.getWorkerGroup()); break; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/HostManagerConfig.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/HostManagerConfig.java index 356679c8e0..10d9e0f491 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/HostManagerConfig.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/HostManagerConfig.java @@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.server.master.dispatch.host; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.dispatch.host.assign.HostSelector; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.context.annotation.Bean; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/AbstractSelector.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/AbstractSelector.java index d07f62a1f4..0e61599e79 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/AbstractSelector.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/AbstractSelector.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master.dispatch.host.assign; import org.apache.commons.collections.CollectionUtils; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java index a5d93a684b..5639fc4ce2 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelector.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master.dispatch.host.assign; import java.util.ArrayList; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/Selector.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/Selector.java index 08649819a0..8eed9d991e 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/Selector.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/Selector.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.server.master.dispatch.host.assign; import java.util.Collection; - /** * selector * @param T diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java index 0712162829..f9b9a119dc 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessor.java @@ -23,7 +23,6 @@ import org.apache.dolphinscheduler.remote.command.CacheExpireCommand; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; -import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java index 6b4c3daf20..e132f285de 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/StateEventProcessor.java @@ -17,16 +17,15 @@ package org.apache.dolphinscheduler.server.master.processor; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService; -import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessor.java index 9c42017b66..1d188a1433 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessor.java @@ -17,10 +17,8 @@ package org.apache.dolphinscheduler.server.master.processor; -import com.google.common.base.Preconditions; -import io.netty.channel.Channel; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; @@ -28,11 +26,16 @@ import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.remote.utils.ChannelUtils; import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseService; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import io.netty.channel.Channel; + /** * task ack processor */ diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java index 64a22cbdaf..ea2e4539c3 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskEventProcessor.java @@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.server.master.processor.queue.StateEventResponseService; -import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessor.java index a367cfe4ae..47bdfcab1f 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessor.java @@ -17,24 +17,23 @@ package org.apache.dolphinscheduler.server.master.processor; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseEvent; import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseService; -import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import com.google.common.base.Preconditions; import io.netty.channel.Channel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; /** * task response processor diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java index 11fc060a4d..cba592c63d 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.server.master.processor.queue; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.thread.Stopper; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.StateEventResponseCommand; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseEvent.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseEvent.java index b32516334a..2a6bd07fe2 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseEvent.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseEvent.java @@ -17,9 +17,8 @@ package org.apache.dolphinscheduler.server.master.processor.queue; - import org.apache.dolphinscheduler.common.enums.Event; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.Date; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseService.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseService.java index 651496691c..a0de0af09f 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseService.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseService.java @@ -18,17 +18,17 @@ package org.apache.dolphinscheduler.server.master.processor.queue; import org.apache.dolphinscheduler.common.enums.Event; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.DBTaskAckCommand; import org.apache.dolphinscheduler.remote.command.DBTaskResponseCommand; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread; -import org.apache.dolphinscheduler.server.utils.DataQualityResultOperator; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPool; +import org.apache.dolphinscheduler.server.utils.DataQualityResultOperator; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.ArrayList; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java index 77e27ec43d..abf1734af4 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java @@ -23,7 +23,6 @@ import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.IStoppable; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.NodeType; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; @@ -32,6 +31,8 @@ import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.registry.api.ConnectionState; import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory; import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder; @@ -40,7 +41,6 @@ import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPoo import org.apache.dolphinscheduler.server.registry.HeartBeatTask; import org.apache.dolphinscheduler.server.utils.ProcessUtils; import org.apache.dolphinscheduler.service.process.ProcessService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import org.apache.dolphinscheduler.service.registry.RegistryClient; import org.apache.commons.collections4.CollectionUtils; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java index 9d61aa1dec..e0fa6b87d9 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterSchedulerService.java @@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.server.master.dispatch.executor.NettyExecutor import org.apache.dolphinscheduler.server.master.registry.ServerNodeManager; import org.apache.dolphinscheduler.service.alert.ProcessAlertManager; import org.apache.dolphinscheduler.service.process.ProcessService; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections4.CollectionUtils; @@ -100,6 +101,9 @@ public class MasterSchedulerService extends Thread { @Autowired private StateWheelExecuteThread stateWheelExecuteThread; + @Autowired + private TaskPluginManager taskPluginManager; + /** * constructor of MasterSchedulerService */ diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java index 6411198108..ba614e573b 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/StateWheelExecuteThread.java @@ -18,7 +18,6 @@ package org.apache.dolphinscheduler.server.master.runner; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; @@ -27,10 +26,11 @@ import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.config.MasterConfig; - import org.apache.dolphinscheduler.server.master.runner.task.TaskInstanceKey; + import org.apache.hadoop.util.ThreadUtil; import java.util.concurrent.ConcurrentLinkedQueue; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java index 418e5dddfe..c7c4163b9e 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java @@ -23,12 +23,10 @@ import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVERY_ST import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES; import static org.apache.dolphinscheduler.common.Constants.DEFAULT_WORKER_GROUP; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.Direct; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.Priority; @@ -36,20 +34,16 @@ import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; 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.process.Property; -import org.apache.dolphinscheduler.common.task.blocking.BlockingParameters; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils; -import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.Environment; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; @@ -61,6 +55,11 @@ import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.utils.DagHelper; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters; import org.apache.dolphinscheduler.remote.command.HostUpdateCommand; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.config.MasterConfig; @@ -684,8 +683,8 @@ public class WorkflowExecuteThread { logger.error("task {} is not a blocking task", task.getTaskCode()); return false; } - BlockingParameters parameters = (BlockingParameters) TaskParametersUtils.getParameters(TaskType.BLOCKING.getDesc(), - task.getTaskParams()); + + BlockingParameters parameters = JSONUtils.parseObject(task.getTaskParams(), BlockingParameters.class); if (parameters.isAlertWhenBlocking()) { ProjectUser projectUser = processService.queryProjectWithUserByProcessInstanceId(processInstance.getId()); processAlertManager.sendProcessBlockingAlert(processInstance, projectUser); @@ -1498,7 +1497,7 @@ public class WorkflowExecuteThread { private ExecutionStatus processReadyBlock() { if (activeTaskProcessorMaps.size() > 0) { for (ITaskProcessor taskProcessor : activeTaskProcessorMaps.values()) { - if (!TaskType.BLOCKING.getDesc().equals(taskProcessor.getType())) { + if (!TASK_TYPE_BLOCKING.equals(taskProcessor.getType())) { taskProcessor.action(TaskAction.PAUSE); } } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java index f9fb9c9314..e51f9f9967 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.server.master.runner; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.StateEvent; import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BaseTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BaseTaskProcessor.java index 174d82f7dd..d17a11a2c3 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BaseTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BaseTaskProcessor.java @@ -24,33 +24,20 @@ import static org.apache.dolphinscheduler.common.Constants.OTHER; import static org.apache.dolphinscheduler.common.Constants.PASSWORD; import static org.apache.dolphinscheduler.common.Constants.SINGLE_SLASH; import static org.apache.dolphinscheduler.common.Constants.USER; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_NAME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_CONNECTOR_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_DATASOURCE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TARGET_CONNECTOR_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TARGET_DATASOURCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DATA_QUALITY; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_NAME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_CONNECTOR_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_DATASOURCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TARGET_CONNECTOR_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TARGET_DATASOURCE_ID; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.SqoopJobType; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.enums.UdfType; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.common.task.datax.DataxParameters; -import org.apache.dolphinscheduler.common.task.dq.DataQualityParameters; -import org.apache.dolphinscheduler.common.task.procedure.ProcedureParameters; -import org.apache.dolphinscheduler.common.task.sql.SqlParameters; -import org.apache.dolphinscheduler.common.task.sqoop.SqoopParameters; -import org.apache.dolphinscheduler.common.task.sqoop.sources.SourceMysqlParameter; -import org.apache.dolphinscheduler.common.task.sqoop.targets.TargetMysqlParameter; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.LoggerUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; -import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.DqComparisonType; import org.apache.dolphinscheduler.dao.entity.DqRule; @@ -61,24 +48,31 @@ import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ConnectorType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.model.JdbcInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.AbstractResourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.DataSourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.UdfFuncParameters; +import org.apache.dolphinscheduler.plugin.task.api.utils.JdbcUrlParser; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; +import org.apache.dolphinscheduler.plugin.task.dq.DataQualityParameters; import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.enums.ResourceType; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.dq.enums.ConnectorType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.dq.model.JdbcInfo; -import org.apache.dolphinscheduler.spi.task.dq.utils.JdbcUrlParser; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.ProcedureTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SqoopTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.UdfFuncRequest; import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.apache.commons.collections.CollectionUtils; @@ -87,6 +81,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.stream.Collectors; @@ -95,8 +90,6 @@ import java.util.stream.Stream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Enums; -import com.google.common.base.Strings; import com.zaxxer.hikari.HikariDataSource; public abstract class BaseTaskProcessor implements ITaskProcessor { @@ -121,6 +114,8 @@ public abstract class BaseTaskProcessor implements ITaskProcessor { protected MasterConfig masterConfig = SpringApplicationContext.getBean(MasterConfig.class); + protected TaskPluginManager taskPluginManager = SpringApplicationContext.getBean(TaskPluginManager.class); + protected String threadLoggerInfoName; @Override @@ -280,32 +275,13 @@ public abstract class BaseTaskProcessor implements ITaskProcessor { taskInstance.getProcessInstance().setTenantCode(tenant.getTenantCode()); taskInstance.setResources(getResourceFullNames(taskInstance)); - SQLTaskExecutionContext sqlTaskExecutionContext = new SQLTaskExecutionContext(); - DataxTaskExecutionContext dataxTaskExecutionContext = new DataxTaskExecutionContext(); - ProcedureTaskExecutionContext procedureTaskExecutionContext = new ProcedureTaskExecutionContext(); - SqoopTaskExecutionContext sqoopTaskExecutionContext = new SqoopTaskExecutionContext(); - DataQualityTaskExecutionContext dataQualityTaskExecutionContext = new DataQualityTaskExecutionContext(); - - // SQL task - if (TaskType.SQL.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { - setSQLTaskRelation(sqlTaskExecutionContext, taskInstance); - } + TaskChannel taskChannel = taskPluginManager.getTaskChannel(taskInstance.getTaskType()); + ResourceParametersHelper resources = taskChannel.getResources(taskInstance.getTaskParams()); + this.setTaskResourceInfo(resources); - // DATAX task - if (TaskType.DATAX.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { - setDataxTaskRelation(dataxTaskExecutionContext, taskInstance); - } - - // procedure task - if (TaskType.PROCEDURE.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { - setProcedureTaskRelation(procedureTaskExecutionContext, taskInstance); - } - - if (TaskType.SQOOP.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { - setSqoopTaskRelation(sqoopTaskExecutionContext, taskInstance); - } - - if (TaskType.DATA_QUALITY.getDesc().equalsIgnoreCase(taskInstance.getTaskType())) { + // TODO to be optimized + DataQualityTaskExecutionContext dataQualityTaskExecutionContext = new DataQualityTaskExecutionContext(); + if (TASK_TYPE_DATA_QUALITY.equalsIgnoreCase(taskInstance.getTaskType())) { setDataQualityTaskRelation(dataQualityTaskExecutionContext,taskInstance,tenant.getTenantCode()); } @@ -314,81 +290,57 @@ public abstract class BaseTaskProcessor implements ITaskProcessor { .buildTaskDefinitionRelatedInfo(taskInstance.getTaskDefine()) .buildProcessInstanceRelatedInfo(taskInstance.getProcessInstance()) .buildProcessDefinitionRelatedInfo(taskInstance.getProcessDefine()) - .buildSQLTaskRelatedInfo(sqlTaskExecutionContext) - .buildDataxTaskRelatedInfo(dataxTaskExecutionContext) - .buildProcedureTaskRelatedInfo(procedureTaskExecutionContext) - .buildSqoopTaskRelatedInfo(sqoopTaskExecutionContext) - .buildDataQualityTaskRelatedInfo(dataQualityTaskExecutionContext) + .buildResourceParametersInfo(resources) + .buildDataQualityTaskExecutionContext(dataQualityTaskExecutionContext) .create(); } - /** - * set procedure task relation - * - * @param procedureTaskExecutionContext procedureTaskExecutionContext - * @param taskInstance taskInstance - */ - private void setProcedureTaskRelation(ProcedureTaskExecutionContext procedureTaskExecutionContext, TaskInstance taskInstance) { - ProcedureParameters procedureParameters = JSONUtils.parseObject(taskInstance.getTaskParams(), ProcedureParameters.class); - int datasourceId = procedureParameters.getDatasource(); - DataSource datasource = processService.findDataSourceById(datasourceId); - procedureTaskExecutionContext.setConnectionParams(datasource.getConnectionParams()); - } - - /** - * set datax task relation - * - * @param dataxTaskExecutionContext dataxTaskExecutionContext - * @param taskInstance taskInstance - */ - protected void setDataxTaskRelation(DataxTaskExecutionContext dataxTaskExecutionContext, TaskInstance taskInstance) { - DataxParameters dataxParameters = JSONUtils.parseObject(taskInstance.getTaskParams(), DataxParameters.class); - - DataSource dbSource = processService.findDataSourceById(dataxParameters.getDataSource()); - DataSource dbTarget = processService.findDataSourceById(dataxParameters.getDataTarget()); - - if (dbSource != null) { - dataxTaskExecutionContext.setDataSourceId(dataxParameters.getDataSource()); - dataxTaskExecutionContext.setSourcetype(dbSource.getType().getCode()); - dataxTaskExecutionContext.setSourceConnectionParams(dbSource.getConnectionParams()); - } - - if (dbTarget != null) { - dataxTaskExecutionContext.setDataTargetId(dataxParameters.getDataTarget()); - dataxTaskExecutionContext.setTargetType(dbTarget.getType().getCode()); - dataxTaskExecutionContext.setTargetConnectionParams(dbTarget.getConnectionParams()); + private void setTaskResourceInfo(ResourceParametersHelper resourceParametersHelper) { + if (Objects.isNull(resourceParametersHelper)) { + return; } + resourceParametersHelper.getResourceMap().forEach((type, map) -> { + switch (type) { + case DATASOURCE: + this.setTaskDataSourceResourceInfo(map); + break; + case UDF: + this.setTaskUdfFuncResourceInfo(map); + break; + default: + break; + } + }); } - /** - * set sqoop task relation - * - * @param sqoopTaskExecutionContext sqoopTaskExecutionContext - * @param taskInstance taskInstance - */ - private void setSqoopTaskRelation(SqoopTaskExecutionContext sqoopTaskExecutionContext, TaskInstance taskInstance) { - SqoopParameters sqoopParameters = JSONUtils.parseObject(taskInstance.getTaskParams(), SqoopParameters.class); - - // sqoop job type is template set task relation - if (sqoopParameters.getJobType().equals(SqoopJobType.TEMPLATE.getDescp())) { - SourceMysqlParameter sourceMysqlParameter = JSONUtils.parseObject(sqoopParameters.getSourceParams(), SourceMysqlParameter.class); - TargetMysqlParameter targetMysqlParameter = JSONUtils.parseObject(sqoopParameters.getTargetParams(), TargetMysqlParameter.class); + private void setTaskDataSourceResourceInfo(Map map) { + if (MapUtils.isEmpty(map)) { + return; + } - DataSource dataSource = processService.findDataSourceById(sourceMysqlParameter.getSrcDatasource()); - DataSource dataTarget = processService.findDataSourceById(targetMysqlParameter.getTargetDatasource()); + map.forEach((code, parameters) -> { + DataSource datasource = processService.findDataSourceById(code); + DataSourceParameters dataSourceParameters = new DataSourceParameters(); + dataSourceParameters.setType(datasource.getType()); + dataSourceParameters.setConnectionParams(datasource.getConnectionParams()); + map.put(code, dataSourceParameters); + }); - if (dataSource != null) { - sqoopTaskExecutionContext.setDataSourceId(dataSource.getId()); - sqoopTaskExecutionContext.setSourcetype(dataSource.getType().getCode()); - sqoopTaskExecutionContext.setSourceConnectionParams(dataSource.getConnectionParams()); - } + } - if (dataTarget != null) { - sqoopTaskExecutionContext.setDataTargetId(dataTarget.getId()); - sqoopTaskExecutionContext.setTargetType(dataTarget.getType().getCode()); - sqoopTaskExecutionContext.setTargetConnectionParams(dataTarget.getConnectionParams()); - } + private void setTaskUdfFuncResourceInfo(Map map) { + if (MapUtils.isEmpty(map)) { + return; } + List udfFuncList = processService.queryUdfFunListByIds(map.keySet().toArray(new Integer[map.size()])); + + udfFuncList.forEach(udfFunc -> { + UdfFuncParameters udfFuncParameters = JSONUtils.parseObject(JSONUtils.toJsonString(udfFunc), UdfFuncParameters.class); + udfFuncParameters.setDefaultFS(HadoopUtils.getInstance().getDefaultFS()); + String tenantCode = processService.queryTenantCodeByResName(udfFunc.getResourceName(), ResourceType.UDF); + udfFuncParameters.setTenantCode(tenantCode); + map.put(udfFunc.getId(), udfFuncParameters); + }); } /** @@ -582,43 +534,6 @@ public abstract class BaseTaskProcessor implements ITaskProcessor { } } - /** - * set SQL task relation - * - * @param sqlTaskExecutionContext sqlTaskExecutionContext - * @param taskInstance taskInstance - */ - private void setSQLTaskRelation(SQLTaskExecutionContext sqlTaskExecutionContext, TaskInstance taskInstance) { - SqlParameters sqlParameters = JSONUtils.parseObject(taskInstance.getTaskParams(), SqlParameters.class); - int datasourceId = sqlParameters.getDatasource(); - DataSource datasource = processService.findDataSourceById(datasourceId); - sqlTaskExecutionContext.setConnectionParams(datasource.getConnectionParams()); - - sqlTaskExecutionContext.setDefaultFS(HadoopUtils.getInstance().getDefaultFS()); - - // whether udf type - boolean udfTypeFlag = Enums.getIfPresent(UdfType.class, Strings.nullToEmpty(sqlParameters.getType())).isPresent() - && !StringUtils.isEmpty(sqlParameters.getUdfs()); - - if (udfTypeFlag) { - String[] udfFunIds = sqlParameters.getUdfs().split(","); - int[] udfFunIdsArray = new int[udfFunIds.length]; - for (int i = 0; i < udfFunIds.length; i++) { - udfFunIdsArray[i] = Integer.parseInt(udfFunIds[i]); - } - - List udfFuncList = processService.queryUdfFunListByIds(udfFunIdsArray); - UdfFuncRequest udfFuncRequest; - Map udfFuncRequestMap = new HashMap<>(); - for (UdfFunc udfFunc : udfFuncList) { - udfFuncRequest = JSONUtils.parseObject(JSONUtils.toJsonString(udfFunc), UdfFuncRequest.class); - String tenantCode = processService.queryTenantCodeByResName(udfFunc.getResourceName(), ResourceType.UDF); - udfFuncRequestMap.put(udfFuncRequest, tenantCode); - } - sqlTaskExecutionContext.setUdfFuncTenantCodeMap(udfFuncRequestMap); - } - } - /** * whehter tenant is null * @@ -641,8 +556,7 @@ public abstract class BaseTaskProcessor implements ITaskProcessor { */ protected Map getResourceFullNames(TaskInstance taskInstance) { Map resourcesMap = new HashMap<>(); - AbstractParameters baseParam = TaskParametersUtils.getParameters(taskInstance.getTaskType(), taskInstance.getTaskParams()); - + AbstractParameters baseParam = taskPluginManager.getParameters(ParametersNode.builder().taskType(taskInstance.getTaskType()).taskParams(taskInstance.getTaskParams()).build()); if (baseParam != null) { List projectResourceFiles = baseParam.getResourceFilesList(); if (CollectionUtils.isNotEmpty(projectResourceFiles)) { diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BlockingTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BlockingTaskProcessor.java index ee52090d9b..1fa6b28625 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BlockingTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/BlockingTaskProcessor.java @@ -17,19 +17,20 @@ package org.apache.dolphinscheduler.server.master.runner.task; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; + import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.BlockingOpportunity; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.task.blocking.BlockingParameters; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.utils.DependentUtils; +import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; -import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; +import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; import org.apache.dolphinscheduler.server.utils.LogUtils; import java.util.ArrayList; @@ -76,8 +77,7 @@ public class BlockingTaskProcessor extends BaseTaskProcessor { this.taskInstance.setStartTime(new Date()); this.processService.saveTaskInstance(taskInstance); this.dependentParameters = taskInstance.getDependency(); - this.blockingParam = (BlockingParameters) TaskParametersUtils.getParameters( - TaskType.BLOCKING.getDesc(), taskInstance.getTaskParams()); + this.blockingParam = JSONUtils.parseObject(taskInstance.getTaskParams(), BlockingParameters.class); } @Override @@ -133,7 +133,7 @@ public class BlockingTaskProcessor extends BaseTaskProcessor { @Override public String getType() { - return TaskType.BLOCKING.getDesc(); + return TASK_TYPE_BLOCKING; } /** diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java index 9d8a717743..3d1c518e51 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java @@ -18,7 +18,8 @@ package org.apache.dolphinscheduler.server.master.runner.task; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; @@ -29,7 +30,6 @@ import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.queue.TaskPriority; import org.apache.dolphinscheduler.service.queue.TaskPriorityQueue; import org.apache.dolphinscheduler.service.queue.TaskPriorityQueueImpl; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/ConditionTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/ConditionTaskProcessor.java index bb639a3ada..0928d122ba 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/ConditionTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/ConditionTaskProcessor.java @@ -17,17 +17,18 @@ package org.apache.dolphinscheduler.server.master.runner.task; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; + import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.utils.DependentUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; +import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; import org.apache.dolphinscheduler.server.utils.LogUtils; import java.util.ArrayList; @@ -118,7 +119,7 @@ public class ConditionTaskProcessor extends BaseTaskProcessor { @Override public String getType() { - return TaskType.CONDITIONS.getDesc(); + return TASK_TYPE_CONDITIONS; } private void initTaskParameters() { diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/DependentTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/DependentTaskProcessor.java index aaeaa974a8..d17f4b6419 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/DependentTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/DependentTaskProcessor.java @@ -18,15 +18,15 @@ package org.apache.dolphinscheduler.server.master.runner.task; import static org.apache.dolphinscheduler.common.Constants.DEPENDENT_SPLIT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; -import org.apache.dolphinscheduler.common.utils.DependentUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.utils.NetUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; +import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; import org.apache.dolphinscheduler.server.utils.DependentExecute; import org.apache.dolphinscheduler.server.utils.LogUtils; @@ -200,6 +200,6 @@ public class DependentTaskProcessor extends BaseTaskProcessor { @Override public String getType() { - return TaskType.DEPENDENT.getDesc(); + return TASK_TYPE_DEPENDENT; } } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java index 19217af2fd..bdd00bf7e4 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java @@ -17,10 +17,11 @@ package org.apache.dolphinscheduler.server.master.runner.task; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; + +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.server.utils.LogUtils; @@ -177,6 +178,6 @@ public class SubTaskProcessor extends BaseTaskProcessor { @Override public String getType() { - return TaskType.SUB_PROCESS.getDesc(); + return TASK_TYPE_SUB_PROCESS; } } diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SwitchTaskProcessor.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SwitchTaskProcessor.java index b194eac71c..444d41622c 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SwitchTaskProcessor.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SwitchTaskProcessor.java @@ -17,15 +17,16 @@ package org.apache.dolphinscheduler.server.master.runner.task; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; -import org.apache.dolphinscheduler.common.process.Property; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchResultVo; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SWITCH; + import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import org.apache.dolphinscheduler.server.utils.LogUtils; import org.apache.dolphinscheduler.server.utils.SwitchTaskUtils; @@ -117,7 +118,7 @@ public class SwitchTaskProcessor extends BaseTaskProcessor { @Override public String getType() { - return TaskType.SWITCH.getDesc(); + return TASK_TYPE_SWITCH; } private boolean setSwitchResult() { diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/TaskInstanceKey.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/TaskInstanceKey.java index a5d7707576..5b3d788c8c 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/TaskInstanceKey.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/TaskInstanceKey.java @@ -57,11 +57,11 @@ public class TaskInstanceKey { @Override public String toString() { - return "TaskKey{" + - "processInstanceId=" + processInstanceId + - ", taskCode=" + taskCode + - ", taskVersion=" + taskVersion + - '}'; + return "TaskKey{" + + "processInstanceId=" + processInstanceId + + ", taskCode=" + taskCode + + ", taskVersion=" + taskVersion + + '}'; } @Override diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DataQualityResultOperator.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DataQualityResultOperator.java index 71429691fa..906c3a9f34 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DataQualityResultOperator.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DataQualityResultOperator.java @@ -17,19 +17,19 @@ package org.apache.dolphinscheduler.server.utils; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DATA_QUALITY; + import org.apache.dolphinscheduler.dao.entity.DqExecuteResult; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; - +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.CheckType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqFailureStrategy; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OperatorType; import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseEvent; import org.apache.dolphinscheduler.service.alert.ProcessAlertManager; import org.apache.dolphinscheduler.service.process.ProcessService; -import org.apache.dolphinscheduler.spi.task.dq.enums.CheckType; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqFailureStrategy; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqTaskState; -import org.apache.dolphinscheduler.spi.task.dq.enums.OperatorType; import java.math.BigDecimal; @@ -60,7 +60,7 @@ public class DataQualityResultOperator { * @param taskInstance */ public void operateDqExecuteResult(TaskResponseEvent taskResponseEvent, TaskInstance taskInstance) { - if (TaskType.DATA_QUALITY == TaskType.valueOf(taskInstance.getTaskType())) { + if (TASK_TYPE_DATA_QUALITY.equals(taskInstance.getTaskType())) { ProcessInstance processInstance = processService.findProcessInstanceDetailById( diff --git a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java index a4c5cb7108..7429dc2e9b 100644 --- a/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java +++ b/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java @@ -18,14 +18,14 @@ package org.apache.dolphinscheduler.server.utils; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.model.DateInterval; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.utils.DependentUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java index 3ca640f494..f3a4414d3d 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java @@ -17,20 +17,21 @@ package org.apache.dolphinscheduler.server.master; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; + +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.task.blocking.BlockingParameters; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.runner.task.BlockingTaskProcessor; import org.apache.dolphinscheduler.server.master.runner.task.TaskAction; @@ -65,7 +66,6 @@ public class BlockingTaskTest { private MasterConfig config; - @Before public void before() { // init spring context @@ -138,7 +138,7 @@ public class BlockingTaskTest { taskNode.setName("4"); taskNode.setCode(1L); taskNode.setVersion(1); - taskNode.setType(TaskType.BLOCKING.getDesc()); + taskNode.setType(TASK_TYPE_BLOCKING); taskNode.setRunFlag(FLOW_NODE_RUN_FLAG_NORMAL); DependentItem dependentItemA = new DependentItem(); @@ -266,5 +266,4 @@ public class BlockingTaskTest { Assert.assertEquals(ExecutionStatus.RUNNING_EXECUTION, status); } - } diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java index 4207d3079c..c4d90718b6 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java @@ -14,22 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; @@ -136,7 +136,7 @@ public class ConditionsTaskTest { taskNode.setName("C"); taskNode.setCode(1L); taskNode.setVersion(1); - taskNode.setType(TaskType.CONDITIONS.getDesc()); + taskNode.setType("CONDITIONS"); taskNode.setRunFlag(FLOWNODE_RUN_FLAG_NORMAL); DependentItem dependentItem = new DependentItem(); diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java index 74017f032b..8172fd44a0 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java @@ -18,20 +18,19 @@ package org.apache.dolphinscheduler.server.master; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.model.DependentItem; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.task.dependent.DependentParameters; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; @@ -362,7 +361,7 @@ public class DependentTaskTest { taskNode.setId("tasks-10"); taskNode.setName("D"); taskNode.setCode(DEPEND_TASK_CODE_D); - taskNode.setType(TaskType.DEPENDENT.getDesc()); + taskNode.setType("DEPENDENT"); taskNode.setRunFlag(FLOWNODE_RUN_FLAG_NORMAL); return taskNode; } @@ -415,7 +414,7 @@ public class DependentTaskTest { long taskCode, ProcessInstance processInstance ) { TaskInstance taskInstance = new TaskInstance(); - taskInstance.setTaskType(TaskType.DEPENDENT.getDesc()); + taskInstance.setTaskType("DEPENDENT"); taskInstance.setId(taskInstanceId); taskInstance.setTaskCode(taskCode); taskInstance.setProcessInstanceId(processInstance.getId()); diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java index 2093d95bbd..34f0a233c5 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.server.master; import org.apache.dolphinscheduler.common.enums.CommandType; @@ -40,9 +41,8 @@ public class MasterCommandTest { private ProcessDefinitionMapper processDefinitionMapper; - @Test - public void StartFromFailedCommand(){ + public void startFromFailedCommand() { Command cmd = new Command(); cmd.setCommandType(CommandType.START_FAILURE_TASK_PROCESS); cmd.setCommandParam("{\"ProcessInstanceId\":325}"); @@ -53,7 +53,7 @@ public class MasterCommandTest { } @Test - public void RecoverSuspendCommand(){ + public void recoverSuspendCommand() { Command cmd = new Command(); cmd.setProcessDefinitionCode(44); @@ -63,11 +63,8 @@ public class MasterCommandTest { commandMapper.insert(cmd); } - - - @Test - public void startNewProcessCommand(){ + public void startNewProcessCommand() { Command cmd = new Command(); cmd.setCommandType(CommandType.START_PROCESS); cmd.setProcessDefinitionCode(167); @@ -80,7 +77,7 @@ public class MasterCommandTest { } @Test - public void ToleranceCommand(){ + public void toleranceCommand() { Command cmd = new Command(); cmd.setCommandType(CommandType.RECOVER_TOLERANCE_FAULT_PROCESS); cmd.setCommandParam("{\"ProcessInstanceId\":816}"); @@ -90,7 +87,7 @@ public class MasterCommandTest { } @Test - public void insertCommand(){ + public void insertCommand() { Command cmd = new Command(); cmd.setCommandType(CommandType.START_PROCESS); cmd.setFailureStrategy(FailureStrategy.CONTINUE); @@ -100,5 +97,4 @@ public class MasterCommandTest { commandMapper.insert(cmd); } - } diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java index 8af61908e6..1a71d85428 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java @@ -17,9 +17,7 @@ package org.apache.dolphinscheduler.server.master; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.thread.Stopper; @@ -27,6 +25,7 @@ import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; @@ -135,7 +134,7 @@ public class SubProcessTaskTest { taskNode.setName("S"); taskNode.setCode(1L); taskNode.setVersion(1); - taskNode.setType(TaskType.SUB_PROCESS.getDesc()); + taskNode.setType("SUB_PROCESS"); taskNode.setRunFlag(FLOWNODE_RUN_FLAG_NORMAL); return taskNode; } @@ -167,7 +166,7 @@ public class SubProcessTaskTest { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1000); taskInstance.setName("S"); - taskInstance.setTaskType(TaskType.SUB_PROCESS.getDesc()); + taskInstance.setTaskType("SUB_PROCESS"); taskInstance.setName(taskNode.getName()); taskInstance.setTaskCode(taskNode.getCode()); taskInstance.setTaskDefinitionVersion(taskNode.getVersion()); diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java index 4516d9dba2..824726bb6f 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java @@ -18,15 +18,15 @@ package org.apache.dolphinscheduler.server.master; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchParameters; -import org.apache.dolphinscheduler.common.task.switchtask.SwitchResultVo; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java index c9ed066003..270dc318a7 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/WorkflowExecuteThreadTest.java @@ -25,7 +25,6 @@ import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODES import static org.powermock.api.mockito.PowerMockito.mock; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.graph.DAG; @@ -35,6 +34,7 @@ import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.runner.StateWheelExecuteThread; import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThread; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java index b17dfc61f4..ec3f58aca0 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java @@ -18,9 +18,7 @@ package org.apache.dolphinscheduler.server.master.consumer; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Priority; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.dao.entity.DataSource; @@ -29,6 +27,7 @@ import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.server.master.dispatch.ExecutorDispatcher; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.queue.TaskPriority; @@ -82,7 +81,7 @@ public class TaskPriorityQueueConsumerTest { public void testSHELLTask() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -111,7 +110,7 @@ public class TaskPriorityQueueConsumerTest { public void testSQLTask() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SQL.getDesc()); + taskInstance.setTaskType("SQL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -152,7 +151,7 @@ public class TaskPriorityQueueConsumerTest { public void testDataxTask() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.DATAX.getDesc()); + taskInstance.setTaskType("DATAX"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -191,7 +190,7 @@ public class TaskPriorityQueueConsumerTest { public void testSqoopTask() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SQOOP.getDesc()); + taskInstance.setTaskType("SQOOP"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -230,7 +229,7 @@ public class TaskPriorityQueueConsumerTest { public void testTaskInstanceIsFinalState() { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -247,7 +246,7 @@ public class TaskPriorityQueueConsumerTest { public void testNotFoundWorkerGroup() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -280,7 +279,7 @@ public class TaskPriorityQueueConsumerTest { public void testDispatch() { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -316,7 +315,7 @@ public class TaskPriorityQueueConsumerTest { public void testRun() throws Exception { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java index 597c985b6d..06265d2e35 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutionContextTestUtils.java @@ -22,11 +22,14 @@ import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.remote.command.Command; +import org.apache.dolphinscheduler.remote.command.TaskExecuteRequestCommand; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.mockito.Mockito; @@ -34,7 +37,7 @@ import org.mockito.Mockito; * for test use only */ public class ExecutionContextTestUtils { - public static ExecutionContext getExecutionContext(int port){ + public static ExecutionContext getExecutionContext(int port) { TaskInstance taskInstance = Mockito.mock(TaskInstance.class); ProcessDefinition processDefinition = Mockito.mock(ProcessDefinition.class); ProcessInstance processInstance = new ProcessInstance(); @@ -45,7 +48,12 @@ public class ExecutionContextTestUtils { .buildProcessInstanceRelatedInfo(processInstance) .buildProcessDefinitionRelatedInfo(processDefinition) .create(); - ExecutionContext executionContext = new ExecutionContext(context.toCommand(), ExecutorType.WORKER); + + TaskExecuteRequestCommand requestCommand = new TaskExecuteRequestCommand(); + requestCommand.setTaskExecutionContext(JSONUtils.toJsonString(context)); + Command command = requestCommand.convert2Command(); + + ExecutionContext executionContext = new ExecutionContext(command, ExecutorType.WORKER); executionContext.setHost(Host.of(NetUtils.getAddr(port))); return executionContext; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java index 757078859f..88c6655d2a 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java @@ -22,7 +22,10 @@ import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.remote.NettyRemotingServer; +import org.apache.dolphinscheduler.remote.command.Command; +import org.apache.dolphinscheduler.remote.command.TaskExecuteRequestCommand; import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder; @@ -30,7 +33,7 @@ import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionConte import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType; import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException; import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteProcessor; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.junit.Assert; import org.junit.Ignore; @@ -67,7 +70,7 @@ public class NettyExecutorManagerTest { .buildProcessInstanceRelatedInfo(processInstance) .buildProcessDefinitionRelatedInfo(processDefinition) .create(); - ExecutionContext executionContext = new ExecutionContext(context.toCommand(), ExecutorType.WORKER); + ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER); executionContext.setHost(Host.of(NetUtils.getAddr(serverConfig.getListenPort()))); Boolean execute = nettyExecutorManager.execute(executionContext); Assert.assertTrue(execute); @@ -86,9 +89,15 @@ public class NettyExecutorManagerTest { .buildProcessInstanceRelatedInfo(processInstance) .buildProcessDefinitionRelatedInfo(processDefinition) .create(); - ExecutionContext executionContext = new ExecutionContext(context.toCommand(), ExecutorType.WORKER); + ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER); executionContext.setHost(Host.of(NetUtils.getAddr(4444))); nettyExecutorManager.execute(executionContext); } + + private Command toCommand(TaskExecutionContext taskExecutionContext) { + TaskExecuteRequestCommand requestCommand = new TaskExecuteRequestCommand(); + requestCommand.setTaskExecutionContext(JSONUtils.toJsonString(taskExecutionContext)); + return requestCommand.convert2Command(); + } } diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java deleted file mode 100644 index 823ffa2cd7..0000000000 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java +++ /dev/null @@ -1,91 +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.server.master.processor; - -import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; -import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseEvent; -import org.apache.dolphinscheduler.server.master.processor.queue.TaskResponseService; -import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; -import org.apache.dolphinscheduler.service.process.ProcessService; - -import java.util.Date; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import io.netty.channel.Channel; - -/** - * task ack processor test - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({SpringApplicationContext.class, TaskResponseEvent.class}) -public class TaskAckProcessorTest { - - private TaskAckProcessor taskAckProcessor; - private TaskResponseService taskResponseService; - private ProcessService processService; - private TaskExecuteAckCommand taskExecuteAckCommand; - private TaskResponseEvent taskResponseEvent; - private Channel channel; - - @Before - public void before() { - PowerMockito.mockStatic(SpringApplicationContext.class); - - taskResponseService = PowerMockito.mock(TaskResponseService.class); - PowerMockito.when(SpringApplicationContext.getBean(TaskResponseService.class)).thenReturn(taskResponseService); - - processService = PowerMockito.mock(ProcessService.class); - PowerMockito.when(SpringApplicationContext.getBean(ProcessService.class)).thenReturn(processService); - - taskAckProcessor = new TaskAckProcessor(); - - channel = PowerMockito.mock(Channel.class); - taskResponseEvent = PowerMockito.mock(TaskResponseEvent.class); - - taskExecuteAckCommand = new TaskExecuteAckCommand(); - taskExecuteAckCommand.setStatus(1); - taskExecuteAckCommand.setExecutePath("/dolphinscheduler/worker"); - taskExecuteAckCommand.setHost("localhost"); - taskExecuteAckCommand.setLogPath("/temp/worker.log"); - taskExecuteAckCommand.setStartTime(new Date()); - taskExecuteAckCommand.setTaskInstanceId(1); - taskExecuteAckCommand.setProcessInstanceId(1); - } - - @Test - public void testProcess() { -// Command command = taskExecuteAckCommand.convert2Command(); -// Assert.assertEquals(CommandType.TASK_EXECUTE_ACK,command.getType()); -// InetSocketAddress socketAddress = new InetSocketAddress("localhost",12345); -// PowerMockito.when(channel.remoteAddress()).thenReturn(socketAddress); -// PowerMockito.mockStatic(TaskResponseEvent.class); -// -// PowerMockito.when(TaskResponseEvent.newAck(Mockito.any(), Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyInt(), channel)) -// .thenReturn(taskResponseEvent); -// TaskInstance taskInstance = PowerMockito.mock(TaskInstance.class); -// PowerMockito.when(processService.findTaskInstanceById(Mockito.any())).thenReturn(taskInstance); -// -// taskAckProcessor.process(channel,command); - } -} diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessorTestConfig.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessorTestConfig.java index c1d96e3e21..c172d21d20 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessorTestConfig.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskResponseProcessorTestConfig.java @@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.server.master.processor; import org.apache.dolphinscheduler.server.utils.DataQualityResultOperator; + import org.mockito.Mockito; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java index 72ea4b903f..9794bdda04 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.server.master.processor.queue; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl; import org.apache.dolphinscheduler.service.process.ProcessService; diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java index afeb8480c0..35128388e3 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java @@ -17,12 +17,11 @@ package org.apache.dolphinscheduler.server.master.runner; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.enums.TaskType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; @@ -36,7 +35,6 @@ import org.junit.runner.RunWith; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; import org.springframework.context.ApplicationContext; @RunWith(MockitoJUnitRunner.Silent.class) @@ -122,7 +120,7 @@ public class MasterTaskExecThreadTest { private TaskInstance getTaskInstance() { TaskInstance taskInstance = new TaskInstance(); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setId(252612); taskInstance.setName("C"); taskInstance.setProcessInstanceId(10111); diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java index 55828e1659..136d26365d 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java @@ -18,22 +18,18 @@ package org.apache.dolphinscheduler.server.master.runner.task; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Priority; -import org.apache.dolphinscheduler.spi.enums.ResourceType; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; -import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.Tenant; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; +import org.apache.dolphinscheduler.spi.enums.ResourceType; import java.util.ArrayList; import java.util.Date; @@ -63,7 +59,7 @@ public class CommonTaskProcessorTest { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -96,7 +92,7 @@ public class CommonTaskProcessorTest { public void testGetResourceFullNames() { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); taskInstance.setState(ExecutionStatus.KILL); taskInstance.setProcessInstancePriority(Priority.MEDIUM); @@ -123,7 +119,7 @@ public class CommonTaskProcessorTest { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); - taskInstance.setTaskType(TaskType.SHELL.getDesc()); + taskInstance.setTaskType("SHELL"); taskInstance.setProcessInstanceId(1); ProcessInstance processInstance = new ProcessInstance(); @@ -145,21 +141,4 @@ public class CommonTaskProcessorTest { } - @Test - public void testSetDataxTaskRelation() throws Exception { - - DataxTaskExecutionContext dataxTaskExecutionContext = new DataxTaskExecutionContext(); - TaskInstance taskInstance = new TaskInstance(); - taskInstance.setTaskParams("{\"dataSource\":1,\"dataTarget\":1}"); - DataSource dataSource = new DataSource(); - dataSource.setId(1); - dataSource.setConnectionParams(""); - dataSource.setType(DbType.MYSQL); - Mockito.doReturn(dataSource).when(processService).findDataSourceById(1); - - commonTaskProcessor.setDataxTaskRelation(dataxTaskExecutionContext, taskInstance); - - Assert.assertEquals(1, dataxTaskExecutionContext.getDataSourceId()); - Assert.assertEquals(1, dataxTaskExecutionContext.getDataTargetId()); - } } diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java index 25f0ae9114..2059f3f266 100644 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java +++ b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java @@ -14,10 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.microbench.base; +import java.io.File; +import java.io.IOException; + import org.junit.Test; -import org.openjdk.jmh.annotations.*; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; import org.openjdk.jmh.results.format.ResultFormatType; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; @@ -25,9 +33,6 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; - /** * BaseBenchMark * If you need to test jmh, please extend him first @@ -46,7 +51,6 @@ public abstract class AbstractBaseBenchmark { private static Logger logger = LoggerFactory.getLogger(AbstractBaseBenchmark.class); - private ChainedOptionsBuilder newOptionsBuilder() { String className = getClass().getSimpleName(); @@ -76,7 +80,6 @@ public abstract class AbstractBaseBenchmark { if (file.exists()) { writeFileStatus = file.delete(); - } else { writeFileStatus = file.getParentFile().mkdirs(); try { @@ -118,6 +121,5 @@ public abstract class AbstractBaseBenchmark { return null != value ? Integer.parseInt(value) : -1; } - } diff --git a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventChangeCommand.java b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventChangeCommand.java index 13cade405d..1e7461b8ab 100644 --- a/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventChangeCommand.java +++ b/dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/command/StateEventChangeCommand.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.remote.command; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.io.Serializable; diff --git a/dolphinscheduler-server/pom.xml b/dolphinscheduler-server/pom.xml index 3b549de420..a446230f09 100644 --- a/dolphinscheduler-server/pom.xml +++ b/dolphinscheduler-server/pom.xml @@ -38,10 +38,6 @@ org.apache.dolphinscheduler dolphinscheduler-service - - org.apache.dolphinscheduler - dolphinscheduler-task-dataquality - org.mockito diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminator.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminator.java index b775d7461e..595dcd92d5 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminator.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminator.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.server.log; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.spi.task.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogFilter.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogFilter.java index b256fc8bb4..f243faba08 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogFilter.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/TaskLogFilter.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.server.log; -import org.apache.dolphinscheduler.spi.task.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LogUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LogUtils.java index 503d4afc8d..aeb3648016 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LogUtils.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LogUtils.java @@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.server.utils; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.utils.DateUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.server.log.TaskLogDiscriminator; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java index 320d30aa82..4dff8ede58 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java @@ -18,16 +18,16 @@ package org.apache.dolphinscheduler.server.utils; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.LoggerUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.log.LogClientService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminatorTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminatorTest.java index a783c84f8b..5b785448b7 100644 --- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminatorTest.java +++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/log/TaskLogDiscriminatorTest.java @@ -16,7 +16,7 @@ */ package org.apache.dolphinscheduler.server.log; -import org.apache.dolphinscheduler.spi.task.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/LogUtilsTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/LogUtilsTest.java index 456ada52d8..b6adb7ba48 100644 --- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/LogUtilsTest.java +++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/LogUtilsTest.java @@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.server.utils; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.utils.DateUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.server.log.TaskLogDiscriminator; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ProcessUtilsTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ProcessUtilsTest.java index 6631d3d9f6..a6243198b7 100644 --- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ProcessUtilsTest.java +++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ProcessUtilsTest.java @@ -20,10 +20,10 @@ package org.apache.dolphinscheduler.server.utils; import static org.powermock.api.mockito.PowerMockito.when; import org.apache.dolphinscheduler.common.Constants; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.lang.SystemUtils; diff --git a/dolphinscheduler-service/pom.xml b/dolphinscheduler-service/pom.xml index 8143cd7725..05ec23c1e0 100644 --- a/dolphinscheduler-service/pom.xml +++ b/dolphinscheduler-service/pom.xml @@ -47,6 +47,11 @@ dolphinscheduler-registry-zookeeper + + org.apache.dolphinscheduler + dolphinscheduler-task-api + + org.springframework.boot spring-boot-starter-quartz diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java index b679a6b363..aca23b8120 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java @@ -32,7 +32,7 @@ import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.TaskAlertContent; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqTaskState; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sClientService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sClientService.java index c921054f6b..63156ec66c 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sClientService.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sClientService.java @@ -70,7 +70,6 @@ public class K8sClientService { .withName(k8sNamespace.getNamespace()) .get(); - ResourceQuota body = yaml.loadAs(yamlStr, ResourceQuota.class); if (queryExist != null) { diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sManager.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sManager.java index c86d0eca07..52aa0876e3 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sManager.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/k8s/K8sManager.java @@ -60,7 +60,6 @@ public class K8sManager { return clientMap.get(k8sName); } - @EventListener public void buildApiClientAll(ApplicationReadyEvent readyEvent) throws RemotingException { QueryWrapper nodeWrapper = new QueryWrapper<>(); diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogPromise.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogPromise.java index 016176764f..f3c1078f07 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogPromise.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogPromise.java @@ -53,7 +53,7 @@ public class LogPromise { */ private Object result; - public LogPromise(long opaque, long timeout){ + public LogPromise(long opaque, long timeout) { this.opaque = opaque; this.timeout = timeout; this.start = System.currentTimeMillis(); @@ -61,15 +61,14 @@ public class LogPromise { PROMISES.put(opaque, this); } - /** * notify client finish * @param opaque unique identification * @param result result */ - public static void notify(long opaque, Object result){ + public static void notify(long opaque, Object result) { LogPromise promise = PROMISES.remove(opaque); - if(promise != null){ + if (promise != null) { promise.doCountDown(result); } } @@ -79,7 +78,7 @@ public class LogPromise { * * @param result result */ - private void doCountDown(Object result){ + private void doCountDown(Object result) { this.result = result; this.latch.countDown(); } @@ -88,7 +87,7 @@ public class LogPromise { * whether timeout * @return timeout */ - public boolean isTimeout(){ + public boolean isTimeout() { return System.currentTimeMillis() - start > timeout; } @@ -96,7 +95,7 @@ public class LogPromise { * get result * @return */ - public Object getResult(){ + public Object getResult() { try { latch.await(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException ignore) { @@ -106,5 +105,4 @@ public class LogPromise { return this.result; } - } diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/PermissionCheck.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/PermissionCheck.java index 491c191b36..fbac03953e 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/PermissionCheck.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/PermissionCheck.java @@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.service.permission; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; -import org.apache.dolphinscheduler.common.process.ResourceInfo; import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.service.exceptions.ServiceException; import org.apache.dolphinscheduler.service.process.ProcessService; diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java index b62e6ed5a1..eab78f1173 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.service.process; -import static java.util.stream.Collectors.toSet; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; @@ -27,13 +26,13 @@ import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; import static org.apache.dolphinscheduler.common.Constants.LOCAL_PARAMS; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TASK_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; + +import static java.util.stream.Collectors.toSet; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.Direct; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ReleaseState; @@ -42,21 +41,15 @@ import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.graph.DAG; -import org.apache.dolphinscheduler.common.model.DateInterval; 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.process.Property; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; -import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter; -import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.TaskTimeoutParameter; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils; -import org.apache.dolphinscheduler.common.utils.TaskParametersUtils; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.DagData; import org.apache.dolphinscheduler.dao.entity.DataSource; @@ -118,6 +111,15 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.WorkFlowLineageMapper; import org.apache.dolphinscheduler.dao.utils.DagHelper; import org.apache.dolphinscheduler.dao.utils.DqRuleUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; +import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SubProcessParameters; import org.apache.dolphinscheduler.remote.command.StateEventChangeCommand; import org.apache.dolphinscheduler.remote.command.TaskEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; @@ -126,12 +128,11 @@ import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.exceptions.ServiceException; import org.apache.dolphinscheduler.service.log.LogClientService; import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.dolphinscheduler.spi.enums.ResourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqTaskState; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang3.SerializationUtils; import java.util.ArrayList; import java.util.Arrays; @@ -144,7 +145,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Objects; import java.util.Set; -import java.util.stream.Collector; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -152,6 +152,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -262,6 +263,9 @@ public class ProcessService { @Autowired private WorkFlowLineageMapper workFlowLineageMapper; + @Autowired + private TaskPluginManager taskPluginManager; + /** * handle Command (construct ProcessInstance from Command) , wrapped in transaction * @@ -2020,7 +2024,7 @@ public class ProcessService { * @param ids ids * @return udf function list */ - public List queryUdfFunListByIds(int[] ids) { + public List queryUdfFunListByIds(Integer[] ids) { return udfFuncMapper.queryUdfByIdStr(ids, null); } @@ -2330,7 +2334,8 @@ public class ProcessService { */ public String getResourceIds(TaskDefinition taskDefinition) { Set resourceIds = null; - AbstractParameters params = TaskParametersUtils.getParameters(taskDefinition.getTaskType(), taskDefinition.getTaskParams()); + AbstractParameters params = taskPluginManager.getParameters(ParametersNode.builder().taskType(taskDefinition.getTaskType()).taskParams(taskDefinition.getTaskParams()).build()); + if (params != null && CollectionUtils.isNotEmpty(params.getResourceFilesList())) { resourceIds = params.getResourceFilesList(). stream() diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/TaskPriority.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/TaskPriority.java index 2cbd2987a8..12a7258d6c 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/TaskPriority.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/TaskPriority.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.service.queue; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import java.util.Map; import java.util.Objects; diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/TaskExecutionContext.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/TaskExecutionContext.java deleted file mode 100644 index a9fc2ae37c..0000000000 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/TaskExecutionContext.java +++ /dev/null @@ -1,630 +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.queue.entity; - -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.common.process.Property; -import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.remote.command.Command; -import org.apache.dolphinscheduler.remote.command.TaskExecuteRequestCommand; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.ProcedureTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.SqoopTaskExecutionContext; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; - - -/** - * master/worker task transport - */ -public class TaskExecutionContext implements Serializable { - - /** - * task id - */ - private int taskInstanceId; - - /** - * task name - */ - private String taskName; - - /** - * task first submit time. - */ - private Date firstSubmitTime; - - /** - * task start time - */ - private Date startTime; - - /** - * task type - */ - private String taskType; - - /** - * host - */ - private String host; - - /** - * task execute path - */ - private String executePath; - - /** - * log path - */ - private String logPath; - - /** - * task json - */ - private String taskJson; - - /** - * processId - */ - private int processId; - - /** - * processCode - */ - private Long processDefineCode; - - /** - * processVersion - */ - private int processDefineVersion; - - /** - * appIds - */ - private String appIds; - - /** - * process instance id - */ - private int processInstanceId; - - - /** - * process instance schedule time - */ - private Date scheduleTime; - - /** - * process instance global parameters - */ - private String globalParams; - - - /** - * execute user id - */ - private int executorId; - - - /** - * command type if complement - */ - private int cmdTypeIfComplement; - - - /** - * tenant code - */ - private String tenantCode; - - /** - * task queue - */ - private String queue; - - /** - * project code - */ - private long projectCode; - - /** - * taskParams - */ - private String taskParams; - - /** - * envFile - */ - private String envFile; - - /** - * environmentConfig - */ - private String environmentConfig; - - - /** - * definedParams - */ - private Map definedParams; - - /** - * task AppId - */ - private String taskAppId; - - /** - * task timeout strategy - */ - private TaskTimeoutStrategy taskTimeoutStrategy; - - /** - * task timeout - */ - private int taskTimeout; - - /** - * worker group - */ - private String workerGroup; - - /** - * delay execution time. - */ - private int delayTime; - - /** - * current execution status - */ - private ExecutionStatus currentExecutionStatus; - - /** - * resources full name and tenant code - */ - private Map resources; - - /** - * sql TaskExecutionContext - */ - private SQLTaskExecutionContext sqlTaskExecutionContext; - - /** - * datax TaskExecutionContext - */ - private DataxTaskExecutionContext dataxTaskExecutionContext; - - /** - * dependence TaskExecutionContext - */ - private DependenceTaskExecutionContext dependenceTaskExecutionContext; - - /** - * sqoop TaskExecutionContext - */ - private SqoopTaskExecutionContext sqoopTaskExecutionContext; - - /** - * data quality TaskExecutionContext - */ - private DataQualityTaskExecutionContext dataQualityTaskExecutionContext; - - /** - * taskInstance varPool - */ - private String varPool; - - /** - * dry run flag - */ - private int dryRun; - - /** - * business param - */ - private Map paramsMap; - - public Map getParamsMap() { - return paramsMap; - } - - public void setParamsMap(Map paramsMap) { - this.paramsMap = paramsMap; - } - - /** - * procedure TaskExecutionContext - */ - private ProcedureTaskExecutionContext procedureTaskExecutionContext; - - public int getTaskInstanceId() { - return taskInstanceId; - } - - public void setTaskInstanceId(int taskInstanceId) { - this.taskInstanceId = taskInstanceId; - } - - public String getTaskName() { - return taskName; - } - - public void setTaskName(String taskName) { - this.taskName = taskName; - } - - public Date getFirstSubmitTime() { - return firstSubmitTime; - } - - public void setFirstSubmitTime(Date firstSubmitTime) { - this.firstSubmitTime = firstSubmitTime; - } - - public Date getStartTime() { - return startTime; - } - - public void setStartTime(Date startTime) { - this.startTime = startTime; - } - - public String getTaskType() { - return taskType; - } - - public void setTaskType(String taskType) { - this.taskType = taskType; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getExecutePath() { - return executePath; - } - - public void setExecutePath(String executePath) { - this.executePath = executePath; - } - - public String getLogPath() { - return logPath; - } - - public void setLogPath(String logPath) { - this.logPath = logPath; - } - - public String getTaskJson() { - return taskJson; - } - - public void setTaskJson(String taskJson) { - this.taskJson = taskJson; - } - - public int getProcessId() { - return processId; - } - - public void setProcessId(int processId) { - this.processId = processId; - } - - public Long getProcessDefineCode() { - return processDefineCode; - } - - public void setProcessDefineCode(Long processDefineCode) { - this.processDefineCode = processDefineCode; - } - - public int getProcessDefineVersion() { - return processDefineVersion; - } - - public void setProcessDefineVersion(int processDefineVersion) { - this.processDefineVersion = processDefineVersion; - } - - public String getAppIds() { - return appIds; - } - - public void setAppIds(String appIds) { - this.appIds = appIds; - } - - public int getProcessInstanceId() { - return processInstanceId; - } - - public void setProcessInstanceId(int processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public Date getScheduleTime() { - return scheduleTime; - } - - public void setScheduleTime(Date scheduleTime) { - this.scheduleTime = scheduleTime; - } - - public String getGlobalParams() { - return globalParams; - } - - public void setGlobalParams(String globalParams) { - this.globalParams = globalParams; - } - - public int getExecutorId() { - return executorId; - } - - public void setExecutorId(int executorId) { - this.executorId = executorId; - } - - public int getCmdTypeIfComplement() { - return cmdTypeIfComplement; - } - - public void setCmdTypeIfComplement(int cmdTypeIfComplement) { - this.cmdTypeIfComplement = cmdTypeIfComplement; - } - - public String getTenantCode() { - return tenantCode; - } - - public void setTenantCode(String tenantCode) { - this.tenantCode = tenantCode; - } - - public String getQueue() { - return queue; - } - - public void setQueue(String queue) { - this.queue = queue; - } - - public long getProjectCode() { - return projectCode; - } - - public void setProjectCode(long projectCode) { - this.projectCode = projectCode; - } - - public String getTaskParams() { - return taskParams; - } - - public void setTaskParams(String taskParams) { - this.taskParams = taskParams; - } - - public String getEnvFile() { - return envFile; - } - - public void setEnvFile(String envFile) { - this.envFile = envFile; - } - - public String getEnvironmentConfig() { - return environmentConfig; - } - - public void setEnvironmentConfig(String config) { - this.environmentConfig = config; - } - - public Map getDefinedParams() { - return definedParams; - } - - public void setDefinedParams(Map definedParams) { - this.definedParams = definedParams; - } - - public String getTaskAppId() { - return taskAppId; - } - - public void setTaskAppId(String taskAppId) { - this.taskAppId = taskAppId; - } - - public TaskTimeoutStrategy getTaskTimeoutStrategy() { - return taskTimeoutStrategy; - } - - public void setTaskTimeoutStrategy(TaskTimeoutStrategy taskTimeoutStrategy) { - this.taskTimeoutStrategy = taskTimeoutStrategy; - } - - public int getTaskTimeout() { - return taskTimeout; - } - - public void setTaskTimeout(int taskTimeout) { - this.taskTimeout = taskTimeout; - } - - public String getWorkerGroup() { - return workerGroup; - } - - public void setWorkerGroup(String workerGroup) { - this.workerGroup = workerGroup; - } - - public int getDelayTime() { - return delayTime; - } - - public void setDelayTime(int delayTime) { - this.delayTime = delayTime; - } - - public ExecutionStatus getCurrentExecutionStatus() { - return currentExecutionStatus; - } - - public void setCurrentExecutionStatus(ExecutionStatus currentExecutionStatus) { - this.currentExecutionStatus = currentExecutionStatus; - } - - public SQLTaskExecutionContext getSqlTaskExecutionContext() { - return sqlTaskExecutionContext; - } - - public void setSqlTaskExecutionContext(SQLTaskExecutionContext sqlTaskExecutionContext) { - this.sqlTaskExecutionContext = sqlTaskExecutionContext; - } - - public DataxTaskExecutionContext getDataxTaskExecutionContext() { - return dataxTaskExecutionContext; - } - - public void setDataxTaskExecutionContext(DataxTaskExecutionContext dataxTaskExecutionContext) { - this.dataxTaskExecutionContext = dataxTaskExecutionContext; - } - - public ProcedureTaskExecutionContext getProcedureTaskExecutionContext() { - return procedureTaskExecutionContext; - } - - public void setProcedureTaskExecutionContext(ProcedureTaskExecutionContext procedureTaskExecutionContext) { - this.procedureTaskExecutionContext = procedureTaskExecutionContext; - } - - public Command toCommand() { - TaskExecuteRequestCommand requestCommand = new TaskExecuteRequestCommand(); - requestCommand.setTaskExecutionContext(JSONUtils.toJsonString(this)); - return requestCommand.convert2Command(); - } - - public DependenceTaskExecutionContext getDependenceTaskExecutionContext() { - return dependenceTaskExecutionContext; - } - - public void setDependenceTaskExecutionContext(DependenceTaskExecutionContext dependenceTaskExecutionContext) { - this.dependenceTaskExecutionContext = dependenceTaskExecutionContext; - } - - public Map getResources() { - return resources; - } - - public void setResources(Map resources) { - this.resources = resources; - } - - public SqoopTaskExecutionContext getSqoopTaskExecutionContext() { - return sqoopTaskExecutionContext; - } - - public void setSqoopTaskExecutionContext(SqoopTaskExecutionContext sqoopTaskExecutionContext) { - this.sqoopTaskExecutionContext = sqoopTaskExecutionContext; - } - - public DataQualityTaskExecutionContext getDataQualityTaskExecutionContext() { - return dataQualityTaskExecutionContext; - } - - public void setDataQualityTaskExecutionContext(DataQualityTaskExecutionContext dataQualityTaskExecutionContext) { - this.dataQualityTaskExecutionContext = dataQualityTaskExecutionContext; - } - - public int getDryRun() { - return dryRun; - } - - public void setDryRun(int dryRun) { - this.dryRun = dryRun; - } - - @Override - public String toString() { - return "TaskExecutionContext{" - + "taskInstanceId=" + taskInstanceId - + ", taskName='" + taskName + '\'' - + ", currentExecutionStatus=" + currentExecutionStatus - + ", firstSubmitTime=" + firstSubmitTime - + ", startTime=" + startTime - + ", taskType='" + taskType + '\'' - + ", host='" + host + '\'' - + ", executePath='" + executePath + '\'' - + ", logPath='" + logPath + '\'' - + ", taskJson='" + taskJson + '\'' - + ", processId=" + processId - + ", processDefineCode=" + processDefineCode - + ", processDefineVersion=" + processDefineVersion - + ", appIds='" + appIds + '\'' - + ", processInstanceId=" + processInstanceId - + ", scheduleTime=" + scheduleTime - + ", globalParams='" + globalParams + '\'' - + ", executorId=" + executorId - + ", cmdTypeIfComplement=" + cmdTypeIfComplement - + ", tenantCode='" + tenantCode + '\'' - + ", queue='" + queue + '\'' - + ", projectCode=" + projectCode - + ", taskParams='" + taskParams + '\'' - + ", envFile='" + envFile + '\'' - + ", dryRun='" + dryRun + '\'' - + ", definedParams=" + definedParams - + ", taskAppId='" + taskAppId + '\'' - + ", taskTimeoutStrategy=" + taskTimeoutStrategy - + ", taskTimeout=" + taskTimeout - + ", workerGroup='" + workerGroup + '\'' - + ", environmentConfig='" + environmentConfig + '\'' - + ", delayTime=" + delayTime - + ", resources=" + resources - + ", sqlTaskExecutionContext=" + sqlTaskExecutionContext - + ", dataxTaskExecutionContext=" + dataxTaskExecutionContext - + ", dependenceTaskExecutionContext=" + dependenceTaskExecutionContext - + ", sqoopTaskExecutionContext=" + sqoopTaskExecutionContext - + ", procedureTaskExecutionContext=" + procedureTaskExecutionContext - + ", dataQualityTaskExecutionContext=" + dataQualityTaskExecutionContext - + '}'; - } - - public String getVarPool() { - return varPool; - } - - public void setVarPool(String varPool) { - this.varPool = varPool; - } -} diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/plugin/TaskPluginManager.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/task/TaskPluginManager.java similarity index 74% rename from dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/plugin/TaskPluginManager.java rename to dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/task/TaskPluginManager.java index 08610a2d3a..72f3454dcb 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/plugin/TaskPluginManager.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/task/TaskPluginManager.java @@ -15,28 +15,29 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.server.worker.plugin; +package org.apache.dolphinscheduler.service.task; import static java.lang.String.format; import org.apache.dolphinscheduler.common.enums.PluginType; import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.entity.PluginDefine; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.PostConstruct; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -64,6 +65,27 @@ public class TaskPluginManager { return Collections.unmodifiableMap(taskChannelMap); } + public TaskChannel getTaskChannel(String type) { + return this.getTaskChannelMap().get(type); + } + + public boolean checkTaskParameters(ParametersNode parametersNode) { + AbstractParameters abstractParameters = this.getParameters(parametersNode); + return abstractParameters != null && abstractParameters.checkParameters(); + } + + public AbstractParameters getParameters(ParametersNode parametersNode) { + String taskType = parametersNode.getTaskType(); + if (Objects.isNull(taskType)) { + return null; + } + TaskChannel taskChannel = this.getTaskChannelMap().get(taskType); + if (Objects.isNull(taskChannel)) { + return null; + } + return taskChannel.parseParameters(parametersNode); + } + @EventListener public void installPlugin(ApplicationReadyEvent readyEvent) { final Set names = new HashSet<>(); diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManagerTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManagerTest.java index d2808e64f7..5c0d4bbcd8 100644 --- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManagerTest.java +++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManagerTest.java @@ -18,12 +18,12 @@ package org.apache.dolphinscheduler.service.alert; import org.apache.dolphinscheduler.common.enums.CommandType; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.TaskInstance; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java index fce25851a1..37c12f36a8 100644 --- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java +++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java @@ -28,14 +28,11 @@ import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.Flag; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.TaskGroupQueueStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; 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.ResourceInfo; -import org.apache.dolphinscheduler.common.task.spark.SparkParameters; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Command; @@ -47,10 +44,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap; -import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation; import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog; import org.apache.dolphinscheduler.dao.entity.Resource; -import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; import org.apache.dolphinscheduler.dao.entity.TaskGroupQueue; import org.apache.dolphinscheduler.dao.entity.TaskInstance; @@ -74,24 +69,22 @@ import org.apache.dolphinscheduler.dao.mapper.TaskGroupMapper; import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ValueType; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.service.exceptions.ServiceException; import org.apache.dolphinscheduler.service.quartz.cron.CronUtilsTest; import org.apache.dolphinscheduler.spi.params.base.FormType; -import org.apache.dolphinscheduler.spi.task.dq.enums.DqTaskState; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.dq.enums.InputType; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ValueType; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.Assert; import org.junit.Rule; @@ -685,7 +678,7 @@ public class ProcessServiceTest { taskDefinition.setCode(751500437479424L); taskDefinition.setName("aa"); taskDefinition.setProjectCode(751485690568704L); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(-1); taskDefinition.setVersion(1); taskDefinition.setCreateTime(new Date()); @@ -722,7 +715,7 @@ public class ProcessServiceTest { taskDefinition.setCode(3L); taskDefinition.setName("1-test"); taskDefinition.setProjectCode(1L); - taskDefinition.setTaskType(TaskType.SHELL.getDesc()); + taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(1); taskDefinition.setVersion(2); taskDefinition.setCreateTime(new Date()); @@ -732,7 +725,7 @@ public class ProcessServiceTest { td2.setCode(2L); td2.setName("unit-test"); td2.setProjectCode(1L); - td2.setTaskType(TaskType.SHELL.getDesc()); + td2.setTaskType("SHELL"); td2.setUserId(1); td2.setVersion(1); td2.setCreateTime(new Date()); @@ -777,89 +770,6 @@ public class ProcessServiceTest { processService.changeOutParam(taskInstance); } - @Test - public void testUpdateTaskDefinitionResources() throws Exception { - TaskDefinition taskDefinition = new TaskDefinition(); - String taskParameters = "{\n" - + " \"mainClass\": \"org.apache.dolphinscheduler.SparkTest\",\n" - + " \"mainJar\": {\n" - + " \"id\": 1\n" - + " },\n" - + " \"deployMode\": \"cluster\",\n" - + " \"resourceList\": [\n" - + " {\n" - + " \"id\": 3\n" - + " },\n" - + " {\n" - + " \"id\": 4\n" - + " }\n" - + " ],\n" - + " \"localParams\": [],\n" - + " \"driverCores\": 1,\n" - + " \"driverMemory\": \"512M\",\n" - + " \"numExecutors\": 2,\n" - + " \"executorMemory\": \"2G\",\n" - + " \"executorCores\": 2,\n" - + " \"appName\": \"\",\n" - + " \"mainArgs\": \"\",\n" - + " \"others\": \"\",\n" - + " \"programType\": \"JAVA\",\n" - + " \"sparkVersion\": \"SPARK2\",\n" - + " \"dependence\": {},\n" - + " \"conditionResult\": {\n" - + " \"successNode\": [\n" - + " \"\"\n" - + " ],\n" - + " \"failedNode\": [\n" - + " \"\"\n" - + " ]\n" - + " },\n" - + " \"waitStartTimeout\": {}\n" - + "}"; - taskDefinition.setTaskParams(taskParameters); - - Map resourceMap = - Stream.of(1, 3, 4) - .map(i -> { - Resource resource = new Resource(); - resource.setId(i); - resource.setFileName("file" + i); - resource.setFullName("/file" + i); - return resource; - }) - .collect( - Collectors.toMap( - Resource::getId, - resource -> resource) - ); - for (Integer integer : Arrays.asList(1, 3, 4)) { - Mockito.when(resourceMapper.selectById(integer)) - .thenReturn(resourceMap.get(integer)); - } - - Whitebox.invokeMethod(processService, - "updateTaskDefinitionResources", - taskDefinition); - - String taskParams = taskDefinition.getTaskParams(); - SparkParameters sparkParameters = JSONUtils.parseObject(taskParams, SparkParameters.class); - ResourceInfo mainJar = sparkParameters.getMainJar(); - Assert.assertEquals(1, mainJar.getId()); - Assert.assertEquals("file1", mainJar.getRes()); - Assert.assertEquals("/file1", mainJar.getResourceName()); - - Assert.assertEquals(2, sparkParameters.getResourceList().size()); - ResourceInfo res1 = sparkParameters.getResourceList().get(0); - ResourceInfo res2 = sparkParameters.getResourceList().get(1); - Assert.assertEquals(3, res1.getId()); - Assert.assertEquals("file3", res1.getRes()); - Assert.assertEquals("/file3", res1.getResourceName()); - Assert.assertEquals(4, res2.getId()); - Assert.assertEquals("file4", res2.getRes()); - Assert.assertEquals("/file4", res2.getResourceName()); - - } - @Test public void testUpdateResourceInfo() throws Exception { // test if input is null diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DataType.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DataType.java deleted file mode 100644 index f4787e5fec..0000000000 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/DataType.java +++ /dev/null @@ -1,37 +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.spi.enums; - -/** - * data types in user define parameter - */ -public enum DataType { - /** - * 0 string - * 1 integer - * 2 long - * 3 float - * 4 double - * 5 date, "YYYY-MM-DD" - * 6 time, "HH:MM:SS" - * 7 time stamp - * 8 Boolean - * 9 list - */ - VARCHAR,INTEGER,LONG,FLOAT,DOUBLE,DATE,TIME,TIMESTAMP,BOOLEAN,LIST -} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/TaskTimeoutStrategy.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/TaskTimeoutStrategy.java deleted file mode 100644 index 9df8d55abe..0000000000 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/enums/TaskTimeoutStrategy.java +++ /dev/null @@ -1,58 +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.spi.enums; - -/** - * task timeout strategy - */ -public enum TaskTimeoutStrategy { - /** - * 0 warn - * 1 failed - * 2 warn+failed - */ - WARN(0, "warn"), - FAILED(1,"failed"), - WARNFAILED(2,"warnfailed"); - - TaskTimeoutStrategy(int code, String descp) { - this.code = code; - this.descp = descp; - } - - private final int code; - private final String descp; - - public int getCode() { - return code; - } - - public String getDescp() { - return descp; - } - - public static TaskTimeoutStrategy of(int status) { - for (TaskTimeoutStrategy es : values()) { - if (es.getCode() == status) { - return es; - } - } - throw new IllegalArgumentException("invalid status : " + status); - } - -} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ExecutionStatus.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ExecutionStatus.java deleted file mode 100644 index 836c0cd3d9..0000000000 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ExecutionStatus.java +++ /dev/null @@ -1,162 +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.spi.task; - -import java.util.HashMap; - -/** - * running status for workflow and task nodes - */ -public enum ExecutionStatus { - - /** - * status: - * 0 submit success - * 1 running - * 2 ready pause - * 3 pause - * 4 ready stop - * 5 stop - * 6 failure - * 7 success - * 8 need fault tolerance - * 9 kill - * 10 waiting thread - * 11 waiting depend node complete - * 12 delay execution - * 13 forced success - */ - SUBMITTED_SUCCESS(0, "submit success"), - RUNNING_EXECUTION(1, "running"), - READY_PAUSE(2, "ready pause"), - PAUSE(3, "pause"), - READY_STOP(4, "ready stop"), - STOP(5, "stop"), - FAILURE(6, "failure"), - SUCCESS(7, "success"), - NEED_FAULT_TOLERANCE(8, "need fault tolerance"), - KILL(9, "kill"), - WAITTING_THREAD(10, "waiting thread"), - WAITTING_DEPEND(11, "waiting depend node complete"), - DELAY_EXECUTION(12, "delay execution"), - FORCED_SUCCESS(13, "forced success"); - - ExecutionStatus(int code, String descp) { - this.code = code; - this.descp = descp; - } - - private final int code; - private final String descp; - - private static final HashMap EXECUTION_STATUS_MAP = new HashMap<>(); - - static { - for (ExecutionStatus executionStatus : ExecutionStatus.values()) { - EXECUTION_STATUS_MAP.put(executionStatus.code, executionStatus); - } - } - - /** - * status is success - * - * @return status - */ - public boolean typeIsSuccess() { - return this == SUCCESS || this == FORCED_SUCCESS; - } - - /** - * status is failure - * - * @return status - */ - public boolean typeIsFailure() { - return this == FAILURE || this == NEED_FAULT_TOLERANCE || this == KILL; - } - - /** - * status is finished - * - * @return status - */ - public boolean typeIsFinished() { - return typeIsSuccess() || typeIsFailure() || typeIsCancel() || typeIsPause() - || typeIsStop(); - } - - /** - * status is waiting thread - * - * @return status - */ - public boolean typeIsWaitingThread() { - return this == WAITTING_THREAD; - } - - /** - * status is pause - * - * @return status - */ - public boolean typeIsPause() { - return this == PAUSE; - } - - /** - * status is pause - * - * @return status - */ - public boolean typeIsStop() { - return this == STOP; - } - - /** - * status is running - * - * @return status - */ - public boolean typeIsRunning() { - return this == RUNNING_EXECUTION || this == WAITTING_DEPEND || this == DELAY_EXECUTION; - } - - /** - * status is cancel - * - * @return status - */ - public boolean typeIsCancel() { - return this == KILL || this == STOP; - } - - public int getCode() { - return code; - } - - public String getDescp() { - return descp; - } - - public static ExecutionStatus of(int status) { - if (EXECUTION_STATUS_MAP.containsKey(status)) { - return EXECUTION_STATUS_MAP.get(status); - } - throw new IllegalArgumentException("invalid status : " + status); - } -} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/IParameters.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/IParameters.java deleted file mode 100644 index 4422f743c0..0000000000 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/IParameters.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.dolphinscheduler.spi.task;/* - * 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. - */ - -import java.util.List; - -/** - * job params interface - */ -public interface IParameters { - /** - * check parameters is valid - * - * @return result - */ - boolean checkParameters(); - - /** - * get project resource files list - * - * @return resource files list - */ - List getResourceFilesList(); -} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/UdfFuncBean.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/UdfFuncBean.java deleted file mode 100644 index 52e77d60c8..0000000000 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/UdfFuncBean.java +++ /dev/null @@ -1,188 +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.spi.task; - -import org.apache.dolphinscheduler.spi.utils.JSONUtils; -import org.apache.dolphinscheduler.spi.utils.StringUtils; - -import java.io.IOException; - -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; - -/** - * udf function - */ -public class UdfFuncBean { - /** - * id - */ - private int id; - /** - * user id - */ - private int userId; - - /** - * udf function name - */ - private String funcName; - - /** - * udf class name - */ - private String className; - - /** - * udf argument types - */ - private String argTypes; - - /** - * udf data base - */ - private String database; - - /** - * udf description - */ - private String description; - - /** - * resource id - */ - private int resourceId; - - /** - * resource name - */ - private String resourceName; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getUserId() { - return userId; - } - - public void setUserId(int userId) { - this.userId = userId; - } - - public String getFuncName() { - return funcName; - } - - public void setFuncName(String funcName) { - this.funcName = funcName; - } - - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } - - public String getArgTypes() { - return argTypes; - } - - public void setArgTypes(String argTypes) { - this.argTypes = argTypes; - } - - public String getDatabase() { - return database; - } - - public void setDatabase(String database) { - this.database = database; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public int getResourceId() { - return resourceId; - } - - public void setResourceId(int resourceId) { - this.resourceId = resourceId; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - UdfFuncBean udfFunc = (UdfFuncBean) o; - - if (id != udfFunc.id) { - return false; - } - return !(funcName != null ? !funcName.equals(udfFunc.funcName) : udfFunc.funcName != null); - - } - - @Override - public int hashCode() { - int result = id; - result = 31 * result + (funcName != null ? funcName.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return JSONUtils.toJsonString(this); - } - - public static class UdfFuncDeserializer extends KeyDeserializer { - - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException { - if (StringUtils.isBlank(key)) { - return null; - } - return JSONUtils.parseObject(key, UdfFuncBean.class); - } - } -} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/DateUtils.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/DateUtils.java index 104e4487b3..4f4a8e7a17 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/DateUtils.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/DateUtils.java @@ -166,6 +166,33 @@ public class DateUtils { return Math.abs(d1.getTime() - d2.getTime()); } + /** + * get the date of the specified date in the days before and after + * + * @param date date + * @param day day + * @return the date of the specified date in the days before and after + */ + public static Date getSomeDay(Date date, int day) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DATE, day); + return calendar.getTime(); + } + + /** + * get the hour of day. + * + * @param date date + * @return hour of day + */ + public static int getHourIndex(Date date) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(Calendar.HOUR_OF_DAY); + } + + /** * compare two dates * @@ -239,6 +266,25 @@ public class DateUtils { return cal.getTime(); } + /** + * get some hour of day + * + * @param date date + * @param offsetHour hours + * @return some hour of day + */ + public static Date getSomeHourOfDay(Date date, int offsetHour) { + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) + offsetHour); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + + return cal.getTime(); + } + /** * get last day of month * @@ -257,6 +303,77 @@ public class DateUtils { return cal.getTime(); } + /** + * return YYYY-MM-DD 00:00:00 + * + * @param inputDay date + * @return start day + */ + public static Date getStartOfDay(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 23:59:59 + * + * @param inputDay day + * @return end of day + */ + public static Date getEndOfDay(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.HOUR_OF_DAY, 23); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + cal.set(Calendar.MILLISECOND, 999); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 00:00:00 + * + * @param inputDay day + * @return start of hour + */ + public static Date getStartOfHour(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); + } + + /** + * return YYYY-MM-DD 23:59:59 + * + * @param inputDay day + * @return end of hour + */ + public static Date getEndOfHour(Date inputDay) { + Calendar cal = Calendar.getInstance(); + cal.setTime(inputDay); + cal.set(Calendar.MINUTE, 59); + cal.set(Calendar.SECOND, 59); + cal.set(Calendar.MILLISECOND, 999); + return cal.getTime(); + } + + /** + * get current date + * + * @return current date + */ + public static Date getCurrentDate() { + return new Date(); + } + public static Date addMonths(Date date, int amount) { return add(date, 2, amount); } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/StringUtils.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/StringUtils.java index 0190e170d2..a98e38b59a 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/StringUtils.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/utils/StringUtils.java @@ -17,8 +17,6 @@ package org.apache.dolphinscheduler.spi.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SINGLE_QUOTES; - import java.io.IOException; import java.io.StringWriter; import java.io.Writer; @@ -280,10 +278,6 @@ public class StringUtils { return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH); } - public static String wrapperSingleQuotes(String value) { - return SINGLE_QUOTES + value + SINGLE_QUOTES; - } - public static String replaceDoubleBrackets(String mainParameter) { mainParameter = mainParameter .replace(Constants.DOUBLE_BRACKETS_LEFT, Constants.DOUBLE_BRACKETS_LEFT_SPACE) diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/utils/StringUtilsTest.java b/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/utils/StringUtilsTest.java index 0ba8787e2c..45e9e35f49 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/utils/StringUtilsTest.java +++ b/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/utils/StringUtilsTest.java @@ -107,11 +107,6 @@ public class StringUtilsTest { assertEquals("str", StringUtils.escapeJava("str")); } - @Test - public void testWrapperSingleQuotes() { - assertEquals("'a'", StringUtils.wrapperSingleQuotes("a")); - } - @Test public void testReplaceDoubleBrackets() { assertEquals("{ {a} }", StringUtils.replaceDoubleBrackets("{{a}}")); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-all/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-all/pom.xml new file mode 100644 index 0000000000..a8c0494f49 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-all/pom.xml @@ -0,0 +1,146 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-all + + + + org.apache.dolphinscheduler + dolphinscheduler-task-conditions + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-dataquality + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-datax + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-dependent + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-flink + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-http + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-mr + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-pigeon + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-procedure + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-python + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-seatunnel + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-shell + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-spark + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-sql + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-sqoop + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-subprocess + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-switch + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-emr + ${project.version} + + + + org.apache.dolphinscheduler + dolphinscheduler-task-blocking + ${project.version} + + + + \ No newline at end of file diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/pom.xml index 5eb651c37d..80fa582310 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/pom.xml +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/pom.xml @@ -33,6 +33,11 @@ dolphinscheduler-spi provided + + com.baomidou + mybatis-plus-annotation + ${mybatis-plus.version} + commons-io commons-io diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java index 660b759f8f..340053844a 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java @@ -17,17 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.api; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_KILL; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; -import org.apache.hadoop.hive.common.LogUtils; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -97,10 +93,10 @@ public abstract class AbstractCommandExecutor { /** * taskRequest */ - protected TaskRequest taskRequest; + protected TaskExecutionContext taskRequest; public AbstractCommandExecutor(Consumer> logHandler, - TaskRequest taskRequest, + TaskExecutionContext taskRequest, Logger logger) { this.logHandler = logHandler; this.taskRequest = taskRequest; @@ -414,7 +410,7 @@ public abstract class AbstractCommandExecutor { * @param line * @return */ - private String findVarPool(String line){ + private String findVarPool(String line) { Matcher matcher = SETVALUE_REGEX.matcher(line); if (matcher.find()) { return matcher.group(1); diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTask.java similarity index 91% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractTask.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTask.java index 5a6cfd2c51..9bf560266c 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTask.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskAlertInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; /** * executive task @@ -32,7 +34,7 @@ public abstract class AbstractTask { /** * taskExecutionContext **/ - TaskRequest taskRequest; + TaskExecutionContext taskRequest; /** * SHELL process pid @@ -69,7 +71,7 @@ public abstract class AbstractTask { * * @param taskExecutionContext taskExecutionContext */ - protected AbstractTask(TaskRequest taskExecutionContext) { + protected AbstractTask(TaskExecutionContext taskExecutionContext) { this.taskRequest = taskExecutionContext; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskExecutor.java index 28c6bad39d..6806d6e2b9 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractTaskExecutor.java @@ -17,10 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.util.Map; import java.util.StringJoiner; @@ -45,7 +42,7 @@ public abstract class AbstractTaskExecutor extends AbstractTask { * * @param taskRequest taskRequest */ - protected AbstractTaskExecutor(TaskRequest taskRequest) { + protected AbstractTaskExecutor(TaskExecutionContext taskRequest) { super(taskRequest); } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java index 303ea030cf..860d5c13c7 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractYarnTask.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; /** * abstract yarn task @@ -34,7 +34,7 @@ public abstract class AbstractYarnTask extends AbstractTaskExecutor { * * @param taskRequest taskRequest */ - public AbstractYarnTask(TaskRequest taskRequest) { + public AbstractYarnTask(TaskExecutionContext taskRequest) { super(taskRequest); this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle, taskRequest, diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataQualityTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/DataQualityTaskExecutionContext.java similarity index 99% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataQualityTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/DataQualityTaskExecutionContext.java index 4ffd62d969..684ed712c9 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataQualityTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/DataQualityTaskExecutionContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.api; import java.io.Serializable; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ProcessUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ProcessUtils.java index 2f94003fbb..d052075988 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ProcessUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ProcessUtils.java @@ -17,9 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -48,7 +46,7 @@ public final class ProcessUtils { /** * kill tasks according to different task types. */ - public static void kill(TaskRequest request) { + public static void kill(TaskExecutionContext request) { try { int processId = request.getProcessId(); if (processId == 0) { diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SQLTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/SQLTaskExecutionContext.java similarity index 73% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SQLTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/SQLTaskExecutionContext.java index c02cd4361c..9c025e800c 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SQLTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/SQLTaskExecutionContext.java @@ -15,14 +15,12 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.task.request.UdfFuncRequest.UdfFuncDeserializer; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.UdfFuncParameters; import java.io.Serializable; -import java.util.Map; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; /** * SQL Task ExecutionContext @@ -39,11 +37,8 @@ public class SQLTaskExecutionContext implements Serializable { * connectionParams */ private String connectionParams; - /** - * udf function tenant code map - */ - @JsonDeserialize(keyUsing = UdfFuncDeserializer.class) - private Map udfFuncTenantCodeMap; + + private List udfFuncParametersList; /** * DefaultFS @@ -58,12 +53,12 @@ public class SQLTaskExecutionContext implements Serializable { this.warningGroupId = warningGroupId; } - public Map getUdfFuncTenantCodeMap() { - return udfFuncTenantCodeMap; + public List getUdfFuncParametersList() { + return udfFuncParametersList; } - public void setUdfFuncTenantCodeMap(Map udfFuncTenantCodeMap) { - this.udfFuncTenantCodeMap = udfFuncTenantCodeMap; + public void setUdfFuncParametersList(List udfFuncParametersList) { + this.udfFuncParametersList = udfFuncParametersList; } public String getConnectionParams() { @@ -87,7 +82,7 @@ public class SQLTaskExecutionContext implements Serializable { return "SQLTaskExecutionContext{" + "warningGroupId=" + warningGroupId + ", connectionParams='" + connectionParams + '\'' - + ", udfFuncTenantCodeMap=" + udfFuncTenantCodeMap + + ", udfFuncParametersList=" + udfFuncParametersList + ", defaultFS='" + defaultFS + '\'' + '}'; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java index 2912395413..37a3e963b7 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java @@ -17,8 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; @@ -56,7 +55,7 @@ public class ShellCommandExecutor extends AbstractCommandExecutor { * @param logger logger */ public ShellCommandExecutor(Consumer> logHandler, - TaskRequest taskRequest, + TaskExecutionContext taskRequest, Logger logger) { super(logHandler, taskRequest, logger); } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannel.java similarity index 63% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannel.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannel.java index 681970f243..421a2646c2 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannel.java @@ -15,14 +15,20 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; public interface TaskChannel { void cancelApplication(boolean status); - AbstractTask createTask(TaskRequest taskRequest); + AbstractTask createTask(TaskExecutionContext taskRequest); + + AbstractParameters parseParameters(ParametersNode parametersNode); + + ResourceParametersHelper getResources(String parameters); } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannelFactory.java similarity index 94% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannelFactory.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannelFactory.java index b2c568f211..643c4cdb70 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskChannelFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api; import org.apache.dolphinscheduler.spi.common.UiChannelFactory; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskConstants.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java similarity index 93% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskConstants.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java index 6489bce22e..cdd2f783dc 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskConstants.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java @@ -15,7 +15,10 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api; + +import java.util.Arrays; +import java.util.List; public class TaskConstants { @@ -372,6 +375,22 @@ public class TaskConstants { */ public static final String DATA_QUALITY_ERROR_OUTPUT_PATH = "data-quality.error.output.path"; + public static final String TASK_TYPE_CONDITIONS = "CONDITIONS"; + + public static final String TASK_TYPE_SWITCH = "SWITCH"; + + public static final String TASK_TYPE_SUB_PROCESS = "SUB_PROCESS"; + + public static final String TASK_TYPE_DEPENDENT = "DEPENDENT"; + + public static final String TASK_TYPE_SQL = "SQL"; + + public static final String TASK_TYPE_DATA_QUALITY = "DATA_QUALITY"; + + public static final String TASK_TYPE_BLOCKING = "BLOCKING"; + + public static final List COMPLEX_TASK_TYPES = Arrays.asList(new String[]{TASK_TYPE_CONDITIONS, TASK_TYPE_SWITCH, TASK_TYPE_SUB_PROCESS, TASK_TYPE_DEPENDENT}); + /** * aws config */ diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/TaskRequest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java similarity index 80% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/TaskRequest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java index df0aa7f5ab..882ab59b0a 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/TaskRequest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContext.java @@ -15,10 +15,12 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.api; -import org.apache.dolphinscheduler.spi.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.spi.task.Property; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import java.util.Date; import java.util.Map; @@ -26,7 +28,7 @@ import java.util.Map; /** * to master/worker task transport */ -public class TaskRequest { +public class TaskExecutionContext { /** * task id @@ -78,6 +80,16 @@ public class TaskRequest { */ private int processId; + /** + * processCode + */ + private Long processDefineCode; + + /** + * processVersion + */ + private int processDefineVersion; + /** * appIds */ @@ -133,6 +145,11 @@ public class TaskRequest { */ private int projectId; + /** + * project code + */ + private long projectCode; + /** * taskParams */ @@ -178,50 +195,45 @@ public class TaskRequest { */ private int delayTime; + /** + * current execution status + */ + private ExecutionStatus currentExecutionStatus; + /** * Task Logger name should be like: Task-{processDefinitionId}-{processInstanceId}-{taskInstanceId} */ private String taskLogName; - public String getTaskLogName() { - return taskLogName; - } - - public void setTaskLogName(String taskLogName) { - this.taskLogName = taskLogName; - } + private ResourceParametersHelper resourceParametersHelper; /** * resources full name and tenant code */ private Map resources; - - private Map paramsMap; - - - /** - * sql TaskExecutionContext - */ - private SQLTaskExecutionContext sqlTaskExecutionContext; - /** - * datax TaskExecutionContext + * taskInstance varPool */ - private DataxTaskExecutionContext dataxTaskExecutionContext; + private String varPool; /** - * procedure TaskExecutionContext + * dry run flag */ - private ProcedureTaskExecutionContext procedureTaskExecutionContext; + private int dryRun; - /** - * sqoop TaskExecutionContext - */ - private SqoopTaskExecutionContext sqoopTaskExecutionContext; + private Map paramsMap; private DataQualityTaskExecutionContext dataQualityTaskExecutionContext; + public String getTaskLogName() { + return taskLogName; + } + + public void setTaskLogName(String taskLogName) { + this.taskLogName = taskLogName; + } + public Map getResources() { return resources; } @@ -470,36 +482,52 @@ public class TaskRequest { this.delayTime = delayTime; } - public SQLTaskExecutionContext getSqlTaskExecutionContext() { - return sqlTaskExecutionContext; + public ResourceParametersHelper getResourceParametersHelper() { + return resourceParametersHelper; } - public void setSqlTaskExecutionContext(SQLTaskExecutionContext sqlTaskExecutionContext) { - this.sqlTaskExecutionContext = sqlTaskExecutionContext; + public void setResourceParametersHelper(ResourceParametersHelper resourceParametersHelper) { + this.resourceParametersHelper = resourceParametersHelper; } - public DataxTaskExecutionContext getDataxTaskExecutionContext() { - return dataxTaskExecutionContext; + public String getVarPool() { + return varPool; } - public void setDataxTaskExecutionContext(DataxTaskExecutionContext dataxTaskExecutionContext) { - this.dataxTaskExecutionContext = dataxTaskExecutionContext; + public void setVarPool(String varPool) { + this.varPool = varPool; } - public SqoopTaskExecutionContext getSqoopTaskExecutionContext() { - return sqoopTaskExecutionContext; + public int getDryRun() { + return dryRun; } - public void setSqoopTaskExecutionContext(SqoopTaskExecutionContext sqoopTaskExecutionContext) { - this.sqoopTaskExecutionContext = sqoopTaskExecutionContext; + public void setDryRun(int dryRun) { + this.dryRun = dryRun; } - public ProcedureTaskExecutionContext getProcedureTaskExecutionContext() { - return procedureTaskExecutionContext; + public Long getProcessDefineCode() { + return processDefineCode; } - public void setProcedureTaskExecutionContext(ProcedureTaskExecutionContext procedureTaskExecutionContext) { - this.procedureTaskExecutionContext = procedureTaskExecutionContext; + public void setProcessDefineCode(Long processDefineCode) { + this.processDefineCode = processDefineCode; + } + + public int getProcessDefineVersion() { + return processDefineVersion; + } + + public void setProcessDefineVersion(int processDefineVersion) { + this.processDefineVersion = processDefineVersion; + } + + public long getProjectCode() { + return projectCode; + } + + public void setProjectCode(long projectCode) { + this.projectCode = projectCode; } public DataQualityTaskExecutionContext getDataQualityTaskExecutionContext() { @@ -509,4 +537,13 @@ public class TaskRequest { public void setDataQualityTaskExecutionContext(DataQualityTaskExecutionContext dataQualityTaskExecutionContext) { this.dataQualityTaskExecutionContext = dataQualityTaskExecutionContext; } + + public ExecutionStatus getCurrentExecutionStatus() { + return currentExecutionStatus; + } + + public void setCurrentExecutionStatus(ExecutionStatus currentExecutionStatus) { + this.currentExecutionStatus = currentExecutionStatus; + } + } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskExecutionContextCacheManager.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContextCacheManager.java similarity index 79% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskExecutionContextCacheManager.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContextCacheManager.java index e2ab195a4b..5ee1f35d17 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskExecutionContextCacheManager.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskExecutionContextCacheManager.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; - -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +package org.apache.dolphinscheduler.plugin.task.api; import java.util.Collection; import java.util.Map; @@ -32,7 +30,7 @@ public class TaskExecutionContextCacheManager { /** * taskInstance cache */ - private static Map taskRequestContextCache = new ConcurrentHashMap<>(); + private static Map taskRequestContextCache = new ConcurrentHashMap<>(); /** * get taskInstance by taskInstance id @@ -41,7 +39,7 @@ public class TaskExecutionContextCacheManager { * @return taskInstance */ - public static TaskRequest getByTaskInstanceId(Integer taskInstanceId) { + public static TaskExecutionContext getByTaskInstanceId(Integer taskInstanceId) { return taskRequestContextCache.get(taskInstanceId); } @@ -50,7 +48,7 @@ public class TaskExecutionContextCacheManager { * * @param request request */ - public static void cacheTaskExecutionContext(TaskRequest request) { + public static void cacheTaskExecutionContext(TaskExecutionContext request) { taskRequestContextCache.put(request.getTaskInstanceId(), request); } @@ -63,12 +61,12 @@ public class TaskExecutionContextCacheManager { taskRequestContextCache.remove(taskInstanceId); } - public static boolean updateTaskExecutionContext(TaskRequest request) { + public static boolean updateTaskExecutionContext(TaskExecutionContext request) { taskRequestContextCache.computeIfPresent(request.getTaskInstanceId(), (k, v) -> request); return taskRequestContextCache.containsKey(request.getTaskInstanceId()); } - public static Collection getAllTaskRequestList() { + public static Collection getAllTaskRequestList() { return taskRequestContextCache.values(); } } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DataType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DataType.java similarity index 95% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DataType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DataType.java index 6f4e563a97..22365f9f81 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DataType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DataType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; /** * data types in user define parameter diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependResult.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependResult.java similarity index 94% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependResult.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependResult.java index a32626a221..0b24dad861 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependResult.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependResult.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; /** * depend result diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependentRelation.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependentRelation.java similarity index 93% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependentRelation.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependentRelation.java index ff4aef0be0..75a02e7766 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/DependentRelation.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/DependentRelation.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; /** * dependent relation: and or diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Direct.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/Direct.java similarity index 93% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Direct.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/Direct.java index 8b3a0abb68..df76ed1fd8 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Direct.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/Direct.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api.enums; /** * parameter of stored procedure diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ExecutionStatus.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatus.java similarity index 98% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ExecutionStatus.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatus.java index 7f0a9714cf..7295f430e1 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/ExecutionStatus.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; import java.util.HashMap; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ResourceType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ResourceType.java new file mode 100644 index 0000000000..62424aacdb --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/ResourceType.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.api.enums; + +public enum ResourceType { + + DATASOURCE, + UDF; +} diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/SqlType.java similarity index 93% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/SqlType.java index c506ca3e88..f4b0ed125e 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/sql/SqlType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/SqlType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.sql; +package org.apache.dolphinscheduler.plugin.task.api.enums; public enum SqlType { /** diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskRunStatus.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskRunStatus.java similarity index 93% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskRunStatus.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskRunStatus.java index 978fde89cb..1f36c2d4c1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskRunStatus.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskRunStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.api; +package org.apache.dolphinscheduler.plugin.task.api.enums; public enum TaskRunStatus { diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskTimeoutStrategy.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskTimeoutStrategy.java similarity index 96% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskTimeoutStrategy.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskTimeoutStrategy.java index 08ad60f17e..9a2818436e 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/TaskTimeoutStrategy.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/TaskTimeoutStrategy.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; import com.baomidou.mybatisplus.annotation.EnumValue; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/UdfType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/UdfType.java index 2b31087797..b9298cec92 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/UdfType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.api.enums; /** * UDF type diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckType.java similarity index 97% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckType.java index 6217c873e7..964ef7f8e5 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorType.java index 8d28a5d107..f3d901a1b4 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategy.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategy.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategy.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategy.java index 97bf00525b..34bc6a65a0 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategy.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategy.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskState.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskState.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskState.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskState.java index ee1c04bd28..d927d57270 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskState.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlType.java index 5dfc2719cb..ae6415226f 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputType.java index 9ab8761f32..5489fb1cf8 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorType.java index 4edbd6062f..898dc12d76 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceType.java index 8533c7f230..9e99c96aa7 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleType.java similarity index 97% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleType.java index 866beebb48..bcede62e4b 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueType.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueType.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueType.java index 1e7bd3037a..d63bf14cb7 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueType.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import java.util.HashMap; import java.util.Map; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DateInterval.java similarity index 96% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DateInterval.java index 4134dc0b74..893cee1d3f 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DateInterval.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.model; +package org.apache.dolphinscheduler.plugin.task.api.model; import java.util.Date; import java.util.Objects; - /** * date interval class */ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentItem.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentItem.java similarity index 92% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentItem.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentItem.java index a9dab84d43..8252bb1904 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentItem.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentItem.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.model; +package org.apache.dolphinscheduler.plugin.task.api.model; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; /** * dependent item diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentTaskModel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentTaskModel.java similarity index 90% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentTaskModel.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentTaskModel.java index eb56ee7dbe..f1b6a5ea5f 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DependentTaskModel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/DependentTaskModel.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.model; +package org.apache.dolphinscheduler.plugin.task.api.model; -import org.apache.dolphinscheduler.common.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; import java.util.List; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/model/JdbcInfo.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/JdbcInfo.java similarity index 97% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/model/JdbcInfo.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/JdbcInfo.java index 1ac65c1fbd..3e8f47ba7b 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/model/JdbcInfo.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/JdbcInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.model; +package org.apache.dolphinscheduler.plugin.task.api.model; /** * JdbcInfo diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Property.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/Property.java similarity index 94% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Property.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/Property.java index cd6e3c1615..7f51c7d9b2 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/Property.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/Property.java @@ -15,9 +15,10 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api.model; -import org.apache.dolphinscheduler.spi.enums.DataType; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import java.io.Serializable; import java.util.Objects; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ResourceInfo.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/ResourceInfo.java similarity index 91% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ResourceInfo.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/ResourceInfo.java index 970783d83b..f86b01daa7 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/ResourceInfo.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/ResourceInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api.model; /** * resource info @@ -26,9 +26,11 @@ public class ResourceInfo { */ private int id; + /** + * full name of the resource that was uploaded + */ private String resourceName; - private String res; public int getId() { diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchResultVo.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/SwitchResultVo.java similarity index 96% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchResultVo.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/SwitchResultVo.java index 07f0f94a54..dd28fc7711 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchResultVo.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/SwitchResultVo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.switchtask; +package org.apache.dolphinscheduler.plugin.task.api.model; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskAlertInfo.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskAlertInfo.java similarity index 95% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskAlertInfo.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskAlertInfo.java index 75faad503f..dc83af2761 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/TaskAlertInfo.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskAlertInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api.model; public class TaskAlertInfo { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskResponse.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskResponse.java similarity index 95% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskResponse.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskResponse.java index 40d38373f9..e4b60c1928 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskResponse.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskResponse.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.api; +package org.apache.dolphinscheduler.plugin.task.api.model; + +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskRunStatus; public class TaskResponse { diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java similarity index 81% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java index 9ae1f357bd..8146482793 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/AbstractParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/AbstractParameters.java @@ -15,8 +15,12 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task; +package org.apache.dolphinscheduler.plugin.task.api.parameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -35,11 +39,18 @@ import com.fasterxml.jackson.databind.node.ArrayNode; * job params related class */ public abstract class AbstractParameters implements IParameters { + @Override + public abstract boolean checkParameters(); + + @Override + public List getResourceFilesList() { + return new ArrayList<>(); + } /** * local parameters */ - protected List localParams; + public List localParams; /** * var pool @@ -48,6 +59,7 @@ public abstract class AbstractParameters implements IParameters { /** * get local parameters list + * * @return Property list */ public List getLocalParams() { @@ -95,7 +107,7 @@ public abstract class AbstractParameters implements IParameters { } public void setVarPool(String varPool) { - if (StringUtils.isEmpty(varPool)) { + if (org.apache.dolphinscheduler.spi.utils.StringUtils.isEmpty(varPool)) { this.varPool = new ArrayList<>(); } else { this.varPool = JSONUtils.toList(varPool, Property.class); @@ -103,14 +115,14 @@ public abstract class AbstractParameters implements IParameters { } public void dealOutParam(String result) { - if (CollectionUtils.isEmpty(localParams)) { + if (org.apache.commons.collections4.CollectionUtils.isEmpty(localParams)) { return; } List outProperty = getOutProperty(localParams); - if (CollectionUtils.isEmpty(outProperty)) { + if (org.apache.commons.collections4.CollectionUtils.isEmpty(outProperty)) { return; } - if (StringUtils.isEmpty(result)) { + if (org.apache.dolphinscheduler.spi.utils.StringUtils.isEmpty(result)) { varPool.addAll(outProperty); return; } @@ -120,7 +132,7 @@ public abstract class AbstractParameters implements IParameters { } for (Property info : outProperty) { String propValue = taskResult.get(info.getProp()); - if (StringUtils.isNotEmpty(propValue)) { + if (org.apache.dolphinscheduler.spi.utils.StringUtils.isNotEmpty(propValue)) { info.setValue(propValue); varPool.add(info); } @@ -167,4 +179,7 @@ public abstract class AbstractParameters implements IParameters { return format; } + public ResourceParametersHelper getResources() { + return new ResourceParametersHelper(); + } } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/blocking/BlockingParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/BlockingParameters.java similarity index 82% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/blocking/BlockingParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/BlockingParameters.java index ae89f37727..c04a7bc2ae 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/blocking/BlockingParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/BlockingParameters.java @@ -15,18 +15,13 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.blocking; +package org.apache.dolphinscheduler.plugin.task.api.parameters; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; -import java.util.ArrayList; -import java.util.List; - public class BlockingParameters extends AbstractParameters { - // condition of blocking: BlockingOnFailed or BlockingOnSuccess + // condition of blocking: BlockingOnFailed or BlockingOnSuccess private String blockingOpportunity; // if true, alert when blocking, otherwise do nothing @@ -38,11 +33,6 @@ public class BlockingParameters extends AbstractParameters { return !StringUtils.isEmpty(blockingOpportunity); } - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - public String getBlockingOpportunity() { return blockingOpportunity; } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/conditions/ConditionsParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ConditionsParameters.java similarity index 88% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/conditions/ConditionsParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ConditionsParameters.java index b136ae295d..a258ebdac4 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/conditions/ConditionsParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ConditionsParameters.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.conditions; +package org.apache.dolphinscheduler.plugin.task.api.parameters; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dependent/DependentParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/DependentParameters.java similarity index 76% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dependent/DependentParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/DependentParameters.java index b62cd4813e..bfbab6b759 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/dependent/DependentParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/DependentParameters.java @@ -15,14 +15,11 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.dependent; +package org.apache.dolphinscheduler.plugin.task.api.parameters; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.model.DependentTaskModel; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; -import java.util.ArrayList; import java.util.List; public class DependentParameters extends AbstractParameters { @@ -35,11 +32,6 @@ public class DependentParameters extends AbstractParameters { return true; } - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - public List getDependTaskList() { return dependTaskList; } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/IParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/IParameters.java similarity index 89% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/IParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/IParameters.java index f64e7098a6..02603efa46 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/IParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/IParameters.java @@ -1,4 +1,4 @@ -/* +package org.apache.dolphinscheduler.plugin.task.api.parameters;/* * 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. @@ -15,9 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ParametersNode.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ParametersNode.java new file mode 100644 index 0000000000..0f6b4107e3 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/ParametersNode.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.api.parameters; + +/** + * TODO

Need to optimize, why there are multiple task parameter variables:taskParams,dependence,switchResult

+ * + */ +public class ParametersNode { + + private String taskType; + + private String taskParams; + + private String dependence; + + private String switchResult; + + public static ParametersNode.ParametersNodeBuilder builder() { + return new ParametersNode.ParametersNodeBuilder(); + } + + public static class ParametersNodeBuilder { + private String taskType; + + private String taskParams; + + private String dependence; + + private String switchResult; + + public ParametersNodeBuilder taskType(String taskType) { + this.taskType = taskType; + return this; + } + + public ParametersNodeBuilder taskParams(String taskParams) { + this.taskParams = taskParams; + return this; + } + + public ParametersNodeBuilder dependence(String dependence) { + this.dependence = dependence; + return this; + } + + public ParametersNodeBuilder switchResult(String switchResult) { + this.switchResult = switchResult; + return this; + } + + public ParametersNode build() { + return new ParametersNode(this.taskType, this.taskParams, this.dependence, this.switchResult); + } + + } + + public ParametersNode() { + + } + + public ParametersNode(String taskType, String taskParams, String dependence, String switchResult) { + this.taskType = taskType; + this.taskParams = taskParams; + this.dependence = dependence; + this.switchResult = switchResult; + } + + public String getTaskType() { + return taskType; + } + + public void setTaskType(String taskType) { + this.taskType = taskType; + } + + public String getTaskParams() { + return taskParams; + } + + public void setTaskParams(String taskParams) { + this.taskParams = taskParams; + } + + public String getDependence() { + return dependence; + } + + public void setDependence(String dependence) { + this.dependence = dependence; + } + + public String getSwitchResult() { + return switchResult; + } + + public void setSwitchResult(String switchResult) { + this.switchResult = switchResult; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParameters.java similarity index 72% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParameters.java index 40d6d9cbd3..045495ce05 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParameters.java @@ -15,12 +15,17 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.sql; - -import org.apache.dolphinscheduler.spi.enums.DataType; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +package org.apache.dolphinscheduler.plugin.task.api.parameters; + +import org.apache.dolphinscheduler.plugin.task.api.SQLTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ResourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.UdfType; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.DataSourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.UdfFuncParameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -31,6 +36,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; + +import com.google.common.base.Enums; +import com.google.common.base.Strings; /** * Sql/Hql parameter @@ -292,4 +301,45 @@ public class SqlParameters extends AbstractParameters { + ", postStatements=" + postStatements + '}'; } + + @Override + public ResourceParametersHelper getResources() { + ResourceParametersHelper resources = super.getResources(); + resources.put(ResourceType.DATASOURCE, datasource); + + // whether udf type + boolean udfTypeFlag = Enums.getIfPresent(UdfType.class, Strings.nullToEmpty(this.getType())).isPresent() + && !StringUtils.isEmpty(this.getUdfs()); + + if (udfTypeFlag) { + String[] udfFunIds = this.getUdfs().split(","); + for (int i = 0; i < udfFunIds.length; i++) { + resources.put(ResourceType.UDF, Integer.parseInt(udfFunIds[i])); + } + } + return resources; + } + + /** + * TODO SQLTaskExecutionContext needs to be optimized + * @param parametersHelper + * @return + */ + public SQLTaskExecutionContext generateExtendedContext(ResourceParametersHelper parametersHelper) { + SQLTaskExecutionContext sqlTaskExecutionContext = new SQLTaskExecutionContext(); + + DataSourceParameters dbSource = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, datasource); + sqlTaskExecutionContext.setConnectionParams(dbSource.getConnectionParams()); + + // whether udf type + boolean udfTypeFlag = Enums.getIfPresent(UdfType.class, Strings.nullToEmpty(this.getType())).isPresent() + && !StringUtils.isEmpty(this.getUdfs()); + + if (udfTypeFlag) { + List collect = parametersHelper.getResourceMap(ResourceType.UDF).entrySet().stream().map(entry -> (UdfFuncParameters) entry.getValue()).collect(Collectors.toList()); + sqlTaskExecutionContext.setUdfFuncParametersList(collect); + } + + return sqlTaskExecutionContext; + } } diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/subprocess/SubProcessParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SubProcessParameters.java similarity index 78% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/subprocess/SubProcessParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SubProcessParameters.java index 6a783c34c3..3616bc57f5 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/subprocess/SubProcessParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SubProcessParameters.java @@ -15,13 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.subprocess; - -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; - -import java.util.ArrayList; -import java.util.List; +package org.apache.dolphinscheduler.plugin.task.api.parameters; public class SubProcessParameters extends AbstractParameters { @@ -43,8 +37,4 @@ public class SubProcessParameters extends AbstractParameters { return this.processDefinitionCode != 0; } - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } } \ No newline at end of file diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SwitchParameters.java similarity index 87% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchParameters.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SwitchParameters.java index e3c9b6e26a..502ea14701 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/switchtask/SwitchParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SwitchParameters.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task.switchtask; +package org.apache.dolphinscheduler.plugin.task.api.parameters; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; import java.util.ArrayList; import java.util.List; @@ -35,11 +34,6 @@ public class SwitchParameters extends AbstractParameters { return true; } - @Override - public List getResourceFilesList() { - return new ArrayList<>(); - } - private int resultConditionLocation; private List dependTaskList; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/TaskTimeoutParameter.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/TaskTimeoutParameter.java similarity index 93% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/TaskTimeoutParameter.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/TaskTimeoutParameter.java index cc1bf4e202..94aa7a3279 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/task/TaskTimeoutParameter.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/TaskTimeoutParameter.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; +package org.apache.dolphinscheduler.plugin.task.api.parameters; -import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; /** * task timeout parameter diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/AbstractResourceParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/AbstractResourceParameters.java new file mode 100644 index 0000000000..7f05b1238d --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/AbstractResourceParameters.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.api.parameters.resource; + +public abstract class AbstractResourceParameters { + +} diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/DependenceTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/DataSourceParameters.java similarity index 59% rename from dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/DependenceTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/DataSourceParameters.java index bddaa4f581..71d0dc0dad 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/queue/entity/DependenceTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/DataSourceParameters.java @@ -15,29 +15,29 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.service.queue.entity; +package org.apache.dolphinscheduler.plugin.task.api.parameters.resource; -import java.io.Serializable; +import org.apache.dolphinscheduler.spi.enums.DbType; -/** - * master/worker task transport - */ -public class DependenceTaskExecutionContext implements Serializable { +public class DataSourceParameters extends AbstractResourceParameters { + + private DbType type; - private String dependence; + private String connectionParams; + + public DbType getType() { + return type; + } - public String getDependence() { - return dependence; + public void setType(DbType type) { + this.type = type; } - public void setDependence(String dependence) { - this.dependence = dependence; + public String getConnectionParams() { + return connectionParams; } - @Override - public String toString() { - return "DependenceTaskExecutionContext{" - + "dependence='" + dependence + '\'' - + '}'; + public void setConnectionParams(String connectionParams) { + this.connectionParams = connectionParams; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/ResourceParametersHelper.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/ResourceParametersHelper.java new file mode 100644 index 0000000000..43c4aaf8be --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/ResourceParametersHelper.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.api.parameters.resource; + +import org.apache.dolphinscheduler.plugin.task.api.enums.ResourceType; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public class ResourceParametersHelper { + + private Map> map = new HashMap<>(); + + public void put(ResourceType resourceType, Integer id) { + put(resourceType, id, null); + } + + public void put(ResourceType resourceType, Integer id, AbstractResourceParameters parameters) { + Map resourceParametersMap = map.get(resourceType); + if (Objects.isNull(resourceParametersMap)) { + resourceParametersMap = new HashMap<>(); + map.put(resourceType, resourceParametersMap); + } + resourceParametersMap.put(id, parameters); + } + + public Map> getResourceMap() { + return map; + } + + public Map getResourceMap(ResourceType resourceType) { + return this.getResourceMap().get(resourceType); + } + + public AbstractResourceParameters getResourceParameters(ResourceType resourceType, Integer code) { + return this.getResourceMap(resourceType).get(code); + } +} diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfFuncRequest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/UdfFuncParameters.java similarity index 85% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfFuncRequest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/UdfFuncParameters.java index 219e382d1a..d1b1f36e47 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/UdfFuncRequest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/resource/UdfFuncParameters.java @@ -15,21 +15,17 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.api.parameters.resource; +import org.apache.dolphinscheduler.plugin.task.api.enums.UdfType; import org.apache.dolphinscheduler.spi.utils.JSONUtils; -import org.apache.dolphinscheduler.spi.utils.StringUtils; -import java.io.IOException; import java.util.Date; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.KeyDeserializer; - /** * udf function */ -public class UdfFuncRequest { +public class UdfFuncParameters extends AbstractResourceParameters { /** * id */ @@ -79,6 +75,10 @@ public class UdfFuncRequest { */ private UdfType type; + private String tenantCode; + + private String defaultFS; + /** * create time */ @@ -185,6 +185,22 @@ public class UdfFuncRequest { this.updateTime = updateTime; } + public String getTenantCode() { + return tenantCode; + } + + public void setTenantCode(String tenantCode) { + this.tenantCode = tenantCode; + } + + public String getDefaultFS() { + return defaultFS; + } + + public void setDefaultFS(String defaultFS) { + this.defaultFS = defaultFS; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -194,7 +210,7 @@ public class UdfFuncRequest { return false; } - UdfFuncRequest udfFuncRequest = (UdfFuncRequest) o; + UdfFuncParameters udfFuncRequest = (UdfFuncParameters) o; if (id != udfFuncRequest.id) { return false; @@ -215,14 +231,4 @@ public class UdfFuncRequest { return JSONUtils.toJsonString(this); } - public static class UdfFuncDeserializer extends KeyDeserializer { - - @Override - public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException { - if (StringUtils.isBlank(key)) { - return null; - } - return JSONUtils.parseObject(key, UdfFuncRequest.class); - } - } } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/BusinessTimeUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/BusinessTimeUtils.java similarity index 83% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/BusinessTimeUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/BusinessTimeUtils.java index eeec408bea..b09d9f8972 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/BusinessTimeUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/BusinessTimeUtils.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; +package org.apache.dolphinscheduler.plugin.task.api.parser; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_BUSINESS_DATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_CURRENT_DATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_DATETIME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_FORMAT_DATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_FORMAT_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_BUSINESS_DATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_CURRENT_DATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_DATETIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_FORMAT_DATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_FORMAT_TIME; import static org.apache.dolphinscheduler.spi.utils.DateUtils.addDays; import static org.apache.dolphinscheduler.spi.utils.DateUtils.format; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParamUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParamUtils.java similarity index 88% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParamUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParamUtils.java index 069f941ff8..876ec2123f 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParamUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParamUtils.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; +package org.apache.dolphinscheduler.plugin.task.api.parser; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_TASK_EXECUTE_PATH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_TASK_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_TASK_EXECUTE_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_TASK_INSTANCE_ID; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.enums.CommandType; -import org.apache.dolphinscheduler.spi.enums.DataType; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Direct; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.Date; @@ -52,7 +52,7 @@ public class ParamUtils { * @return global params * */ - public static Map convert(TaskRequest taskExecutionContext, AbstractParameters parameters) { + public static Map convert(TaskExecutionContext taskExecutionContext, AbstractParameters parameters) { Preconditions.checkNotNull(taskExecutionContext); Preconditions.checkNotNull(parameters); Map globalParams = getUserDefParamsMap(taskExecutionContext.getDefinedParams()); diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParameterUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParameterUtils.java similarity index 95% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParameterUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParameterUtils.java index 208022f5ca..383424f71a 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/ParameterUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/ParameterUtils.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; +package org.apache.dolphinscheduler.plugin.task.api.parser; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_DATETIME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_FORMAT_TIME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_SHECDULE_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_DATETIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_FORMAT_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_SHECDULE_TIME; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.spi.enums.CommandType; -import org.apache.dolphinscheduler.spi.enums.DataType; -import org.apache.dolphinscheduler.spi.task.Property; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.dolphinscheduler.spi.utils.DateUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PlaceholderUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PlaceholderUtils.java similarity index 98% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PlaceholderUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PlaceholderUtils.java index 90ee18311a..f266ced99b 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PlaceholderUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PlaceholderUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; +package org.apache.dolphinscheduler.plugin.task.api.parser; import java.util.Map; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PropertyPlaceholderHelper.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PropertyPlaceholderHelper.java similarity index 99% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PropertyPlaceholderHelper.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PropertyPlaceholderHelper.java index 7c571d6c63..a4b08a6f98 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/PropertyPlaceholderHelper.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/PropertyPlaceholderHelper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; +package org.apache.dolphinscheduler.plugin.task.api.parser; import java.util.HashMap; import java.util.HashSet; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/TimePlaceholderUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/TimePlaceholderUtils.java similarity index 91% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/TimePlaceholderUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/TimePlaceholderUtils.java index da72089f92..f4d6732cce 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/paramparser/TimePlaceholderUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parser/TimePlaceholderUtils.java @@ -15,29 +15,29 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.paramparser; - -import static org.apache.dolphinscheduler.spi.task.TaskConstants.ADD_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.ADD_MONTHS; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.ADD_STRING; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.COMMA; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DIVISION_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DIVISION_STRING; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.LEFT_BRACE_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.LEFT_BRACE_STRING; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.MONTH_BEGIN; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.MONTH_END; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.MULTIPLY_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.MULTIPLY_STRING; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.N; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.P; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_FORMAT_TIME; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.RIGHT_BRACE_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SUBTRACT_CHAR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SUBTRACT_STRING; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.TIMESTAMP; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.WEEK_BEGIN; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.WEEK_END; +package org.apache.dolphinscheduler.plugin.task.api.parser; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.ADD_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.ADD_MONTHS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.ADD_STRING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMMA; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DIVISION_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DIVISION_STRING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LEFT_BRACE_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LEFT_BRACE_STRING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.MONTH_BEGIN; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.MONTH_END; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.MULTIPLY_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.MULTIPLY_STRING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.N; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.P; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_FORMAT_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RIGHT_BRACE_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SUBTRACT_CHAR; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SUBTRACT_STRING; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TIMESTAMP; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.WEEK_BEGIN; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.WEEK_END; import static org.apache.dolphinscheduler.spi.utils.DateUtils.addDays; import static org.apache.dolphinscheduler.spi.utils.DateUtils.addMinutes; import static org.apache.dolphinscheduler.spi.utils.DateUtils.addMonths; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/ArgsUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ArgsUtils.java similarity index 80% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/ArgsUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ArgsUtils.java index b4aa5db95a..38d5e686c7 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/ArgsUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ArgsUtils.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.util; +package org.apache.dolphinscheduler.plugin.task.api.utils; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; public class ArgsUtils { @@ -27,4 +29,8 @@ public class ArgsUtils { return arg.replace(" ", "\\ ").replace("\"", "\\\"").replace("'", "\\'"); } + public static String wrapperSingleQuotes(String value) { + return SINGLE_QUOTES + value + SINGLE_QUOTES; + } + } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/DataQualityConstants.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DataQualityConstants.java similarity index 98% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/DataQualityConstants.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DataQualityConstants.java index 4f39d0f13d..bcdb3b7880 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/DataQualityConstants.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DataQualityConstants.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.utils; +package org.apache.dolphinscheduler.plugin.task.api.utils; /** * DataQualityConstants diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/dependent/DependentDateUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentDateUtils.java similarity index 90% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/dependent/DependentDateUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentDateUtils.java index 15bec19e0f..a1ca404161 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/dependent/DependentDateUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentDateUtils.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.common.utils.dependent; -import org.apache.dolphinscheduler.common.model.DateInterval; -import org.apache.dolphinscheduler.common.utils.DateUtils; +package org.apache.dolphinscheduler.plugin.task.api.utils; + +import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; +import org.apache.dolphinscheduler.spi.utils.DateUtils; import java.util.ArrayList; import java.util.Date; @@ -31,7 +32,7 @@ public class DependentDateUtils { * @param hourNumber hourNumber * @return DateInterval list */ - public static List getLastHoursInterval(Date businessDate, int hourNumber){ + public static List getLastHoursInterval(Date businessDate, int hourNumber) { List dateIntervals = new ArrayList<>(); if (hourNumber == 0) { Date lastHour = DateUtils.getSomeHourOfDay(businessDate, 0); @@ -40,7 +41,7 @@ public class DependentDateUtils { dateIntervals.add(new DateInterval(beginTime, endTime)); return dateIntervals; } - for(int index = hourNumber; index > 0; index--){ + for (int index = hourNumber; index > 0; index--) { Date lastHour = DateUtils.getSomeHourOfDay(businessDate, -index); Date beginTime = DateUtils.getStartOfHour(lastHour); Date endTime = DateUtils.getEndOfHour(lastHour); @@ -54,7 +55,7 @@ public class DependentDateUtils { * @param businessDate businessDate * @return DateInterval list */ - public static List getTodayInterval(Date businessDate){ + public static List getTodayInterval(Date businessDate) { List dateIntervals = new ArrayList<>(); @@ -70,10 +71,10 @@ public class DependentDateUtils { * @param someDay someDay * @return DateInterval list */ - public static List getLastDayInterval(Date businessDate, int someDay){ + public static List getLastDayInterval(Date businessDate, int someDay) { List dateIntervals = new ArrayList<>(); - for(int index = someDay; index > 0; index--){ + for (int index = someDay; index > 0; index--) { Date lastDay = DateUtils.getSomeDay(businessDate, -index); Date beginTime = DateUtils.getStartOfDay(lastDay); @@ -88,13 +89,13 @@ public class DependentDateUtils { * @param businessDate businessDate * @return DateInterval list */ - public static List getSpecialLastDayInterval(Date businessDate){ + public static List getSpecialLastDayInterval(Date businessDate) { List dateIntervals = new ArrayList<>(); int hourIndex = DateUtils.getHourIndex(businessDate); int startIndex = hourIndex + 23; int endIndex = startIndex - 24; - for(int index = startIndex; index > endIndex; index--) { + for (int index = startIndex; index > endIndex; index--) { Date lastHour = DateUtils.getSomeHourOfDay(businessDate, -index); Date beginTime = DateUtils.getStartOfHour(lastHour); Date endTime = DateUtils.getEndOfHour(lastHour); @@ -123,10 +124,9 @@ public class DependentDateUtils { Date firstDayThisMonth = DateUtils.getFirstDayOfMonth(businessDate); Date lastDay = DateUtils.getSomeDay(firstDayThisMonth, -1); Date firstDay = DateUtils.getFirstDayOfMonth(lastDay); - return getDateIntervalListBetweenTwoDates( firstDay, lastDay); + return getDateIntervalListBetweenTwoDates(firstDay, lastDay); } - /** * get interval on first/last day of the last month * @param businessDate businessDate @@ -139,9 +139,9 @@ public class DependentDateUtils { Date firstDayThisMonth = DateUtils.getFirstDayOfMonth(businessDate); Date lastDay = DateUtils.getSomeDay(firstDayThisMonth, -1); Date firstDay = DateUtils.getFirstDayOfMonth(lastDay); - if(isBeginDay){ + if (isBeginDay) { return getDateIntervalListBetweenTwoDates(firstDay, firstDay); - }else{ + } else { return getDateIntervalListBetweenTwoDates(lastDay, lastDay); } } @@ -178,9 +178,9 @@ public class DependentDateUtils { */ public static List getLastWeekOneDayInterval(Date businessDate, int dayOfWeek) { Date mondayThisWeek = DateUtils.getMonday(businessDate); - Date sunday = DateUtils.getSomeDay(mondayThisWeek, -1); + Date sunday = DateUtils.getSomeDay(mondayThisWeek, - 1); Date monday = DateUtils.getMonday(sunday); - Date destDay = DateUtils.getSomeDay(monday, dayOfWeek -1); + Date destDay = DateUtils.getSomeDay(monday, dayOfWeek - 1); return getDateIntervalListBetweenTwoDates(destDay, destDay); } @@ -192,7 +192,7 @@ public class DependentDateUtils { */ public static List getDateIntervalListBetweenTwoDates(Date firstDay, Date lastDay) { List dateIntervals = new ArrayList<>(); - while(!firstDay.after(lastDay)){ + while (!firstDay.after(lastDay)) { Date beginTime = DateUtils.getStartOfDay(firstDay); Date endTime = DateUtils.getEndOfDay(firstDay); dateIntervals.add(new DateInterval(beginTime, endTime)); diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DependentUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtils.java similarity index 94% rename from dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DependentUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtils.java index d6cea28780..b79e8b4830 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DependentUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtils.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.utils; +package org.apache.dolphinscheduler.plugin.task.api.utils; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.model.DateInterval; -import org.apache.dolphinscheduler.common.utils.dependent.DependentDateUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; import java.util.ArrayList; import java.util.Date; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParser.java similarity index 81% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParser.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParser.java index a1d246b2f7..deafbb2617 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParser.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.utils; +package org.apache.dolphinscheduler.plugin.task.api.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.COLON; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DOUBLE_SLASH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.QUESTION; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SEMICOLON; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SINGLE_SLASH; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.MYSQL; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.POSTGRESQL; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COLON; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_SLASH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.QUESTION; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SEMICOLON; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.MYSQL; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.POSTGRESQL; +import org.apache.dolphinscheduler.plugin.task.api.model.JdbcInfo; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.task.dq.model.JdbcInfo; import org.apache.dolphinscheduler.spi.utils.StringUtils; /** diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/MapUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/MapUtils.java similarity index 94% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/MapUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/MapUtils.java index ddddb04e83..ea419748bb 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/MapUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/MapUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.util; +package org.apache.dolphinscheduler.plugin.task.api.utils; import java.util.Map; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/OSUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/OSUtils.java similarity index 98% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/OSUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/OSUtils.java index f34268d179..0c8b78df75 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/util/OSUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/OSUtils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.plugin.task.util; +package org.apache.dolphinscheduler.plugin.task.api.utils; import org.apache.dolphinscheduler.plugin.task.api.ShellExecutor; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/task/plugin/api/TaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/TaskTest.java similarity index 93% rename from dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/task/plugin/api/TaskTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/TaskTest.java index 7f20c146b3..e388d7a7dc 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/task/plugin/api/TaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/TaskTest.java @@ -1,4 +1,4 @@ -package org.apache.dolphinscheduler.task.plugin.api;/* +package org.apache.dolphinscheduler.plugin.task.api;/* * 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. diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/enums/ExecutionStatusTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatusTest.java similarity index 95% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/enums/ExecutionStatusTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatusTest.java index d1b44b7069..9b7dfa26b0 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/enums/ExecutionStatusTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/ExecutionStatusTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums; import junit.framework.TestCase; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckTypeTest.java index 8aa20c0944..14d6fbb18b 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/CheckTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/CheckTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorTypeTest.java similarity index 95% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorTypeTest.java index fa091578f9..534c3eba3a 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ConnectorTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ConnectorTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategyTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategyTest.java similarity index 95% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategyTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategyTest.java index 07878ce6ff..f5f478c82e 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqFailureStrategyTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqFailureStrategyTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskStateTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskStateTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskStateTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskStateTest.java index a23b05cc53..ed3a306819 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/DqTaskStateTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/DqTaskStateTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlTypeTest.java index c4623fb889..5262eff30d 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ExecuteSqlTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ExecuteSqlTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputTypeTest.java index b59941e407..d4515cd720 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/InputTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/InputTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorTypeTest.java similarity index 97% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorTypeTest.java index 83c53de686..0e8f2914b1 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OperatorTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OperatorTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceTypeTest.java index 6ee19b0edd..7813a5b2b1 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/OptionSourceTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/OptionSourceTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleTypeTest.java index 32f6580d73..f8e93f8073 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/RuleTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/RuleTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueTypeTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueTypeTest.java similarity index 96% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueTypeTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueTypeTest.java index 6022b680f5..c45c8b9b5b 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/enums/ValueTypeTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/enums/dp/ValueTypeTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.enums; +package org.apache.dolphinscheduler.plugin.task.api.enums.dp; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqlParametersTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParametersTest.java similarity index 92% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqlParametersTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParametersTest.java index 3f7a980b42..8aded957b6 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqlParametersTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParametersTest.java @@ -15,14 +15,13 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; +package org.apache.dolphinscheduler.plugin.task.api.parameters; import static org.junit.Assert.assertNotNull; -import org.apache.dolphinscheduler.common.enums.DataType; -import org.apache.dolphinscheduler.common.enums.Direct; -import org.apache.dolphinscheduler.common.process.Property; -import org.apache.dolphinscheduler.common.task.sql.SqlParameters; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.commons.collections.CollectionUtils; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtilsTest.java similarity index 96% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtilsTest.java index a018c5af52..1f21989a6a 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/DependentUtilsTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/DependentUtilsTest.java @@ -14,21 +14,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.common.utils; -import com.google.common.collect.Lists; -import org.apache.dolphinscheduler.common.enums.DependResult; -import org.apache.dolphinscheduler.common.enums.DependentRelation; -import org.apache.dolphinscheduler.common.model.DateInterval; -import org.apache.dolphinscheduler.common.utils.dependent.DependentDateUtils; +package org.apache.dolphinscheduler.plugin.task.api.utils; + +import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; +import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; +import org.apache.dolphinscheduler.spi.utils.DateUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + import org.junit.Assert; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import com.google.common.collect.Lists; public class DependentUtilsTest { private static final Logger logger = LoggerFactory.getLogger(DependentUtilsTest.class); @@ -124,7 +127,7 @@ public class DependentUtilsTest { dateValue = "last2Days"; dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue); - for(DateInterval dateInterval : dateIntervals){ + for (DateInterval dateInterval : dateIntervals) { logger.info(dateInterval.getStartTime().toString() + " == " + dateInterval.getEndTime().toString()); } @@ -135,7 +138,6 @@ public class DependentUtilsTest { dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue); Assert.assertEquals(dateIntervals.get(0), diCur); - dateValue = "thisWeek"; Date firstWeekDay = DateUtils.getMonday(curDay); dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue); @@ -146,7 +148,6 @@ public class DependentUtilsTest { Assert.assertEquals(dateIntervals.get(0), weekHead); Assert.assertEquals(dateIntervals.get(dateIntervals.size() - 1), weekThis); - dateValue = "thisMonth"; Date firstMonthDay = DateUtils.getFirstDayOfMonth(curDay); dateIntervals = DependentUtils.getDateIntervalList(curDay, dateValue); @@ -269,7 +270,7 @@ public class DependentUtilsTest { } @Test - public void testWeek(){ + public void testWeek() { Date curDay = DateUtils.stringToDate("2019-02-05 00:00:00"); Date day1 = DateUtils.stringToDate("2019-01-28 00:00:00"); @@ -318,7 +319,7 @@ public class DependentUtilsTest { } @Test - public void testHour(){ + public void testHour() { Date curDay = DateUtils.stringToDate("2019-02-05 12:10:00"); Date day1 = DateUtils.stringToDate("2019-02-05 11:00:00"); @@ -370,7 +371,8 @@ public class DependentUtilsTest { if (a < 10) { i = "0" + i; } - DateInterval dateInterval = new DateInterval(DateUtils.getStartOfHour(DateUtils.stringToDate("2020-05-14 " + i + ":00:00")), DateUtils.getEndOfHour(DateUtils.stringToDate("2020-05-14 " + i + ":59:59"))); + DateInterval dateInterval = new DateInterval(DateUtils.getStartOfHour(DateUtils.stringToDate("2020-05-14 " + i + ":00:00")), + DateUtils.getEndOfHour(DateUtils.stringToDate("2020-05-14 " + i + ":59:59"))); expect.add(dateInterval); } DateInterval dateInterval = new DateInterval(DateUtils.getStartOfHour(DateUtils.stringToDate("2020-05-15 00:00:00")), DateUtils.getEndOfHour(DateUtils.stringToDate("2020-05-15 00:59:59"))); @@ -378,13 +380,13 @@ public class DependentUtilsTest { Assert.assertEquals(24, dateIntervals.size()); - for (int i = 0; i< expect.size(); i++) { + for (int i = 0; i < expect.size(); i++) { Assert.assertEquals(expect.get(i), dateIntervals.get(i)); } } @Test - public void testMonth(){ + public void testMonth() { Date curDay = DateUtils.stringToDate("2019-02-05 00:00:00"); Date day1 = DateUtils.stringToDate("2019-01-01 00:00:00"); DateInterval di1 = new DateInterval(DateUtils.getStartOfDay(day1), diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParserTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParserTest.java similarity index 92% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParserTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParserTest.java index 85f2d7e3f0..63c3c321fe 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/JdbcUrlParserTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/JdbcUrlParserTest.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.utils; +package org.apache.dolphinscheduler.plugin.task.api.utils; -import org.apache.dolphinscheduler.spi.task.dq.model.JdbcInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.JdbcInfo; import org.junit.Assert; import org.junit.Test; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/pom.xml new file mode 100644 index 0000000000..b0e4deff3f --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/pom.xml @@ -0,0 +1,44 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-blocking + jar + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + org.apache.dolphinscheduler + dolphinscheduler-task-api + ${project.version} + + + + diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannel.java new file mode 100644 index 0000000000..f300cf0258 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannel.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.blocking; + +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; + +public class BlockingTaskChannel implements TaskChannel { + + @Override + public void cancelApplication(boolean status) { + + } + + @Override + public AbstractTask createTask(TaskExecutionContext taskRequest) { + return null; + } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), BlockingParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannelFactory.java new file mode 100644 index 0000000000..a8f0660cb6 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-blocking/src/main/java/org/apache/dolphinscheduler/plugin/task/blocking/BlockingTaskChannelFactory.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.blocking; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; + +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; + +import java.util.List; + +import com.google.auto.service.AutoService; + +@AutoService(TaskChannelFactory.class) +public class BlockingTaskChannelFactory implements TaskChannelFactory { + @Override + public TaskChannel create() { + return new BlockingTaskChannel(); + } + + @Override + public String getName() { + return TASK_TYPE_BLOCKING; + } + + @Override + public List getParams() { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/pom.xml new file mode 100644 index 0000000000..9d00da37e6 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/pom.xml @@ -0,0 +1,44 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-conditions + jar + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + org.apache.dolphinscheduler + dolphinscheduler-task-api + ${project.version} + + + + \ No newline at end of file diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannel.java new file mode 100644 index 0000000000..7d20d63582 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannel.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.conditions; + +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; + +public class ConditionsTaskChannel implements TaskChannel { + + @Override + public void cancelApplication(boolean status) { + + } + + @Override + public AbstractTask createTask(TaskExecutionContext taskRequest) { + return null; + } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), ConditionsParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannelFactory.java new file mode 100644 index 0000000000..e0a41c1d0d --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-conditions/src/main/java/org/apache/dolphinscheduler/plugin/task/conditions/ConditionsTaskChannelFactory.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.conditions; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; + +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; +import org.apache.dolphinscheduler.spi.params.base.Validate; +import org.apache.dolphinscheduler.spi.params.input.InputParam; +import org.apache.dolphinscheduler.spi.params.radio.RadioParam; + +import java.util.ArrayList; +import java.util.List; + +import com.google.auto.service.AutoService; + +@AutoService(TaskChannelFactory.class) +public class ConditionsTaskChannelFactory implements TaskChannelFactory { + @Override + public TaskChannel create() { + return new ConditionsTaskChannel(); + } + + @Override + public String getName() { + return TASK_TYPE_CONDITIONS; + } + + @Override + public List getParams() { + List paramsList = new ArrayList<>(); + + InputParam nodeName = InputParam.newBuilder("name", "$t('Node name')") + .addValidate(Validate.newBuilder() + .setRequired(true) + .build()) + .build(); + + RadioParam runFlag = RadioParam.newBuilder("runFlag", "RUN_FLAG") + .addParamsOptions(new ParamsOptions("NORMAL", "NORMAL", false)) + .addParamsOptions(new ParamsOptions("FORBIDDEN", "FORBIDDEN", false)) + .build(); + + paramsList.add(nodeName); + paramsList.add(runFlag); + return paramsList; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityParameters.java index 2493c533f6..d5002bacfd 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityParameters.java @@ -17,10 +17,10 @@ package org.apache.dolphinscheduler.plugin.task.dq; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.plugin.task.dq.utils.spark.SparkParameters; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTask.java index e344995e36..d0575573a1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTask.java @@ -17,33 +17,34 @@ package org.apache.dolphinscheduler.plugin.task.dq; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SLASH; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.UNDERLINE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.CREATE_TIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.DATA_TIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.ERROR_OUTPUT_PATH; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PROCESS_DEFINITION_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PROCESS_INSTANCE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.REGEXP_PATTERN; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.RULE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.RULE_NAME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.RULE_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TASK_INSTANCE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.UPDATE_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SLASH; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.UNDERLINE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.CREATE_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.DATA_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.ERROR_OUTPUT_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PROCESS_DEFINITION_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PROCESS_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.REGEXP_PATTERN; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.RULE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.RULE_NAME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.RULE_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.UPDATE_TIME; import static org.apache.dolphinscheduler.spi.utils.Constants.YYYY_MM_DD_HH_MM_SS; import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; import org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; import org.apache.dolphinscheduler.plugin.task.dq.utils.spark.SparkArgsUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -68,9 +69,9 @@ public class DataQualityTask extends AbstractYarnTask { private DataQualityParameters dataQualityParameters; - private final TaskRequest dqTaskExecutionContext; + private final TaskExecutionContext dqTaskExecutionContext; - public DataQualityTask(TaskRequest taskExecutionContext) { + public DataQualityTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.dqTaskExecutionContext = taskExecutionContext; } @@ -128,15 +129,15 @@ public class DataQualityTask extends AbstractYarnTask { inputParameter.put(RULE_ID, String.valueOf(dataQualityTaskExecutionContext.getRuleId())); inputParameter.put(RULE_TYPE, String.valueOf(dataQualityTaskExecutionContext.getRuleType())); - inputParameter.put(RULE_NAME, StringUtils.wrapperSingleQuotes(dataQualityTaskExecutionContext.getRuleName())); - inputParameter.put(CREATE_TIME, StringUtils.wrapperSingleQuotes(now)); - inputParameter.put(UPDATE_TIME, StringUtils.wrapperSingleQuotes(now)); + inputParameter.put(RULE_NAME, ArgsUtils.wrapperSingleQuotes(dataQualityTaskExecutionContext.getRuleName())); + inputParameter.put(CREATE_TIME, ArgsUtils.wrapperSingleQuotes(now)); + inputParameter.put(UPDATE_TIME, ArgsUtils.wrapperSingleQuotes(now)); inputParameter.put(PROCESS_DEFINITION_ID, String.valueOf(dqTaskExecutionContext.getProcessDefineId())); inputParameter.put(PROCESS_INSTANCE_ID, String.valueOf(dqTaskExecutionContext.getProcessInstanceId())); inputParameter.put(TASK_INSTANCE_ID, String.valueOf(dqTaskExecutionContext.getTaskInstanceId())); if (StringUtils.isEmpty(inputParameter.get(DATA_TIME))) { - inputParameter.put(DATA_TIME,StringUtils.wrapperSingleQuotes(now)); + inputParameter.put(DATA_TIME,ArgsUtils.wrapperSingleQuotes(now)); } if (StringUtils.isNotEmpty(inputParameter.get(REGEXP_PATTERN))) { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannel.java index 53247dc4a1..bd4990a555 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.dq; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class DataQualityTaskChannel implements TaskChannel { @@ -29,7 +33,17 @@ public class DataQualityTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new DataQualityTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), DataQualityParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannelFactory.java index 557d39f45e..f56d65723f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.dq; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/RuleManager.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/RuleManager.java index 36cc83bc8e..b7a550a9de 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/RuleManager.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/RuleManager.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.UNIQUE_CODE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.UNIQUE_CODE; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.RuleType; +import org.apache.dolphinscheduler.plugin.task.api.parser.BusinessTimeUtils; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleInputEntry; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; @@ -30,11 +34,7 @@ import org.apache.dolphinscheduler.plugin.task.dq.rule.parser.SingleTableCustomS import org.apache.dolphinscheduler.plugin.task.dq.rule.parser.SingleTableRuleParser; import org.apache.dolphinscheduler.plugin.task.dq.utils.RuleParserUtils; import org.apache.dolphinscheduler.spi.enums.CommandType; -import org.apache.dolphinscheduler.spi.task.dq.enums.RuleType; -import org.apache.dolphinscheduler.spi.task.paramparser.BusinessTimeUtils; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; -import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.Date; import java.util.Map; @@ -109,7 +109,7 @@ public class RuleManager { inputParameterValueResult.putAll(BusinessTimeUtils.getBusinessTime(CommandType.START_PROCESS, new Date())); inputParameterValueResult.putIfAbsent(COMPARISON_TYPE, NONE_COMPARISON_TYPE); inputParameterValueResult.put(UNIQUE_CODE, - StringUtils.wrapperSingleQuotes(RuleParserUtils.generateUniqueCode(inputParameterValueResult))); + SINGLE_QUOTES + RuleParserUtils.generateUniqueCode(inputParameterValueResult) + SINGLE_QUOTES); IRuleParser ruleParser = null; switch (RuleType.of(dataQualityTaskExecutionContext.getRuleType())) { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleExecuteSql.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleExecuteSql.java index f03b03d0f1..8e49df09e1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleExecuteSql.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleExecuteSql.java @@ -17,12 +17,11 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.entity; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; import java.io.Serializable; import java.util.Date; - /** * RuleExecuteSql */ diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleInputEntry.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleInputEntry.java index 0f08b6347d..0e88b6e430 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleInputEntry.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/entity/DqRuleInputEntry.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.entity; -import org.apache.dolphinscheduler.spi.task.dq.enums.InputType; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ValueType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ValueType; import java.io.Serializable; import java.util.Date; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/IRuleParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/IRuleParser.java index c2da180b52..de7b6e6230 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/IRuleParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/IRuleParser.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.parser; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import java.util.Map; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableAccuracyRuleParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableAccuracyRuleParser.java index 950e3e1a01..314a6272da 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableAccuracyRuleParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableAccuracyRuleParser.java @@ -17,19 +17,19 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.parser; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.MAPPING_COLUMNS; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.ON_CLAUSE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.STATISTICS_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.WHERE_CLAUSE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.MAPPING_COLUMNS; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.ON_CLAUSE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.STATISTICS_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.WHERE_CLAUSE; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.BaseConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; import org.apache.dolphinscheduler.plugin.task.dq.utils.RuleParserUtils; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableComparisonRuleParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableComparisonRuleParser.java index 32df66c3de..bc04fd629e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableComparisonRuleParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/MultiTableComparisonRuleParser.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.parser; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.BaseConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; import org.apache.dolphinscheduler.plugin.task.dq.utils.RuleParserUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableCustomSqlRuleParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableCustomSqlRuleParser.java index b3673b9e74..09d9e63ac7 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableCustomSqlRuleParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableCustomSqlRuleParser.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.parser; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.BaseConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; import org.apache.dolphinscheduler.plugin.task.dq.utils.RuleParserUtils; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableRuleParser.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableRuleParser.java index cf7c30723b..92ead2a007 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableRuleParser.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/rule/parser/SingleTableRuleParser.java @@ -17,16 +17,16 @@ package org.apache.dolphinscheduler.plugin.task.dq.rule.parser; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.STATISTICS_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.STATISTICS_TABLE; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.BaseConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.DataQualityConfiguration; import org.apache.dolphinscheduler.plugin.task.dq.utils.RuleParserUtils; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5Utils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5Utils.java similarity index 96% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5Utils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5Utils.java index e4778ed66d..d03a3ecd97 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5Utils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5Utils.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.utils; +package org.apache.dolphinscheduler.plugin.task.dq.utils; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/RuleParserUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/RuleParserUtils.java index 565a501043..ead7187081 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/RuleParserUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/RuleParserUtils.java @@ -17,62 +17,61 @@ package org.apache.dolphinscheduler.plugin.task.dq.utils; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_BUSINESS_DATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_CURRENT_DATE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.PARAMETER_DATETIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.AND; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.BATCH; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.CHECK_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_NAME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.CREATE_TIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.DATABASE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.DATA_TIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.DRIVER; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.ERROR_OUTPUT_PATH; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.FAILURE_STRATEGY; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.HDFS_FILE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.INDEX; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.INPUT_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.OPERATOR; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.OUTPUT_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PASSWORD; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PATH; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PROCESS_DEFINITION_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.PROCESS_INSTANCE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.RULE_NAME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.RULE_TYPE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SQL; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_FIELD; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_FILTER; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.STATISTICS_EXECUTE_SQL; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.STATISTICS_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TARGET_FIELD; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TARGET_FILTER; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TARGET_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.TASK_INSTANCE_ID; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.THRESHOLD; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.UPDATE_TIME; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.URL; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.USER; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_BUSINESS_DATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_CURRENT_DATE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.PARAMETER_DATETIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.AND; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.BATCH; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.CHECK_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_NAME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.CREATE_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.DATABASE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.DATA_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.DRIVER; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.ERROR_OUTPUT_PATH; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.FAILURE_STRATEGY; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.HDFS_FILE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.INDEX; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.INPUT_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.OPERATOR; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.OUTPUT_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PASSWORD; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PATH; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PROCESS_DEFINITION_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.PROCESS_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.RULE_NAME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.RULE_TYPE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SQL; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_FIELD; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_FILTER; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.STATISTICS_EXECUTE_SQL; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.STATISTICS_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TARGET_FIELD; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TARGET_FILTER; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TARGET_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.THRESHOLD; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.UPDATE_TIME; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.URL; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.USER; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.plugin.task.dq.exception.DataQualityException; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleInputEntry; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.BaseConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parameter.EnvConfig; import org.apache.dolphinscheduler.plugin.task.dq.rule.parser.MappingColumn; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.dq.utils.Md5Utils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkArgsUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkArgsUtils.java index 5459618113..b60aeaa500 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkArgsUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkArgsUtils.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.dq.utils.spark; -import org.apache.dolphinscheduler.plugin.task.util.ArgsUtils; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkParameters.java index 8de367ab32..9ba5976546 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/main/java/org/apache/dolphinscheduler/plugin/task/dq/utils/spark/SparkParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.dq.utils.spark; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java index c8c5cf2514..e3bd5f55d3 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java @@ -17,19 +17,19 @@ package org.apache.dolphinscheduler.plugin.task.dq; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.COMPARISON_TABLE; -import static org.apache.dolphinscheduler.spi.task.dq.utils.DataQualityConstants.SRC_FIELD; - +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.COMPARISON_TABLE; +import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.SRC_FIELD; + +import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.OptionSourceType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.RuleType; +import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ValueType; import org.apache.dolphinscheduler.plugin.task.dq.rule.RuleManager; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleExecuteSql; import org.apache.dolphinscheduler.plugin.task.dq.rule.entity.DqRuleInputEntry; import org.apache.dolphinscheduler.spi.params.base.FormType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ExecuteSqlType; -import org.apache.dolphinscheduler.spi.task.dq.enums.InputType; -import org.apache.dolphinscheduler.spi.task.dq.enums.OptionSourceType; -import org.apache.dolphinscheduler.spi.task.dq.enums.RuleType; -import org.apache.dolphinscheduler.spi.task.dq.enums.ValueType; -import org.apache.dolphinscheduler.spi.task.request.DataQualityTaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5UtilsTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5UtilsTest.java similarity index 94% rename from dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5UtilsTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5UtilsTest.java index 96bc7c6d16..cf71a05f60 100644 --- a/dolphinscheduler-spi/src/test/java/org/apache/dolphinscheduler/spi/task/dq/utils/Md5UtilsTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/utils/Md5UtilsTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.dq.utils; +package org.apache.dolphinscheduler.plugin.task.dq.utils; import static org.junit.Assert.assertEquals; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParameters.java index fd6ea7a953..e84508221a 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParameters.java @@ -17,13 +17,17 @@ package org.apache.dolphinscheduler.plugin.task.datax; +import org.apache.dolphinscheduler.plugin.task.api.enums.ResourceType; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.DataSourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import org.apache.dolphinscheduler.spi.enums.Flag; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * DataX parameter @@ -248,4 +252,32 @@ public class DataxParameters extends AbstractParameters { + ", xmx=" + xmx + '}'; } + + @Override + public ResourceParametersHelper getResources() { + ResourceParametersHelper resources = super.getResources(); + resources.put(ResourceType.DATASOURCE, dataSource); + resources.put(ResourceType.DATASOURCE, dataTarget); + return resources; + } + + public DataxTaskExecutionContext generateExtendedContext(ResourceParametersHelper parametersHelper) { + DataSourceParameters dbSource = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, dataSource); + DataSourceParameters dbTarget = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, dataTarget); + + DataxTaskExecutionContext dataxTaskExecutionContext = new DataxTaskExecutionContext(); + + if (Objects.nonNull(dbSource)) { + dataxTaskExecutionContext.setDataSourceId(dataSource); + dataxTaskExecutionContext.setSourcetype(dbSource.getType()); + dataxTaskExecutionContext.setSourceConnectionParams(dbSource.getConnectionParams()); + } + + if (Objects.nonNull(dbTarget)) { + dataxTaskExecutionContext.setDataTargetId(dataTarget); + dataxTaskExecutionContext.setTargetType(dbTarget.getType()); + dataxTaskExecutionContext.setTargetConnectionParams(dbTarget.getConnectionParams()); + } + return dataxTaskExecutionContext; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java index 073552d15d..e24276701d 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTask.java @@ -18,25 +18,24 @@ package org.apache.dolphinscheduler.plugin.task.datax; import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.RWXR_XR_X; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RWXR_XR_X; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; -import org.apache.dolphinscheduler.plugin.task.api.TaskResponse; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.enums.Flag; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.DataxTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -109,14 +108,16 @@ public class DataxTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; + + private DataxTaskExecutionContext dataxTaskExecutionContext; /** * constructor * * @param taskExecutionContext taskExecutionContext */ - public DataxTask(TaskRequest taskExecutionContext) { + public DataxTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; @@ -135,6 +136,8 @@ public class DataxTask extends AbstractTaskExecutor { if (!dataXParameters.checkParameters()) { throw new RuntimeException("datax task params is not valid"); } + + dataxTaskExecutionContext = dataXParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper()); } /** @@ -230,13 +233,13 @@ public class DataxTask extends AbstractTaskExecutor { * @throws SQLException if error throws SQLException */ private List buildDataxJobContentJson() { - DataxTaskExecutionContext dataxTaskExecutionContext = taskExecutionContext.getDataxTaskExecutionContext(); + BaseConnectionParam dataSourceCfg = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( - DbType.of(dataxTaskExecutionContext.getSourcetype()), + dataxTaskExecutionContext.getSourcetype(), dataxTaskExecutionContext.getSourceConnectionParams()); BaseConnectionParam dataTargetCfg = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( - DbType.of(dataxTaskExecutionContext.getTargetType()), + dataxTaskExecutionContext.getTargetType(), dataxTaskExecutionContext.getTargetConnectionParams()); List readerConnArr = new ArrayList<>(); @@ -258,7 +261,7 @@ public class DataxTask extends AbstractTaskExecutor { readerParam.putArray("connection").addAll(readerConnArr); ObjectNode reader = JSONUtils.createObjectNode(); - reader.put("name", DataxUtils.getReaderPluginName(DbType.of(dataxTaskExecutionContext.getSourcetype()))); + reader.put("name", DataxUtils.getReaderPluginName(dataxTaskExecutionContext.getSourcetype())); reader.set("parameter", readerParam); List writerConnArr = new ArrayList<>(); @@ -273,8 +276,8 @@ public class DataxTask extends AbstractTaskExecutor { writerParam.put("username", dataTargetCfg.getUser()); writerParam.put("password", decodePassword(dataTargetCfg.getPassword())); - String[] columns = parsingSqlColumnNames(DbType.of(dataxTaskExecutionContext.getSourcetype()), - DbType.of(dataxTaskExecutionContext.getTargetType()), + String[] columns = parsingSqlColumnNames(dataxTaskExecutionContext.getSourcetype(), + dataxTaskExecutionContext.getTargetType(), dataSourceCfg, dataXParameters.getSql()); ArrayNode columnArr = writerParam.putArray("column"); @@ -299,7 +302,7 @@ public class DataxTask extends AbstractTaskExecutor { } ObjectNode writer = JSONUtils.createObjectNode(); - writer.put("name", DataxUtils.getWriterPluginName(DbType.of(dataxTaskExecutionContext.getTargetType()))); + writer.put("name", DataxUtils.getWriterPluginName(dataxTaskExecutionContext.getTargetType())); writer.set("parameter", writerParam); List contentList = new ArrayList<>(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannel.java index a45ed4c5f3..f3ca636baa 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.datax; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class DataxTaskChannel implements TaskChannel { @@ -29,7 +33,17 @@ public class DataxTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new DataxTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), DataxParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannelFactory.java index d9c16ef0b2..332d6bf708 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.datax; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataxTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskExecutionContext.java similarity index 73% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataxTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskExecutionContext.java index 276923d37c..fae66c8fd6 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/DataxTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/main/java/org/apache/dolphinscheduler/plugin/task/datax/DataxTaskExecutionContext.java @@ -15,14 +15,16 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.datax; + +import org.apache.dolphinscheduler.spi.enums.DbType; import java.io.Serializable; /** * master/worker task transport */ -public class DataxTaskExecutionContext implements Serializable{ +public class DataxTaskExecutionContext implements Serializable { /** * dataSourceId @@ -32,7 +34,7 @@ public class DataxTaskExecutionContext implements Serializable{ /** * sourcetype */ - private int sourcetype; + private DbType sourcetype; /** * sourceConnectionParams @@ -47,7 +49,7 @@ public class DataxTaskExecutionContext implements Serializable{ /** * targetType */ - private int targetType; + private DbType targetType; /** * targetConnectionParams @@ -62,11 +64,11 @@ public class DataxTaskExecutionContext implements Serializable{ this.dataSourceId = dataSourceId; } - public int getSourcetype() { + public DbType getSourcetype() { return sourcetype; } - public void setSourcetype(int sourcetype) { + public void setSourcetype(DbType sourcetype) { this.sourcetype = sourcetype; } @@ -86,11 +88,11 @@ public class DataxTaskExecutionContext implements Serializable{ this.dataTargetId = dataTargetId; } - public int getTargetType() { + public DbType getTargetType() { return targetType; } - public void setTargetType(int targetType) { + public void setTargetType(DbType targetType) { this.targetType = targetType; } @@ -104,13 +106,13 @@ public class DataxTaskExecutionContext implements Serializable{ @Override public String toString() { - return "DataxTaskExecutionContext{" + - "dataSourceId=" + dataSourceId + - ", sourcetype=" + sourcetype + - ", sourceConnectionParams='" + sourceConnectionParams + '\'' + - ", dataTargetId=" + dataTargetId + - ", targetType=" + targetType + - ", targetConnectionParams='" + targetConnectionParams + '\'' + - '}'; + return "DataxTaskExecutionContext{" + + "dataSourceId=" + dataSourceId + + ", sourcetype=" + sourcetype + + ", sourceConnectionParams='" + sourceConnectionParams + '\'' + + ", dataTargetId=" + dataTargetId + + ", targetType=" + targetType + + ", targetConnectionParams='" + targetConnectionParams + '\'' + + '}'; } } diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataxParametersTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/test/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParametersTest.java similarity index 96% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataxParametersTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/test/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParametersTest.java index dd11aab260..05fdaeaf71 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/DataxParametersTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-datax/src/test/java/org/apache/dolphinscheduler/plugin/task/datax/DataxParametersTest.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; - -import org.apache.dolphinscheduler.common.task.datax.DataxParameters; +package org.apache.dolphinscheduler.plugin.task.datax; import org.junit.Assert; import org.junit.Test; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/pom.xml new file mode 100644 index 0000000000..e0597896c3 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/pom.xml @@ -0,0 +1,44 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-dependent + jar + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + org.apache.dolphinscheduler + dolphinscheduler-task-api + ${project.version} + + + + \ No newline at end of file diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannel.java new file mode 100644 index 0000000000..1d24e8527a --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannel.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.dependent; + +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; +import org.apache.dolphinscheduler.spi.utils.StringUtils; + +public class DependentTaskChannel implements TaskChannel { + + @Override + public void cancelApplication(boolean status) { + + } + + @Override + public AbstractTask createTask(TaskExecutionContext taskRequest) { + return null; + } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(StringUtils.isEmpty(parametersNode.getDependence()) + ? parametersNode.getTaskParams() : parametersNode.getDependence(), DependentParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannelFactory.java new file mode 100644 index 0000000000..ad976d5857 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-dependent/src/main/java/org/apache/dolphinscheduler/plugin/task/dependent/DependentTaskChannelFactory.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.dependent; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; + +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; + +import java.util.List; + +import com.google.auto.service.AutoService; + +@AutoService(TaskChannelFactory.class) +public class DependentTaskChannelFactory implements TaskChannelFactory { + @Override + public TaskChannel create() { + return new DependentTaskChannel(); + } + + @Override + public String getName() { + return TASK_TYPE_DEPENDENT; + } + + @Override + public List getParams() { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrParameters.java index 9f8ef03acc..14396fcebc 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.emr; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.Collections; @@ -44,7 +44,6 @@ public class EmrParameters extends AbstractParameters { } - public String getJobFlowDefineJson() { return jobFlowDefineJson; } @@ -55,8 +54,8 @@ public class EmrParameters extends AbstractParameters { @Override public String toString() { - return "EmrParameters{" + - "jobFlowDefineJson='" + jobFlowDefineJson + '\'' + - '}'; + return "EmrParameters{" + + "jobFlowDefineJson='" + jobFlowDefineJson + '\'' + + '}'; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTask.java index bc9de5925a..ada0041bf9 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTask.java @@ -23,9 +23,9 @@ import static com.fasterxml.jackson.databind.DeserializationFeature.READ_UNKNOWN import static com.fasterxml.jackson.databind.MapperFeature.REQUIRE_SETTERS_FOR_GETTERS; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.PropertyUtils; @@ -59,7 +59,7 @@ public class EmrTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private final TaskRequest taskExecutionContext; + private final TaskExecutionContext taskExecutionContext; /** * emr parameters */ @@ -92,7 +92,7 @@ public class EmrTask extends AbstractTaskExecutor { * * @param taskExecutionContext taskExecutionContext */ - protected EmrTask(TaskRequest taskExecutionContext) { + protected EmrTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; @@ -226,7 +226,7 @@ public class EmrTask extends AbstractTaskExecutor { @Override public void cancelApplication(boolean status) throws Exception { super.cancelApplication(status); - logger.info("trying terminate job flow, taskId:{}, clusterId:{}", this.taskExecutionContext.getTaskInstanceId() , clusterId); + logger.info("trying terminate job flow, taskId:{}, clusterId:{}", this.taskExecutionContext.getTaskInstanceId(), clusterId); TerminateJobFlowsRequest terminateJobFlowsRequest = new TerminateJobFlowsRequest().withJobFlowIds(clusterId); TerminateJobFlowsResult terminateJobFlowsResult = emrClient.terminateJobFlows(terminateJobFlowsRequest); logger.info("the result of terminate job flow is:{}", terminateJobFlowsResult); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannel.java index 9a7561b866..898362f2cc 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.emr; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class EmrTaskChannel implements TaskChannel { @Override @@ -28,7 +32,17 @@ public class EmrTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new EmrTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), EmrParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannelFactory.java index 09d0c52f22..daf67cb2d2 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.emr; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.Collections; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/test/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/test/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskTest.java index d03d06005f..285078f21f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/test/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/test/java/org/apache/dolphinscheduler/plugin/task/emr/EmrTaskTest.java @@ -17,9 +17,10 @@ package org.apache.dolphinscheduler.plugin.task.emr; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_KILL; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_SUCCESS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_SUCCESS; + import static org.mockito.ArgumentMatchers.any; import static org.powermock.api.mockito.PowerMockito.doReturn; import static org.powermock.api.mockito.PowerMockito.mock; @@ -27,7 +28,7 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.spy; import static org.powermock.api.mockito.PowerMockito.when; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.io.IOUtils; @@ -120,7 +121,7 @@ public class EmrTaskTest { @Before public void before() throws Exception { String emrParameters = buildEmrTaskParameters(); - TaskRequest taskExecutionContext = PowerMockito.mock(TaskRequest.class); + TaskExecutionContext taskExecutionContext = PowerMockito.mock(TaskExecutionContext.class); when(taskExecutionContext.getTaskParams()).thenReturn(emrParameters); emrTask = spy(new EmrTask(taskExecutionContext)); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtils.java index def81b0367..ea047bea6c 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkArgsUtils.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.flink; -import org.apache.dolphinscheduler.plugin.task.util.ArgsUtils; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParameters.java index 0b422e4ccd..c458c24f90 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.flink; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTask.java index 6b77a3eca3..5e1734b7bf 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTask.java @@ -18,13 +18,13 @@ package org.apache.dolphinscheduler.plugin.task.flink; import org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -50,9 +50,9 @@ public class FlinkTask extends AbstractYarnTask { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; - public FlinkTask(TaskRequest taskExecutionContext) { + public FlinkTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannel.java index ceb36c395f..2f1daf3bde 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannel.java @@ -17,8 +17,12 @@ package org.apache.dolphinscheduler.plugin.task.flink; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class FlinkTaskChannel implements TaskChannel { @Override @@ -27,7 +31,17 @@ public class FlinkTaskChannel implements TaskChannel { } @Override - public FlinkTask createTask(TaskRequest taskRequest) { + public FlinkTask createTask(TaskExecutionContext taskRequest) { return new FlinkTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), FlinkParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannelFactory.java index 7501f16fe8..48363803c5 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/main/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.flink; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/FlinkParametersTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParametersTest.java similarity index 90% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/FlinkParametersTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParametersTest.java index f7ad9de70e..001f177b82 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/FlinkParametersTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-flink/src/test/java/org/apache/dolphinscheduler/plugin/task/flink/FlinkParametersTest.java @@ -14,19 +14,19 @@ * 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.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.flink.FlinkParameters; +package org.apache.dolphinscheduler.plugin.task.flink; -import org.apache.commons.collections.CollectionUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; -import org.junit.Assert; -import org.junit.Test; +import org.apache.commons.collections.CollectionUtils; import java.util.LinkedList; import java.util.List; +import org.junit.Assert; +import org.junit.Test; + public class FlinkParametersTest { @Test public void getResourceFilesList() { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpParameters.java index 0317592b35..2676dd675c 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.http; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java index 22b8700a8f..c829ad0736 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java @@ -20,12 +20,12 @@ package org.apache.dolphinscheduler.plugin.task.http; import static org.apache.dolphinscheduler.plugin.task.http.HttpTaskConstants.APPLICATION_JSON; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.DateUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -66,14 +66,14 @@ public class HttpTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; /** * constructor * * @param taskExecutionContext taskExecutionContext */ - public HttpTask(TaskRequest taskExecutionContext) { + public HttpTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannel.java index 6f7806341b..2af67b3415 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.http; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class HttpTaskChannel implements TaskChannel { @@ -29,7 +33,17 @@ public class HttpTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new HttpTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), HttpParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannelFactory.java index e69524c9ba..efbc254b0d 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.http; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/HttpParametersTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/test/java/org/apache/dolphinscheduler/plugin/task/http/HttpParametersTest.java similarity index 62% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/HttpParametersTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/test/java/org/apache/dolphinscheduler/plugin/task/http/HttpParametersTest.java index 6bd3bc76b5..aede1781cb 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/HttpParametersTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/test/java/org/apache/dolphinscheduler/plugin/task/http/HttpParametersTest.java @@ -14,12 +14,11 @@ * 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; +package org.apache.dolphinscheduler.plugin.task.http; + +import org.apache.dolphinscheduler.spi.utils.JSONUtils; + import org.junit.Assert; import org.junit.Test; @@ -28,32 +27,29 @@ import org.junit.Test; */ 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\"}"; + 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()); + 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\"}"; + 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.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()); @@ -62,15 +58,14 @@ public class HttpParametersTest { } - @Test public void testCheckValues() { - String paramData = "{\"localParams\":[],\"httpParams\":[],\"url\":\"https://www.baidu.com/\"," + - "\"httpMethod\":\"GET\",\"httpCheckCondition\":\"STATUS_CODE_DEFAULT\",\"condition\":\"\",\"connectTimeout\":\"10000\",\"socketTimeout\":\"10000\"}"; + 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.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()); @@ -80,5 +75,4 @@ public class HttpParametersTest { Assert.assertEquals(0,httpParameters.getResourceFilesList().size()); } - } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceArgsUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceArgsUtils.java index 84eee6ccd7..48025d4bee 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceArgsUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceArgsUtils.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.mr; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.D; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.JAR; import static org.apache.dolphinscheduler.plugin.task.mr.MapReduceTaskConstants.MR_NAME; import static org.apache.dolphinscheduler.plugin.task.mr.MapReduceTaskConstants.MR_QUEUE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.D; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAR; -import org.apache.dolphinscheduler.plugin.task.util.ArgsUtils; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceParameters.java index d099ca6cce..e6a67065f4 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.mr; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTask.java index 350de7d574..588dcda184 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTask.java @@ -18,14 +18,14 @@ package org.apache.dolphinscheduler.plugin.task.mr; import org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; @@ -52,13 +52,13 @@ public class MapReduceTask extends AbstractYarnTask { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; /** * constructor * @param taskExecutionContext taskExecutionContext */ - public MapReduceTask(TaskRequest taskExecutionContext) { + public MapReduceTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannel.java index 4c721f0859..931adbf509 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.mr; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class MapReduceTaskChannel implements TaskChannel { @Override @@ -28,7 +32,17 @@ public class MapReduceTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new MapReduceTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), MapReduceParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannelFactory.java index 6d1beadcbe..e42737d83e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-mr/src/main/java/org/apache/dolphinscheduler/plugin/task/mr/MapReduceTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.mr; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonParameters.java index 94a544f138..db839d886f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.pigeon; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.Collections; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTask.java index a17b9951e9..028eddb1c1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTask.java @@ -18,9 +18,9 @@ package org.apache.dolphinscheduler.plugin.task.pigeon; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -51,13 +51,13 @@ import org.java_websocket.handshake.ServerHandshake; public class PigeonTask extends AbstractTaskExecutor { public static final String KEY_POOL_VAR_PIGEON_HOST = "p_host"; - private final TaskRequest taskExecutionContext; + private final TaskExecutionContext taskExecutionContext; private PigeonParameters parameters; private BizResult triggerResult; private final PigeonConfig config; - public PigeonTask(TaskRequest taskExecutionContext) { + public PigeonTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; this.config = PigeonConfig.getInstance(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannel.java index 78b087a57e..72fff0277c 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.pigeon; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +37,17 @@ public class PigeonTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new PigeonTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), PigeonParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannelFactory.java index 290acd6f77..e95f1330bb 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/main/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskChannelFactory.java @@ -17,11 +17,11 @@ package org.apache.dolphinscheduler.plugin.task.pigeon; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.Arrays; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/test/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/test/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskTest.java index 4d64598ce0..d02dd8d4a1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/test/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-pigeon/src/test/java/org/apache/dolphinscheduler/plugin/task/pigeon/PigeonTaskTest.java @@ -21,8 +21,8 @@ import static com.github.dreamhead.moco.Moco.file; import static com.github.dreamhead.moco.MocoJsonRunner.jsonHttpServer; import static com.github.dreamhead.moco.Runner.running; -import org.apache.dolphinscheduler.spi.task.ExecutionStatus; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.io.IOUtils; @@ -47,14 +47,14 @@ public class PigeonTaskTest { private static final Logger logger = LoggerFactory.getLogger(PigeonTaskTest.class); private PigeonTask pigeonTask; - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; @Before public void before() throws Exception { String taskParams = "{\"targetJobName\":\"mysql_elastic\"}"; - taskExecutionContext = Mockito.mock(TaskRequest.class); + taskExecutionContext = Mockito.mock(TaskExecutionContext.class); Mockito.when(taskExecutionContext.getTaskLogName()).thenReturn("pigeonlogger"); Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(taskParams); Mockito.when(taskExecutionContext.getExecutePath()).thenReturn("/tmp"); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureParameters.java index d0e35b9642..129b3120e8 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureParameters.java @@ -17,16 +17,21 @@ package org.apache.dolphinscheduler.plugin.task.procedure; -import org.apache.commons.collections.CollectionUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.enums.ResourceType; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.DataSourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import org.apache.dolphinscheduler.spi.utils.StringUtils; +import org.apache.commons.collections.CollectionUtils; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * procedure parameter @@ -121,4 +126,18 @@ public class ProcedureParameters extends AbstractParameters { public void setOutProperty(Map outProperty) { this.outProperty = outProperty; } + + @Override + public ResourceParametersHelper getResources() { + ResourceParametersHelper resources = super.getResources(); + resources.put(ResourceType.DATASOURCE, datasource); + return resources; + } + + public ProcedureTaskExecutionContext generateExtendedContext(ResourceParametersHelper parametersHelper) { + DataSourceParameters dataSourceParameters = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, datasource); + ProcedureTaskExecutionContext procedureTaskExecutionContext = new ProcedureTaskExecutionContext(); + procedureTaskExecutionContext.setConnectionParams(Objects.nonNull(dataSourceParameters) ? dataSourceParameters.getConnectionParams() : null); + return procedureTaskExecutionContext; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java index b33a00cb70..4f61ef1022 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java @@ -17,19 +17,22 @@ package org.apache.dolphinscheduler.plugin.task.procedure; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_SUCCESS; + import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; -import org.apache.dolphinscheduler.spi.enums.DataType; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Direct; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -41,9 +44,6 @@ import java.sql.Types; import java.util.HashMap; import java.util.Map; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_SUCCESS; - /** * procedure task */ @@ -57,14 +57,16 @@ public class ProcedureTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; + + private ProcedureTaskExecutionContext procedureTaskExecutionContext; /** * constructor * * @param taskExecutionContext taskExecutionContext */ - public ProcedureTask(TaskRequest taskExecutionContext) { + public ProcedureTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; @@ -77,6 +79,8 @@ public class ProcedureTask extends AbstractTaskExecutor { if (!procedureParameters.checkParameters()) { throw new RuntimeException("procedure task params is not valid"); } + + procedureTaskExecutionContext = procedureParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper()); } @Override @@ -94,7 +98,7 @@ public class ProcedureTask extends AbstractTaskExecutor { DbType dbType = DbType.valueOf(procedureParameters.getType()); // get datasource ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(DbType.valueOf(procedureParameters.getType()), - taskExecutionContext.getProcedureTaskExecutionContext().getConnectionParams()); + procedureTaskExecutionContext.getConnectionParams()); // get jdbc connection connection = DataSourceClientProvider.getInstance().getConnection(dbType, connectionParam); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannel.java index 5181dc1254..927559debd 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.procedure; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class ProcedureTaskChannel implements TaskChannel { @@ -29,7 +33,17 @@ public class ProcedureTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new ProcedureTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), ProcedureParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannelFactory.java index d313ddfc3f..a96a082af0 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.procedure; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/ProcedureTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskExecutionContext.java similarity index 86% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/ProcedureTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskExecutionContext.java index 07d94b145b..08620df412 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/ProcedureTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTaskExecutionContext.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.procedure; import java.io.Serializable; /** * master/worker task transport */ -public class ProcedureTaskExecutionContext implements Serializable{ +public class ProcedureTaskExecutionContext implements Serializable { /** * connectionParams @@ -39,8 +39,8 @@ public class ProcedureTaskExecutionContext implements Serializable{ @Override public String toString() { - return "ProcedureTaskExecutionContext{" + - "connectionParams='" + connectionParams + '\'' + - '}'; + return "ProcedureTaskExecutionContext{" + + "connectionParams='" + connectionParams + '\'' + + '}'; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonParameters.java index a870f4cec9..68e6c23e4b 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.python; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java index 6d924780d9..1df388f756 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java @@ -19,15 +19,15 @@ package org.apache.dolphinscheduler.plugin.task.python; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskException; -import org.apache.dolphinscheduler.plugin.task.api.TaskResponse; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.io.FileUtils; @@ -58,18 +58,18 @@ public class PythonTask extends AbstractTaskExecutor { */ private ShellCommandExecutor shellCommandExecutor; - private TaskRequest taskRequest; + private TaskExecutionContext taskRequest; - private final String PYTHON_HOME = "PYTHON_HOME"; + private static final String PYTHON_HOME = "PYTHON_HOME"; - private final String DEFAULT_PYTHON_VERSION = "python"; + private static final String DEFAULT_PYTHON_VERSION = "python"; /** * constructor * * @param taskRequest taskRequest */ - public PythonTask(TaskRequest taskRequest) { + public PythonTask(TaskExecutionContext taskRequest) { super(taskRequest); this.taskRequest = taskRequest; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannel.java index a3774c5d3e..56dab9b2f2 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannel.java @@ -17,8 +17,12 @@ package org.apache.dolphinscheduler.plugin.task.python; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class PythonTaskChannel implements TaskChannel { @Override @@ -27,7 +31,17 @@ public class PythonTaskChannel implements TaskChannel { } @Override - public PythonTask createTask(TaskRequest taskRequest) { + public PythonTask createTask(TaskExecutionContext taskRequest) { return new PythonTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), PythonParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannelFactory.java index 55514e48f6..00c44ee310 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTaskChannelFactory.java @@ -15,9 +15,9 @@ package org.apache.dolphinscheduler.plugin.task.python;/* * limitations under the License. */ +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelParameters.java index 5c02efee2c..95e5b5047c 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.seatunnel; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java index 58dc4bc4b6..e725a25021 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTask.java @@ -17,18 +17,18 @@ package org.apache.dolphinscheduler.plugin.task.seatunnel; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.RWXR_XR_X; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RWXR_XR_X; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; -import org.apache.dolphinscheduler.plugin.task.api.TaskResponse; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.collections4.MapUtils; @@ -62,14 +62,14 @@ public class SeatunnelTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; /** * constructor * * @param taskExecutionContext taskExecutionContext */ - public SeatunnelTask(TaskRequest taskExecutionContext) { + public SeatunnelTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannel.java index 54799aee05..4981a90388 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannel.java @@ -17,8 +17,12 @@ package org.apache.dolphinscheduler.plugin.task.seatunnel; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class SeatunnelTaskChannel implements TaskChannel { @@ -28,8 +32,18 @@ public class SeatunnelTaskChannel implements TaskChannel { } @Override - public SeatunnelTask createTask(TaskRequest taskRequest) { + public SeatunnelTask createTask(TaskExecutionContext taskRequest) { return new SeatunnelTask(taskRequest); } + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), SeatunnelParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } + } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannelFactory.java index 15581dac75..2763c00d50 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-seatunnel/src/main/java/org/apache/dolphinscheduler/plugin/task/seatunnel/SeatunnelTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.seatunnel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellParameters.java index fe51f89dd0..ffbaf8cc90 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.shell; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java index 45ca6b66e1..737b876b74 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java @@ -17,18 +17,18 @@ package org.apache.dolphinscheduler.plugin.task.shell; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.RWXR_XR_X; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RWXR_XR_X; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; -import org.apache.dolphinscheduler.plugin.task.api.TaskResponse; -import org.apache.dolphinscheduler.plugin.task.util.OSUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.commons.collections4.MapUtils; @@ -62,14 +62,14 @@ public class ShellTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; /** * constructor * * @param taskExecutionContext taskExecutionContext */ - public ShellTask(TaskRequest taskExecutionContext) { + public ShellTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; @@ -144,7 +144,7 @@ public class ShellTask extends AbstractTaskExecutor { if (OSUtils.isWindows()) { Files.createFile(path); } else { - if (!file.getParentFile().exists()){ + if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } Files.createFile(path, attr); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannel.java index 73d2c2a885..389a52d380 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannel.java @@ -17,8 +17,12 @@ package org.apache.dolphinscheduler.plugin.task.shell; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class ShellTaskChannel implements TaskChannel { @@ -28,8 +32,18 @@ public class ShellTaskChannel implements TaskChannel { } @Override - public ShellTask createTask(TaskRequest taskRequest) { + public ShellTask createTask(TaskExecutionContext taskRequest) { return new ShellTask(taskRequest); } + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), ShellParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } + } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannelFactory.java index 521e59bcce..c960a0d5c1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTaskChannelFactory.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.shell; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.input.InputParam; import org.apache.dolphinscheduler.spi.params.radio.RadioParam; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkArgsUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkArgsUtils.java index b1018e24a2..1a5c662118 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkArgsUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkArgsUtils.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.spark; -import org.apache.dolphinscheduler.plugin.task.util.ArgsUtils; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.utils.ArgsUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.util.ArrayList; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParameters.java index b4cb14ead6..44a3d0cc81 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParameters.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.spark; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import java.util.ArrayList; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java index 9f9588eaa7..54073e8fdd 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTask.java @@ -18,13 +18,13 @@ package org.apache.dolphinscheduler.plugin.task.spark; import org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; @@ -42,9 +42,9 @@ public class SparkTask extends AbstractYarnTask { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; - public SparkTask(TaskRequest taskExecutionContext) { + public SparkTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannel.java index 2e9f6b2336..9728492986 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannel.java @@ -17,9 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.spark; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class SparkTaskChannel implements TaskChannel { @@ -29,7 +33,17 @@ public class SparkTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new SparkTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), SparkParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannelFactory.java index a468a9274f..0d307bde55 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/main/java/org/apache/dolphinscheduler/plugin/task/spark/SparkTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.spark; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SparkParametersTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/test/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParametersTest.java similarity index 92% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SparkParametersTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/test/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParametersTest.java index a3d4d9eda9..b1c7806d12 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SparkParametersTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-spark/src/test/java/org/apache/dolphinscheduler/plugin/task/spark/SparkParametersTest.java @@ -15,10 +15,9 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; +package org.apache.dolphinscheduler.plugin.task.spark; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.spark.SparkParameters; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.commons.collections.CollectionUtils; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlBinds.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlBinds.java index a90c8db5e5..5f2741d952 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlBinds.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlBinds.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.sql; -import org.apache.dolphinscheduler.spi.task.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.util.Map; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java index 45e6c39d56..e85ccc6432 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java @@ -21,21 +21,22 @@ import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClient import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor; +import org.apache.dolphinscheduler.plugin.task.api.SQLTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskException; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.enums.SqlType; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskAlertInfo; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.UdfFuncParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.enums.TaskTimeoutStrategy; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Direct; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.TaskAlertInfo; -import org.apache.dolphinscheduler.spi.task.TaskConstants; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.SQLTaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; -import org.apache.dolphinscheduler.spi.task.request.UdfFuncRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -52,9 +53,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -69,7 +68,7 @@ public class SqlTask extends AbstractTaskExecutor { /** * taskExecutionContext */ - private TaskRequest taskExecutionContext; + private TaskExecutionContext taskExecutionContext; /** * sql parameters @@ -91,12 +90,14 @@ public class SqlTask extends AbstractTaskExecutor { */ private static final int QUERY_LIMIT = 10000; + private SQLTaskExecutionContext sqlTaskExecutionContext; + /** * Abstract Yarn Task * * @param taskRequest taskRequest */ - public SqlTask(TaskRequest taskRequest) { + public SqlTask(TaskExecutionContext taskRequest) { super(taskRequest); this.taskExecutionContext = taskRequest; this.sqlParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), SqlParameters.class); @@ -105,6 +106,8 @@ public class SqlTask extends AbstractTaskExecutor { if (!sqlParameters.checkParameters()) { throw new RuntimeException("sql task params is not valid"); } + + sqlTaskExecutionContext = sqlParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper()); } @Override @@ -126,7 +129,6 @@ public class SqlTask extends AbstractTaskExecutor { sqlParameters.getVarPool(), sqlParameters.getLimit()); try { - SQLTaskExecutionContext sqlTaskExecutionContext = taskExecutionContext.getSqlTaskExecutionContext(); // get datasource baseConnectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( @@ -146,8 +148,7 @@ public class SqlTask extends AbstractTaskExecutor { .map(this::getSqlAndSqlParamsMap) .collect(Collectors.toList()); - List createFuncs = createFuncs(sqlTaskExecutionContext.getUdfFuncTenantCodeMap(), - sqlTaskExecutionContext.getDefaultFS(), logger); + List createFuncs = createFuncs(sqlTaskExecutionContext.getUdfFuncParametersList(), logger); // execute sql task executeFuncAndSql(mainSqlBinds, preStatementSqlBinds, postStatementSqlBinds, createFuncs); @@ -485,57 +486,49 @@ public class SqlTask extends AbstractTaskExecutor { /** * create function list * - * @param udfFuncTenantCodeMap key is udf function,value is tenant code + * @param udfFuncParameters udfFuncParameters * @param logger logger - * @return create function list + * @return */ - public static List createFuncs(Map udfFuncTenantCodeMap, String defaultFS, Logger logger) { + private List createFuncs(List udfFuncParameters, Logger logger) { - if (MapUtils.isEmpty(udfFuncTenantCodeMap)) { + if (CollectionUtils.isEmpty(udfFuncParameters)) { logger.info("can't find udf function resource"); return null; } - List funcList = new ArrayList<>(); - // build jar sql - buildJarSql(funcList, udfFuncTenantCodeMap, defaultFS); + List funcList = buildJarSql(udfFuncParameters); // build temp function sql - buildTempFuncSql(funcList, new ArrayList<>(udfFuncTenantCodeMap.keySet())); - + List tempFuncList = buildTempFuncSql(udfFuncParameters); + funcList.addAll(tempFuncList); return funcList; } /** * build temp function sql - * - * @param sqls sql list - * @param udfFuncRequests udf function list + * @param udfFuncParameters udfFuncParameters + * @return */ - private static void buildTempFuncSql(List sqls, List udfFuncRequests) { - if (CollectionUtils.isNotEmpty(udfFuncRequests)) { - for (UdfFuncRequest udfFuncRequest : udfFuncRequests) { - sqls.add(MessageFormat - .format(CREATE_FUNCTION_FORMAT, udfFuncRequest.getFuncName(), udfFuncRequest.getClassName())); - } - } + private List buildTempFuncSql(List udfFuncParameters) { + return udfFuncParameters.stream().map(value -> MessageFormat + .format(CREATE_FUNCTION_FORMAT, value.getFuncName(), value.getClassName())).collect(Collectors.toList()); } /** * build jar sql - * @param sqls sql list - * @param udfFuncTenantCodeMap key is udf function,value is tenant code + * @param udfFuncParameters udfFuncParameters + * @return */ - private static void buildJarSql(List sqls, Map udfFuncTenantCodeMap, String defaultFS) { - String resourceFullName; - Set> entries = udfFuncTenantCodeMap.entrySet(); - for (Map.Entry entry : entries) { + private List buildJarSql(List udfFuncParameters) { + return udfFuncParameters.stream().map(value -> { + String defaultFS = value.getDefaultFS(); String prefixPath = defaultFS.startsWith("file://") ? "file://" : defaultFS; - String uploadPath = CommonUtils.getHdfsUdfDir(entry.getValue()); - resourceFullName = entry.getKey().getResourceName(); + String uploadPath = CommonUtils.getHdfsUdfDir(value.getTenantCode()); + String resourceFullName = value.getResourceName(); resourceFullName = resourceFullName.startsWith("/") ? resourceFullName : String.format("/%s", resourceFullName); - sqls.add(String.format("add jar %s%s%s", prefixPath, uploadPath, resourceFullName)); - } + return String.format("add jar %s%s%s", prefixPath, uploadPath, resourceFullName); + }).collect(Collectors.toList()); } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannel.java index 8da50f2a3b..390ef863fb 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannel.java @@ -17,9 +17,14 @@ package org.apache.dolphinscheduler.plugin.task.sql; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class SqlTaskChannel implements TaskChannel { @Override @@ -28,8 +33,18 @@ public class SqlTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new SqlTask(taskRequest); } + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), SqlParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return JSONUtils.parseObject(parameters, SqlParameters.class).getResources(); + } + } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannelFactory.java index 7259671954..7389dcad0b 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.sql; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlType.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlType.java deleted file mode 100644 index 9db9268902..0000000000 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlType.java +++ /dev/null @@ -1,27 +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.plugin.task.sql; - -public enum SqlType { - /** - * sql type - * 0 query - * 1 NON_QUERY - */ - QUERY, NON_QUERY -} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTask.java index a958c6e501..d0e58911a2 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTask.java @@ -18,14 +18,14 @@ package org.apache.dolphinscheduler.plugin.task.sqoop; import org.apache.dolphinscheduler.plugin.task.api.AbstractYarnTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; +import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; +import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.SqoopJobGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; -import org.apache.dolphinscheduler.plugin.task.util.MapUtils; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils; -import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.HashMap; @@ -44,9 +44,11 @@ public class SqoopTask extends AbstractYarnTask { /** * taskExecutionContext */ - private final TaskRequest taskExecutionContext; + private final TaskExecutionContext taskExecutionContext; - public SqoopTask(TaskRequest taskExecutionContext) { + private SqoopTaskExecutionContext sqoopTaskExecutionContext; + + public SqoopTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; } @@ -64,13 +66,15 @@ public class SqoopTask extends AbstractYarnTask { if (!sqoopParameters.checkParameters()) { throw new IllegalArgumentException("Sqoop Task params check fail"); } + + sqoopTaskExecutionContext = sqoopParameters.generateExtendedContext(taskExecutionContext.getResourceParametersHelper()); } @Override protected String buildCommand() { //get sqoop scripts SqoopJobGenerator generator = new SqoopJobGenerator(); - String script = generator.generateSqoopJob(sqoopParameters, taskExecutionContext); + String script = generator.generateSqoopJob(sqoopParameters, sqoopTaskExecutionContext); // combining local and global parameters Map paramsMap = ParamUtils.convert(taskExecutionContext, getParameters()); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannel.java index aa43669602..9be753677a 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannel.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannel.java @@ -17,9 +17,14 @@ package org.apache.dolphinscheduler.plugin.task.sqoop; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; public class SqoopTaskChannel implements TaskChannel { @@ -29,7 +34,17 @@ public class SqoopTaskChannel implements TaskChannel { } @Override - public AbstractTask createTask(TaskRequest taskRequest) { + public AbstractTask createTask(TaskExecutionContext taskRequest) { return new SqoopTask(taskRequest); } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), SqoopParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannelFactory.java index 462c0397f0..6879af6a6e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannelFactory.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskChannelFactory.java @@ -17,9 +17,9 @@ package org.apache.dolphinscheduler.plugin.task.sqoop; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; import java.util.List; diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SqoopTaskExecutionContext.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskExecutionContext.java similarity index 73% rename from dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SqoopTaskExecutionContext.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskExecutionContext.java index 720892c93f..310001471c 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/task/request/SqoopTaskExecutionContext.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopTaskExecutionContext.java @@ -15,14 +15,16 @@ * limitations under the License. */ -package org.apache.dolphinscheduler.spi.task.request; +package org.apache.dolphinscheduler.plugin.task.sqoop; + +import org.apache.dolphinscheduler.spi.enums.DbType; import java.io.Serializable; /** * master/worker task transport */ -public class SqoopTaskExecutionContext implements Serializable{ +public class SqoopTaskExecutionContext implements Serializable { /** * dataSourceId @@ -32,7 +34,7 @@ public class SqoopTaskExecutionContext implements Serializable{ /** * sourcetype */ - private int sourcetype; + private DbType sourcetype; /** * sourceConnectionParams @@ -47,7 +49,7 @@ public class SqoopTaskExecutionContext implements Serializable{ /** * targetType */ - private int targetType; + private DbType targetType; /** * targetConnectionParams @@ -62,11 +64,11 @@ public class SqoopTaskExecutionContext implements Serializable{ this.dataSourceId = dataSourceId; } - public int getSourcetype() { + public DbType getSourcetype() { return sourcetype; } - public void setSourcetype(int sourcetype) { + public void setSourcetype(DbType sourcetype) { this.sourcetype = sourcetype; } @@ -86,11 +88,11 @@ public class SqoopTaskExecutionContext implements Serializable{ this.dataTargetId = dataTargetId; } - public int getTargetType() { + public DbType getTargetType() { return targetType; } - public void setTargetType(int targetType) { + public void setTargetType(DbType targetType) { this.targetType = targetType; } @@ -104,13 +106,13 @@ public class SqoopTaskExecutionContext implements Serializable{ @Override public String toString() { - return "SqoopTaskExecutionContext{" + - "dataSourceId=" + dataSourceId + - ", sourcetype=" + sourcetype + - ", sourceConnectionParams='" + sourceConnectionParams + '\'' + - ", dataTargetId=" + dataTargetId + - ", targetType=" + targetType + - ", targetConnectionParams='" + targetConnectionParams + '\'' + - '}'; + return "SqoopTaskExecutionContext{" + + "dataSourceId=" + dataSourceId + + ", sourcetype=" + sourcetype + + ", sourceConnectionParams='" + sourceConnectionParams + '\'' + + ", dataTargetId=" + dataTargetId + + ", targetType=" + targetType + + ", targetConnectionParams='" + targetConnectionParams + '\'' + + '}'; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/CommonGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/CommonGenerator.java index 0635296433..d1e13ae096 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/CommonGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/CommonGenerator.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.D; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EQUAL_SIGN; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.D; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EQUAL_SIGN; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; -import org.apache.dolphinscheduler.spi.task.Property; import org.apache.commons.collections4.CollectionUtils; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ISourceGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ISourceGenerator.java index 7e770a84e5..8a20464181 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ISourceGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ISourceGenerator.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; /** * Source Generator Interface @@ -29,8 +29,8 @@ public interface ISourceGenerator { * generate the source script * * @param sqoopParameters sqoopParameters - * @param taskExecutionContext taskExecutionContext + * @param sqoopTaskExecutionContext sqoopTaskExecutionContext * @return source script */ - String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext); + String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext); } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ITargetGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ITargetGenerator.java index 9b31273eda..d2138f0c6e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ITargetGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/ITargetGenerator.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; /** * Target Generator Interface @@ -29,8 +29,8 @@ public interface ITargetGenerator { * generate the target script * * @param sqoopParameters sqoopParameters - * @param taskExecutionContext taskExecutionContext + * @param sqoopTaskExecutionContext sqoopTaskExecutionContext * @return target script */ - String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext); + String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext); } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java index 58894799f0..67bd60880a 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/SqoopJobGenerator.java @@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator; import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopJobType; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources.HdfsSourceGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources.HiveSourceGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources.MySQLSourceGenerator; @@ -25,7 +26,6 @@ import org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets.HdfsTarge import org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets.HiveTargetGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets.MySQLTargetGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; /** * Sqoop Job Scripts Generator @@ -62,9 +62,10 @@ public class SqoopJobGenerator { * get the final sqoop scripts * * @param sqoopParameters sqoop params + * @param sqoopTaskExecutionContext * @return sqoop scripts */ - public String generateSqoopJob(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generateSqoopJob(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { String sqoopScripts = ""; @@ -75,8 +76,8 @@ public class SqoopJobGenerator { } sqoopScripts = String.format("%s%s%s", commonGenerator.generate(sqoopParameters), - sourceGenerator.generate(sqoopParameters, taskExecutionContext), - targetGenerator.generate(sqoopParameters, taskExecutionContext)); + sourceGenerator.generate(sqoopParameters, sqoopTaskExecutionContext), + targetGenerator.generate(sqoopParameters, sqoopTaskExecutionContext)); } else if (SqoopJobType.CUSTOM.getDescp().equals(sqoopParameters.getJobType())) { sqoopScripts = sqoopParameters.getCustomShell().replaceAll("\\r\\n", "\n"); } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HdfsSourceGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HdfsSourceGenerator.java index ec8f23e212..652aff530e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HdfsSourceGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HdfsSourceGenerator.java @@ -17,13 +17,13 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HDFS_EXPORT_DIR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceHdfsParameter; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -38,7 +38,7 @@ public class HdfsSourceGenerator implements ISourceGenerator { private static final Logger logger = LoggerFactory.getLogger(HdfsSourceGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder hdfsSourceSb = new StringBuilder(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HiveSourceGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HiveSourceGenerator.java index 4d334f0d3d..de1c9597b2 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HiveSourceGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/HiveSourceGenerator.java @@ -17,16 +17,16 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HCATALOG_DATABASE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HCATALOG_PARTITION_KEYS; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HCATALOG_PARTITION_VALUES; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HCATALOG_TABLE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceHiveParameter; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -41,7 +41,7 @@ public class HiveSourceGenerator implements ISourceGenerator { private static final Logger logger = LoggerFactory.getLogger(HiveSourceGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder hiveSourceSb = new StringBuilder(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/MySQLSourceGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/MySQLSourceGenerator.java index 56a8f8055e..8e8ab4cdc9 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/MySQLSourceGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/sources/MySQLSourceGenerator.java @@ -18,6 +18,10 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.sources; import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.COMMA; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EQUAL_SIGN; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; @@ -29,20 +33,16 @@ import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WHERE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.QUERY_WITHOUT_CONDITION; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.COMMA; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DOUBLE_QUOTES; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.EQUAL_SIGN; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopQueryType; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ISourceGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceMysqlParameter; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -59,7 +59,7 @@ public class MySQLSourceGenerator implements ISourceGenerator { private static final Logger logger = LoggerFactory.getLogger(MySQLSourceGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder mysqlSourceSb = new StringBuilder(); @@ -68,8 +68,8 @@ public class MySQLSourceGenerator implements ISourceGenerator { if (null != sourceMysqlParameter) { BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( - DbType.of(taskExecutionContext.getSqoopTaskExecutionContext().getSourcetype()), - taskExecutionContext.getSqoopTaskExecutionContext().getSourceConnectionParams()); + sqoopTaskExecutionContext.getSourcetype(), + sqoopTaskExecutionContext.getSourceConnectionParams()); if (null != baseDataSource) { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HdfsTargetGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HdfsTargetGenerator.java index 84adf92233..4a619ca1f1 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HdfsTargetGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HdfsTargetGenerator.java @@ -17,19 +17,19 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COMPRESSION_CODEC; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DELETE_TARGET_DIR; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.FIELDS_TERMINATED_BY; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.FIELD_NULL_PLACEHOLDER; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.LINES_TERMINATED_BY; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TARGET_DIR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SINGLE_QUOTES; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetHdfsParameter; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -44,7 +44,7 @@ public class HdfsTargetGenerator implements ITargetGenerator { private static final Logger logger = LoggerFactory.getLogger(HdfsTargetGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder hdfsTargetSb = new StringBuilder(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HiveTargetGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HiveTargetGenerator.java index 5e768f3850..0fba0fed40 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HiveTargetGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/HiveTargetGenerator.java @@ -17,6 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.CREATE_HIVE_TABLE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DELETE_TARGET_DIR; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HIVE_DATABASE; @@ -28,12 +29,11 @@ import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HIVE_ import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HIVE_PARTITION_VALUE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.HIVE_TABLE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TARGET_DIR; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetHiveParameter; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -48,7 +48,7 @@ public class HiveTargetGenerator implements ITargetGenerator { private static final Logger logger = LoggerFactory.getLogger(HiveTargetGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder hiveTargetSb = new StringBuilder(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/MySQLTargetGenerator.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/MySQLTargetGenerator.java index 9771807b61..e8f7e85a5f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/MySQLTargetGenerator.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/generator/targets/MySQLTargetGenerator.java @@ -18,6 +18,9 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.generator.targets; import static org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils.decodePassword; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.DOUBLE_QUOTES; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_QUOTES; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SPACE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.COLUMNS; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_CONNECT; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.DB_PWD; @@ -27,17 +30,14 @@ import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.LINES import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.TABLE; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_KEY; import static org.apache.dolphinscheduler.plugin.task.sqoop.SqoopConstants.UPDATE_MODE; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.DOUBLE_QUOTES; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SINGLE_QUOTES; -import static org.apache.dolphinscheduler.spi.task.TaskConstants.SPACE; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.sqoop.generator.ITargetGenerator; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetMysqlParameter; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; @@ -52,7 +52,7 @@ public class MySQLTargetGenerator implements ITargetGenerator { private static final Logger logger = LoggerFactory.getLogger(MySQLTargetGenerator.class); @Override - public String generate(SqoopParameters sqoopParameters, TaskRequest taskExecutionContext) { + public String generate(SqoopParameters sqoopParameters, SqoopTaskExecutionContext sqoopTaskExecutionContext) { StringBuilder mysqlTargetSb = new StringBuilder(); @@ -64,8 +64,8 @@ public class MySQLTargetGenerator implements ITargetGenerator { // get datasource BaseConnectionParam baseDataSource = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( - DbType.of(taskExecutionContext.getSqoopTaskExecutionContext().getTargetType()), - taskExecutionContext.getSqoopTaskExecutionContext().getTargetConnectionParams()); + sqoopTaskExecutionContext.getTargetType(), + sqoopTaskExecutionContext.getTargetConnectionParams()); if (null != baseDataSource) { diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/SqoopParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/SqoopParameters.java index d63734ff81..3a7f31fd2e 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/SqoopParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/SqoopParameters.java @@ -17,14 +17,20 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.parameter; +import org.apache.dolphinscheduler.plugin.task.api.enums.ResourceType; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.DataSourceParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopJobType; -import org.apache.dolphinscheduler.spi.task.AbstractParameters; -import org.apache.dolphinscheduler.spi.task.Property; -import org.apache.dolphinscheduler.spi.task.ResourceInfo; +import org.apache.dolphinscheduler.plugin.task.sqoop.SqoopTaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceMysqlParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetMysqlParameter; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; -import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * sqoop parameters @@ -198,7 +204,41 @@ public class SqoopParameters extends AbstractParameters { } @Override - public List getResourceFilesList() { - return new ArrayList<>(); + public ResourceParametersHelper getResources() { + ResourceParametersHelper resources = super.getResources(); + if (SqoopJobType.TEMPLATE.getDescp().equals(this.getJobType())) { + SourceMysqlParameter sourceMysqlParameter = JSONUtils.parseObject(this.getSourceParams(), SourceMysqlParameter.class); + TargetMysqlParameter targetMysqlParameter = JSONUtils.parseObject(this.getTargetParams(), TargetMysqlParameter.class); + resources.put(ResourceType.DATASOURCE, sourceMysqlParameter.getSrcDatasource()); + resources.put(ResourceType.DATASOURCE, targetMysqlParameter.getTargetDatasource()); + } + return resources; + } + + public SqoopTaskExecutionContext generateExtendedContext(ResourceParametersHelper parametersHelper) { + + SqoopTaskExecutionContext sqoopTaskExecutionContext = new SqoopTaskExecutionContext(); + + if (SqoopJobType.TEMPLATE.getDescp().equals(this.getJobType())) { + SourceMysqlParameter sourceMysqlParameter = JSONUtils.parseObject(this.getSourceParams(), SourceMysqlParameter.class); + TargetMysqlParameter targetMysqlParameter = JSONUtils.parseObject(this.getTargetParams(), TargetMysqlParameter.class); + + DataSourceParameters dataSource = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, sourceMysqlParameter.getSrcDatasource()); + DataSourceParameters dataTarget = (DataSourceParameters) parametersHelper.getResourceParameters(ResourceType.DATASOURCE, targetMysqlParameter.getTargetDatasource()); + + if (Objects.nonNull(dataSource)) { + sqoopTaskExecutionContext.setDataSourceId(sourceMysqlParameter.getSrcDatasource()); + sqoopTaskExecutionContext.setSourcetype(dataSource.getType()); + sqoopTaskExecutionContext.setSourceConnectionParams(dataSource.getConnectionParams()); + } + + if (Objects.nonNull(dataTarget)) { + sqoopTaskExecutionContext.setDataTargetId(targetMysqlParameter.getTargetDatasource()); + sqoopTaskExecutionContext.setTargetType(dataTarget.getType()); + sqoopTaskExecutionContext.setTargetConnectionParams(dataTarget.getConnectionParams()); + } + } + + return sqoopTaskExecutionContext; } } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/sources/SourceMysqlParameter.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/sources/SourceMysqlParameter.java index 07c5c27591..749d712b85 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/sources/SourceMysqlParameter.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/main/java/org/apache/dolphinscheduler/plugin/task/sqoop/parameter/sources/SourceMysqlParameter.java @@ -17,7 +17,7 @@ package org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources; -import org.apache.dolphinscheduler.spi.task.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; import java.util.List; diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/EntityTestUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/EntityTestUtils.java similarity index 95% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/EntityTestUtils.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/EntityTestUtils.java index 8e9b451141..37388dbf1d 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/EntityTestUtils.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/EntityTestUtils.java @@ -14,12 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dolphinscheduler.common.task; + +package org.apache.dolphinscheduler.plugin.task.sqoop; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * entity test utils diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqoopParameterEntityTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopParameterEntityTest.java similarity index 68% rename from dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqoopParameterEntityTest.java rename to dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopParameterEntityTest.java index 5f35e89ddd..627b82ce9f 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/task/SqoopParameterEntityTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-sqoop/src/test/java/org/apache/dolphinscheduler/plugin/task/sqoop/SqoopParameterEntityTest.java @@ -14,27 +14,30 @@ * 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.task.sqoop.SqoopParameters; -import org.apache.dolphinscheduler.common.task.sqoop.sources.SourceHdfsParameter; -import org.apache.dolphinscheduler.common.task.sqoop.sources.SourceHiveParameter; -import org.apache.dolphinscheduler.common.task.sqoop.sources.SourceMysqlParameter; -import org.apache.dolphinscheduler.common.task.sqoop.targets.TargetHdfsParameter; -import org.apache.dolphinscheduler.common.task.sqoop.targets.TargetHiveParameter; -import org.apache.dolphinscheduler.common.task.sqoop.targets.TargetMysqlParameter; -import org.junit.Assert; -import org.junit.Test; +package org.apache.dolphinscheduler.plugin.task.sqoop; + +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.SqoopParameters; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceHdfsParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceHiveParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.sources.SourceMysqlParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetHdfsParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetHiveParameter; +import org.apache.dolphinscheduler.plugin.task.sqoop.parameter.targets.TargetMysqlParameter; + import java.util.ArrayList; import java.util.List; +import org.junit.Assert; +import org.junit.Test; + /** * sqoop parameter entity test */ public class SqoopParameterEntityTest { @Test - public void testEntity(){ + public void testEntity() { try { List classList = new ArrayList<>(); classList.add(SourceMysqlParameter.class); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/pom.xml new file mode 100644 index 0000000000..69da8953dc --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/pom.xml @@ -0,0 +1,44 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-subprocess + jar + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + org.apache.dolphinscheduler + dolphinscheduler-task-api + ${project.version} + + + + \ No newline at end of file diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannel.java new file mode 100644 index 0000000000..4c034cea7e --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannel.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.subprocess; + +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SubProcessParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; + +public class SubProcessTaskChannel implements TaskChannel { + + @Override + public void cancelApplication(boolean status) { + + } + + @Override + public AbstractTask createTask(TaskExecutionContext taskRequest) { + return null; + } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(parametersNode.getTaskParams(), SubProcessParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannelFactory.java new file mode 100644 index 0000000000..18f356b944 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-subprocess/src/main/java/org/apache/dolphinscheduler/plugin/task/subprocess/SubProcessTaskChannelFactory.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.subprocess; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; + +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; + +import java.util.List; + +import com.google.auto.service.AutoService; + +@AutoService(TaskChannelFactory.class) +public class SubProcessTaskChannelFactory implements TaskChannelFactory { + @Override + public TaskChannel create() { + return new SubProcessTaskChannel(); + } + + @Override + public String getName() { + return TASK_TYPE_SUB_PROCESS; + } + + @Override + public List getParams() { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/pom.xml b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/pom.xml new file mode 100644 index 0000000000..20e696289d --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/pom.xml @@ -0,0 +1,44 @@ + + + + + dolphinscheduler-task-plugin + org.apache.dolphinscheduler + 2.0.4-SNAPSHOT + + 4.0.0 + + dolphinscheduler-task-switch + jar + + + + org.apache.dolphinscheduler + dolphinscheduler-spi + provided + + + org.apache.dolphinscheduler + dolphinscheduler-task-api + ${project.version} + + + + \ No newline at end of file diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannel.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannel.java new file mode 100644 index 0000000000..fed18b4571 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannel.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.switchtask; + +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.resource.ResourceParametersHelper; +import org.apache.dolphinscheduler.spi.utils.JSONUtils; +import org.apache.dolphinscheduler.spi.utils.StringUtils; + +public class SubProcessTaskChannel implements TaskChannel { + + @Override + public void cancelApplication(boolean status) { + + } + + @Override + public AbstractTask createTask(TaskExecutionContext taskRequest) { + return null; + } + + @Override + public AbstractParameters parseParameters(ParametersNode parametersNode) { + return JSONUtils.parseObject(StringUtils.isEmpty(parametersNode.getSwitchResult()) + ? parametersNode.getTaskParams() : parametersNode.getSwitchResult(), SwitchParameters.class); + } + + @Override + public ResourceParametersHelper getResources(String parameters) { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannelFactory.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannelFactory.java new file mode 100644 index 0000000000..68807ba752 --- /dev/null +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-switch/src/main/java/org/apache/dolphinscheduler/plugin/task/switchtask/SubProcessTaskChannelFactory.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.plugin.task.switchtask; + +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SWITCH; + +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; + +import java.util.List; + +import com.google.auto.service.AutoService; + +@AutoService(TaskChannelFactory.class) +public class SubProcessTaskChannelFactory implements TaskChannelFactory { + @Override + public TaskChannel create() { + return new SubProcessTaskChannel(); + } + + @Override + public String getName() { + return TASK_TYPE_SWITCH; + } + + @Override + public List getParams() { + return null; + } +} diff --git a/dolphinscheduler-task-plugin/pom.xml b/dolphinscheduler-task-plugin/pom.xml index 6c99247b58..2144322499 100644 --- a/dolphinscheduler-task-plugin/pom.xml +++ b/dolphinscheduler-task-plugin/pom.xml @@ -43,6 +43,12 @@ dolphinscheduler-task-pigeon dolphinscheduler-task-dataquality dolphinscheduler-task-seatunnel + dolphinscheduler-task-conditions + dolphinscheduler-task-dependent + dolphinscheduler-task-subprocess + dolphinscheduler-task-switch + dolphinscheduler-task-all dolphinscheduler-task-emr + dolphinscheduler-task-blocking diff --git a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java index 2978a62be1..06b8aab12c 100644 --- a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java +++ b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/dao/UpgradeDao.java @@ -17,14 +17,16 @@ package org.apache.dolphinscheduler.tools.datasource.dao; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_CONDITIONS; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_DEPENDENT; +import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_SUB_PROCESS; + import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ConditionType; 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.enums.TimeoutFlag; -import org.apache.dolphinscheduler.common.process.ResourceInfo; -import org.apache.dolphinscheduler.common.task.TaskTimeoutParameter; +import org.apache.dolphinscheduler.plugin.task.api.parameters.TaskTimeoutParameter; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.common.utils.ConnectionUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; @@ -39,6 +41,7 @@ import org.apache.dolphinscheduler.dao.upgrade.ProjectDao; import org.apache.dolphinscheduler.dao.upgrade.ScheduleDao; import org.apache.dolphinscheduler.dao.upgrade.SchemaUtils; import org.apache.dolphinscheduler.dao.upgrade.WorkerGroupDao; +import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.commons.collections.CollectionUtils; @@ -358,8 +361,7 @@ public abstract class UpgradeDao { ConnectionUtils.releaseResource(pstmt, conn); } } - - + /** * update version * @@ -471,7 +473,7 @@ public abstract class UpgradeDao { } else { taskDefinitionLog.setResourceIds(StringUtils.EMPTY); } - if (TaskType.SUB_PROCESS.getDesc().equals(taskType)) { + if (TASK_TYPE_SUB_PROCESS.equals(taskType)) { JsonNode jsonNodeDefinitionId = param.get("processDefinitionId"); if (jsonNodeDefinitionId != null) { param.put("processDefinitionCode", processDefinitionMap.get(jsonNodeDefinitionId.asInt()).getCode()); @@ -493,8 +495,8 @@ public abstract class UpgradeDao { taskDefinitionLog.setDescription(desc); taskDefinitionLog.setFlag(Constants.FLOWNODE_RUN_FLAG_NORMAL.equals(task.get("runFlag").asText()) ? Flag.YES : Flag.NO); taskDefinitionLog.setTaskType(taskType); - taskDefinitionLog.setFailRetryInterval(TaskType.SUB_PROCESS.getDesc().equals(taskType) ? 1 : task.get("retryInterval").asInt()); - taskDefinitionLog.setFailRetryTimes(TaskType.SUB_PROCESS.getDesc().equals(taskType) ? 0 : task.get("maxRetryTimes").asInt()); + taskDefinitionLog.setFailRetryInterval(TASK_TYPE_SUB_PROCESS.equals(taskType) ? 1 : task.get("retryInterval").asInt()); + taskDefinitionLog.setFailRetryTimes(TASK_TYPE_SUB_PROCESS.equals(taskType) ? 0 : task.get("maxRetryTimes").asInt()); taskDefinitionLog.setTaskPriority(JSONUtils.parseObject(JSONUtils.toJsonString(task.get("taskInstancePriority")), Priority.class)); String name = task.get("name").asText(); taskDefinitionLog.setName(name); @@ -532,7 +534,7 @@ public abstract class UpgradeDao { public void convertConditions(List taskDefinitionLogList, Map taskNameCodeMap) throws Exception { for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogList) { - if (TaskType.CONDITIONS.getDesc().equals(taskDefinitionLog.getTaskType())) { + if (TASK_TYPE_CONDITIONS.equals(taskDefinitionLog.getTaskType())) { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode taskParams = JSONUtils.parseObject(taskDefinitionLog.getTaskParams()); // reset conditionResult @@ -592,7 +594,7 @@ public abstract class UpgradeDao { Map projectIdCodeMap, Map>> processTaskMap) { for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) { - if (TaskType.DEPENDENT.getDesc().equals(taskDefinitionLog.getTaskType())) { + if (TASK_TYPE_DEPENDENT.equals(taskDefinitionLog.getTaskType())) { ObjectNode taskParams = JSONUtils.parseObject(taskDefinitionLog.getTaskParams()); ObjectNode dependence = (ObjectNode) taskParams.get("dependence"); ArrayNode dependTaskList = JSONUtils.parseArray(JSONUtils.toJsonString(dependence.get("dependTaskList"))); diff --git a/dolphinscheduler-worker/pom.xml b/dolphinscheduler-worker/pom.xml index add49925f5..32037a4969 100644 --- a/dolphinscheduler-worker/pom.xml +++ b/dolphinscheduler-worker/pom.xml @@ -51,64 +51,10 @@ org.apache.dolphinscheduler dolphinscheduler-meter
- - org.apache.dolphinscheduler - dolphinscheduler-task-datax - - - org.apache.dolphinscheduler - dolphinscheduler-task-flink - - - org.apache.dolphinscheduler - dolphinscheduler-task-http - - - org.apache.dolphinscheduler - dolphinscheduler-task-mr - - - org.apache.dolphinscheduler - dolphinscheduler-task-pigeon - - - org.apache.dolphinscheduler - dolphinscheduler-task-procedure - - - org.apache.dolphinscheduler - dolphinscheduler-task-python - - - org.apache.dolphinscheduler - dolphinscheduler-task-shell - - - org.apache.dolphinscheduler - dolphinscheduler-task-spark - - - org.apache.dolphinscheduler - dolphinscheduler-task-sql - - - org.apache.dolphinscheduler - dolphinscheduler-task-sqoop - - - - org.apache.dolphinscheduler - dolphinscheduler-task-seatunnel - - - - org.apache.dolphinscheduler - dolphinscheduler-task-emr - org.apache.dolphinscheduler - dolphinscheduler-data-quality + dolphinscheduler-task-all diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java index 592a418bdf..d5ce17a340 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java @@ -21,12 +21,13 @@ import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.IStoppable; import org.apache.dolphinscheduler.common.enums.NodeType; import org.apache.dolphinscheduler.common.thread.Stopper; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager; import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.config.NettyServerConfig; import org.apache.dolphinscheduler.server.log.LoggerRequestProcessor; import org.apache.dolphinscheduler.server.worker.config.WorkerConfig; -import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; import org.apache.dolphinscheduler.server.worker.processor.DBTaskAckProcessor; import org.apache.dolphinscheduler.server.worker.processor.DBTaskResponseProcessor; import org.apache.dolphinscheduler.server.worker.processor.HostUpdateProcessor; @@ -37,8 +38,7 @@ import org.apache.dolphinscheduler.server.worker.runner.RetryReportTaskStatusThr import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread; import org.apache.dolphinscheduler.service.alert.AlertClientService; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections4.CollectionUtils; @@ -233,14 +233,14 @@ public class WorkerServer implements IStoppable { * kill all tasks which are running */ public void killAllRunningTasks() { - Collection taskRequests = TaskExecutionContextCacheManager.getAllTaskRequestList(); + Collection taskRequests = TaskExecutionContextCacheManager.getAllTaskRequestList(); logger.info("ready to kill all cache job, job size:{}", taskRequests.size()); if (CollectionUtils.isEmpty(taskRequests)) { return; } - for (TaskRequest taskRequest : taskRequests) { + for (TaskExecutionContext taskRequest : taskRequests) { // kill task when it's not finished yet org.apache.dolphinscheduler.plugin.task.api.ProcessUtils.kill(taskRequest); } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/cache/ResponseCache.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/cache/ResponseCache.java index ea88db9d1d..aaf557be51 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/cache/ResponseCache.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/cache/ResponseCache.java @@ -32,22 +32,21 @@ public class ResponseCache { private ResponseCache(){} - public static ResponseCache get(){ + public static ResponseCache get() { return instance; } private Map ackCache = new ConcurrentHashMap<>(); private Map responseCache = new ConcurrentHashMap<>(); - /** * cache response * @param taskInstanceId taskInstanceId * @param command command * @param event event ACK/RESULT */ - public void cache(Integer taskInstanceId, Command command, Event event){ - switch (event){ + public void cache(Integer taskInstanceId, Command command, Event event) { + switch (event) { case ACK: ackCache.put(taskInstanceId,command); break; @@ -59,12 +58,11 @@ public class ResponseCache { } } - /** * remove ack cache * @param taskInstanceId taskInstanceId */ - public void removeAckCache(Integer taskInstanceId){ + public void removeAckCache(Integer taskInstanceId) { ackCache.remove(taskInstanceId); } @@ -72,7 +70,7 @@ public class ResponseCache { * remove reponse cache * @param taskInstanceId taskInstanceId */ - public void removeResponseCache(Integer taskInstanceId){ + public void removeResponseCache(Integer taskInstanceId) { responseCache.remove(taskInstanceId); } @@ -80,7 +78,7 @@ public class ResponseCache { * getAckCache * @return getAckCache */ - public Map getAckCache(){ + public Map getAckCache() { return ackCache; } @@ -88,7 +86,7 @@ public class ResponseCache { * getResponseCache * @return getResponseCache */ - public Map getResponseCache(){ + public Map getResponseCache() { return responseCache; } } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskAckProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskAckProcessor.java index 6ac8601484..7a80f84401 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskAckProcessor.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskAckProcessor.java @@ -17,18 +17,22 @@ package org.apache.dolphinscheduler.server.worker.processor; -import io.netty.channel.Channel; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.remote.command.*; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.remote.command.Command; +import org.apache.dolphinscheduler.remote.command.CommandType; +import org.apache.dolphinscheduler.remote.command.DBTaskAckCommand; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.server.worker.cache.ResponseCache; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.google.common.base.Preconditions; +import io.netty.channel.Channel; + /** * db task ack processor */ @@ -45,16 +49,15 @@ public class DBTaskAckProcessor implements NettyRequestProcessor { DBTaskAckCommand taskAckCommand = JSONUtils.parseObject( command.getBody(), DBTaskAckCommand.class); - if (taskAckCommand == null){ + if (taskAckCommand == null) { logger.error("dBTask ACK request command is null"); return; } logger.info("dBTask ACK request command : {}", taskAckCommand); - if (taskAckCommand.getStatus() == ExecutionStatus.SUCCESS.getCode()){ + if (taskAckCommand.getStatus() == ExecutionStatus.SUCCESS.getCode()) { ResponseCache.get().removeAckCache(taskAckCommand.getTaskInstanceId()); } } - } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskResponseProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskResponseProcessor.java index b70f8567fb..bedc5a68d6 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskResponseProcessor.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/DBTaskResponseProcessor.java @@ -17,8 +17,8 @@ package org.apache.dolphinscheduler.server.worker.processor; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.DBTaskResponseCommand; @@ -55,7 +55,6 @@ public class DBTaskResponseProcessor implements NettyRequestProcessor { } logger.info("dBTask Response command : {}", taskResponseCommand); - if (taskResponseCommand.getStatus() == ExecutionStatus.SUCCESS.getCode()) { ResponseCache.get().removeResponseCache(taskResponseCommand.getTaskInstanceId()); TaskCallbackService.remove(taskResponseCommand.getTaskInstanceId()); @@ -63,5 +62,4 @@ public class DBTaskResponseProcessor implements NettyRequestProcessor { } } - } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/HostUpdateProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/HostUpdateProcessor.java index 09e786be63..d1ceca6c9e 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/HostUpdateProcessor.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/HostUpdateProcessor.java @@ -17,19 +17,22 @@ package org.apache.dolphinscheduler.server.worker.processor; -import com.google.common.base.Preconditions; -import io.netty.channel.Channel; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.HostUpdateCommand; import org.apache.dolphinscheduler.remote.processor.NettyRemoteChannel; import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Preconditions; + +import io.netty.channel.Channel; + /** * update process host * this used when master failover @@ -49,7 +52,7 @@ public class HostUpdateProcessor implements NettyRequestProcessor { public void process(Channel channel, Command command) { Preconditions.checkArgument(CommandType.PROCESS_HOST_UPDATE_REQUEST == command.getType(), String.format("invalid command type : %s", command.getType())); HostUpdateCommand updateCommand = JSONUtils.parseObject(command.getBody(), HostUpdateCommand.class); - if (updateCommand == null){ + if (updateCommand == null) { logger.error("host update command is null"); return; } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessor.java index 185ac9c7e9..88021e122d 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessor.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessor.java @@ -19,14 +19,15 @@ package org.apache.dolphinscheduler.server.worker.processor; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.Event; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.utils.CommonUtils; 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.NetUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; @@ -36,13 +37,10 @@ import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor; import org.apache.dolphinscheduler.server.utils.LogUtils; import org.apache.dolphinscheduler.server.worker.cache.ResponseCache; import org.apache.dolphinscheduler.server.worker.config.WorkerConfig; -import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; import org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread; import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread; import org.apache.dolphinscheduler.service.alert.AlertClientService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import java.util.Date; @@ -96,8 +94,9 @@ public class TaskExecuteProcessor implements NettyRequestProcessor { * @param taskExecutionContext task */ private void setTaskCache(TaskExecutionContext taskExecutionContext) { - TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); - TaskExecutionContextCacheManager.cacheTaskExecutionContext(taskRequest); + TaskExecutionContext preTaskCache = new TaskExecutionContext(); + preTaskCache.setTaskInstanceId(taskExecutionContext.getTaskInstanceId()); + TaskExecutionContextCacheManager.cacheTaskExecutionContext(preTaskCache); } @Override @@ -187,11 +186,9 @@ public class TaskExecuteProcessor implements NettyRequestProcessor { ackCommand.setLogPath(LogUtils.getTaskLogPath(taskExecutionContext)); ackCommand.setHost(taskExecutionContext.getHost()); ackCommand.setStartTime(taskExecutionContext.getStartTime()); - if (TaskType.SQL.getDesc().equalsIgnoreCase(taskExecutionContext.getTaskType()) || TaskType.PROCEDURE.getDesc().equalsIgnoreCase(taskExecutionContext.getTaskType())) { - ackCommand.setExecutePath(null); - } else { - ackCommand.setExecutePath(taskExecutionContext.getExecutePath()); - } + + ackCommand.setExecutePath(taskExecutionContext.getExecutePath()); + taskExecutionContext.setLogPath(ackCommand.getLogPath()); ackCommand.setProcessInstanceId(taskExecutionContext.getProcessInstanceId()); diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java index 4668c7e9c8..3ec0e9ab30 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskKillProcessor.java @@ -17,10 +17,12 @@ package org.apache.dolphinscheduler.server.worker.processor; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.LoggerUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand; @@ -32,9 +34,6 @@ import org.apache.dolphinscheduler.remote.utils.Pair; import org.apache.dolphinscheduler.server.utils.ProcessUtils; import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread; import org.apache.dolphinscheduler.service.log.LogClientService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import org.apache.commons.lang.StringUtils; @@ -80,7 +79,7 @@ public class TaskKillProcessor implements NettyRequestProcessor { public void process(Channel channel, Command command) { Preconditions.checkArgument(CommandType.TASK_KILL_REQUEST == command.getType(), String.format("invalid command type : %s", command.getType())); TaskKillRequestCommand killCommand = JSONUtils.parseObject(command.getBody(), TaskKillRequestCommand.class); - if (killCommand == null){ + if (killCommand == null) { logger.error("task kill request command is null"); return; } @@ -107,8 +106,7 @@ public class TaskKillProcessor implements NettyRequestProcessor { boolean processFlag = true; List appIds = Collections.emptyList(); int taskInstanceId = killCommand.getTaskInstanceId(); - TaskRequest taskRequest = TaskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId); - TaskExecutionContext taskExecutionContext = JSONUtils.parseObject(JSONUtils.toJsonString(taskRequest), TaskExecutionContext.class); + TaskExecutionContext taskExecutionContext = TaskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId); try { Integer processId = taskExecutionContext.getProcessId(); @@ -151,11 +149,10 @@ public class TaskKillProcessor implements NettyRequestProcessor { TaskKillResponseCommand taskKillResponseCommand = new TaskKillResponseCommand(); taskKillResponseCommand.setStatus(result.getLeft() ? ExecutionStatus.SUCCESS.getCode() : ExecutionStatus.FAILURE.getCode()); taskKillResponseCommand.setAppIds(result.getRight()); - TaskRequest taskRequest = TaskExecutionContextCacheManager.getByTaskInstanceId(killCommand.getTaskInstanceId()); - if (taskRequest == null) { + TaskExecutionContext taskExecutionContext = TaskExecutionContextCacheManager.getByTaskInstanceId(killCommand.getTaskInstanceId()); + if (taskExecutionContext == null) { return taskKillResponseCommand; } - TaskExecutionContext taskExecutionContext = JSONUtils.parseObject(JSONUtils.toJsonString(taskRequest), TaskExecutionContext.class); if (taskExecutionContext != null) { taskKillResponseCommand.setTaskInstanceId(taskExecutionContext.getTaskInstanceId()); taskKillResponseCommand.setHost(taskExecutionContext.getHost()); diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/RetryReportTaskStatusThread.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/RetryReportTaskStatusThread.java index d9beaaeb0f..42013730f0 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/RetryReportTaskStatusThread.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/RetryReportTaskStatusThread.java @@ -18,18 +18,18 @@ package org.apache.dolphinscheduler.server.worker.runner; import org.apache.dolphinscheduler.common.thread.Stopper; - import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.server.worker.cache.ResponseCache; import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; + +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Map; - /** * Retry Report Task Status Thread */ @@ -46,7 +46,7 @@ public class RetryReportTaskStatusThread implements Runnable { @Autowired private TaskCallbackService taskCallbackService; - public void start(){ + public void start() { Thread thread = new Thread(this,"RetryReportTaskStatusThread"); thread.setDaemon(true); thread.start(); @@ -59,30 +59,30 @@ public class RetryReportTaskStatusThread implements Runnable { public void run() { ResponseCache instance = ResponseCache.get(); - while (Stopper.isRunning()){ + while (Stopper.isRunning()) { // sleep 5 minutes ThreadUtils.sleep(RETRY_REPORT_TASK_STATUS_INTERVAL); try { - if (!instance.getAckCache().isEmpty()){ + if (!instance.getAckCache().isEmpty()) { Map ackCache = instance.getAckCache(); - for (Map.Entry entry : ackCache.entrySet()){ + for (Map.Entry entry : ackCache.entrySet()) { Integer taskInstanceId = entry.getKey(); Command ackCommand = entry.getValue(); taskCallbackService.sendAck(taskInstanceId,ackCommand); } } - if (!instance.getResponseCache().isEmpty()){ + if (!instance.getResponseCache().isEmpty()) { Map responseCache = instance.getResponseCache(); - for (Map.Entry entry : responseCache.entrySet()){ + for (Map.Entry entry : responseCache.entrySet()) { Integer taskInstanceId = entry.getKey(); Command responseCommand = entry.getValue(); taskCallbackService.sendResult(taskInstanceId,responseCommand); } } - }catch (Exception e){ + } catch (Exception e) { logger.warn("retry report task status error", e); } } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java index ff3c4212d0..8d7046d29f 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java @@ -19,10 +19,7 @@ package org.apache.dolphinscheduler.server.worker.runner; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.Event; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.WarningType; -import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; @@ -30,20 +27,21 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.LoggerUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.common.utils.RetryerUtils; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskChannel; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.TaskAlertInfo; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand; import org.apache.dolphinscheduler.server.utils.ProcessUtils; import org.apache.dolphinscheduler.server.worker.cache.ResponseCache; -import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; import org.apache.dolphinscheduler.service.alert.AlertClientService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.AbstractTask; -import org.apache.dolphinscheduler.spi.task.TaskAlertInfo; -import org.apache.dolphinscheduler.spi.task.TaskChannel; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; +import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; @@ -168,18 +166,17 @@ public class TaskExecuteThread implements Runnable, Delayed { if (null == taskChannel) { throw new RuntimeException(String.format("%s Task Plugin Not Found,Please Check Config File.", taskExecutionContext.getTaskType())); } - TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); String taskLogName = LoggerUtils.buildTaskId(taskExecutionContext.getFirstSubmitTime(), taskExecutionContext.getProcessDefineCode(), taskExecutionContext.getProcessDefineVersion(), taskExecutionContext.getProcessInstanceId(), taskExecutionContext.getTaskInstanceId()); - taskRequest.setTaskLogName(taskLogName); + taskExecutionContext.setTaskLogName(taskLogName); // set the name of the current thread Thread.currentThread().setName(taskLogName); - task = taskChannel.createTask(taskRequest); + task = taskChannel.createTask(taskExecutionContext); // task init this.task.init(); @@ -345,11 +342,9 @@ public class TaskExecuteThread implements Runnable, Delayed { ackCommand.setStartTime(taskExecutionContext.getStartTime()); ackCommand.setLogPath(taskExecutionContext.getLogPath()); ackCommand.setHost(taskExecutionContext.getHost()); - if (TaskType.SQL.getDesc().equalsIgnoreCase(taskExecutionContext.getTaskType()) || TaskType.PROCEDURE.getDesc().equalsIgnoreCase(taskExecutionContext.getTaskType())) { - ackCommand.setExecutePath(null); - } else { - ackCommand.setExecutePath(taskExecutionContext.getExecutePath()); - } + + ackCommand.setExecutePath(taskExecutionContext.getExecutePath()); + return ackCommand; } diff --git a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerManagerThread.java b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerManagerThread.java index 3484adbc5d..31919726ad 100644 --- a/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerManagerThread.java +++ b/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/WorkerManagerThread.java @@ -18,17 +18,15 @@ package org.apache.dolphinscheduler.server.worker.runner; import org.apache.dolphinscheduler.common.enums.Event; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.common.thread.ThreadUtils; -import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.TaskExecuteResponseCommand; import org.apache.dolphinscheduler.server.worker.cache.ResponseCache; import org.apache.dolphinscheduler.server.worker.config.WorkerConfig; import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; -import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; -import org.apache.dolphinscheduler.spi.task.request.TaskRequest; import java.util.concurrent.DelayQueue; import java.util.concurrent.ExecutorService; @@ -100,11 +98,10 @@ public class WorkerManagerThread implements Runnable { * kill task before execute , like delay task */ private void sendTaskKillResponse(Integer taskInstanceId) { - TaskRequest taskRequest = TaskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId); - if (taskRequest == null) { + TaskExecutionContext taskExecutionContext = TaskExecutionContextCacheManager.getByTaskInstanceId(taskInstanceId); + if (taskExecutionContext == null) { return; } - TaskExecutionContext taskExecutionContext = JSONUtils.parseObject(JSONUtils.toJsonString(taskRequest), TaskExecutionContext.class); TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand(taskExecutionContext.getTaskInstanceId(), taskExecutionContext.getProcessInstanceId()); responseCommand.setStatus(ExecutionStatus.KILL.getCode()); ResponseCache.get().cache(taskExecutionContext.getTaskInstanceId(), responseCommand.convert2Command(), Event.RESULT); diff --git a/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessorTest.java b/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessorTest.java index b07ffa6fcb..fba6c0e030 100644 --- a/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessorTest.java +++ b/dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessorTest.java @@ -17,12 +17,11 @@ package org.apache.dolphinscheduler.server.worker.processor; -import org.apache.dolphinscheduler.common.enums.ExecutionStatus; -import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.common.utils.LoggerUtils; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.TaskExecuteAckCommand; @@ -34,7 +33,6 @@ import org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread; import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread; import org.apache.dolphinscheduler.service.alert.AlertClientService; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; -import org.apache.dolphinscheduler.service.queue.entity.TaskExecutionContext; import java.util.Date; import java.util.concurrent.ExecutorService; @@ -163,7 +161,7 @@ public class TaskExecuteProcessorTest { taskExecutionContext.setTaskInstanceId(1); taskExecutionContext.setProcessDefineCode(1L); taskExecutionContext.setProcessDefineVersion(1); - taskExecutionContext.setTaskType(TaskType.SQL.getDesc()); + taskExecutionContext.setTaskType("SQL"); taskExecutionContext.setFirstSubmitTime(new Date()); taskExecutionContext.setDelayTime(0); taskExecutionContext.setLogPath("/tmp/test.log"); diff --git a/pom.xml b/pom.xml index 9fb4674daf..d78fef9456 100644 --- a/pom.xml +++ b/pom.xml @@ -448,69 +448,10 @@ org.apache.dolphinscheduler - dolphinscheduler-task-datax - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-flink - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-http - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-mr - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-pigeon - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-procedure - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-python - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-shell - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-spark - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-sql - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-sqoop - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-seatunnel - ${project.version} - - - org.apache.dolphinscheduler - dolphinscheduler-task-emr + dolphinscheduler-task-all ${project.version} + org.apache.dolphinscheduler dolphinscheduler-ui-next @@ -521,11 +462,6 @@ dolphinscheduler-tools ${project.version} - - org.apache.dolphinscheduler - dolphinscheduler-task-dataquality - ${project.version} - org.apache.curator diff --git a/tools/dependencies/known-dependencies.txt b/tools/dependencies/known-dependencies.txt index 8affc9662e..4b021a3326 100755 --- a/tools/dependencies/known-dependencies.txt +++ b/tools/dependencies/known-dependencies.txt @@ -270,4 +270,6 @@ okhttp-3.14.9.jar okio-1.17.2.jar jmespath-java-1.12.160.jar jackson-dataformat-cbor-2.12.5.jar -ion-java-1.0.2.jar \ No newline at end of file +ion-java-1.0.2.jar +aws-java-sdk-core-1.12.160.jar +aws-java-sdk-emr-1.12.160.jar