status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
unknown
language
stringclasses
5 values
commit_datetime
unknown
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
/** * check connection * * @param data source * @param data source s * @return true if connect successfully, otherwise false */ public Result<Object> checkConnection(DbType , String ) { Result<Object> result = new Result<>(); BaseDataSource datasource = DataSourceFactory.getDatasource(, ); if (datasource == null) { putMsg(result, Status.DATASOURCE_TYPE_NOT_EXIST, ); return result; } try (Connection connection = datasource.getConnection()) { if (connection == null) { putMsg(result, Status.CONNECTION_TEST_FAILURE); return result; } putMsg(result, Status.SUCCESS); return result; } catch (Exception e) { logger.error("datasource test connection error, dbType:{}, jdbcUrl:{}, message:{}.", , datasource.getJdbcUrl(), e.getMessage()); return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(),e.getMessage()); } } /** * test connection * * @param id datasource id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
* @return connect result code */ public Result<Object> connectionTest(int id) { DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { Result<Object> result = new Result<>(); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } return checkConnection(dataSource.getType(), dataSource.getConnectionParams()); } /** * build paramters * * @param data source * @param host data source host * @param port data source port * @param database data source database * @param userName user * @param password password * @param other other s * @param principal principal * @return datasource */ public String buildParameter(DbType , String host, String port, String database, String principal, String userName, String password, DbConnectType connectType, String other, String javaSecurityKrb5Conf, String loginUserKeytabUser, String loginUserKeytabPath) { String address = buildAddress(, host, port, connectType); Map<String, Object> Map = new LinkedHashMap<String, Object>(6);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
String jdbcUrl; if (DbType.SQLSERVER == ) { jdbcUrl = address + ";databaseName=" + database; } else { jdbcUrl = address + "/" + database; } if (Constants.ORACLE.equals(.())) { Map.put(Constants.ORACLE_DB_CONNECT_TYPE, connectType); } if (CommonUtils.getKerberosStartupState() && ( == DbType.HIVE || == DbType.SPARK)) { jdbcUrl += ";principal=" + principal; } String separator = ""; if (Constants.MYSQL.equals(.()) || Constants.POSTGRESQL.equals(.()) || Constants.CLICKHOUSE.equals(.()) || Constants.ORACLE.equals(.()) || Constants.PRESTO.equals(.())) { separator = "&"; } else if (Constants.HIVE.equals(.()) || Constants.SPARK.equals(.()) || Constants.DB2.equals(.()) || Constants.SQLSERVER.equals(.())) { separator = ";"; } Map.put(TYPE, connectType); Map.put(Constants.ADDRESS, address); Map.put(Constants.DATABASE, database); Map.put(Constants.JDBC_URL, jdbcUrl);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
Map.put(Constants.USER, userName); Map.put(Constants.PASSWORD, CommonUtils.encodePassword(password)); if (CommonUtils.getKerberosStartupState() && ( == DbType.HIVE || == DbType.SPARK)) { Map.put(Constants.PRINCIPAL, principal); Map.put(Constants.KERBEROS_KRB5_CONF_PATH, javaSecurityKrb5Conf); Map.put(Constants.KERBEROS_KEY_TAB_USERNAME, loginUserKeytabUser); Map.put(Constants.KERBEROS_KEY_TAB_PATH, loginUserKeytabPath); } Map<String, String> map = JSONUtils.toMap(other); if (map != null) { StringBuilder otherSb = new StringBuilder(); for (Map.Entry<String, String> entry: map.entrySet()) { otherSb.append(String.format("%s=%s%s", entry.getKey(), entry.getValue(), separator)); } if (!Constants.DB2.equals(.())) { otherSb.deleteCharAt(otherSb.length() - 1); } Map.put(Constants.OTHER, otherSb); } if (logger.isDebugEnabled()) { logger.info("s map:{}", JSONUtils.toJsonString(Map)); } return JSONUtils.toJsonString(Map); } private String buildAddress(DbType , String host, String port, DbConnectType connectType) { StringBuilder sb = new StringBuilder(); if (Constants.MYSQL.equals(.())) { sb.append(Constants.JDBC_MYSQL); sb.append(host).append(":").append(port);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
} else if (Constants.POSTGRESQL.equals(.())) { sb.append(Constants.JDBC_POSTGRESQL); sb.append(host).append(":").append(port); } else if (Constants.HIVE.equals(.()) || Constants.SPARK.equals(.())) { sb.append(Constants.JDBC_HIVE_2); String[] hostArray = host.split(","); if (hostArray.length > 0) { for (String zkHost : hostArray) { sb.append(String.format("%s:%s,", zkHost, port)); } sb.deleteCharAt(sb.length() - 1); } } else if (Constants.CLICKHOUSE.equals(.())) { sb.append(Constants.JDBC_CLICKHOUSE); sb.append(host).append(":").append(port); } else if (Constants.ORACLE.equals(.())) { if (connectType == DbConnectType.ORACLE_SID) { sb.append(Constants.JDBC_ORACLE_SID); } else { sb.append(Constants.JDBC_ORACLE_SERVICE_NAME); } sb.append(host).append(":").append(port); } else if (Constants.SQLSERVER.equals(.())) { sb.append(Constants.JDBC_SQLSERVER); sb.append(host).append(":").append(port); } else if (Constants.DB2.equals(.())) { sb.append(Constants.JDBC_DB2); sb.append(host).append(":").append(port); } else if (Constants.PRESTO.equals(.())) { sb.append(Constants.JDBC_PRESTO);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
sb.append(host).append(":").append(port); } return sb.toString(); } /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code */ @Transactional(rollbackFor = RuntimeException.class) public Result<Object> delete(User loginUser, int datasourceId) { Result<Object> result = new Result<>(); try { // DataSource dataSource = dataSourceMapper.selectById(datasourceId); if (dataSource == null) { logger.error("resource id {} not exist", datasourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, dataSource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } dataSourceMapper.deleteById(datasourceId); datasourceUserMapper.deleteByDatasourceId(datasourceId); putMsg(result, Status.SUCCESS); } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
logger.error("delete datasource error", e); throw new RuntimeException("delete datasource error"); } return result; } /** * unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ public Map<String, Object> unauthDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); // if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } /** * query all data sources except userId */ List<DataSource> resultList = new ArrayList<>(); List<DataSource> datasourceList = dataSourceMapper.queryDatasourceExceptUserId(userId); Set<DataSource> datasourceSet = null; if (datasourceList != null && datasourceList.size() > 0) { datasourceSet = new HashSet<>(datasourceList); List<DataSource> authedDataSourceList = dataSourceMapper.queryAuthedDatasource(userId); Set<DataSource> authedDataSourceSet = null; if (authedDataSourceList != null && authedDataSourceList.size() > 0) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
authedDataSourceSet = new HashSet<>(authedDataSourceList); datasourceSet.removeAll(authedDataSourceSet); } resultList = new ArrayList<>(datasourceSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ public Map<String, Object> authedDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } List<DataSource> authedDatasourceList = dataSourceMapper.queryAuthedDatasource(userId); result.put(Constants.DATA_LIST, authedDatasourceList); putMsg(result, Status.SUCCESS); return result; } /** * get host and port by address *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataSourceService.java
* @param address address * @return sting array: [host,port] */ private String[] getHostsAndPort(String address) { return getHostsAndPort(address, Constants.DOUBLE_SLASH); } /** * get host and port by address * * @param address address * @param separator separator * @return sting array: [host,port] */ private String[] getHostsAndPort(String address, String separator) { String[] result = new String[2]; String[] tmpArray = address.split(separator); String hostsAndPorts = tmpArray[tmpArray.length - 1]; StringBuilder hosts = new StringBuilder(); String[] hostPortArray = hostsAndPorts.split(Constants.COMMA); String port = hostPortArray[0].split(Constants.COLON)[1]; for (String hostPort : hostPortArray) { hosts.append(hostPort.split(Constants.COLON)[0]).append(Constants.COMMA); } hosts.deleteCharAt(hosts.length() - 1); result[0] = hosts.toString(); result[1] = port; return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
/* * 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. */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
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.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODE_NAMES; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.Status; 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.FailureStrategy; 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.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.dao.entity.Command; 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.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
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.service.process.ProcessService; import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; 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; /** * executor service */ @Service public class ExecutorService extends BaseService { private static final Logger logger = LoggerFactory.getLogger(ExecutorService.class); @Autowired private ProjectMapper projectMapper; @Autowired private ProjectService projectService; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private MonitorService monitorService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
@Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private ProcessService processService; /** * execute process instance * * @param loginUser login user * @param projectName project name * @param processDefinitionId process Definition Id * @param cronTime cron time * @param commandType command type * @param failureStrategy failuer strategy * @param startNodeList start nodelist * @param taskDependType node dependency type * @param warningType warning type * @param warningGroupId notify group id * @param processInstancePriority process instance priority * @param workerGroup worker group name * @param runMode run mode * @param timeout timeout * @param startParams the global param values which pass to new process instance * @return execute process instance code * @throws ParseException Parse Exception */ public Map<String, Object> execProcessInstance(User loginUser, String projectName, int processDefinitionId, String cronTime, CommandType commandType, FailureStrategy failureStrategy, String startNodeList, TaskDependType taskDependType, WarningType warningType, int warningGroupId, RunMode runMode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
Priority processInstancePriority, String workerGroup, Integer timeout, Map<String, String> startParams) throws ParseException { Map<String, Object> result = new HashMap<>(); if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { putMsg(result, Status.TASK_TIMEOUT_PARAMS_ERROR); return result; } Project project = projectMapper.queryByName(projectName); Map<String, Object> checkResultAndAuth = checkResultAndAuth(loginUser, projectName, project); if (checkResultAndAuth != null) { return checkResultAndAuth; } ProcessDefinition processDefinition = processDefinitionMapper.selectById(processDefinitionId); result = checkProcessDefinitionValid(processDefinition, processDefinitionId); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName()); putMsg(result, Status.TENANT_NOT_SUITABLE); return result; } if (!checkMasterExists(result)) { return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
* create command */ int create = this.createCommand(commandType, processDefinitionId, taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority, workerGroup, startParams); if (create > 0) { processDefinition.setWarningGroupId(warningGroupId); processDefinitionMapper.updateById(processDefinition); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.START_PROCESS_INSTANCE_ERROR); } return result; } /** * check whether master exists * * @param result result * @return master exists return true , otherwise return false */ private boolean checkMasterExists(Map<String, Object> result) { List<Server> masterServers = monitorService.getServerListFromZK(true); if (masterServers.size() == 0) { putMsg(result, Status.MASTER_NOT_EXISTS); return false; } return true; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
/** * check whether the process definition can be executed * * @param processDefinition process definition * @param processDefineId process definition id * @return check result code */ public Map<String, Object> checkProcessDefinitionValid(ProcessDefinition processDefinition, int processDefineId) { Map<String, Object> result = new HashMap<>(); if (processDefinition == null) { putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineId); } else if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefineId); } else { result.put(Constants.STATUS, Status.SUCCESS); } return result; } /** * do action to process instance:pause, stop, repeat, recover from pause, recover from stop * * @param loginUser login user * @param projectName project name * @param processInstanceId process instance id * @param executeType execute type * @return execute result code */ public Map<String, Object> execute(User loginUser, String projectName, Integer processInstanceId, ExecuteType executeType) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
Map<String, Object> result = new HashMap<>(); Project project = projectMapper.queryByName(projectName); Map<String, Object> checkResult = checkResultAndAuth(loginUser, projectName, project); if (checkResult != null) { return checkResult; } if (!checkMasterExists(result)) { return result; } ProcessInstance processInstance = processService.findProcessInstanceDetailById(processInstanceId); if (processInstance == null) { putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } ProcessDefinition processDefinition = processService.findProcessDefineById(processInstance.getProcessDefinitionId()); if (executeType != ExecuteType.STOP && executeType != ExecuteType.PAUSE) { result = checkProcessDefinitionValid(processDefinition, processInstance.getProcessDefinitionId()); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result; } } checkResult = checkExecuteType(processInstance, executeType); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { return checkResult; } if (!checkTenantSuitable(processDefinition)) { logger.error("there is not any valid tenant for the process definition: id:{},name:{}, ", processDefinition.getId(), processDefinition.getName());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
putMsg(result, Status.TENANT_NOT_SUITABLE); } switch (executeType) { case REPEAT_RUNNING: result = insertCommand(loginUser, processInstanceId, processDefinition.getId(), CommandType.REPEAT_RUNNING); break; case RECOVER_SUSPENDED_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getId(), CommandType.RECOVER_SUSPENDED_PROCESS); break; case START_FAILURE_TASK_PROCESS: result = insertCommand(loginUser, processInstanceId, processDefinition.getId(), CommandType.START_FAILURE_TASK_PROCESS); break; case STOP: if (processInstance.getState() == ExecutionStatus.READY_STOP) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.STOP, ExecutionStatus.READY_STOP); } break; case PAUSE: if (processInstance.getState() == ExecutionStatus.READY_PAUSE) { putMsg(result, Status.PROCESS_INSTANCE_ALREADY_CHANGED, processInstance.getName(), processInstance.getState()); } else { result = updateProcessInstancePrepare(processInstance, CommandType.PAUSE, ExecutionStatus.READY_PAUSE); } break; default: logger.error("unknown execute type : {}", executeType); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "unknown execute type"); break;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
} return result; } /** * check tenant suitable * * @param processDefinition process definition * @return true if tenant suitable, otherwise return false */ private boolean checkTenantSuitable(ProcessDefinition processDefinition) { // Tenant tenant = processService.getTenantForProcess(processDefinition.getTenantId(), processDefinition.getUserId()); return tenant != null; } /** * Check the state of process instance and the type of operation match * * @param processInstance process instance * @param executeType execute type * @return check result code */ private Map<String, Object> checkExecuteType(ProcessInstance processInstance, ExecuteType executeType) { Map<String, Object> result = new HashMap<>(); ExecutionStatus executionStatus = processInstance.getState(); boolean checkResult = false; switch (executeType) { case PAUSE: case STOP: if (executionStatus.typeIsRunning()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
checkResult = true; } break; case REPEAT_RUNNING: if (executionStatus.typeIsFinished()) { checkResult = true; } break; case START_FAILURE_TASK_PROCESS: if (executionStatus.typeIsFailure()) { checkResult = true; } break; case RECOVER_SUSPENDED_PROCESS: if (executionStatus.typeIsPause() || executionStatus.typeIsCancel()) { checkResult = true; } break; default: break; } if (!checkResult) { putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstance.getName(), executionStatus.toString(), executeType.toString()); } else { putMsg(result, Status.SUCCESS); } return result; } /** * prepare to update process instance command type and status
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
* * @param processInstance process instance * @param commandType command type * @param executionStatus execute status * @return update result */ private Map<String, Object> updateProcessInstancePrepare(ProcessInstance processInstance, CommandType commandType, ExecutionStatus executionStatus) { Map<String, Object> result = new HashMap<>(); processInstance.setCommandType(commandType); processInstance.addHistoryCmd(commandType); processInstance.setState(executionStatus); int update = processService.updateProcessInstance(processInstance); // if (update > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * insert command, used in the implementation of the page, re run, recovery (pause / failure) execution * * @param loginUser login user * @param instanceId instance id * @param processDefinitionId process definition id * @param commandType command type * @return insert result code */ private Map<String, Object> insertCommand(User loginUser, Integer instanceId, Integer processDefinitionId, CommandType commandType) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
Map<String, Object> result = new HashMap<>(); Command command = new Command(); command.setCommandType(commandType); command.setProcessDefinitionId(processDefinitionId); command.setCommandParam(String.format("{\"%s\":%d}", CMD_PARAM_RECOVER_PROCESS_ID_STRING, instanceId)); command.setExecutorId(loginUser.getId()); if (!processService.verifyIsNeedCreateCommand(command)) { putMsg(result, Status.PROCESS_INSTANCE_EXECUTING_COMMAND, processDefinitionId); return result; } int create = processService.createCommand(command); if (create > 0) { putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.EXECUTE_PROCESS_INSTANCE_ERROR); } return result; } /** * check if sub processes are offline before starting process definition * * @param processDefineId process definition id * @return check result code */ public Map<String, Object> startCheckByProcessDefinedId(int processDefineId) { Map<String, Object> result = new HashMap<>(); if (processDefineId == 0) { logger.error("process definition id is null"); putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "process definition id");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
} List<Integer> ids = new ArrayList<>(); processService.recurseFindSubProcessId(processDefineId, ids); Integer[] idArray = ids.toArray(new Integer[ids.size()]); if (!ids.isEmpty()) { List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryDefinitionListByIdList(idArray); if (processDefinitionList != null) { for (ProcessDefinition processDefinition : processDefinitionList) { /** * if there is no online process, exit directly */ if (processDefinition.getReleaseState() != ReleaseState.ONLINE) { putMsg(result, Status.PROCESS_DEFINE_NOT_RELEASE, processDefinition.getName()); logger.info("not release process definition id: {} , name : {}", processDefinition.getId(), processDefinition.getName()); return result; } } } } putMsg(result, Status.SUCCESS); return result; } /** * create command * * @param commandType commandType * @param processDefineId processDefineId * @param nodeDep nodeDep * @param failureStrategy failureStrategy
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
* @param startNodeList startNodeList * @param schedule schedule * @param warningType warningType * @param executorId executorId * @param warningGroupId warningGroupId * @param runMode runMode * @param processInstancePriority processInstancePriority * @param workerGroup workerGroup * @return command id */ private int createCommand(CommandType commandType, int processDefineId, TaskDependType nodeDep, FailureStrategy failureStrategy, String startNodeList, String schedule, WarningType warningType, int executorId, int warningGroupId, RunMode runMode, Priority processInstancePriority, String workerGroup, Map<String, String> startParams) throws ParseException { /** * instantiate command schedule instance */ Command command = new Command(); Map<String, String> cmdParam = new HashMap<>(); if (commandType == null) { command.setCommandType(CommandType.START_PROCESS); } else { command.setCommandType(commandType); } command.setProcessDefinitionId(processDefineId); if (nodeDep != null) { command.setTaskDependType(nodeDep); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
if (failureStrategy != null) { command.setFailureStrategy(failureStrategy); } if (StringUtils.isNotEmpty(startNodeList)) { cmdParam.put(CMD_PARAM_START_NODE_NAMES, startNodeList); } if (warningType != null) { command.setWarningType(warningType); } if (startParams != null && startParams.size() > 0) { cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams)); } command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setExecutorId(executorId); command.setWarningGroupId(warningGroupId); command.setProcessInstancePriority(processInstancePriority); command.setWorkerGroup(workerGroup); Date start = null; Date end = null; if (StringUtils.isNotEmpty(schedule)) { String[] interval = schedule.split(","); if (interval.length == 2) { start = DateUtils.getScheduleDate(interval[0]); end = DateUtils.getScheduleDate(interval[1]); } } // if (commandType == CommandType.COMPLEMENT_DATA) { runMode = (runMode == null) ? RunMode.RUN_MODE_SERIAL : runMode; if (null != start && null != end && !start.after(end)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
if (runMode == RunMode.RUN_MODE_SERIAL) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start)); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(end)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); return processService.createCommand(command); } else if (runMode == RunMode.RUN_MODE_PARALLEL) { List<Schedule> schedules = processService.queryReleaseSchedulerListByProcessDefinitionId(processDefineId); List<Date> listDate = new LinkedList<>(); if (!CollectionUtils.isEmpty(schedules)) { for (Schedule item : schedules) { listDate.addAll(CronUtils.getSelfFireDateList(start, end, item.getCrontab())); } } if (!CollectionUtils.isEmpty(listDate)) { // for (Date date : listDate) { cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(date)); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(date)); command.setCommandParam(JSONUtils.toJsonString(cmdParam)); processService.createCommand(command); } return listDate.size(); } else { // int runCunt = 0; while (!start.after(end)) { runCunt += 1; cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, DateUtils.dateToString(start)); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, DateUtils.dateToString(start)); command.setCommandParam(JSONUtils.toJsonString(cmdParam));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
processService.createCommand(command); start = DateUtils.getSomeDay(start, 1); } return runCunt; } } } else { logger.error("there is not valid schedule date for the process definition: id:{},date:{}", processDefineId, schedule); } } else { command.setCommandParam(JSONUtils.toJsonString(cmdParam)); return processService.createCommand(command); } return 0; } /** * check result and auth */ private Map<String, Object> checkResultAndAuth(User loginUser, String projectName, Project project) { // Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { return checkResult; } return null; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
/* * 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.api.service; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.DbConnectType; import org.apache.dolphinscheduler.common.enums.DbType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.datasource.BaseDataSource; import org.apache.dolphinscheduler.dao.datasource.DataSourceFactory; import org.apache.dolphinscheduler.dao.datasource.MySQLDataSource;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import java.sql.Connection; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) @PowerMockIgnore({"sun.security.*", "javax.net.*"}) @PrepareForTest({DataSourceFactory.class, CommonUtils.class}) public class DataSourceServiceTest { @InjectMocks private DataSourceService dataSourceService; @Mock private DataSourceMapper dataSourceMapper; @Mock private DataSourceUserMapper datasourceUserMapper; public void createDataSourceTest() { User loginUser = getAdminUser();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; DbType dataSourceType = DbType.POSTGRESQL; String parameter = dataSourceService.buildParameter(dataSourceType, "172.16.133.200", "5432", "dolphinscheduler", null, "postgres", "", null, null, null, null, null); List<DataSource> dataSourceList = new ArrayList<>(); DataSource dataSource = new DataSource(); dataSource.setName(dataSourceName); dataSourceList.add(dataSource); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(dataSourceList); Result dataSourceExitsResult = dataSourceService.createDataSource(loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceExitsResult.getCode().intValue()); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); Result connectionResult = new Result(Status.DATASOURCE_CONNECT_FAILED.getCode(),Status.DATASOURCE_CONNECT_FAILED.getMsg()); PowerMockito.doReturn(connectionResult).when(dataSourceService).checkConnection(dataSourceType, parameter); Result connectFailedResult = dataSourceService.createDataSource(loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.DATASOURCE_CONNECT_FAILED.getCode(), connectFailedResult.getCode().intValue()); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); connectionResult = new Result(Status.SUCCESS.getCode(),Status.SUCCESS.getMsg()); PowerMockito.when(dataSourceService.checkConnection(dataSourceType, parameter)).thenReturn(connectionResult); PowerMockito.when(DataSourceFactory.getDatasource(dataSourceType, parameter)).thenReturn(null); Result notValidError = dataSourceService.createDataSource(loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), notValidError.getCode().intValue()); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); PowerMockito.when(dataSourceService.checkConnection(dataSourceType, parameter)).thenReturn(connectionResult); PowerMockito.when(DataSourceFactory.getDatasource(dataSourceType, parameter)).thenReturn(JSONUtils.parseObject(parameter, MySQLDataSource.class));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Result success = dataSourceService.createDataSource(loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } public void updateDataSourceTest() { User loginUser = getAdminUser(); int dataSourceId = 12; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; DbType dataSourceType = DbType.POSTGRESQL; String parameter = dataSourceService.buildParameter(dataSourceType, "172.16.133.200", "5432", "dolphinscheduler", null, "postgres", "", null, null, null, null, null); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result resourceNotExits = dataSourceService.updateDataSource(dataSourceId, loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(), resourceNotExits.getCode().intValue()); DataSource dataSource = new DataSource(); dataSource.setUserId(0); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Result userNoOperationPerm = dataSourceService.updateDataSource(dataSourceId, loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), userNoOperationPerm.getCode().intValue()); dataSource.setUserId(-1); List<DataSource> dataSourceList = new ArrayList<>(); dataSourceList.add(dataSource); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(dataSourceList); Result dataSourceNameExist = dataSourceService.updateDataSource(dataSourceId, loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceNameExist.getCode().intValue()); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(null); Result connectionResult = new Result(Status.SUCCESS.getCode(),Status.SUCCESS.getMsg()); PowerMockito.when(dataSourceService.checkConnection(dataSourceType, parameter)).thenReturn(connectionResult); Result connectFailed = dataSourceService.updateDataSource(dataSourceId, loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.DATASOURCE_CONNECT_FAILED.getCode(), connectFailed.getCode().intValue()); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(null); connectionResult = new Result(Status.DATASOURCE_CONNECT_FAILED.getCode(),Status.DATASOURCE_CONNECT_FAILED.getMsg()); PowerMockito.when(dataSourceService.checkConnection(dataSourceType, parameter)).thenReturn(connectionResult); Result success = dataSourceService.updateDataSource(dataSourceId, loginUser, dataSourceName, dataSourceDesc, dataSourceType, parameter); Assert.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } @Test public void queryDataSourceListPagingTest() { User loginUser = getAdminUser(); String searchVal = ""; int pageNo = 1; int pageSize = 10; Map<String, Object> success = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize); Assert.assertEquals(Status.SUCCESS, success.get(Constants.STATUS)); } @Test public void connectionTest() { int dataSourceId = -1; PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result result = dataSourceService.connectionTest(dataSourceId); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(),result.getCode().intValue()); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
public void deleteTest() { User loginUser = getAdminUser(); int dataSourceId = 1; Result result = new Result(); dataSourceService.putMsg(result, Status.RESOURCE_NOT_EXIST); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Assert.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.USER_NO_OPERATION_PERM); DataSource dataSource = new DataSource(); dataSource.setUserId(0); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assert.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.SUCCESS); dataSource.setUserId(-1); PowerMockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assert.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); } @Test public void unauthDatasourceTest() { User loginUser = getAdminUser(); int userId = -1; Map<String, Object> noOperationPerm = dataSourceService.unauthDatasource(loginUser, userId); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, noOperationPerm.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); Map<String, Object> success = dataSourceService.unauthDatasource(loginUser, userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assert.assertEquals(Status.SUCCESS, success.get(Constants.STATUS)); } @Test public void authedDatasourceTest() { User loginUser = getAdminUser(); int userId = -1; Map<String, Object> noOperationPerm = dataSourceService.authedDatasource(loginUser, userId); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, noOperationPerm.get(Constants.STATUS)); loginUser.setUserType(UserType.ADMIN_USER); Map<String, Object> success = dataSourceService.authedDatasource(loginUser, userId); Assert.assertEquals(Status.SUCCESS, success.get(Constants.STATUS)); } @Test public void queryDataSourceListTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); Map<String, Object> map = dataSourceService.queryDataSourceList(loginUser, DbType.MYSQL.ordinal()); Assert.assertEquals(Status.SUCCESS, map.get(Constants.STATUS)); } @Test public void verifyDataSourceNameTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); String dataSourceName = "dataSource1"; PowerMockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(getDataSourceList()); Result result = dataSourceService.verifyDataSourceName(dataSourceName); Assert.assertEquals(Status.DATASOURCE_EXIST.getMsg(), result.getMsg()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
@Test public void queryDataSourceTest() { PowerMockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(null); Map<String, Object> result = dataSourceService.queryDataSource(Mockito.anyInt()); Assert.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.RESOURCE_NOT_EXIST.getCode()); PowerMockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(getOracleDataSource()); result = dataSourceService.queryDataSource(Mockito.anyInt()); Assert.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.SUCCESS.getCode()); } private List<DataSource> getDataSourceList() { List<DataSource> dataSources = new ArrayList<>(); dataSources.add(getOracleDataSource()); return dataSources; } private DataSource getOracleDataSource() { DataSource dataSource = new DataSource(); dataSource.setName("test"); dataSource.setNote("Note"); dataSource.setType(DbType.ORACLE); dataSource.setConnectionParams("{\"connectType\":\"ORACLE_SID\",\"address\":\"jdbc:oracle:thin:@192.168.xx.xx:49161\",\"database\":\"XE\"," + "\"jdbcUrl\":\"jdbc:oracle:thin:@192.168.xx.xx:49161/XE\",\"user\":\"system\",\"password\":\"oracle\"}"); return dataSource; } @Test public void buildParameter() { String param = dataSourceService.buildParameter(DbType.ORACLE, "192.168.9.1", "1521", "im" , "", "test", "test", DbConnectType.ORACLE_SERVICE_NAME, "", "", "",""); String expected = "{\"connectType\":\"ORACLE_SERVICE_NAME\",\"type\":\"ORACLE_SERVICE_NAME\",\"address\":\"jdbc:oracle:thin:@//192.168.9.1:1521\",\"database\":\"im\"," + "\"jdbcUrl\":\"jdbc:oracle:thin:@//192.168.9.1:1521/im\",\"user\":\"test\",\"password\":\"test\"}"; Assert.assertEquals(expected, param);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
PowerMockito.mockStatic(CommonUtils.class); PowerMockito.when(CommonUtils.getKerberosStartupState()).thenReturn(true); PowerMockito.when(CommonUtils.encodePassword(Mockito.anyString())).thenReturn("test"); param = dataSourceService.buildParameter(DbType.HIVE, "192.168.9.1", "10000", "im" , "hive/[email protected]", "test", "test", null, "", "/opt/krb5.conf", "test2/[email protected]", "/opt/hdfs.headless.keytab"); expected = "{\"type\":null,\"address\":\"jdbc:hive2://192.168.9.1:10000\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:hive2://192.168.9.1:10000/im;principal=hive/[email protected]\"," + "\"user\":\"test\",\"password\":\"test\",\"principal\":\"hive/[email protected]\",\"javaSecurityKrb5Conf\":\"/opt/krb5.conf\"," + "\"loginUserKeytabUsername\":\"test2/[email protected]\",\"loginUserKeytabPath\":\"/opt/hdfs.headless.keytab\"}"; Assert.assertEquals(expected, param); } @Test public void buildParameterWithDecodePassword() { PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "true"); String param = dataSourceService.buildParameter(DbType.MYSQL, "192.168.9.1", "1521", "im" , "", "test", "123456", null, "", "", "", ""); String expected = "{\"type\":null,\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\"," + "\"user\":\"test\",\"password\":\"IUAjJCVeJipNVEl6TkRVMg==\"}"; Assert.assertEquals(expected, param); PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "false"); param = dataSourceService.buildParameter(DbType.MYSQL, "192.168.9.1", "1521", "im" , "", "test", "123456", null, "", "", "", ""); expected = "{\"type\":null,\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"user\":\"test\",\"password\":\"123456\"}"; Assert.assertEquals(expected, param); } /** * get Mock Admin User * * @return admin user */ private User getAdminUser() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
User loginUser = new User(); loginUser.setId(-1); loginUser.setUserName("admin"); loginUser.setUserType(UserType.GENERAL_USER); return loginUser; } /** * test check connection * @throws Exception */ @Test public void testCheckConnection() throws Exception { DbType dataSourceType = DbType.POSTGRESQL; String parameter = dataSourceService.buildParameter(dataSourceType, "172.16.133.200", "5432", "dolphinscheduler", null, "postgres", "", null, null, null, null, null); PowerMockito.mockStatic(DataSourceFactory.class); PowerMockito.when(DataSourceFactory.getDatasource(Mockito.any(), Mockito.anyString())).thenReturn(null); Result result = dataSourceService.checkConnection(dataSourceType, parameter); Assert.assertEquals(Status.DATASOURCE_TYPE_NOT_EXIST.getCode(), result.getCode().intValue()); BaseDataSource dataSource = PowerMockito.mock(BaseDataSource.class); PowerMockito.when(DataSourceFactory.getDatasource(Mockito.any(), Mockito.anyString())).thenReturn(dataSource); PowerMockito.when(dataSource.getConnection()).thenReturn(null); result = dataSourceService.checkConnection(dataSourceType, parameter); Assert.assertEquals(Status.CONNECTION_TEST_FAILURE.getCode(), result.getCode().intValue()); Connection connection = PowerMockito.mock(Connection.class); PowerMockito.when(dataSource.getConnection()).thenReturn(connection); result = dataSourceService.checkConnection(dataSourceType, parameter); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
/* * 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.api.service; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import org.apache.dolphinscheduler.api.enums.Status; 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.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.RunMode;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.dao.entity.Command; 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.dao.entity.Schedule; 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.service.process.ProcessService; import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; /** * test for ExecutorService */ @RunWith(MockitoJUnitRunner.Silent.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
public class ExecutorService2Test { @InjectMocks private ExecutorService executorService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
@Mock private ProcessService processService; @Mock private ProcessDefinitionMapper processDefinitionMapper; @Mock private ProjectMapper projectMapper; @Mock private ProjectServiceImpl projectService; @Mock private MonitorService monitorService; private int processDefinitionId = 1; private int processInstanceId = 1; private int tenantId = 1; private int userId = 1; private ProcessDefinition processDefinition = new ProcessDefinition(); private ProcessInstance processInstance = new ProcessInstance(); private User loginUser = new User(); private String projectName = "projectName"; private Project project = new Project(); private String cronTime; @Before public void init() { loginUser.setId(userId); processDefinition.setId(processDefinitionId); processDefinition.setReleaseState(ReleaseState.ONLINE); processDefinition.setTenantId(tenantId); processDefinition.setUserId(userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
processInstance.setId(processInstanceId); processInstance.setProcessDefinitionId(processDefinitionId); processInstance.setState(ExecutionStatus.FAILURE); processInstance.setExecutorId(userId); processInstance.setTenantId(tenantId); project.setName(projectName); cronTime = "2020-01-01 00:00:00,2020-01-31 23:00:00"; Mockito.when(projectMapper.queryByName(projectName)).thenReturn(project); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(checkProjectAndAuth()); Mockito.when(processDefinitionMapper.selectById(processDefinitionId)).thenReturn(processDefinition); Mockito.when(processService.getTenantForProcess(tenantId, userId)).thenReturn(new Tenant()); Mockito.when(processService.createCommand(any(Command.class))).thenReturn(1); Mockito.when(monitorService.getServerListFromZK(true)).thenReturn(getMasterServersList()); Mockito.when(processService.findProcessInstanceDetailById(processInstanceId)).thenReturn(processInstance); Mockito.when(processService.findProcessDefineById(processDefinitionId)).thenReturn(processDefinition); } /** * not complement */ @Test public void testNoComplement() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.START_PROCESS, null, null, null, null, 0, RunMode.RUN_MODE_SERIAL,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(processService, times(1)).createCommand(any(Command.class)); } /** * not complement */ @Test public void testComplementWithStartNodeList() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.START_PROCESS, null, "n1,n2", null, null, 0, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(processService, times(1)).createCommand(any(Command.class)); } /** * date error */ @Test public void testDateError() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, "2020-01-31 23:00:00,2020-01-01 00:00:00", CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_SERIAL,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.START_PROCESS_INSTANCE_ERROR, result.get(Constants.STATUS)); verify(processService, times(0)).createCommand(any(Command.class)); } /** * serial */ @Test public void testSerial() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_SERIAL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(processService, times(1)).createCommand(any(Command.class)); } /** * without schedule */ @Test public void testParallelWithOutSchedule() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_PARALLEL,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(processService, times(31)).createCommand(any(Command.class)); } /** * with schedule */ @Test public void testParallelWithSchedule() throws ParseException { Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(oneSchedulerList()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); verify(processService, times(15)).createCommand(any(Command.class)); } @Test public void testNoMsterServers() throws ParseException { Mockito.when(monitorService.getServerListFromZK(true)).thenReturn(new ArrayList<>()); Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, null, null, null, null, 0, RunMode.RUN_MODE_PARALLEL, Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110, null); Assert.assertEquals(result.get(Constants.STATUS), Status.MASTER_NOT_EXISTS); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
private List<Server> getMasterServersList() { List<Server> masterServerList = new ArrayList<>(); Server masterServer1 = new Server(); masterServer1.setId(1); masterServer1.setHost("192.168.220.188"); masterServer1.setPort(1121); masterServerList.add(masterServer1); Server masterServer2 = new Server(); masterServer2.setId(2); masterServer2.setHost("192.168.220.189"); masterServer2.setPort(1122); masterServerList.add(masterServer2); return masterServerList; } private List zeroSchedulerList() { return Collections.EMPTY_LIST; } private List<Schedule> oneSchedulerList() { List<Schedule> schedulerList = new LinkedList<>(); Schedule schedule = new Schedule(); schedule.setCrontab("0 0 0 1/2 * ?"); schedulerList.add(schedule); return schedulerList; } private Map<String, Object> checkProjectAndAuth() { Map<String, Object> result = new HashMap<>(); result.put(Constants.STATUS, Status.SUCCESS); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
/* * 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.api.service; import org.apache.dolphinscheduler.api.ApiApplicationServer; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.common.Constants; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorServiceTest.java
import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @RunWith(SpringRunner.class) @SpringBootTest(classes = ApiApplicationServer.class) public class ExecutorServiceTest { private static final Logger logger = LoggerFactory.getLogger(ExecutorServiceTest.class); @Autowired private ExecutorService executorService; @Ignore @Test public void startCheckByProcessDefinedId(){ Map<String, Object> map = executorService.startCheckByProcessDefinedId(1234); Assert.assertNull(map); } @Test public void putMsgWithParamsTest() { Map<String,Object> map = new HashMap<>(); putMsgWithParams(map, Status.PROJECT_ALREADY_EXISTS); logger.info(map.toString()); } void putMsgWithParams(Map<String, Object> result, Status status,Object ... statusParams) { result.put(Constants.STATUS, status); if(statusParams != null && statusParams.length > 0){ result.put(Constants.MSG, MessageFormat.format(status.getMsg(), statusParams)); }else { result.put(Constants.MSG, status.getMsg()); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
/* * 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.process; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_EMPTY_SUB_PROCESS; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_DEFINE_ID; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID; import static org.apache.dolphinscheduler.common.Constants.YYYY_MM_DD_HH_MM_SS; 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.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.ResourceType; import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.model.DateInterval; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.process.Property; import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters; import org.apache.dolphinscheduler.common.task.subprocess.SubProcessParameters; import org.apache.dolphinscheduler.common.utils.CollectionUtils; 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.StringUtils; import org.apache.dolphinscheduler.dao.entity.Command;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
import org.apache.dolphinscheduler.dao.entity.CycleDependency; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.ErrorCommand; import org.apache.dolphinscheduler.dao.entity.ProcessData; 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.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Schedule; 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.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.CommandMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ErrorCommandMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.log.LogClientService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
import org.apache.dolphinscheduler.service.quartz.cron.CronUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import org.quartz.CronExpression; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.cronutils.model.Cron; import com.fasterxml.jackson.databind.node.ObjectNode; /** * process relative dao that some mappers in this. */ @Component public class ProcessService { private final Logger logger = LoggerFactory.getLogger(getClass()); private final int[] stateArray = new int[]{ExecutionStatus.SUBMITTED_SUCCESS.ordinal(), ExecutionStatus.RUNNING_EXECUTION.ordinal(), ExecutionStatus.DELAY_EXECUTION.ordinal(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
ExecutionStatus.READY_PAUSE.ordinal(), ExecutionStatus.READY_STOP.ordinal()}; @Autowired private UserMapper userMapper; @Autowired private ProcessDefinitionMapper processDefineMapper; @Autowired private ProcessInstanceMapper processInstanceMapper; @Autowired private DataSourceMapper dataSourceMapper; @Autowired private ProcessInstanceMapMapper processInstanceMapMapper; @Autowired private TaskInstanceMapper taskInstanceMapper; @Autowired private CommandMapper commandMapper; @Autowired private ScheduleMapper scheduleMapper; @Autowired private UdfFuncMapper udfFuncMapper; @Autowired private ResourceMapper resourceMapper; @Autowired private ErrorCommandMapper errorCommandMapper; @Autowired private TenantMapper tenantMapper; @Autowired private ProjectMapper projectMapper; /** * handle Command (construct ProcessInstance from Command) , wrapped in transaction
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* * @param logger logger * @param host host * @param validThreadNum validThreadNum * @param command found command * @return process instance */ @Transactional(rollbackFor = Exception.class) public ProcessInstance handleCommand(Logger logger, String host, int validThreadNum, Command command) { ProcessInstance processInstance = constructProcessInstance(command, host); if (processInstance == null) { logger.error("scan command, command parameter is error: {}", command); moveToErrorCommand(command, "process instance is null"); return null; } if (!checkThreadNum(command, validThreadNum)) { logger.info("there is not enough thread for this command: {}", command); return setWaitingThreadProcess(command, processInstance); } processInstance.setCommandType(command.getCommandType()); processInstance.addHistoryCmd(command.getCommandType()); saveProcessInstance(processInstance); this.setSubProcessParam(processInstance); delCommandById(command.getId()); return processInstance; } /** * save error command, and delete original command *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* @param command command * @param message message */ @Transactional(rollbackFor = Exception.class) public void moveToErrorCommand(Command command, String message) { ErrorCommand errorCommand = new ErrorCommand(command, message); this.errorCommandMapper.insert(errorCommand); delCommandById(command.getId()); } /** * set process waiting thread * * @param command command * @param processInstance processInstance * @return process instance */ private ProcessInstance setWaitingThreadProcess(Command command, ProcessInstance processInstance) { processInstance.setState(ExecutionStatus.WAITTING_THREAD); if (command.getCommandType() != CommandType.RECOVER_WAITTING_THREAD) { processInstance.addHistoryCmd(command.getCommandType()); } saveProcessInstance(processInstance); this.setSubProcessParam(processInstance); createRecoveryWaitingThreadCommand(command, processInstance); return null; } /** * check thread num * * @param command command
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* @param validThreadNum validThreadNum * @return if thread is enough */ private boolean checkThreadNum(Command command, int validThreadNum) { int commandThreadCount = this.workProcessThreadNumCount(command.getProcessDefinitionId()); return validThreadNum >= commandThreadCount; } /** * insert one command * * @param command command * @return create result */ public int createCommand(Command command) { int result = 0; if (command != null) { result = commandMapper.insert(command); } return result; } /** * find one command from queue list * * @return command */ public Command findOneCommand() { return commandMapper.getOneToRun(); } /** * check the input command exists in queue list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* * @param command command * @return create command result */ 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)) { ObjectNode cmdParamObj = JSONUtils.parseObject(command.getCommandParam()); int processInstanceId = cmdParamObj.path(CMD_PARAM_RECOVER_PROCESS_ID_STRING).asInt(); List<Command> commands = commandMapper.selectList(null); for (Command tmpCommand : commands) { if (cmdTypeMap.containsKey(tmpCommand.getCommandType())) { ObjectNode tempObj = JSONUtils.parseObject(tmpCommand.getCommandParam()); if (tempObj != null && processInstanceId == tempObj.path(CMD_PARAM_RECOVER_PROCESS_ID_STRING).asInt()) { isNeedCreate = false; break; } } } } return isNeedCreate; } /** * find process instance detail by id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* * @param processId processId * @return process instance */ public ProcessInstance findProcessInstanceDetailById(int processId) { return processInstanceMapper.queryDetailById(processId); } /** * get task node list by definitionId */ public List<TaskNode> getTaskNodeListByDefinitionId(Integer defineId) { ProcessDefinition processDefinition = processDefineMapper.selectById(defineId); if (processDefinition == null) { logger.info("process define not exists"); return null; } String processDefinitionJson = processDefinition.getProcessDefinitionJson(); ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); if (null == processData) { logger.error("process data is null"); return new ArrayList<>(); } return processData.getTasks(); } /** * find process instance by id * * @param processId processId * @return process instance
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
*/ public ProcessInstance findProcessInstanceById(int processId) { return processInstanceMapper.selectById(processId); } /** * find process define by id. * * @param processDefinitionId processDefinitionId * @return process definition */ public ProcessDefinition findProcessDefineById(int processDefinitionId) { return processDefineMapper.selectById(processDefinitionId); } /** * delete work process instance by id * * @param processInstanceId processInstanceId * @return delete process instance result */ public int deleteWorkProcessInstanceById(int processInstanceId) { return processInstanceMapper.deleteById(processInstanceId); } /** * delete all sub process by parent instance id * * @param processInstanceId processInstanceId * @return delete all sub process instance result */ public int deleteAllSubWorkProcessByParentId(int processInstanceId) { List<Integer> subProcessIdList = processInstanceMapMapper.querySubIdListByParentId(processInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
for (Integer subId : subProcessIdList) { deleteAllSubWorkProcessByParentId(subId); deleteWorkProcessMapByParentId(subId); removeTaskLogFile(subId); deleteWorkProcessInstanceById(subId); } return 1; } /** * remove task log file * * @param processInstanceId processInstanceId */ public void removeTaskLogFile(Integer processInstanceId) { LogClientService logClient = null; try { logClient = new LogClientService(); List<TaskInstance> taskInstanceList = findValidTaskListByProcessId(processInstanceId); if (CollectionUtils.isEmpty(taskInstanceList)) { return; } for (TaskInstance taskInstance : taskInstanceList) { String taskLogPath = taskInstance.getLogPath(); if (StringUtils.isEmpty(taskInstance.getHost())) { continue; } int port = Constants.RPC_PORT; String ip = ""; try { ip = Host.of(taskInstance.getHost()).getIp();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} catch (Exception e) { ip = taskInstance.getHost(); } logClient.removeTaskLog(ip, port, taskLogPath); } } finally { if (logClient != null) { logClient.close(); } } } /** * calculate sub process number in the process define. * * @param processDefinitionId processDefinitionId * @return process thread num count */ private Integer workProcessThreadNumCount(Integer processDefinitionId) { List<Integer> ids = new ArrayList<>(); recurseFindSubProcessId(processDefinitionId, ids); return ids.size() + 1; } /** * recursive query sub process definition id by parent id. * * @param parentId parentId * @param ids ids */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
public void recurseFindSubProcessId(int parentId, List<Integer> ids) { ProcessDefinition processDefinition = processDefineMapper.selectById(parentId); String processDefinitionJson = processDefinition.getProcessDefinitionJson(); ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); List<TaskNode> taskNodeList = processData.getTasks(); if (taskNodeList != null && !taskNodeList.isEmpty()) { for (TaskNode taskNode : taskNodeList) { String parameter = taskNode.getParams(); ObjectNode parameterJson = JSONUtils.parseObject(parameter); if (parameterJson.get(CMD_PARAM_SUB_PROCESS_DEFINE_ID) != null) { SubProcessParameters subProcessParam = JSONUtils.parseObject(parameter, SubProcessParameters.class); ids.add(subProcessParam.getProcessDefinitionId()); recurseFindSubProcessId(subProcessParam.getProcessDefinitionId(), ids); } } } } /** * create recovery waiting thread command when thread pool is not enough for the process instance. * sub work process instance need not to create recovery command. * create recovery waiting thread command and delete origin command at the same time. * if the recovery command is exists, only update the field update_time * * @param originCommand originCommand * @param processInstance processInstance */ public void createRecoveryWaitingThreadCommand(Command originCommand, ProcessInstance processInstance) { if (processInstance.getIsSubProcess() == Flag.YES) { if (originCommand != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
commandMapper.deleteById(originCommand.getId()); } return; } Map<String, String> cmdParam = new HashMap<>(); cmdParam.put(Constants.CMD_PARAM_RECOVERY_WAITING_THREAD, String.valueOf(processInstance.getId())); if (originCommand == null) { Command command = new Command( CommandType.RECOVER_WAITTING_THREAD, processInstance.getTaskDependType(), processInstance.getFailureStrategy(), processInstance.getExecutorId(), processInstance.getProcessDefinitionId(), JSONUtils.toJsonString(cmdParam), processInstance.getWarningType(), processInstance.getWarningGroupId(), processInstance.getScheduleTime(), processInstance.getWorkerGroup(), processInstance.getProcessInstancePriority() ); saveCommand(command); return; } if (originCommand.getCommandType() == CommandType.RECOVER_WAITTING_THREAD) { originCommand.setUpdateTime(new Date()); saveCommand(originCommand); } else {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
commandMapper.deleteById(originCommand.getId()); originCommand.setId(0); originCommand.setCommandType(CommandType.RECOVER_WAITTING_THREAD); originCommand.setUpdateTime(new Date()); originCommand.setCommandParam(JSONUtils.toJsonString(cmdParam)); originCommand.setProcessInstancePriority(processInstance.getProcessInstancePriority()); saveCommand(originCommand); } } /** * get schedule time from command * * @param command command * @param cmdParam cmdParam map * @return date */ private Date getScheduleTime(Command command, Map<String, String> cmdParam) { Date scheduleTime = command.getScheduleTime(); if (scheduleTime == null && cmdParam != null && cmdParam.containsKey(CMDPARAM_COMPLEMENT_DATA_START_DATE)) { scheduleTime = DateUtils.stringToDate(cmdParam.get(CMDPARAM_COMPLEMENT_DATA_START_DATE)); } return scheduleTime; } /** * generate a new work process instance from command. * * @param processDefinition processDefinition * @param command command * @param cmdParam cmdParam map * @return process instance
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
*/ private ProcessInstance generateNewProcessInstance(ProcessDefinition processDefinition, Command command, Map<String, String> cmdParam) { ProcessInstance processInstance = new ProcessInstance(processDefinition); processInstance.setState(ExecutionStatus.RUNNING_EXECUTION); processInstance.setRecovery(Flag.NO); processInstance.setStartTime(new Date()); processInstance.setRunTimes(1); processInstance.setMaxTryTimes(0); processInstance.setProcessDefinitionId(command.getProcessDefinitionId()); processInstance.setCommandParam(command.getCommandParam()); processInstance.setCommandType(command.getCommandType()); processInstance.setIsSubProcess(Flag.NO); processInstance.setTaskDependType(command.getTaskDependType()); processInstance.setFailureStrategy(command.getFailureStrategy()); processInstance.setExecutorId(command.getExecutorId()); WarningType warningType = command.getWarningType() == null ? WarningType.NONE : command.getWarningType(); processInstance.setWarningType(warningType); Integer warningGroupId = command.getWarningGroupId() == null ? 0 : command.getWarningGroupId(); processInstance.setWarningGroupId(warningGroupId); Date scheduleTime = getScheduleTime(command, cmdParam); if (scheduleTime != null) { processInstance.setScheduleTime(scheduleTime); } processInstance.setCommandStartTime(command.getStartTime()); processInstance.setLocations(processDefinition.getLocations()); processInstance.setConnects(processDefinition.getConnects());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
Map<String, String> startParamMap = null; if (cmdParam != null && cmdParam.containsKey(Constants.CMD_PARAM_START_PARAMS)) { String startParamJson = cmdParam.get(Constants.CMD_PARAM_START_PARAMS); startParamMap = JSONUtils.toMap(startParamJson); } if (startParamMap != null && startParamMap.size() > 0 && processDefinition.getGlobalParamMap() != null) { for (Map.Entry<String, String> param : processDefinition.getGlobalParamMap().entrySet()) { String val = startParamMap.get(param.getKey()); if (val != null) { param.setValue(val); } } } processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( processDefinition.getGlobalParamMap(), processDefinition.getGlobalParamList(), getCommandTypeIfComplement(processInstance, command), processInstance.getScheduleTime())); processInstance.setProcessInstanceJson(processDefinition.getProcessDefinitionJson()); processInstance.setProcessInstancePriority(command.getProcessInstancePriority()); String workerGroup = StringUtils.isBlank(command.getWorkerGroup()) ? Constants.DEFAULT_WORKER_GROUP : command.getWorkerGroup(); processInstance.setWorkerGroup(workerGroup); processInstance.setTimeout(processDefinition.getTimeout()); processInstance.setTenantId(processDefinition.getTenantId()); return processInstance;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} /** * get process tenant * there is tenant id in definition, use the tenant of the definition. * if there is not tenant id in the definiton or the tenant not exist * use definition creator's tenant. * * @param tenantId tenantId * @param userId userId * @return tenant */ public Tenant getTenantForProcess(int tenantId, int userId) { Tenant tenant = null; if (tenantId >= 0) { tenant = tenantMapper.queryById(tenantId); } if (userId == 0) { return null; } if (tenant == null) { User user = userMapper.selectById(userId); tenant = tenantMapper.queryById(user.getTenantId()); } return tenant; } /** * check command parameters is valid * * @param command command * @param cmdParam cmdParam map
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* @return whether command param is valid */ private Boolean checkCmdParam(Command command, Map<String, String> cmdParam) { if (command.getTaskDependType() == TaskDependType.TASK_ONLY || command.getTaskDependType() == TaskDependType.TASK_PRE) { if (cmdParam == null || !cmdParam.containsKey(Constants.CMD_PARAM_START_NODE_NAMES) || cmdParam.get(Constants.CMD_PARAM_START_NODE_NAMES).isEmpty()) { logger.error("command node depend type is {}, but start nodes is null ", command.getTaskDependType()); return false; } } return true; } /** * construct process instance according to one command. * * @param command command * @param host host * @return process instance */ private ProcessInstance constructProcessInstance(Command command, String host) { ProcessInstance processInstance = null; CommandType commandType = command.getCommandType(); Map<String, String> cmdParam = JSONUtils.toMap(command.getCommandParam()); ProcessDefinition processDefinition = null; if (command.getProcessDefinitionId() != 0) { processDefinition = processDefineMapper.selectById(command.getProcessDefinitionId()); if (processDefinition == null) { logger.error("cannot find the work process define! define id : {}", command.getProcessDefinitionId()); return null;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} } if (cmdParam != null) { Integer processInstanceId = 0; if (cmdParam.containsKey(Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING)) { String processId = cmdParam.get(Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING); processInstanceId = Integer.parseInt(processId); if (processInstanceId == 0) { logger.error("command parameter is error, [ ProcessInstanceId ] is 0"); return null; } } else if (cmdParam.containsKey(Constants.CMD_PARAM_SUB_PROCESS)) { String pId = cmdParam.get(Constants.CMD_PARAM_SUB_PROCESS); processInstanceId = Integer.parseInt(pId); } else if (cmdParam.containsKey(Constants.CMD_PARAM_RECOVERY_WAITING_THREAD)) { String pId = cmdParam.get(Constants.CMD_PARAM_RECOVERY_WAITING_THREAD); processInstanceId = Integer.parseInt(pId); } if (processInstanceId == 0) { processInstance = generateNewProcessInstance(processDefinition, command, cmdParam); } else { processInstance = this.findProcessInstanceDetailById(processInstanceId); processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( processDefinition.getGlobalParamMap(), processDefinition.getGlobalParamList(), getCommandTypeIfComplement(processInstance, command),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
processInstance.getScheduleTime())); } processDefinition = processDefineMapper.selectById(processInstance.getProcessDefinitionId()); processInstance.setProcessDefinition(processDefinition); if (processInstance.getCommandParam() != null) { Map<String, String> processCmdParam = JSONUtils.toMap(processInstance.getCommandParam()); for (Map.Entry<String, String> entry : processCmdParam.entrySet()) { if (!cmdParam.containsKey(entry.getKey())) { cmdParam.put(entry.getKey(), entry.getValue()); } } } if (cmdParam.containsKey(Constants.CMD_PARAM_SUB_PROCESS)) { processInstance.setCommandParam(command.getCommandParam()); } } else { processInstance = generateNewProcessInstance(processDefinition, command, cmdParam); } if (Boolean.FALSE.equals(checkCmdParam(command, cmdParam))) { logger.error("command parameter check failed!"); return null; } if (command.getScheduleTime() != null) { processInstance.setScheduleTime(command.getScheduleTime()); } processInstance.setHost(host); ExecutionStatus runStatus = ExecutionStatus.RUNNING_EXECUTION;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
int runTime = processInstance.getRunTimes(); switch (commandType) { case START_PROCESS: break; case START_FAILURE_TASK_PROCESS: List<Integer> failedList = this.findTaskIdByInstanceState(processInstance.getId(), ExecutionStatus.FAILURE); List<Integer> toleranceList = this.findTaskIdByInstanceState(processInstance.getId(), ExecutionStatus.NEED_FAULT_TOLERANCE); List<Integer> killedList = this.findTaskIdByInstanceState(processInstance.getId(), ExecutionStatus.KILL); cmdParam.remove(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING); failedList.addAll(killedList); failedList.addAll(toleranceList); for (Integer taskId : failedList) { initTaskInstance(this.findTaskInstanceById(taskId)); } cmdParam.put(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING, String.join(Constants.COMMA, convertIntListToString(failedList))); processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); processInstance.setRunTimes(runTime + 1); break; case START_CURRENT_TASK_PROCESS: break; case RECOVER_WAITTING_THREAD: break; case RECOVER_SUSPENDED_PROCESS: cmdParam.remove(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING); List<Integer> suspendedNodeList = this.findTaskIdByInstanceState(processInstance.getId(), ExecutionStatus.PAUSE); List<Integer> stopNodeList = findTaskIdByInstanceState(processInstance.getId(), ExecutionStatus.KILL);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
suspendedNodeList.addAll(stopNodeList); for (Integer taskId : suspendedNodeList) { initTaskInstance(this.findTaskInstanceById(taskId)); } cmdParam.put(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING, String.join(",", convertIntListToString(suspendedNodeList))); processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); processInstance.setRunTimes(runTime + 1); break; case RECOVER_TOLERANCE_FAULT_PROCESS: processInstance.setRecovery(Flag.YES); runStatus = processInstance.getState(); break; case COMPLEMENT_DATA: List<TaskInstance> taskInstanceList = this.findValidTaskListByProcessId(processInstance.getId()); for (TaskInstance taskInstance : taskInstanceList) { taskInstance.setFlag(Flag.NO); this.updateTaskInstance(taskInstance); } initComplementDataParam(processDefinition, processInstance, cmdParam); break; case REPEAT_RUNNING: if (cmdParam.containsKey(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING)) { cmdParam.remove(Constants.CMD_PARAM_RECOVERY_START_NODE_STRING); processInstance.setCommandParam(JSONUtils.toJsonString(cmdParam)); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
List<TaskInstance> validTaskList = findValidTaskListByProcessId(processInstance.getId()); for (TaskInstance taskInstance : validTaskList) { taskInstance.setFlag(Flag.NO); updateTaskInstance(taskInstance); } processInstance.setStartTime(new Date()); processInstance.setEndTime(null); processInstance.setRunTimes(runTime + 1); initComplementDataParam(processDefinition, processInstance, cmdParam); break; case SCHEDULER: break; default: break; } processInstance.setState(runStatus); return processInstance; } /** * return complement data if the process start with complement data * * @param processInstance processInstance * @param command command * @return command type */ private CommandType getCommandTypeIfComplement(ProcessInstance processInstance, Command command) { if (CommandType.COMPLEMENT_DATA == processInstance.getCmdTypeIfComplement()) { return CommandType.COMPLEMENT_DATA; } else { return command.getCommandType();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} } /** * initialize complement data parameters * * @param processDefinition processDefinition * @param processInstance processInstance * @param cmdParam cmdParam */ private void initComplementDataParam(ProcessDefinition processDefinition, ProcessInstance processInstance, Map<String, String> cmdParam) { if (!processInstance.isComplementData()) { return; } Date startComplementTime = DateUtils.parse(cmdParam.get(CMDPARAM_COMPLEMENT_DATA_START_DATE), YYYY_MM_DD_HH_MM_SS); if (Flag.NO == processInstance.getIsSubProcess()) { processInstance.setScheduleTime(startComplementTime); } processInstance.setGlobalParams(ParameterUtils.curingGlobalParams( processDefinition.getGlobalParamMap(), processDefinition.getGlobalParamList(), CommandType.COMPLEMENT_DATA, processInstance.getScheduleTime())); } /** * set sub work process parameters. * handle sub work process instance, update relation table and command parameters * set sub work process flag, extends parent work process command parameters *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* @param subProcessInstance subProcessInstance * @return process instance */ public ProcessInstance setSubProcessParam(ProcessInstance subProcessInstance) { String cmdParam = subProcessInstance.getCommandParam(); if (StringUtils.isEmpty(cmdParam)) { return subProcessInstance; } Map<String, String> paramMap = JSONUtils.toMap(cmdParam); if (paramMap.containsKey(CMD_PARAM_SUB_PROCESS) && CMD_PARAM_EMPTY_SUB_PROCESS.equals(paramMap.get(CMD_PARAM_SUB_PROCESS))) { paramMap.remove(CMD_PARAM_SUB_PROCESS); paramMap.put(CMD_PARAM_SUB_PROCESS, String.valueOf(subProcessInstance.getId())); subProcessInstance.setCommandParam(JSONUtils.toJsonString(paramMap)); subProcessInstance.setIsSubProcess(Flag.YES); this.saveProcessInstance(subProcessInstance); } String parentInstanceId = paramMap.get(CMD_PARAM_SUB_PROCESS_PARENT_INSTANCE_ID); if (StringUtils.isNotEmpty(parentInstanceId)) { ProcessInstance parentInstance = findProcessInstanceDetailById(Integer.parseInt(parentInstanceId)); if (parentInstance != null) { subProcessInstance.setGlobalParams( joinGlobalParams(parentInstance.getGlobalParams(), subProcessInstance.getGlobalParams())); this.saveProcessInstance(subProcessInstance); } else { logger.error("sub process command params error, cannot find parent instance: {} ", cmdParam); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
ProcessInstanceMap processInstanceMap = JSONUtils.parseObject(cmdParam, ProcessInstanceMap.class); if (processInstanceMap == null || processInstanceMap.getParentProcessInstanceId() == 0) { return subProcessInstance; } processInstanceMap.setProcessInstanceId(subProcessInstance.getId()); this.updateWorkProcessInstanceMap(processInstanceMap); return subProcessInstance; } /** * join parent global params into sub process. * only the keys doesn't in sub process global would be joined. * * @param parentGlobalParams parentGlobalParams * @param subGlobalParams subGlobalParams * @return global params join */ private String joinGlobalParams(String parentGlobalParams, String subGlobalParams) { List<Property> parentPropertyList = JSONUtils.toList(parentGlobalParams, Property.class); List<Property> subPropertyList = JSONUtils.toList(subGlobalParams, Property.class); Map<String, String> subMap = subPropertyList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); for (Property parent : parentPropertyList) { if (!subMap.containsKey(parent.getProp())) { subPropertyList.add(parent); } } return JSONUtils.toJsonString(subPropertyList); } /** * initialize task instance
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* * @param taskInstance taskInstance */ private void initTaskInstance(TaskInstance taskInstance) { if (!taskInstance.isSubProcess() && (taskInstance.getState().typeIsCancel() || taskInstance.getState().typeIsFailure())) { taskInstance.setFlag(Flag.NO); updateTaskInstance(taskInstance); return; } taskInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS); updateTaskInstance(taskInstance); } /** * submit task to db * submit sub process to command * * @param taskInstance taskInstance * @return task instance */ @Transactional(rollbackFor = Exception.class) public TaskInstance submitTask(TaskInstance taskInstance) { ProcessInstance processInstance = this.findProcessInstanceDetailById(taskInstance.getProcessInstanceId()); logger.info("start submit task : {}, instance id:{}, state: {}", taskInstance.getName(), taskInstance.getProcessInstanceId(), processInstance.getState()); TaskInstance task = submitTaskInstanceToDB(taskInstance, processInstance); if (task == null) { logger.error("end submit task to db error, task name:{}, process id:{} state: {} ", taskInstance.getName(), taskInstance.getProcessInstance(), processInstance.getState());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return task; } if (!task.getState().typeIsFinished()) { createSubWorkProcess(processInstance, task); } logger.info("end submit task to db successfully:{} state:{} complete, instance id:{} state: {} ", taskInstance.getName(), task.getState(), processInstance.getId(), processInstance.getState()); return task; } /** * set work process instance map * consider o * repeat running does not generate new sub process instance * set map {parent instance id, task instance id, 0(child instance id)} * * @param parentInstance parentInstance * @param parentTask parentTask * @return process instance map */ private ProcessInstanceMap setProcessInstanceMap(ProcessInstance parentInstance, TaskInstance parentTask) { ProcessInstanceMap processMap = findWorkProcessMapByParent(parentInstance.getId(), parentTask.getId()); if (processMap != null) { return processMap; } if (parentInstance.getCommandType() == CommandType.REPEAT_RUNNING) { processMap = findPreviousTaskProcessMap(parentInstance, parentTask); if (processMap != null) { processMap.setParentTaskInstanceId(parentTask.getId()); updateWorkProcessInstanceMap(processMap);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return processMap; } } processMap = new ProcessInstanceMap(); processMap.setParentProcessInstanceId(parentInstance.getId()); processMap.setParentTaskInstanceId(parentTask.getId()); createWorkProcessInstanceMap(processMap); return processMap; } /** * find previous task work process map. * * @param parentProcessInstance parentProcessInstance * @param parentTask parentTask * @return process instance map */ private ProcessInstanceMap findPreviousTaskProcessMap(ProcessInstance parentProcessInstance, TaskInstance parentTask) { Integer preTaskId = 0; List<TaskInstance> preTaskList = this.findPreviousTaskListByWorkProcessId(parentProcessInstance.getId()); for (TaskInstance task : preTaskList) { if (task.getName().equals(parentTask.getName())) { preTaskId = task.getId(); ProcessInstanceMap map = findWorkProcessMapByParent(parentProcessInstance.getId(), preTaskId); if (map != null) { return map; } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
logger.info("sub process instance is not found,parent task:{},parent instance:{}", parentTask.getId(), parentProcessInstance.getId()); return null; } /** * create sub work process command * * @param parentProcessInstance parentProcessInstance * @param task task */ public void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task) { if (!task.isSubProcess()) { return; } ProcessInstanceMap instanceMap = findWorkProcessMapByParent(parentProcessInstance.getId(), task.getId()); if (null != instanceMap && CommandType.RECOVER_TOLERANCE_FAULT_PROCESS == parentProcessInstance.getCommandType()) { return; } instanceMap = setProcessInstanceMap(parentProcessInstance, task); ProcessInstance childInstance = null; if (instanceMap.getProcessInstanceId() != 0) { childInstance = findProcessInstanceById(instanceMap.getProcessInstanceId()); } Command subProcessCommand = createSubProcessCommand(parentProcessInstance, childInstance, instanceMap, task); updateSubProcessDefinitionByParent(parentProcessInstance, subProcessCommand.getProcessDefinitionId()); initSubInstanceState(childInstance); createCommand(subProcessCommand); logger.info("sub process command created: {} ", subProcessCommand);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} /** * complement data needs transform parent parameter to child. */ private String getSubWorkFlowParam(ProcessInstanceMap instanceMap, ProcessInstance parentProcessInstance) { String processMapStr = JSONUtils.toJsonString(instanceMap); Map<String, String> cmdParam = JSONUtils.toMap(processMapStr); if (parentProcessInstance.isComplementData()) { Map<String, String> parentParam = JSONUtils.toMap(parentProcessInstance.getCommandParam()); String endTime = parentParam.get(CMDPARAM_COMPLEMENT_DATA_END_DATE); String startTime = parentParam.get(CMDPARAM_COMPLEMENT_DATA_START_DATE); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_END_DATE, endTime); cmdParam.put(CMDPARAM_COMPLEMENT_DATA_START_DATE, startTime); processMapStr = JSONUtils.toJsonString(cmdParam); } return processMapStr; } /** * create sub work process command */ public Command createSubProcessCommand(ProcessInstance parentProcessInstance, ProcessInstance childInstance, ProcessInstanceMap instanceMap, TaskInstance task) { CommandType commandType = getSubCommandType(parentProcessInstance, childInstance); TaskNode taskNode = JSONUtils.parseObject(task.getTaskJson(), TaskNode.class); Map<String, String> subProcessParam = JSONUtils.toMap(taskNode.getParams()); Integer childDefineId = Integer.parseInt(subProcessParam.get(Constants.CMD_PARAM_SUB_PROCESS_DEFINE_ID)); String processParam = getSubWorkFlowParam(instanceMap, parentProcessInstance);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return new Command( commandType, TaskDependType.TASK_POST, parentProcessInstance.getFailureStrategy(), parentProcessInstance.getExecutorId(), childDefineId, processParam, parentProcessInstance.getWarningType(), parentProcessInstance.getWarningGroupId(), parentProcessInstance.getScheduleTime(), task.getWorkerGroup(), parentProcessInstance.getProcessInstancePriority() ); } /** * initialize sub work flow state * child instance state would be initialized when 'recovery from pause/stop/failure' */ private void initSubInstanceState(ProcessInstance childInstance) { if (childInstance != null) { childInstance.setState(ExecutionStatus.RUNNING_EXECUTION); updateProcessInstance(childInstance); } } /** * get sub work flow command type * child instance exist: child command = fatherCommand * child instance not exists: child command = fatherCommand[0] */ private CommandType getSubCommandType(ProcessInstance parentProcessInstance, ProcessInstance childInstance) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
CommandType commandType = parentProcessInstance.getCommandType(); if (childInstance == null) { String fatherHistoryCommand = parentProcessInstance.getHistoryCmd(); commandType = CommandType.valueOf(fatherHistoryCommand.split(Constants.COMMA)[0]); } return commandType; } /** * update sub process definition * * @param parentProcessInstance parentProcessInstance * @param childDefinitionId childDefinitionId */ private void updateSubProcessDefinitionByParent(ProcessInstance parentProcessInstance, int childDefinitionId) { ProcessDefinition fatherDefinition = this.findProcessDefineById(parentProcessInstance.getProcessDefinitionId()); ProcessDefinition childDefinition = this.findProcessDefineById(childDefinitionId); if (childDefinition != null && fatherDefinition != null) { childDefinition.setWarningGroupId(fatherDefinition.getWarningGroupId()); processDefineMapper.updateById(childDefinition); } } /** * submit task to mysql * * @param taskInstance taskInstance * @param processInstance processInstance * @return task instance */ public TaskInstance submitTaskInstanceToDB(TaskInstance taskInstance, ProcessInstance processInstance) { ExecutionStatus processInstanceState = processInstance.getState();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
if (taskInstance.getState().typeIsFailure()) { if (taskInstance.isSubProcess()) { taskInstance.setRetryTimes(taskInstance.getRetryTimes() + 1); } else { if (processInstanceState != ExecutionStatus.READY_STOP && processInstanceState != ExecutionStatus.READY_PAUSE) { taskInstance.setFlag(Flag.NO); updateTaskInstance(taskInstance); if (taskInstance.getState() != ExecutionStatus.NEED_FAULT_TOLERANCE) { taskInstance.setRetryTimes(taskInstance.getRetryTimes() + 1); } taskInstance.setSubmitTime(null); taskInstance.setStartTime(null); taskInstance.setEndTime(null); taskInstance.setFlag(Flag.YES); taskInstance.setHost(null); taskInstance.setId(0); } } } taskInstance.setExecutorId(processInstance.getExecutorId()); taskInstance.setProcessInstancePriority(processInstance.getProcessInstancePriority()); taskInstance.setState(getSubmitTaskState(taskInstance, processInstanceState)); if (taskInstance.getSubmitTime() == null) { taskInstance.setSubmitTime(new Date()); } if (taskInstance.getFirstSubmitTime() == null) { taskInstance.setFirstSubmitTime(taskInstance.getSubmitTime());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} boolean saveResult = saveTaskInstance(taskInstance); if (!saveResult) { return null; } return taskInstance; } /** * get submit task instance state by the work process state * cannot modify the task state when running/kill/submit success, or this * task instance is already exists in task queue . * return pause if work process state is ready pause * return stop if work process state is ready stop * if all of above are not satisfied, return submit success * * @param taskInstance taskInstance * @param processInstanceState processInstanceState * @return process instance state */ public ExecutionStatus getSubmitTaskState(TaskInstance taskInstance, ExecutionStatus processInstanceState) { ExecutionStatus state = taskInstance.getState(); if ( state == ExecutionStatus.RUNNING_EXECUTION || state == ExecutionStatus.DELAY_EXECUTION || state == ExecutionStatus.KILL ) { return state;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} if (processInstanceState == ExecutionStatus.READY_PAUSE) { state = ExecutionStatus.PAUSE; } else if (processInstanceState == ExecutionStatus.READY_STOP || !checkProcessStrategy(taskInstance)) { state = ExecutionStatus.KILL; } else { state = ExecutionStatus.SUBMITTED_SUCCESS; } return state; } /** * check process instance strategy * * @param taskInstance taskInstance * @return check strategy result */ private boolean checkProcessStrategy(TaskInstance taskInstance) { ProcessInstance processInstance = this.findProcessInstanceById(taskInstance.getProcessInstanceId()); FailureStrategy failureStrategy = processInstance.getFailureStrategy(); if (failureStrategy == FailureStrategy.CONTINUE) { return true; } List<TaskInstance> taskInstances = this.findValidTaskListByProcessId(taskInstance.getProcessInstanceId()); for (TaskInstance task : taskInstances) { if (task.getState() == ExecutionStatus.FAILURE) { return false; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} return true; } /** * create a new process instance * * @param processInstance processInstance */ public void createProcessInstance(ProcessInstance processInstance) { if (processInstance != null) { processInstanceMapper.insert(processInstance); } } /** * insert or update work process instance to data base * * @param processInstance processInstance */ public void saveProcessInstance(ProcessInstance processInstance) { if (processInstance == null) { logger.error("save error, process instance is null!"); return; } if (processInstance.getId() != 0) { processInstanceMapper.updateById(processInstance); } else { createProcessInstance(processInstance); } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* insert or update command * * @param command command * @return save command result */ public int saveCommand(Command command) { if (command.getId() != 0) { return commandMapper.updateById(command); } else { return commandMapper.insert(command); } } /** * insert or update task instance * * @param taskInstance taskInstance * @return save task instance result */ public boolean saveTaskInstance(TaskInstance taskInstance) { if (taskInstance.getId() != 0) { return updateTaskInstance(taskInstance); } else { return createTaskInstance(taskInstance); } } /** * insert task instance * * @param taskInstance taskInstance * @return create task instance result
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
*/ public boolean createTaskInstance(TaskInstance taskInstance) { int count = taskInstanceMapper.insert(taskInstance); return count > 0; } /** * update task instance * * @param taskInstance taskInstance * @return update task instance result */ public boolean updateTaskInstance(TaskInstance taskInstance) { int count = taskInstanceMapper.updateById(taskInstance); return count > 0; } /** * delete a command by id * * @param id id */ public void delCommandById(int id) { commandMapper.deleteById(id); } /** * find task instance by id * * @param taskId task id * @return task intance */ public TaskInstance findTaskInstanceById(Integer taskId) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return taskInstanceMapper.selectById(taskId); } /** * package task instance,associate processInstance and processDefine * * @param taskInstId taskInstId * @return task instance */ public TaskInstance getTaskInstanceDetailByTaskId(int taskInstId) { // TaskInstance taskInstance = findTaskInstanceById(taskInstId); if (taskInstance == null) { return taskInstance; } // ProcessInstance processInstance = findProcessInstanceDetailById(taskInstance.getProcessInstanceId()); // ProcessDefinition processDefine = findProcessDefineById(taskInstance.getProcessDefinitionId()); taskInstance.setProcessInstance(processInstance); taskInstance.setProcessDefine(processDefine); return taskInstance; } /** * get id list by task state * * @param instanceId instanceId * @param state state * @return task instance states */ public List<Integer> findTaskIdByInstanceState(int instanceId, ExecutionStatus state) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return taskInstanceMapper.queryTaskByProcessIdAndState(instanceId, state.ordinal()); } /** * find valid task list by process definition id * * @param processInstanceId processInstanceId * @return task instance list */ public List<TaskInstance> findValidTaskListByProcessId(Integer processInstanceId) { return taskInstanceMapper.findValidTaskListByProcessId(processInstanceId, Flag.YES); } /** * find previous task list by work process id * * @param processInstanceId processInstanceId * @return task instance list */ public List<TaskInstance> findPreviousTaskListByWorkProcessId(Integer processInstanceId) { return taskInstanceMapper.findValidTaskListByProcessId(processInstanceId, Flag.NO); } /** * update work process instance map * * @param processInstanceMap processInstanceMap * @return update process instance result */ public int updateWorkProcessInstanceMap(ProcessInstanceMap processInstanceMap) { return processInstanceMapMapper.updateById(processInstanceMap); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* create work process instance map * * @param processInstanceMap processInstanceMap * @return create process instance result */ public int createWorkProcessInstanceMap(ProcessInstanceMap processInstanceMap) { int count = 0; if (processInstanceMap != null) { return processInstanceMapMapper.insert(processInstanceMap); } return count; } /** * find work process map by parent process id and parent task id. * * @param parentWorkProcessId parentWorkProcessId * @param parentTaskId parentTaskId * @return process instance map */ public ProcessInstanceMap findWorkProcessMapByParent(Integer parentWorkProcessId, Integer parentTaskId) { return processInstanceMapMapper.queryByParentId(parentWorkProcessId, parentTaskId); } /** * delete work process map by parent process id * * @param parentWorkProcessId parentWorkProcessId * @return delete process map result */ public int deleteWorkProcessMapByParentId(int parentWorkProcessId) { return processInstanceMapMapper.deleteByParentProcessId(parentWorkProcessId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
} /** * find sub process instance * * @param parentProcessId parentProcessId * @param parentTaskId parentTaskId * @return process instance */ public ProcessInstance findSubProcessInstance(Integer parentProcessId, Integer parentTaskId) { ProcessInstance processInstance = null; ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryByParentId(parentProcessId, parentTaskId); if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) { return processInstance; } processInstance = findProcessInstanceById(processInstanceMap.getProcessInstanceId()); return processInstance; } /** * find parent process instance * * @param subProcessId subProcessId * @return process instance */ public ProcessInstance findParentProcessInstance(Integer subProcessId) { ProcessInstance processInstance = null; ProcessInstanceMap processInstanceMap = processInstanceMapMapper.queryBySubProcessId(subProcessId); if (processInstanceMap == null || processInstanceMap.getProcessInstanceId() == 0) { return processInstance; } processInstance = findProcessInstanceById(processInstanceMap.getParentProcessInstanceId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return processInstance; } /** * change task state * * @param state state * @param startTime startTime * @param host host * @param executePath executePath * @param logPath logPath * @param taskInstId taskInstId */ public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, Date startTime, String host, String executePath, String logPath, int taskInstId) { taskInstance.setState(state); taskInstance.setStartTime(startTime); taskInstance.setHost(host); taskInstance.setExecutePath(executePath); taskInstance.setLogPath(logPath); saveTaskInstance(taskInstance); } /** * update process instance * * @param processInstance processInstance * @return update process instance result */ public int updateProcessInstance(ProcessInstance processInstance) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return processInstanceMapper.updateById(processInstance); } /** * update the process instance * * @param processInstanceId processInstanceId * @param processJson processJson * @param globalParams globalParams * @param scheduleTime scheduleTime * @param flag flag * @param locations locations * @param connects connects * @return update process instance result */ public int updateProcessInstance(Integer processInstanceId, String processJson, String globalParams, Date scheduleTime, Flag flag, String locations, String connects) { ProcessInstance processInstance = processInstanceMapper.queryDetailById(processInstanceId); if (processInstance != null) { processInstance.setProcessInstanceJson(processJson); processInstance.setGlobalParams(globalParams); processInstance.setScheduleTime(scheduleTime); processInstance.setLocations(locations); processInstance.setConnects(connects); return processInstanceMapper.updateById(processInstance); } return 0; } /** * change task state
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
* * @param state state * @param endTime endTime * @param taskInstId taskInstId * @param varPool varPool */ public void changeTaskState(TaskInstance taskInstance, ExecutionStatus state, Date endTime, int processId, String appIds, int taskInstId, String varPool) { taskInstance.setPid(processId); taskInstance.setAppLink(appIds); taskInstance.setState(state); taskInstance.setEndTime(endTime); taskInstance.setVarPool(varPool); saveTaskInstance(taskInstance); } /** * convert integer list to string list * * @param intList intList * @return string list */ public List<String> convertIntListToString(List<Integer> intList) { if (intList == null) { return new ArrayList<>(); } List<String> result = new ArrayList<>(intList.size());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
for (Integer intVar : intList) { result.add(String.valueOf(intVar)); } return result; } /** * query schedule by id * * @param id id * @return schedule */ public Schedule querySchedule(int id) { return scheduleMapper.selectById(id); } /** * query Schedule by processDefinitionId * * @param processDefinitionId processDefinitionId * @see Schedule */ public List<Schedule> queryReleaseSchedulerListByProcessDefinitionId(int processDefinitionId) { return scheduleMapper.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId); } /** * query need failover process instance * * @param host host * @return process instance list */ public List<ProcessInstance> queryNeedFailoverProcessInstances(String host) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return processInstanceMapper.queryByHostAndStatus(host, stateArray); } /** * process need failover process instance * * @param processInstance processInstance */ @Transactional(rollbackFor = RuntimeException.class) public void processNeedFailoverProcessInstances(ProcessInstance processInstance) { // processInstance.setHost(Constants.NULL); processInstanceMapper.updateById(processInstance); // Command cmd = new Command(); cmd.setProcessDefinitionId(processInstance.getProcessDefinitionId()); cmd.setCommandParam(String.format("{\"%s\":%d}", Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING, processInstance.getId())); cmd.setExecutorId(processInstance.getExecutorId()); cmd.setCommandType(CommandType.RECOVER_TOLERANCE_FAULT_PROCESS); createCommand(cmd); } /** * query all need failover task instances by host * * @param host host * @return task instance list */ public List<TaskInstance> queryNeedFailoverTaskInstances(String host) { return taskInstanceMapper.queryByHostAndStatus(host, stateArray); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
/** * find data source by id * * @param id id * @return datasource */ public DataSource findDataSourceById(int id) { return dataSourceMapper.selectById(id); } /** * update process instance state by id * * @param processInstanceId processInstanceId * @param executionStatus executionStatus * @return update process result */ public int updateProcessInstanceState(Integer processInstanceId, ExecutionStatus executionStatus) { ProcessInstance instance = processInstanceMapper.selectById(processInstanceId); instance.setState(executionStatus); return processInstanceMapper.updateById(instance); } /** * find process instance by the task id * * @param taskId taskId * @return process instance */ public ProcessInstance findProcessInstanceByTaskId(int taskId) { TaskInstance taskInstance = taskInstanceMapper.selectById(taskId); if (taskInstance != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
3,369
[Improvement][api] Introduce interface about api module service
**Describe the question** Introduce interface about api module service for clearly service module. **What are the current deficiencies and the benefits of improvement** - A clear and concise service will help contributor or user to ready the code and locate the function. **Which version of DolphinScheduler:** -[dev] **Describe alternatives you've considered** Introduce service interface
https://github.com/apache/dolphinscheduler/issues/3369
https://github.com/apache/dolphinscheduler/pull/4759
9ae29a756f0aeed894c80f5e495d786ccf03f41f
15a5b0588399bbafd201405af02d611d548fac12
"2020-07-31T13:52:28Z"
java
"2021-02-18T15:27:37Z"
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
return processInstanceMapper.selectById(taskInstance.getProcessInstanceId()); } return null; } /** * find udf function list by id list string * * @param ids ids * @return udf function list */ public List<UdfFunc> queryUdfFunListByIds(int[] ids) { return udfFuncMapper.queryUdfByIdStr(ids, null); } /** * find tenant code by resource name * * @param resName resource name * @param resourceType resource type * @return tenant code */ public String queryTenantCodeByResName(String resName, ResourceType resourceType) { // String fullName = resName.startsWith("/") ? resName : String.format("/%s", resName); return resourceMapper.queryTenantCodeByResourceName(fullName, resourceType.ordinal()); } /** * find schedule list by process define id. * * @param ids ids * @return schedule list