You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/20 16:33:53 UTC
[GitHub] [dolphinscheduler] DarkAssassinator opened a new pull request, #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
DarkAssassinator opened a new pull request, #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474
<!--Thanks very much for contributing to Apache DolphinScheduler. Please review https://dolphinscheduler.apache.org/en-us/community/development/pull-request.html before opening a pull request.-->
## Purpose of the pull request
+ This PR close #12468
+ This is a part of #12403
## Brief change log
+ Migrate command-related interface functions to `CommandService`
+ Add `ParamUtils`
## Verify this pull request
This pull request is already covered by existing tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] github-code-scanning[bot] commented on a diff in pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#discussion_r1000987970
##########
dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/utils/ParamUtilsTest.java:
##########
@@ -0,0 +1,22 @@
+package org.apache.dolphinscheduler.service.utils;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.Map;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ParamUtilsTest {
Review Comment:
## Unused classes and interfaces
Unused class: ParamUtilsTest is not referenced within this codebase. If not used as an external API it should be removed.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1998)
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandServiceImpl.java:
##########
@@ -0,0 +1,267 @@
+/*
+ * 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.command;
+
+import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.CommandType;
+import org.apache.dolphinscheduler.common.enums.Flag;
+import org.apache.dolphinscheduler.common.enums.TaskDependType;
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ErrorCommand;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.Schedule;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+import org.apache.dolphinscheduler.dao.mapper.CommandMapper;
+import org.apache.dolphinscheduler.dao.mapper.ErrorCommandMapper;
+import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
+import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
+import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.service.utils.ParamUtils;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Date;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
+import io.micrometer.core.annotation.Counted;
+
+/**
+ * Command Service implementation
+ */
+@Component
+public class CommandServiceImpl implements CommandService {
+
+ @Autowired
+ private ErrorCommandMapper errorCommandMapper;
+
+ @Autowired
+ private CommandMapper commandMapper;
+
+ @Autowired
+ private ScheduleMapper scheduleMapper;
+
+ @Autowired
+ private ProcessDefinitionMapper processDefineMapper;
+
+ @Override
+ public void moveToErrorCommand(Command command, String message) {
+ ErrorCommand errorCommand = new ErrorCommand(command, message);
+ this.errorCommandMapper.insert(errorCommand);
+ this.commandMapper.deleteById(command.getId());
+ }
+
+ @Override
+ @Counted("ds.workflow.create.command.count")
+ public int createCommand(Command command) {
+ int result = 0;
+ if (command == null) {
+ return result;
+ }
+ // add command timezone
+ Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(command.getProcessDefinitionCode());
+ if (schedule != null) {
+ Map<String, String> commandParams =
+ StringUtils.isNotBlank(command.getCommandParam()) ? JSONUtils.toMap(command.getCommandParam())
+ : new HashMap<>();
+ commandParams.put(Constants.SCHEDULE_TIMEZONE, schedule.getTimezoneId());
+ command.setCommandParam(JSONUtils.toJsonString(commandParams));
+ }
+ command.setId(null);
+ result = commandMapper.insert(command);
+ return result;
+ }
+
+ @Override
+ public List<Command> findCommandPage(int pageSize, int pageNumber) {
+ return commandMapper.queryCommandPage(pageSize, pageNumber * pageSize);
+ }
+
+ @Override
+ public List<Command> findCommandPageBySlot(int pageSize, int pageNumber, int masterCount, int thisMasterSlot) {
+ if (masterCount <= 0) {
+ return Lists.newArrayList();
+ }
+ return commandMapper.queryCommandPageBySlot(pageSize, pageNumber * pageSize, masterCount, thisMasterSlot);
+ }
+
+ @Override
+ public boolean verifyIsNeedCreateCommand(Command command) {
+ boolean isNeedCreate = true;
+ EnumMap<CommandType, Integer> cmdTypeMap = new EnumMap<>(CommandType.class);
+ cmdTypeMap.put(CommandType.REPEAT_RUNNING, 1);
+ cmdTypeMap.put(CommandType.RECOVER_SUSPENDED_PROCESS, 1);
+ cmdTypeMap.put(CommandType.START_FAILURE_TASK_PROCESS, 1);
+ CommandType commandType = command.getCommandType();
+
+ if (!cmdTypeMap.containsKey(commandType)) {
+ return true;
+ }
+
+ ObjectNode cmdParamObj = JSONUtils.parseObject(command.getCommandParam());
+ int processInstanceId = cmdParamObj.path(CMD_PARAM_RECOVER_PROCESS_ID_STRING).asInt();
+
+ List<Command> commands = commandMapper.selectList(null);
+ // for all commands
+ for (Command tmpCommand : commands) {
+ if (!cmdTypeMap.containsKey(tmpCommand.getCommandType())) {
+ continue;
+ }
+ ObjectNode tempObj = JSONUtils.parseObject(tmpCommand.getCommandParam());
+ if (tempObj != null
+ && processInstanceId == tempObj.path(CMD_PARAM_RECOVER_PROCESS_ID_STRING).asInt()) {
+ isNeedCreate = false;
+ break;
+ }
+ }
+ return isNeedCreate;
+ }
+
+ @Override
+ public int saveCommand(Command command) {
+ if (command.getId() != null) {
+ return commandMapper.updateById(command);
+ } else {
+ return commandMapper.insert(command);
+ }
+ }
+
+ @Override
+ public void createRecoveryWaitingThreadCommand(Command originCommand, ProcessInstance processInstance) {
+ // sub process doesn't need to create wait command
+ if (processInstance.getIsSubProcess() == Flag.YES) {
+ if (originCommand != null) {
+ commandMapper.deleteById(originCommand.getId());
+ }
+ return;
+ }
+ Map<String, String> cmdParam = new HashMap<>();
+ cmdParam.put(Constants.CMD_PARAM_RECOVERY_WAITING_THREAD, String.valueOf(processInstance.getId()));
+ // process instance quit by "waiting thread" state
+ if (originCommand == null) {
+ Command command = new Command(
+ CommandType.RECOVER_WAITING_THREAD,
+ processInstance.getTaskDependType(),
+ processInstance.getFailureStrategy(),
+ processInstance.getExecutorId(),
+ processInstance.getProcessDefinition().getCode(),
+ JSONUtils.toJsonString(cmdParam),
+ processInstance.getWarningType(),
+ processInstance.getWarningGroupId(),
+ processInstance.getScheduleTime(),
+ processInstance.getWorkerGroup(),
+ processInstance.getEnvironmentCode(),
+ processInstance.getProcessInstancePriority(),
+ processInstance.getDryRun(),
+ processInstance.getId(),
+ processInstance.getProcessDefinitionVersion(),
+ processInstance.getTestFlag());
+ saveCommand(command);
+ return;
+ }
+
+ // update the command time if current command if recover from waiting
+ if (originCommand.getCommandType() == CommandType.RECOVER_WAITING_THREAD) {
+ originCommand.setUpdateTime(new Date());
+ saveCommand(originCommand);
+ } else {
+ // delete old command and create new waiting thread command
+ commandMapper.deleteById(originCommand.getId());
+ originCommand.setId(0);
+ originCommand.setCommandType(CommandType.RECOVER_WAITING_THREAD);
+ originCommand.setUpdateTime(new Date());
+ originCommand.setCommandParam(JSONUtils.toJsonString(cmdParam));
+ originCommand.setProcessInstancePriority(processInstance.getProcessInstancePriority());
+ saveCommand(originCommand);
+ }
+ }
+
+ @Override
+ public Command createSubProcessCommand(ProcessInstance parentProcessInstance, ProcessInstance childInstance,
+ ProcessInstanceMap instanceMap, TaskInstance task) {
+ CommandType commandType = getSubCommandType(parentProcessInstance, childInstance);
+ Map<String, Object> subProcessParam = JSONUtils.toMap(task.getTaskParams(), String.class, Object.class);
+ long childDefineCode = 0L;
+ if (subProcessParam.containsKey(Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE)) {
+ childDefineCode =
+ Long.parseLong(String.valueOf(subProcessParam.get(Constants.CMD_PARAM_SUB_PROCESS_DEFINE_CODE)));
Review Comment:
## Missing catch of NumberFormatException
Potential uncaught 'java.lang.NumberFormatException'.
[Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/1999)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#issuecomment-1287594544
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/12474?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12474](https://codecov.io/gh/apache/dolphinscheduler/pull/12474?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4842822) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/b5193ee4e50e5d0b7464eab3ee331a858151540c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b5193ee) will **increase** coverage by `0.00%`.
> The diff coverage is `67.83%`.
```diff
@@ Coverage Diff @@
## dev #12474 +/- ##
=========================================
Coverage 39.41% 39.41%
Complexity 4214 4214
=========================================
Files 1039 1041 +2
Lines 39140 39123 -17
Branches 4475 4460 -15
=========================================
- Hits 15426 15420 -6
+ Misses 21941 21937 -4
+ Partials 1773 1766 -7
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/12474?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...server/master/runner/MasterSchedulerBootstrap.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1tYXN0ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9ydW5uZXIvTWFzdGVyU2NoZWR1bGVyQm9vdHN0cmFwLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...nscheduler/service/process/ProcessServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kb2xwaGluc2NoZWR1bGVyL3NlcnZpY2UvcHJvY2Vzcy9Qcm9jZXNzU2VydmljZUltcGwuamF2YQ==) | `28.64% <0.00%> (-3.17%)` | :arrow_down: |
| [...cheduler/api/service/impl/ExecutorServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9FeGVjdXRvclNlcnZpY2VJbXBsLmphdmE=) | `43.73% <40.00%> (ø)` | |
| [.../server/master/runner/WorkflowExecuteRunnable.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1tYXN0ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9ydW5uZXIvV29ya2Zsb3dFeGVjdXRlUnVubmFibGUuamF2YQ==) | `8.00% <50.00%> (+0.08%)` | :arrow_up: |
| [...che/dolphinscheduler/service/utils/ParamUtils.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kb2xwaGluc2NoZWR1bGVyL3NlcnZpY2UvdXRpbHMvUGFyYW1VdGlscy5qYXZh) | `69.56% <69.56%> (ø)` | |
| [...nscheduler/service/command/CommandServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2aWNlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kb2xwaGluc2NoZWR1bGVyL3NlcnZpY2UvY29tbWFuZC9Db21tYW5kU2VydmljZUltcGwuamF2YQ==) | `75.80% <75.80%> (ø)` | |
| [...erver/master/processor/queue/TaskEventService.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1tYXN0ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9wcm9jZXNzb3IvcXVldWUvVGFza0V2ZW50U2VydmljZS5qYXZh) | `69.64% <0.00%> (-10.72%)` | :arrow_down: |
| [...r/plugin/registry/zookeeper/ZookeeperRegistry.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS9kb2xwaGluc2NoZWR1bGVyLXJlZ2lzdHJ5LXBsdWdpbnMvZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS16b29rZWVwZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL3JlZ2lzdHJ5L3pvb2tlZXBlci9ab29rZWVwZXJSZWdpc3RyeS5qYXZh) | `43.54% <0.00%> (-6.46%)` | :arrow_down: |
| [...org/apache/dolphinscheduler/remote/utils/Host.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1yZW1vdGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcmVtb3RlL3V0aWxzL0hvc3QuamF2YQ==) | `42.55% <0.00%> (-2.13%)` | :arrow_down: |
| [...e/dolphinscheduler/remote/NettyRemotingClient.java](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1yZW1vdGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcmVtb3RlL05ldHR5UmVtb3RpbmdDbGllbnQuamF2YQ==) | `51.38% <0.00%> (-1.39%)` | :arrow_down: |
| ... and [20 more](https://codecov.io/gh/apache/dolphinscheduler/pull/12474/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#discussion_r1002292254
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.command;
+
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+
+import java.util.List;
+
+/**
+ * Command Service
+ */
+public interface CommandService {
+
+ /**
+ * Save error command, and delete original command. If the given command has already been moved into error command,
+ * will throw {@link java.sql.SQLIntegrityConstraintViolationException ).
+ * @param command command
+ * @param message message
+ */
+ void moveToErrorCommand(Command command, String message);
+
+ /**
+ * Create new command
+ * @param command command
+ * @return result
+ */
+ int createCommand(Command command);
Review Comment:
This method make confusion with `saveCommand`, we would better don't keep both.
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.command;
+
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+
+import java.util.List;
+
+/**
+ * Command Service
+ */
+public interface CommandService {
+
+ /**
+ * Save error command, and delete original command. If the given command has already been moved into error command,
+ * will throw {@link java.sql.SQLIntegrityConstraintViolationException ).
+ * @param command command
+ * @param message message
+ */
+ void moveToErrorCommand(Command command, String message);
+
+ /**
+ * Create new command
+ * @param command command
+ * @return result
+ */
+ int createCommand(Command command);
+
+ /**
+ * Get command page
+ * @param pageSize page size
+ * @param pageNumber page number
+ * @return command page
+ */
+ List<Command> findCommandPage(int pageSize, int pageNumber);
+
+ /**
+ * Get command page
+ * @param pageSize page size
+ * @param pageNumber page number
+ * @param masterCount master count
+ * @param thisMasterSlot master slot
+ * @return command page
+ */
+ List<Command> findCommandPageBySlot(int pageSize, int pageNumber, int masterCount, int thisMasterSlot);
+
+ /**
+ * check the input command exists in queue list
+ *
+ * @param command command
+ * @return create command result
+ */
+ boolean verifyIsNeedCreateCommand(Command command);
+
+ /**
+ * insert or update command
+ *
+ * @param command command
+ * @return save command result
+ */
+ int saveCommand(Command command);
Review Comment:
```suggestion
int upsertCommand(@Nonnull Command command);
```
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.command;
+
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+
+import java.util.List;
+
+/**
+ * Command Service
+ */
+public interface CommandService {
+
+ /**
+ * Save error command, and delete original command. If the given command has already been moved into error command,
+ * will throw {@link java.sql.SQLIntegrityConstraintViolationException ).
+ * @param command command
+ * @param message message
+ */
+ void moveToErrorCommand(Command command, String message);
+
+ /**
+ * Create new command
+ * @param command command
+ * @return result
+ */
+ int createCommand(Command command);
+
+ /**
+ * Get command page
+ * @param pageSize page size
+ * @param pageNumber page number
+ * @return command page
+ */
+ List<Command> findCommandPage(int pageSize, int pageNumber);
Review Comment:
Dose this method still used?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] DarkAssassinator commented on a diff in pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
DarkAssassinator commented on code in PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#discussion_r1002293501
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.command;
+
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+
+import java.util.List;
+
+/**
+ * Command Service
+ */
+public interface CommandService {
+
+ /**
+ * Save error command, and delete original command. If the given command has already been moved into error command,
+ * will throw {@link java.sql.SQLIntegrityConstraintViolationException ).
+ * @param command command
+ * @param message message
+ */
+ void moveToErrorCommand(Command command, String message);
+
+ /**
+ * Create new command
+ * @param command command
+ * @return result
+ */
+ int createCommand(Command command);
+
+ /**
+ * Get command page
+ * @param pageSize page size
+ * @param pageNumber page number
+ * @return command page
+ */
+ List<Command> findCommandPage(int pageSize, int pageNumber);
Review Comment:
> Dose this method still used?
i think not, i will remove it to keep code clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#issuecomment-1287595532
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=12474)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL) [16 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_coverage&view=list) [70.8% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] ruanwenjun merged pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
ruanwenjun merged PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] DarkAssassinator commented on a diff in pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
DarkAssassinator commented on code in PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#discussion_r1002294768
##########
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandService.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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.command;
+
+import org.apache.dolphinscheduler.dao.entity.Command;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
+import org.apache.dolphinscheduler.dao.entity.ProcessInstanceMap;
+import org.apache.dolphinscheduler.dao.entity.TaskInstance;
+
+import java.util.List;
+
+/**
+ * Command Service
+ */
+public interface CommandService {
+
+ /**
+ * Save error command, and delete original command. If the given command has already been moved into error command,
+ * will throw {@link java.sql.SQLIntegrityConstraintViolationException ).
+ * @param command command
+ * @param message message
+ */
+ void moveToErrorCommand(Command command, String message);
+
+ /**
+ * Create new command
+ * @param command command
+ * @return result
+ */
+ int createCommand(Command command);
Review Comment:
> This method make confusion with `saveCommand`, we would better don't keep both.
+1, I think `saveCommand` should be made a private method, not a interface function, i will improve it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #12474: [Refactor] Migrate all command-related interface functions from ProcessServiceImpl
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #12474:
URL: https://github.com/apache/dolphinscheduler/pull/12474#issuecomment-1287595456
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=12474)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL) [16 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=12474&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_coverage&view=list) [71.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=12474&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org