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
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
connectionResult = new Result(Status.SUCCESS.getCode(), Status.SUCCESS.getMsg()); Mockito.when(dataSourceService.checkConnection(dataSourceType, connectionParam)).thenReturn(connectionResult); Result notValidError = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), notValidError.getCode().intValue()); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); Mockito.when(dataSourceService.checkConnection(dataSourceType, connectionParam)).thenReturn(connectionResult); Result success = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } public void updateDataSourceTest() { User loginUser = getAdminUser(); int dataSourceId = 12; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; PostgreSQLDataSourceParamDTO postgreSqlDatasourceParam = new PostgreSQLDataSourceParamDTO(); postgreSqlDatasourceParam.setDatabase(dataSourceName); postgreSqlDatasourceParam.setNote(dataSourceDesc); postgreSqlDatasourceParam.setHost("172.16.133.200"); postgreSqlDatasourceParam.setPort(5432); postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result resourceNotExits = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(), resourceNotExits.getCode().intValue()); DataSource dataSource = new DataSource();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
dataSource.setUserId(0); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Result userNoOperationPerm = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), userNoOperationPerm.getCode().intValue()); dataSource.setUserId(-1); List<DataSource> dataSourceList = new ArrayList<>(); dataSourceList.add(dataSource); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(dataSourceList); Result dataSourceNameExist = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceNameExist.getCode().intValue()); DbType dataSourceType = postgreSqlDatasourceParam.getType(); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(postgreSqlDatasourceParam); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(null); Result connectionResult = new Result(Status.SUCCESS.getCode(), Status.SUCCESS.getMsg()); Mockito.when(dataSourceService.checkConnection(dataSourceType, connectionParam)).thenReturn(connectionResult); Result connectFailed = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_CONNECT_FAILED.getCode(), connectFailed.getCode().intValue()); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(null); connectionResult = new Result(Status.DATASOURCE_CONNECT_FAILED.getCode(), Status.DATASOURCE_CONNECT_FAILED.getMsg()); Mockito.when(dataSourceService.checkConnection(dataSourceType, connectionParam)).thenReturn(connectionResult); Result success = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assertions.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } @Test public void queryDataSourceListPagingTest() { User loginUser = getAdminUser(); String searchVal = ""; int pageNo = 1; int pageSize = 10; Result result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode()); } @Test public void connectionTest() { int dataSourceId = -1; Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Result result = dataSourceService.connectionTest(dataSourceId); Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getCode(), result.getCode().intValue()); } @Test public void deleteTest() { User loginUser = getAdminUser(); int dataSourceId = 1; Result result = new Result(); dataSourceService.putMsg(result, Status.RESOURCE_NOT_EXIST); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(null); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.USER_NO_OPERATION_PERM); DataSource dataSource = new DataSource();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
dataSource.setUserId(0); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.SUCCESS); dataSource.setUserId(-1); loginUser.setUserType(UserType.ADMIN_USER); loginUser.setId(1); dataSource.setId(22); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), DATASOURCE_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, new Object[]{dataSource.getId()}, 0, baseServiceLogger)).thenReturn(true); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); } @Test public void unauthDatasourceTest() { User loginUser = getAdminUser(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, null, 0, baseServiceLogger)).thenReturn(true); Mockito.when(dataSourceMapper.queryAuthedDatasource(userId)).thenReturn(getSingleDataSourceList()); Mockito.when(dataSourceMapper.queryDatasourceExceptUserId(userId)).thenReturn(getDataSourceList()); Map<String, Object> result = dataSourceService.unauthDatasource(loginUser, userId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
logger.info(result.toString()); List<DataSource> dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources)); loginUser.setId(2); loginUser.setUserType(UserType.GENERAL_USER); Mockito.when(dataSourceMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId()))) .thenReturn(getDataSourceList()); result = dataSourceService.unauthDatasource(loginUser, userId); logger.info(result.toString()); dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources)); } @Test public void authedDatasourceTest() { User loginUser = getAdminUser(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(dataSourceMapper.queryAuthedDatasource(userId)).thenReturn(getSingleDataSourceList()); Map<String, Object> result = dataSourceService.authedDatasource(loginUser, userId); logger.info(result.toString()); List<DataSource> dataSources = (List<DataSource>) result.get(Constants.DATA_LIST); Assertions.assertTrue(CollectionUtils.isNotEmpty(dataSources)); loginUser.setId(2); loginUser.setUserType(UserType.GENERAL_USER); Map<String, Object> success = dataSourceService.authedDatasource(loginUser, userId); logger.info(result.toString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assertions.assertEquals(Status.SUCCESS, success.get(Constants.STATUS)); } @Test public void queryDataSourceListTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); Set<Integer> dataSourceIds = new HashSet<>(); dataSourceIds.add(1); Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), dataSourceServiceLogger)).thenReturn(dataSourceIds); DataSource dataSource = new DataSource(); dataSource.setType(DbType.MYSQL); Mockito.when(dataSourceMapper.selectBatchIds(dataSourceIds)).thenReturn(Collections.singletonList(dataSource)); Map<String, Object> map = dataSourceService.queryDataSourceList(loginUser, DbType.MYSQL.ordinal(), Constants.TEST_FLAG_NO); Assertions.assertEquals(Status.SUCCESS, map.get(Constants.STATUS)); } @Test public void verifyDataSourceNameTest() { User loginUser = new User(); loginUser.setUserType(UserType.GENERAL_USER); String dataSourceName = "dataSource1"; Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName)).thenReturn(getDataSourceList()); Result result = dataSourceService.verifyDataSourceName(dataSourceName); Assertions.assertEquals(Status.DATASOURCE_EXIST.getMsg(), result.getMsg()); } @Test public void queryDataSourceTest() { Mockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(null); Map<String, Object> result = dataSourceService.queryDataSource(Mockito.anyInt());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assertions.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.RESOURCE_NOT_EXIST.getCode()); Mockito.when(dataSourceMapper.selectById(Mockito.anyInt())).thenReturn(getOracleDataSource()); result = dataSourceService.queryDataSource(Mockito.anyInt()); Assertions.assertEquals(((Status) result.get(Constants.STATUS)).getCode(), Status.SUCCESS.getCode()); } private List<DataSource> getDataSourceList() { List<DataSource> dataSources = new ArrayList<>(); dataSources.add(getOracleDataSource(1)); dataSources.add(getOracleDataSource(2)); dataSources.add(getOracleDataSource(3)); return dataSources; } private List<DataSource> getSingleDataSourceList() { return Collections.singletonList(getOracleDataSource(3)); } 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; } private DataSource getOracleDataSource(int dataSourceId) { DataSource dataSource = new DataSource(); dataSource.setId(dataSourceId); dataSource.setName("test"); dataSource.setNote("Note");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
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() { OracleDataSourceParamDTO oracleDatasourceParamDTO = new OracleDataSourceParamDTO(); oracleDatasourceParamDTO.setHost("192.168.9.1"); oracleDatasourceParamDTO.setPort(1521); oracleDatasourceParamDTO.setDatabase("im"); oracleDatasourceParamDTO.setUserName("test"); oracleDatasourceParamDTO.setPassword("test"); oracleDatasourceParamDTO.setConnectType(DbConnectType.ORACLE_SERVICE_NAME); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(oracleDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:oracle:thin:@//192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:oracle:thin:@//192.168.9.1:1521/im\"," + "\"driverClassName\":\"oracle.jdbc.OracleDriver\",\"validationQuery\":\"select 1 from dual\",\"connectType\":\"ORACLE_SERVICE_NAME\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); try (MockedStatic<CommonUtils> mockedStaticCommonUtils = Mockito.mockStatic(CommonUtils.class)) { mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(true); HiveDataSourceParamDTO hiveDataSourceParamDTO = new HiveDataSourceParamDTO(); hiveDataSourceParamDTO.setHost("192.168.9.1"); hiveDataSourceParamDTO.setPort(10000); hiveDataSourceParamDTO.setDatabase("im"); hiveDataSourceParamDTO.setPrincipal("hive/[email protected]"); hiveDataSourceParamDTO.setUserName("test"); hiveDataSourceParamDTO.setPassword("test"); hiveDataSourceParamDTO.setJavaSecurityKrb5Conf("/opt/krb5.conf");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
hiveDataSourceParamDTO.setLoginUserKeytabPath("/opt/hdfs.headless.keytab"); hiveDataSourceParamDTO.setLoginUserKeytabUsername("test2/[email protected]"); connectionParam = DataSourceUtils.buildConnectionParams(hiveDataSourceParamDTO); expected = "{\"user\":\"test\",\"password\":\"test\",\"address\":\"jdbc:hive2://192.168.9.1:10000\",\"database\":\"im\"," + "\"jdbcUrl\":\"jdbc:hive2://192.168.9.1:10000/im\",\"driverClassName\":\"org.apache.hive.jdbc.HiveDriver\",\"validationQuery\":\"select 1\"," + "\"principal\":\"hive/[email protected]\",\"javaSecurityKrb5Conf\":\"/opt/krb5.conf\",\"loginUserKeytabUsername\":\"test2/[email protected]\"," + "\"loginUserKeytabPath\":\"/opt/hdfs.headless.keytab\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } } @Test public void buildParameterWithDecodePassword() { try (MockedStatic<PropertyUtils> mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class)) { mockedStaticPropertyUtils .when(() -> PropertyUtils.getBoolean(DataSourceConstants.DATASOURCE_ENCRYPTION_ENABLE, false)) .thenReturn(true); Map<String, String> other = new HashMap<>(); other.put("autoDeserialize", "yes"); other.put("allowUrlInLocalInfile", "true"); MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); mysqlDatasourceParamDTO.setHost("192.168.9.1"); mysqlDatasourceParamDTO.setPort(1521); mysqlDatasourceParamDTO.setDatabase("im"); mysqlDatasourceParamDTO.setUserName("test"); mysqlDatasourceParamDTO.setPassword("123456"); mysqlDatasourceParamDTO.setOther(other); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(mysqlDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"bnVsbE1USXpORFUy\",\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\",\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/"
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
+ "im\",\"driverClassName\":\"com.mysql.cj.jdbc.Driver\",\"validationQuery\":\"select 1\",\"props\":{\"autoDeserialize\":\"yes\",\"allowUrlInLocalInfile\":\"true\"}}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } MySQLDataSourceParamDTO mysqlDatasourceParamDTO = new MySQLDataSourceParamDTO(); mysqlDatasourceParamDTO.setHost("192.168.9.1"); mysqlDatasourceParamDTO.setPort(1521); mysqlDatasourceParamDTO.setDatabase("im"); mysqlDatasourceParamDTO.setUserName("test"); mysqlDatasourceParamDTO.setPassword("123456"); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(mysqlDatasourceParamDTO); String expected = "{\"user\":\"test\",\"password\":\"123456\",\"address\":\"jdbc:mysql://192.168.9.1:1521\",\"database\":\"im\"," + "\"jdbcUrl\":\"jdbc:mysql://192.168.9.1:1521/im\",\"driverClassName\":\"com.mysql.cj.jdbc.Driver\",\"validationQuery\":\"select 1\"}"; Assertions.assertEquals(expected, JSONUtils.toJsonString(connectionParam)); } /** * get Mock Admin User * * @return admin user */ private User getAdminUser() { User loginUser = new User(); loginUser.setId(-1); loginUser.setUserName("admin"); loginUser.setUserType(UserType.GENERAL_USER); return loginUser; } /** * test check connection */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,838
[Improvement][UT] Improve the ut of datasource
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of datasource ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12838
https://github.com/apache/dolphinscheduler/pull/12839
e3cf72cbcd022adb0527b5c22199a851b11be6bf
813c44b22b3561f4c32524781ef395892512aef8
2022-11-09T08:23:10Z
java
2022-11-14T03:30:10Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
@Test public void testCheckConnection() throws Exception { DbType dataSourceType = DbType.POSTGRESQL; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; PostgreSQLDataSourceParamDTO postgreSqlDatasourceParam = new PostgreSQLDataSourceParamDTO(); postgreSqlDatasourceParam.setDatabase(dataSourceName); postgreSqlDatasourceParam.setNote(dataSourceDesc); postgreSqlDatasourceParam.setHost("172.16.133.200"); postgreSqlDatasourceParam.setPort(5432); postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(postgreSqlDatasourceParam); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); Mockito.when(DataSourceClientProvider.getInstance()).thenReturn(clientProvider); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); Result result = dataSourceService.checkConnection(dataSourceType, connectionParam); Assertions.assertEquals(Status.CONNECTION_TEST_FAILURE.getCode(), result.getCode().intValue()); Connection connection = Mockito.mock(Connection.class); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(connection); result = dataSourceService.checkConnection(dataSourceType, connectionParam); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/PythonGatewayConfiguration.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.configuration; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.stereotype.Component; @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/PythonGatewayConfiguration.java
@EnableConfigurationProperties @ConfigurationProperties(value = "python-gateway", ignoreUnknownFields = false) public class PythonGatewayConfiguration { private boolean enabled; private String gatewayServerAddress; private int gatewayServerPort; private String pythonAddress; private int pythonPort; private int connectTimeout; private int readTimeout; public boolean getEnabled() { return enabled; } public void setEnabled(boolean enabled) { this.enabled = enabled; } public String getGatewayServerAddress() { return gatewayServerAddress; } public void setGatewayServerAddress(String gatewayServerAddress) { this.gatewayServerAddress = gatewayServerAddress; } public int getGatewayServerPort() { return gatewayServerPort;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/PythonGatewayConfiguration.java
} public void setGatewayServerPort(int gatewayServerPort) { this.gatewayServerPort = gatewayServerPort; } public String getPythonAddress() { return pythonAddress; } public void setPythonAddress(String pythonAddress) { this.pythonAddress = pythonAddress; } public int getPythonPort() { return pythonPort; } public void setPythonPort(int pythonPort) { this.pythonPort = pythonPort; } public int getConnectTimeout() { return connectTimeout; } public void setConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; } public int getReadTimeout() { return readTimeout; } public void setReadTimeout(int readTimeout) { this.readTimeout = readTimeout; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.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
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
package org.apache.dolphinscheduler.api.python; import org.apache.dolphinscheduler.api.configuration.PythonGatewayConfiguration; import org.apache.dolphinscheduler.api.dto.EnvironmentDto; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.EnvironmentService; import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.ProcessDefinitionService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.service.TenantService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.ComplementDependentMode; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ProcessExecutionTypeEnum; import org.apache.dolphinscheduler.common.enums.ProgramType; 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.UserType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.spi.enums.ResourceType; import py4j.GatewayServer; import org.apache.commons.collections.CollectionUtils; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
public class PythonGateway { private static final Logger logger = LoggerFactory.getLogger(PythonGateway.class); private static final FailureStrategy DEFAULT_FAILURE_STRATEGY = FailureStrategy.CONTINUE; private static final Priority DEFAULT_PRIORITY = Priority.MEDIUM; private static final Long DEFAULT_ENVIRONMENT_CODE = -1L; private static final TaskDependType DEFAULT_TASK_DEPEND_TYPE = TaskDependType.TASK_POST; private static final RunMode DEFAULT_RUN_MODE = RunMode.RUN_MODE_SERIAL; private static final int DEFAULT_DRY_RUN = 0; private static final int DEFAULT_TEST_FLAG = 0; private static final ComplementDependentMode COMPLEMENT_DEPENDENT_MODE = ComplementDependentMode.OFF_MODE; private static final int ADMIN_USER_ID = 1; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProjectService projectService; @Autowired private TenantService tenantService; @Autowired private EnvironmentService environmentService; @Autowired private ExecutorService executorService; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
private ProcessDefinitionService processDefinitionService; @Autowired private TaskDefinitionService taskDefinitionService; @Autowired private UsersService usersService; @Autowired private ResourcesService resourceService; @Autowired private ProjectMapper projectMapper; @Autowired private TaskDefinitionMapper taskDefinitionMapper; @Autowired private SchedulerService schedulerService; @Autowired private ScheduleMapper scheduleMapper; @Autowired private DataSourceMapper dataSourceMapper; @Autowired private PythonGatewayConfiguration pythonGatewayConfiguration; @Autowired private ProjectUserMapper projectUserMapper; private final User dummyAdminUser = new User() { { setId(ADMIN_USER_ID); setUserName("dummyUser"); setUserType(UserType.ADMIN_USER); } }; private final Queue queuePythonGateway = new Queue() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
{ setId(Integer.MAX_VALUE); setQueueName("queuePythonGateway"); } }; public String ping() { return "PONG"; } public Map<String, Object> genTaskCodeList(Integer genNum) { return taskDefinitionService.genTaskCodeList(genNum); } public Map<String, Long> getCodeAndVersion(String projectName, String processDefinitionName, String taskName) throws CodeGenerateUtils.CodeGenerateException { Project project = projectMapper.queryByName(projectName); Map<String, Long> result = new HashMap<>(); if (project == null) { result.put("code", CodeGenerateUtils.getInstance().genCode()); result.put("version", 0L); return result; } ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getCode(), processDefinitionName); if (processDefinition == null) { result.put("code", CodeGenerateUtils.getInstance().genCode()); result.put("version", 0L);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), processDefinition.getCode(), taskName); if (taskDefinition == null) { result.put("code", CodeGenerateUtils.getInstance().genCode()); result.put("version", 0L); } else { result.put("code", taskDefinition.getCode()); result.put("version", (long) taskDefinition.getVersion()); } return result; } /** * create or update process definition. * If process definition do not exists in Project=`projectCode` would create a new one * If process definition already exists in Project=`projectCode` would update it * * @param userName user name who create or update process definition * @param projectName project name which process definition belongs to * @param name process definition name * @param description description * @param globalParams global params * @param schedule schedule for process definition, will not set schedule if null, * and if would always fresh exists schedule if not null * @param warningType warning type * @param warningGroupId warning group id * @param timeout timeout for process definition working, if running time longer than timeout, * task will mark as fail * @param workerGroup run task in which worker group
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
* @param tenantCode tenantCode * @param taskRelationJson relation json for nodes * @param taskDefinitionJson taskDefinitionJson * @param otherParamsJson otherParamsJson handle other params * @return create result code */ public Long createOrUpdateProcessDefinition(String userName, String projectName, String name, String description, String globalParams, String schedule, String warningType, int warningGroupId, int timeout, String workerGroup, String tenantCode, int releaseState, String taskRelationJson, String taskDefinitionJson, String otherParamsJson, String executionType) { User user = usersService.queryUser(userName); Project project = projectMapper.queryByName(projectName); long projectCode = project.getCode(); ProcessDefinition processDefinition = getProcessDefinition(user, projectCode, name); ProcessExecutionTypeEnum executionTypeEnum = ProcessExecutionTypeEnum.valueOf(executionType); long processDefinitionCode; if (processDefinition != null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
processDefinitionCode = processDefinition.getCode(); processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams, null, timeout, tenantCode, taskRelationJson, taskDefinitionJson, otherParamsJson, executionTypeEnum); } else { Map<String, Object> result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams, null, timeout, tenantCode, taskRelationJson, taskDefinitionJson, otherParamsJson, executionTypeEnum); processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST); processDefinitionCode = processDefinition.getCode(); } if (schedule != null) { createOrUpdateSchedule(user, projectCode, processDefinitionCode, schedule, workerGroup, warningType, warningGroupId); } processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.getEnum(releaseState)); return processDefinitionCode; } /** * get process definition * * @param user user who create or update schedule * @param projectCode project which process definition belongs to
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
* @param processDefinitionName process definition name */ private ProcessDefinition getProcessDefinition(User user, long projectCode, String processDefinitionName) { Map<String, Object> verifyProcessDefinitionExists = processDefinitionService.verifyProcessDefinitionName(user, projectCode, processDefinitionName, 0); Status verifyStatus = (Status) verifyProcessDefinitionExists.get(Constants.STATUS); ProcessDefinition processDefinition = null; if (verifyStatus == Status.PROCESS_DEFINITION_NAME_EXIST) { processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName); } else if (verifyStatus != Status.SUCCESS) { String msg = "Verify process definition exists status is invalid, neither SUCCESS or PROCESS_DEFINITION_NAME_EXIST."; logger.error(msg); throw new RuntimeException(msg); } return processDefinition; } /** * create or update process definition schedule. * It would always use latest schedule define in workflow-as-code, and set schedule online when * it's not null * * @param user user who create or update schedule * @param projectCode project which process definition belongs to * @param processDefinitionCode process definition code * @param schedule schedule expression * @param workerGroup work group * @param warningType warning type * @param warningGroupId warning group id */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
private void createOrUpdateSchedule(User user, long projectCode, long processDefinitionCode, String schedule, String workerGroup, String warningType, int warningGroupId) { Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(processDefinitionCode); int scheduleId; if (scheduleObj == null) { processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE); Map<String, Object> result = schedulerService.insertSchedule(user, projectCode, processDefinitionCode, schedule, WarningType.valueOf(warningType), warningGroupId, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); scheduleId = (int) result.get("scheduleId"); } else { scheduleId = scheduleObj.getId(); processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE); schedulerService.updateSchedule(user, projectCode, scheduleId, schedule, WarningType.valueOf(warningType), warningGroupId, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); } schedulerService.setScheduleState(user, projectCode, scheduleId, ReleaseState.ONLINE); } public void execProcessInstance(String userName, String projectName, String processDefinitionName, String cronTime,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
String workerGroup, String warningType, Integer warningGroupId, Integer timeout) { User user = usersService.queryUser(userName); Project project = projectMapper.queryByName(projectName); ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getCode(), processDefinitionName); processDefinitionService.releaseProcessDefinition(user, project.getCode(), processDefinition.getCode(), ReleaseState.ONLINE); executorService.execProcessInstance(user, project.getCode(), processDefinition.getCode(), cronTime, null, DEFAULT_FAILURE_STRATEGY, null, DEFAULT_TASK_DEPEND_TYPE, WarningType.valueOf(warningType), warningGroupId, DEFAULT_RUN_MODE, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE, timeout, null, null, DEFAULT_DRY_RUN, DEFAULT_TEST_FLAG,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
COMPLEMENT_DEPENDENT_MODE); } /* * Grant project's permission to user. Use when project's created user not current but Python API use it to change * process definition. */ private Integer grantProjectToUser(Project project, User user) { Date now = new Date(); ProjectUser projectUser = new ProjectUser(); projectUser.setUserId(user.getId()); projectUser.setProjectId(project.getId()); projectUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); projectUser.setCreateTime(now); projectUser.setUpdateTime(now); return projectUserMapper.insert(projectUser); } /* * Grant or create project. Create a new project if project do not exists, and grant the project permission to user * if project exists but without permission to this user. */ public void createOrGrantProject(String userName, String name, String desc) { User user = usersService.queryUser(userName); Project project; project = projectMapper.queryByName(name); if (project == null) { projectService.createProject(user, name, desc); } else if (project.getUserId() != user.getId()) { ProjectUser projectUser = projectUserMapper.queryProjectRelation(project.getId(), user.getId()); if (projectUser == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
grantProjectToUser(project, user); } } } public Project queryProjectByName(String userName, String projectName) { User user = usersService.queryUser(userName); return (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST); } public void updateProject(String userName, Long projectCode, String projectName, String desc) { User user = usersService.queryUser(userName); projectService.update(user, projectCode, projectName, desc, userName); } public void deleteProject(String userName, Long projectCode) { User user = usersService.queryUser(userName); projectService.deleteProject(user, projectCode); } public Tenant createTenant(String tenantCode, String desc, String queueName) { return tenantService.createTenantIfNotExists(tenantCode, desc, queueName, queueName); } public Tenant queryTenantByCode(String tenantCode) { return (Tenant) tenantService.queryByTenantCode(tenantCode).get(Constants.DATA_LIST); } public void updateTenant(String userName, int id, String tenantCode, int queueId, String desc) throws Exception { User user = usersService.queryUser(userName); tenantService.updateTenant(user, id, tenantCode, queueId, desc); } public void deleteTenantById(String userName, Integer tenantId) throws Exception { User user = usersService.queryUser(userName); tenantService.deleteTenantById(user, tenantId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
public User createUser(String userName, String userPassword, String email, String phone, String tenantCode, String queue, int state) throws IOException { return usersService.createUserIfNotExists(userName, userPassword, email, phone, tenantCode, queue, state); } public User queryUser(int id) { User user = usersService.queryUser(id); if (user == null) { throw new RuntimeException("User not found"); } return user; } public User updateUser(String userName, String userPassword, String email, String phone, String tenantCode, String queue, int state) throws Exception { return usersService.createUserIfNotExists(userName, userPassword, email, phone, tenantCode, queue, state); } public User deleteUser(String userName, int id) throws Exception { User user = usersService.queryUser(userName); usersService.deleteUserById(user, id); return usersService.queryUser(userName); } /** * Get datasource by given datasource name. It return map contain datasource id, type, name. * Useful in Python API create sql task which need datasource information. * * @param datasourceName user who create or update schedule
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
*/ public Map<String, Object> getDatasourceInfo(String datasourceName) { Map<String, Object> result = new HashMap<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(datasourceName); if (dataSourceList == null || dataSourceList.isEmpty()) { String msg = String.format("Can not find any datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else if (dataSourceList.size() > 1) { String msg = String.format("Get more than one datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else { DataSource dataSource = dataSourceList.get(0); result.put("id", dataSource.getId()); result.put("type", dataSource.getType().name()); result.put("name", dataSource.getName()); } return result; } /** * Get processDefinition by given processDefinitionName name. It return map contain processDefinition id, name, code. * Useful in Python API create subProcess task which need processDefinition information. * * @param userName user who create or update schedule * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name */ public Map<String, Object> getProcessDefinitionInfo(String userName, String projectName, String processDefinitionName) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
Map<String, Object> result = new HashMap<>(); User user = usersService.queryUser(userName); Project project = (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST); long projectCode = project.getCode(); ProcessDefinition processDefinition = getProcessDefinition(user, projectCode, processDefinitionName); if (processDefinition != null) { processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinition.getCode(), ReleaseState.ONLINE); result.put("id", processDefinition.getId()); result.put("name", processDefinition.getName()); result.put("code", processDefinition.getCode()); } else { String msg = String.format("Can not find valid process definition by name %s", processDefinitionName); logger.error(msg); throw new IllegalArgumentException(msg); } return result; } /** * Get project, process definition, task code. * Useful in Python API create dependent task which need processDefinition information. * * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name * @param taskName task name */ public Map<String, Object> getDependentInfo(String projectName, String processDefinitionName, String taskName) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
Project project = projectMapper.queryByName(projectName); if (project == null) { String msg = String.format("Can not find valid project by name %s", projectName); logger.error(msg); throw new IllegalArgumentException(msg); } long projectCode = project.getCode(); result.put("projectCode", projectCode); ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName); if (processDefinition == null) { String msg = String.format("Can not find valid process definition by name %s", processDefinitionName); logger.error(msg); throw new IllegalArgumentException(msg); } result.put("processDefinitionCode", processDefinition.getCode()); if (taskName != null) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(projectCode, processDefinition.getCode(), taskName); result.put("taskDefinitionCode", taskDefinition.getCode()); } return result; } /** * Get resource by given program type and full name. It return map contain resource id, name. * Useful in Python API create flink or spark task which need processDefinition information. * * @param programType program type one of SCALA, JAVA and PYTHON * @param fullName full name of the resource */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
public Map<String, Object> getResourcesFileInfo(String programType, String fullName) { Map<String, Object> result = new HashMap<>(); Result<Object> resources = resourceService.queryResourceByProgramType(dummyAdminUser, ResourceType.FILE, ProgramType.valueOf(programType)); List<ResourceComponent> resourcesComponent = (List<ResourceComponent>) resources.getData(); List<ResourceComponent> namedResources = resourcesComponent.stream().filter(s -> fullName.equals(s.getFullName())).collect(Collectors.toList()); if (CollectionUtils.isEmpty(namedResources)) { String msg = String.format("Can not find valid resource by program type %s and name %s", programType, fullName); logger.error(msg); throw new IllegalArgumentException(msg); } result.put("id", namedResources.get(0).getId()); result.put("name", namedResources.get(0).getName()); return result; } /** * Get environment info by given environment name. It return environment code. * Useful in Python API create task which need environment information. * * @param environmentName name of the environment */ public Long getEnvironmentInfo(String environmentName) { Map<String, Object> result = environmentService.queryEnvironmentByName(environmentName); if (result.get("data") == null) { String msg = String.format("Can not find valid environment by name %s", environmentName); logger.error(msg); throw new IllegalArgumentException(msg); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
EnvironmentDto environmentDto = EnvironmentDto.class.cast(result.get("data")); return environmentDto.getCode(); } /** * Get resource by given resource type and full name. It return map contain resource id, name. * Useful in Python API create task which need processDefinition information. * * @param userName user who query resource * @param fullName full name of the resource */ public Resource queryResourcesFileInfo(String userName, String fullName) { return resourceService.queryResourcesFileInfo(userName, fullName); } public String getGatewayVersion() { return PythonGateway.class.getPackage().getImplementationVersion(); } /** * create or update resource. * If the folder is not already created, it will be * * @param userName user who create or update resource * @param fullName The fullname of resource.Includes path and suffix. * @param description description of resource * @param resourceContent content of resource * @return id of resource */ public Integer createOrUpdateResource( String userName, String fullName, String description, String resourceContent) { return resourceService.createOrUpdateResource(userName, fullName, description, resourceContent);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
8,255
[Feature][python] Add authentication for python gateway server
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description separate from #6407 . **Authentication**, add secret to ensure only trusted people could connect to gateway. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/8255
https://github.com/apache/dolphinscheduler/pull/12893
70fe39bb2d2012a7d792f9248b8c10d48569a3a8
6d8befa0752c1e8005651c7b57b2301c7b9606fc
2022-01-29T07:59:32Z
java
2022-11-14T10:43:08Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
} @PostConstruct public void init() { if (pythonGatewayConfiguration.getEnabled()) { this.start(); } } private void start() { GatewayServer server; try { InetAddress gatewayHost = InetAddress.getByName(pythonGatewayConfiguration.getGatewayServerAddress()); InetAddress pythonHost = InetAddress.getByName(pythonGatewayConfiguration.getPythonAddress()); server = new GatewayServer( this, pythonGatewayConfiguration.getGatewayServerPort(), pythonGatewayConfiguration.getPythonPort(), gatewayHost, pythonHost, pythonGatewayConfiguration.getConnectTimeout(), pythonGatewayConfiguration.getReadTimeout(), null); GatewayServer.turnLoggingOn(); logger.info("PythonGatewayService started on: " + gatewayHost.toString()); server.start(); } catch (UnknownHostException e) { logger.error("exception occurred while constructing PythonGatewayService().", e); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
* (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.dao.mapper; import static java.util.stream.Collectors.toList; import org.apache.dolphinscheduler.common.enums.UdfType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.entity.UDFUser; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; public class UdfFuncMapperTest extends BaseDaoTest {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
@Autowired private UserMapper userMapper; @Autowired private UdfFuncMapper udfFuncMapper; @Autowired private UDFUserMapper udfUserMapper; /** * insert one udf * * @return UdfFunc */ private UdfFunc insertOne(String funcName) { UdfFunc udfFunc = new UdfFunc(); udfFunc.setUserId(1); udfFunc.setFuncName(funcName); udfFunc.setClassName("org.apache.dolphinscheduler.test.mr"); udfFunc.setType(UdfType.HIVE); udfFunc.setResourceId(1); udfFunc.setResourceName("dolphin_resource"); udfFunc.setCreateTime(new Date()); udfFunc.setUpdateTime(new Date()); udfFuncMapper.insert(udfFunc); return udfFunc; } /** * insert one udf * * @return */ private UdfFunc insertOne(User user) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
UdfFunc udfFunc = new UdfFunc(); udfFunc.setUserId(user.getId()); udfFunc.setFuncName("dolphin_udf_func" + user.getUserName()); udfFunc.setClassName("org.apache.dolphinscheduler.test.mr"); udfFunc.setType(UdfType.HIVE); udfFunc.setResourceId(1); udfFunc.setResourceName("dolphin_resource"); udfFunc.setCreateTime(new Date()); udfFunc.setUpdateTime(new Date()); udfFuncMapper.insert(udfFunc); return udfFunc; } /** * insert one user * * @return User */ private User insertOneUser() { User user = new User(); user.setUserName("user1"); user.setUserPassword("1"); user.setEmail("[email protected]"); user.setUserType(UserType.GENERAL_USER); user.setCreateTime(new Date()); user.setTenantId(1); user.setUpdateTime(new Date()); userMapper.insert(user); return user; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
* insert one user * * @return User */ private User insertOneUser(String userName) { User user = new User(); user.setUserName(userName); user.setUserPassword("1"); user.setEmail("[email protected]"); user.setUserType(UserType.GENERAL_USER); user.setCreateTime(new Date()); user.setTenantId(1); user.setUpdateTime(new Date()); userMapper.insert(user); return user; } /** * insert UDFUser * * @param user user * @param udfFunc udf func * @return UDFUser */ private UDFUser insertOneUDFUser(User user, UdfFunc udfFunc) { UDFUser udfUser = new UDFUser(); udfUser.setUdfId(udfFunc.getId()); udfUser.setUserId(user.getId()); udfUser.setCreateTime(new Date()); udfUser.setUpdateTime(new Date()); udfUserMapper.insert(udfUser);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
return udfUser; } /** * create general user * * @return User */ private User createGeneralUser(String userName) { User user = new User(); user.setUserName(userName); user.setUserPassword("1"); user.setEmail("[email protected]"); user.setUserType(UserType.GENERAL_USER); user.setCreateTime(new Date()); user.setTenantId(1); user.setUpdateTime(new Date()); userMapper.insert(user); return user; } /** * test update */ @Test public void testUpdate() { UdfFunc udfFunc = insertOne("func1"); udfFunc.setResourceName("dolphin_resource_update"); udfFunc.setResourceId(2); udfFunc.setClassName("org.apache.dolphinscheduler.test.mrUpdate"); udfFunc.setUpdateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
int update = udfFuncMapper.updateById(udfFunc); Assertions.assertEquals(update, 1); } /** * test delete */ @Test public void testDelete() { UdfFunc udfFunc = insertOne("func2"); int delete = udfFuncMapper.deleteById(udfFunc.getId()); Assertions.assertEquals(delete, 1); } /** * test query udf by ids */ @Test public void testQueryUdfByIdStr() { UdfFunc udfFunc = insertOne("func3"); UdfFunc udfFunc1 = insertOne("func4"); Integer[] idArray = new Integer[]{udfFunc.getId(), udfFunc1.getId()}; List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfByIdStr(idArray, ""); Assertions.assertNotEquals(udfFuncList.size(), 0); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
* test page */ @Test public void testQueryUdfFuncPaging() { User user = insertOneUser(); UdfFunc udfFunc = insertOne(user); Page<UdfFunc> page = new Page(1, 3); IPage<UdfFunc> udfFuncIPage = udfFuncMapper.queryUdfFuncPaging(page, Collections.singletonList(udfFunc.getId()), ""); Assertions.assertNotEquals(udfFuncIPage.getTotal(), 0); } /** * test get udffunc by type */ @Test public void testGetUdfFuncByType() { User user = insertOneUser(); UdfFunc udfFunc = insertOne(user); List<UdfFunc> udfFuncList = udfFuncMapper.getUdfFuncByType(Collections.singletonList(udfFunc.getId()), udfFunc.getType().ordinal()); Assertions.assertNotEquals(udfFuncList.size(), 0); } /** * test query udffunc expect userId
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
*/ @Test public void testQueryUdfFuncExceptUserId() { User user1 = insertOneUser(); User user2 = insertOneUser("user2"); UdfFunc udfFunc1 = insertOne(user1); UdfFunc udfFunc2 = insertOne(user2); List<UdfFunc> udfFuncList = udfFuncMapper.queryUdfFuncExceptUserId(user1.getId()); Assertions.assertNotEquals(udfFuncList.size(), 0); } /** * test query authed udffunc */ @Test public void testQueryAuthedUdfFunc() { User user = insertOneUser(); UdfFunc udfFunc = insertOne(user); UDFUser udfUser = insertOneUDFUser(user, udfFunc); List<UdfFunc> udfFuncList = udfFuncMapper.queryAuthedUdfFunc(user.getId()); Assertions.assertNotEquals(udfFuncList.size(), 0); } @Test public void testListAuthorizedUdfFunc() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,856
[Improvement][UT] Refactor duplicated code fragment in `UdfFuncMapperTest`
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Improve the ut of UdfFuncMapperTest ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12856
https://github.com/apache/dolphinscheduler/pull/12857
713046b04328edd10c06711a39092f739298c6c6
83f9588eb07832f058c3fafe990a997069baf68f
2022-11-10T07:12:10Z
java
2022-11-15T14:59:11Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UdfFuncMapperTest.java
User generalUser1 = createGeneralUser("user1"); User generalUser2 = createGeneralUser("user2"); UdfFunc udfFunc = insertOne(generalUser1); UdfFunc unauthorizdUdfFunc = insertOne(generalUser2); Integer[] udfFuncIds = new Integer[]{udfFunc.getId(), unauthorizdUdfFunc.getId()}; List<UdfFunc> authorizedUdfFunc = udfFuncMapper.listAuthorizedUdfFunc(generalUser1.getId(), udfFuncIds); Assertions.assertEquals(generalUser1.getId().intValue(), udfFunc.getUserId()); Assertions.assertNotEquals(generalUser1.getId().intValue(), unauthorizdUdfFunc.getUserId()); Assertions.assertFalse(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList()) .containsAll(Arrays.asList(udfFuncIds))); insertOneUDFUser(generalUser1, unauthorizdUdfFunc); authorizedUdfFunc = udfFuncMapper.listAuthorizedUdfFunc(generalUser1.getId(), udfFuncIds); Assertions.assertTrue(authorizedUdfFunc.stream().map(t -> t.getId()).collect(toList()) .containsAll(Arrays.asList(udfFuncIds))); } @Test public void batchUpdateUdfFuncTest() { User generalUser1 = createGeneralUser("user1"); UdfFunc udfFunc = insertOne(generalUser1); udfFunc.setResourceName("/updateTest"); List<UdfFunc> udfFuncList = new ArrayList<>(); udfFuncList.add(udfFunc); Assertions.assertTrue(udfFuncMapper.batchUpdateUdfFunc(udfFuncList) > 0); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.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.controller; import static org.apache.dolphinscheduler.api.enums.Status.FORCE_TASK_SUCCESS_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.TASK_SAVEPOINT_ERROR;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
import static org.apache.dolphinscheduler.api.enums.Status.TASK_STOP_ERROR; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; /** * task instance controller */ @Tag(name = "TASK_INSTANCE_TAG")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
@RestController @RequestMapping("/projects/{projectCode}/task-instances") public class TaskInstanceController extends BaseController { @Autowired private TaskInstanceService taskInstanceService; /** * query task list paging * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param searchVal search value * @param taskName task name
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
* @param stateType state type * @param host host * @param startTime start time * @param endTime end time * @param pageNo page number * @param pageSize page size * @param taskExecuteType task execute type * @return task list page */ @Operation(summary = "queryTaskListPaging", description = "QUERY_TASK_INSTANCE_LIST_PAGING_NOTES") @Parameters({ @Parameter(name = "processInstanceId", description = "PROCESS_INSTANCE_ID", required = false, schema = @Schema(implementation = int.class, example = "100")), @Parameter(name = "processInstanceName", description = "PROCESS_INSTANCE_NAME", required = false, schema = @Schema(implementation = String.class)), @Parameter(name = "searchVal", description = "SEARCH_VAL", schema = @Schema(implementation = String.class)), @Parameter(name = "taskName", description = "TASK_NAME", schema = @Schema(implementation = String.class)), @Parameter(name = "executorName", description = "EXECUTOR_NAME", schema = @Schema(implementation = String.class)), @Parameter(name = "stateType", description = "EXECUTION_STATUS", schema = @Schema(implementation = TaskExecutionStatus.class)), @Parameter(name = "host", description = "HOST", schema = @Schema(implementation = String.class)), @Parameter(name = "startDate", description = "START_DATE", schema = @Schema(implementation = String.class)), @Parameter(name = "endDate", description = "END_DATE", schema = @Schema(implementation = String.class)), @Parameter(name = "taskExecuteType", description = "TASK_EXECUTE_TYPE", required = false, schema = @Schema(implementation = TaskExecuteType.class, example = "STREAM")), @Parameter(name = "pageNo", description = "PAGE_NO", required = true, schema = @Schema(implementation = int.class, example = "1")), @Parameter(name = "pageSize", description = "PAGE_SIZE", required = true, schema = @Schema(implementation = int.class, example = "20")), }) @GetMapping() @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_TASK_LIST_PAGING_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryTaskListPaging(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
@RequestParam(value = "processInstanceId", required = false, defaultValue = "0") Integer processInstanceId, @RequestParam(value = "processInstanceName", required = false) String processInstanceName, @RequestParam(value = "processDefinitionName", required = false) String processDefinitionName, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "taskName", required = false) String taskName, @RequestParam(value = "executorName", required = false) String executorName, @RequestParam(value = "stateType", required = false) TaskExecutionStatus stateType, @RequestParam(value = "host", required = false) String host, @RequestParam(value = "startDate", required = false) String startTime, @RequestParam(value = "endDate", required = false) String endTime, @RequestParam(value = "taskExecuteType", required = false, defaultValue = "BATCH") TaskExecuteType taskExecuteType, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { Result result = checkPageParams(pageNo, pageSize); if (!result.checkResult()) { return result; } searchVal = ParameterUtils.handleEscapes(searchVal); result = taskInstanceService.queryTaskListPaging(loginUser, projectCode, processInstanceId, processInstanceName, processDefinitionName, taskName, executorName, startTime, endTime, searchVal, stateType, host, taskExecuteType, pageNo, pageSize); return result; } /** * change one task instance's state from FAILURE to FORCED_SUCCESS * * @param loginUser login user * @param projectCode project code * @param id task instance id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
* @return the result code and msg */ @Operation(summary = "force-success", description = "FORCE_TASK_SUCCESS") @Parameters({ @Parameter(name = "id", description = "TASK_INSTANCE_ID", required = true, schema = @Schema(implementation = int.class, example = "12")) }) @PostMapping(value = "/{id}/force-success") @ResponseStatus(HttpStatus.OK) @ApiException(FORCE_TASK_SUCCESS_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result<Object> forceTaskSuccess(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable(value = "id") Integer id) { Map<String, Object> result = taskInstanceService.forceTaskSuccess(loginUser, projectCode, id); return returnDataList(result); } /** * task savepoint, for stream task * * @param loginUser login user * @param projectCode project code * @param id task instance id * @return the result code and msg */ @Operation(summary = "savepoint", description = "TASK_SAVEPOINT") @Parameters({ @Parameter(name = "id", description = "TASK_INSTANCE_ID", required = true, schema = @Schema(implementation = int.class, example = "12")) }) @PostMapping(value = "/{id}/savepoint") @ResponseStatus(HttpStatus.OK)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/TaskInstanceController.java
@ApiException(TASK_SAVEPOINT_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result<Object> taskSavePoint(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable(value = "id") Integer id) { return taskInstanceService.taskSavePoint(loginUser, projectCode, id); } /** * task stop, for stream task * * @param loginUser login user * @param projectCode project code * @param id task instance id * @return the result code and msg */ @Operation(summary = "stop", description = "TASK_INSTANCE_STOP") @Parameters({ @Parameter(name = "id", description = "TASK_INSTANCE_ID", required = true, schema = @Schema(implementation = int.class, example = "12")) }) @PostMapping(value = "/{id}/stop") @ResponseStatus(HttpStatus.OK) @ApiException(TASK_STOP_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result<Object> stopTask(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @PathVariable(value = "id") Integer id) { return taskInstanceService.stopTask(loginUser, projectCode, id); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.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.utils.Result; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import java.util.Map; /** * task instance service */ public interface TaskInstanceService { /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java
* query task list by project, process instance, task name, task start time, task end time, task status, keyword paging * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param searchVal search value * @param taskName task name * @param stateType state type * @param host host * @param startDate start time * @param endDate end time * @param taskExecuteType task execute type * @param pageNo page number * @param pageSize page size * @return task list page */ Result queryTaskListPaging(User loginUser, long projectCode, Integer processInstanceId, String processInstanceName, String processDefinitionName, String taskName, String executorName, String startDate, String endDate, String searchVal, TaskExecutionStatus stateType, String host, TaskExecuteType taskExecuteType, Integer pageNo,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java
Integer pageSize); /** * change one task instance's state from failure to forced success * * @param loginUser login user * @param projectCode project code * @param taskInstanceId task instance id * @return the result code and msg */ Map<String, Object> forceTaskSuccess(User loginUser, long projectCode, Integer taskInstanceId); /** * task savepoint * @param loginUser * @param projectCode * @param taskInstanceId * @return */ Result taskSavePoint(User loginUser, long projectCode, Integer taskInstanceId); /** * stop task * @param loginUser * @param projectCode * @param taskInstanceId * @return */ Result stopTask(User loginUser, long projectCode, Integer taskInstanceId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.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.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.FORCED_SUCCESS; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_INSTANCE; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ProcessInstanceService; import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand; import org.apache.dolphinscheduler.remote.command.TaskSavePointRequestCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * task instance service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInstanceService { private static final Logger logger = LoggerFactory.getLogger(TaskInstanceServiceImpl.class); @Autowired ProjectMapper projectMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
@Autowired ProjectService projectService; @Autowired ProcessService processService; @Autowired TaskInstanceMapper taskInstanceMapper; @Autowired ProcessInstanceService processInstanceService; @Autowired UsersService usersService; @Autowired TaskDefinitionMapper taskDefinitionMapper; @Autowired private StateEventCallbackService stateEventCallbackService; /** * query task list by project, process instance, task name, task start time, task end time, task status, keyword paging * * @param loginUser login user * @param projectCode project code * @param processInstanceId process instance id * @param searchVal search value * @param taskName task name * @param stateType state type * @param host host * @param startDate start time * @param endDate end time * @param pageNo page number * @param pageSize page size * @return task list page */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
@Override public Result queryTaskListPaging(User loginUser, long projectCode, Integer processInstanceId, String processInstanceName, String processDefinitionName, String taskName, String executorName, String startDate, String endDate, String searchVal, TaskExecutionStatus stateType, String host, TaskExecuteType taskExecuteType, Integer pageNo, Integer pageSize) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_INSTANCE); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { putMsg(result, status); return result; } int[] statusArray = null; if (stateType != null) { statusArray = new int[]{stateType.getCode()}; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate); status = (Status) checkAndParseDateResult.get(Constants.STATUS); if (status != Status.SUCCESS) { putMsg(result, status); return result; } Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME); Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME); Page<TaskInstance> page = new Page<>(pageNo, pageSize); PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(pageNo, pageSize); int executorId = usersService.getUserIdByName(executorName); IPage<TaskInstance> taskInstanceIPage; if (taskExecuteType == TaskExecuteType.STREAM) { taskInstanceIPage = taskInstanceMapper.queryStreamTaskInstanceListPaging( page, project.getCode(), processDefinitionName, searchVal, taskName, executorId, statusArray, host, taskExecuteType, start, end); } else { taskInstanceIPage = taskInstanceMapper.queryTaskInstanceListPaging( page, project.getCode(), processInstanceId, processInstanceName, searchVal, taskName, executorId, statusArray, host, taskExecuteType, start, end); } Set<String> exclusionSet = new HashSet<>(); exclusionSet.add(Constants.CLASS); exclusionSet.add("taskJson"); List<TaskInstance> taskInstanceList = taskInstanceIPage.getRecords(); List<Integer> executorIds = taskInstanceList.stream().map(TaskInstance::getExecutorId).distinct().collect(Collectors.toList()); List<User> users = usersService.queryUser(executorIds); Map<Integer, User> userMap = users.stream().collect(Collectors.toMap(User::getId, v -> v));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
for (TaskInstance taskInstance : taskInstanceList) { taskInstance.setDuration(DateUtils.format2Duration(taskInstance.getStartTime(), taskInstance.getEndTime())); User user = userMap.get(taskInstance.getExecutorId()); if (user != null) { taskInstance.setExecutorName(user.getUserName()); } } pageInfo.setTotal((int) taskInstanceIPage.getTotal()); pageInfo.setTotalList(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet)); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * change one task instance's state from failure to forced success * * @param loginUser login user * @param projectCode project code * @param taskInstanceId task instance id * @return the result code and msg */ @Transactional @Override public Map<String, Object> forceTaskSuccess(User loginUser, long projectCode, Integer taskInstanceId) { Project project = projectMapper.queryByCode(projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode, FORCED_SUCCESS); if (result.get(Constants.STATUS) != Status.SUCCESS) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
} TaskInstance task = taskInstanceMapper.selectById(taskInstanceId); if (task == null) { logger.error("Task instance can not be found, projectCode:{}, taskInstanceId:{}.", projectCode, taskInstanceId); putMsg(result, Status.TASK_INSTANCE_NOT_FOUND); return result; } TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(task.getTaskCode()); if (taskDefinition != null && projectCode != taskDefinition.getProjectCode()) { logger.error("Task definition can not be found, projectCode:{}, taskDefinitionCode:{}.", projectCode, task.getTaskCode()); putMsg(result, Status.TASK_INSTANCE_NOT_FOUND, taskInstanceId); return result; } if (!task.getState().isFailure() && !task.getState().isKill()) { logger.warn("{} type task instance can not perform force success, projectCode:{}, taskInstanceId:{}.", task.getState().getDesc(), projectCode, taskInstanceId); putMsg(result, Status.TASK_INSTANCE_STATE_OPERATION_ERROR, taskInstanceId, task.getState().toString()); return result; } task.setState(TaskExecutionStatus.FORCED_SUCCESS); int changedNum = taskInstanceMapper.updateById(task); if (changedNum > 0) { processService.forceProcessInstanceSuccessByTaskInstanceId(taskInstanceId); logger.info("Task instance performs force success complete, projectCode:{}, taskInstanceId:{}", projectCode, taskInstanceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
putMsg(result, Status.SUCCESS); } else { logger.error("Task instance performs force success complete, projectCode:{}, taskInstanceId:{}", projectCode, taskInstanceId); putMsg(result, Status.FORCE_TASK_SUCCESS_ERROR); } return result; } @Override public Result taskSavePoint(User loginUser, long projectCode, Integer taskInstanceId) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode, FORCED_SUCCESS); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { putMsg(result, status); return result; } TaskInstance taskInstance = taskInstanceMapper.selectById(taskInstanceId); if (taskInstance == null) { logger.error("Task definition can not be found, projectCode:{}, taskInstanceId:{}.", projectCode, taskInstanceId); putMsg(result, Status.TASK_INSTANCE_NOT_FOUND); return result; } TaskSavePointRequestCommand command = new TaskSavePointRequestCommand(taskInstanceId); Host host = new Host(taskInstance.getHost()); stateEventCallbackService.sendResult(host, command.convert2Command());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java
putMsg(result, Status.SUCCESS); return result; } @Override public Result stopTask(User loginUser, long projectCode, Integer taskInstanceId) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode, FORCED_SUCCESS); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { putMsg(result, status); return result; } TaskInstance taskInstance = taskInstanceMapper.selectById(taskInstanceId); if (taskInstance == null) { logger.error("Task definition can not be found, projectCode:{}, taskInstanceId:{}.", projectCode, taskInstanceId); putMsg(result, Status.TASK_INSTANCE_NOT_FOUND); return result; } TaskKillRequestCommand command = new TaskKillRequestCommand(taskInstanceId); Host host = new Host(taskInstance.getHost()); stateEventCallbackService.sendResult(host, command.convert2Command()); putMsg(result, Status.SUCCESS); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.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.controller; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; public class TaskInstanceControllerTest extends AbstractControllerTest { @InjectMocks private TaskInstanceController taskInstanceController; @Mock private TaskInstanceService taskInstanceService; @Test public void testQueryTaskListPaging() { Result result = new Result(); Integer pageNo = 1; Integer pageSize = 20; PageInfo pageInfo = new PageInfo<TaskInstance>(pageNo, pageSize); result.setData(pageInfo);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TaskInstanceControllerTest.java
result.setCode(Status.SUCCESS.getCode()); result.setMsg(Status.SUCCESS.getMsg()); when(taskInstanceService.queryTaskListPaging(any(), eq(1L), eq(1), eq(""), eq(""), eq(""), eq(""), any(), any(), eq(""), Mockito.any(), eq("192.168.xx.xx"), eq(TaskExecuteType.BATCH), any(), any())) .thenReturn(result); Result taskResult = taskInstanceController.queryTaskListPaging(null, 1L, 1, "", "", "", "", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", "2020-01-01 00:00:00", "2020-01-02 00:00:00", TaskExecuteType.BATCH, pageNo, pageSize); Assertions.assertEquals(Integer.valueOf(Status.SUCCESS.getCode()), taskResult.getCode()); } @Disabled @Test public void testForceTaskSuccess() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("taskInstanceId", "104"); Map<String, Object> mockResult = new HashMap<>(5); mockResult.put(Constants.STATUS, Status.SUCCESS); mockResult.put(Constants.MSG, Status.SUCCESS.getMsg()); when(taskInstanceService.forceTaskSuccess(any(User.class), anyLong(), anyInt())).thenReturn(mockResult); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/task-instance/force-success", "cxc_1113") .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
* 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.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.FORCED_SUCCESS; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.TASK_INSTANCE; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import org.apache.dolphinscheduler.api.ApiApplicationServer; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl; import org.apache.dolphinscheduler.api.service.impl.TaskInstanceServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.TaskExecuteType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.User;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.service.process.ProcessService; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import org.springframework.boot.test.context.SpringBootTest; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * task instance service test */ @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) @SpringBootTest(classes = ApiApplicationServer.class) public class TaskInstanceServiceTest {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
@InjectMocks private TaskInstanceServiceImpl taskInstanceService; @Mock ProjectMapper projectMapper; @Mock ProjectServiceImpl projectService; @Mock ProcessService processService; @Mock TaskInstanceMapper taskInstanceMapper; @Mock UsersService usersService; @Mock TaskDefinitionMapper taskDefinitionMapper; @Test public void queryTaskListPaging() { long projectCode = 1L; User loginUser = getAdminUser(); Project project = getProject(projectCode); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_INSTANCE)).thenReturn(result); Result projectAuthFailRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 0, "", "", "",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
"test_user", "2019-02-26 19:48:00", "2019-02-26 19:48:22", "", null, "", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), (int) projectAuthFailRes.getCode()); putMsg(result, Status.SUCCESS, projectCode); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_INSTANCE)).thenReturn(result); Result dataParameterRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "test_user", "20200101 00:00:00", "2020-01-02 00:00:00", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int) dataParameterRes.getCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
putMsg(result, Status.SUCCESS, projectCode); Date start = DateUtils.stringToDate("2020-01-01 00:00:00"); Date end = DateUtils.stringToDate("2020-01-02 00:00:00"); ProcessInstance processInstance = getProcessInstance(); TaskInstance taskInstance = getTaskInstance(); List<TaskInstance> taskInstanceList = new ArrayList<>(); Page<TaskInstance> pageReturn = new Page<>(1, 10); taskInstanceList.add(taskInstance); pageReturn.setRecords(taskInstanceList); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(loginUser, project, projectCode, TASK_INSTANCE)).thenReturn(result); when(usersService.queryUser(loginUser.getId())).thenReturn(loginUser); when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(loginUser.getId()); when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""), eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(TaskExecuteType.BATCH), eq(start), eq(end))) .thenReturn(pageReturn); when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser); when(processService.findProcessInstanceDetailById(taskInstance.getProcessInstanceId())) .thenReturn(Optional.of(processInstance)); Result successRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) successRes.getCode()); when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""), eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(TaskExecuteType.BATCH), eq(start), eq(end))) .thenReturn(pageReturn);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
Result executorEmptyRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) executorEmptyRes.getCode()); when(usersService.queryUser(loginUser.getId())).thenReturn(null); when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(-1); Result executorNullRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) executorNullRes.getCode()); when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""), eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(TaskExecuteType.BATCH), any(), any())) .thenReturn(pageReturn); Result executorNullDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "", null, null, "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.SUCCESS.getCode(), (int) executorNullDateRes.getCode()); when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""), eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(TaskExecuteType.BATCH), any(), any())) .thenReturn(pageReturn); Result executorErrorStartDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "", "", "error date", null, "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int) executorErrorStartDateRes.getCode()); Result executorErrorEndDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 1, "", "", "",
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
"", null, "error date", "", TaskExecutionStatus.SUCCESS, "192.168.xx.xx", TaskExecuteType.BATCH, 1, 20); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int) executorErrorEndDateRes.getCode()); } /** * get Mock Admin User * * @return admin user */ private User getAdminUser() { User loginUser = new User(); loginUser.setId(-1); loginUser.setUserName("admin"); loginUser.setUserType(UserType.GENERAL_USER); return loginUser; } /** * get mock Project * * @param projectCode projectCode * @return Project */ private Project getProject(long projectCode) { Project project = new Project(); project.setCode(projectCode); project.setId(1); project.setName("project_test1"); project.setUserId(1); return project; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
/** * get Mock process instance * * @return process instance */ private ProcessInstance getProcessInstance() { ProcessInstance processInstance = new ProcessInstance(); processInstance.setId(1); processInstance.setName("test_process_instance"); processInstance.setStartTime(new Date()); processInstance.setEndTime(new Date()); processInstance.setExecutorId(-1); return processInstance; } /** * get Mock task instance * * @return task instance */ private TaskInstance getTaskInstance() { TaskInstance taskInstance = new TaskInstance(); taskInstance.setId(1); taskInstance.setName("test_task_instance"); taskInstance.setStartTime(new Date()); taskInstance.setEndTime(new Date()); taskInstance.setExecutorId(-1); taskInstance.setTaskExecuteType(TaskExecuteType.BATCH); taskInstance.setState(TaskExecutionStatus.SUBMITTED_SUCCESS); return taskInstance; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
private void putMsg(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()); } } @Test public void forceTaskSuccess() { User user = getAdminUser(); long projectCode = 1L; Project project = getProject(projectCode); int taskId = 1; TaskInstance task = getTaskInstance(); Map<String, Object> mockSuccess = new HashMap<>(5); putMsg(mockSuccess, Status.SUCCESS); when(projectMapper.queryByCode(projectCode)).thenReturn(project); Map<String, Object> mockFailure = new HashMap<>(5); putMsg(mockFailure, Status.USER_NO_OPERATION_PROJECT_PERM, user.getUserName(), projectCode); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(mockFailure); Map<String, Object> authFailRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Assertions.assertNotSame(Status.SUCCESS, authFailRes.get(Constants.STATUS)); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(mockSuccess); when(taskInstanceMapper.selectById(Mockito.anyInt())).thenReturn(null); TaskDefinition taskDefinition = new TaskDefinition(); taskDefinition.setProjectCode(projectCode); when(taskDefinitionMapper.queryByCode(task.getTaskCode())).thenReturn(taskDefinition);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,713
[Feature][Api] Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description https://github.com/apache/dolphinscheduler/issues/10257 Suggest refactor the backend api Refactor org.apache.dolphinscheduler.api.controller.TaskInstanceController #### Suggested optimization - Content-Type change to application/json - Add more example to api doc - Improve the accuracy of error reporting - The input and output parameters of API should use entity ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/11713
https://github.com/apache/dolphinscheduler/pull/11747
9e6f4d2bc17579cdf9ca1f45fa006b01103efac8
0186413a9f752bbe015f804a165b5f587232653a
2022-08-31T08:23:51Z
java
2022-11-16T10:32:42Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
Map<String, Object> taskNotFoundRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Assertions.assertEquals(Status.TASK_INSTANCE_NOT_FOUND, taskNotFoundRes.get(Constants.STATUS)); task.setState(TaskExecutionStatus.SUCCESS); when(taskInstanceMapper.selectById(1)).thenReturn(task); Map<String, Object> result = new HashMap<>(); putMsg(result, Status.SUCCESS, projectCode); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(result); Map<String, Object> taskStateErrorRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Assertions.assertEquals(Status.TASK_INSTANCE_STATE_OPERATION_ERROR, taskStateErrorRes.get(Constants.STATUS)); task.setState(TaskExecutionStatus.FAILURE); when(taskInstanceMapper.updateById(task)).thenReturn(0); putMsg(result, Status.SUCCESS, projectCode); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(result); Map<String, Object> errorRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Assertions.assertEquals(Status.FORCE_TASK_SUCCESS_ERROR, errorRes.get(Constants.STATUS)); task.setState(TaskExecutionStatus.FAILURE); when(taskInstanceMapper.updateById(task)).thenReturn(1); putMsg(result, Status.SUCCESS, projectCode); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(user, project, projectCode, FORCED_SUCCESS)).thenReturn(result); Map<String, Object> successRes = taskInstanceService.forceTaskSuccess(user, projectCode, taskId); Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.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.alert; import org.apache.dolphinscheduler.alert.api.AlertChannel; import org.apache.dolphinscheduler.alert.api.AlertConstants; import org.apache.dolphinscheduler.alert.api.AlertData;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
import org.apache.dolphinscheduler.alert.api.AlertInfo; import org.apache.dolphinscheduler.alert.api.AlertResult; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertType; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager; import org.apache.dolphinscheduler.common.thread.ThreadUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertSendStatus; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseResult; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import com.google.common.collect.Lists; @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
public final class AlertSenderService extends Thread { private static final Logger logger = LoggerFactory.getLogger(AlertSenderService.class); private final AlertDao alertDao; private final AlertPluginManager alertPluginManager; private final AlertConfig alertConfig; public AlertSenderService(AlertDao alertDao, AlertPluginManager alertPluginManager, AlertConfig alertConfig) { this.alertDao = alertDao; this.alertPluginManager = alertPluginManager; this.alertConfig = alertConfig; } @Override public synchronized void start() { super.setName("AlertSenderService");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
super.start(); } @Override public void run() { logger.info("Alert sender thread started"); while (!ServerLifeCycleManager.isStopped()) { try { List<Alert> alerts = alertDao.listPendingAlerts(); if (CollectionUtils.isEmpty(alerts)) { logger.debug("There is not waiting alerts"); continue; } AlertServerMetrics.registerPendingAlertGauge(alerts::size); this.send(alerts); } catch (Exception e) { logger.error("Alert sender thread meet an exception", e); } finally { ThreadUtils.sleep(Constants.SLEEP_TIME_MILLIS * 5L); } } logger.info("Alert sender thread stopped"); } public void send(List<Alert> alerts) { for (Alert alert : alerts) { int alertId = alert.getId(); int alertGroupId = Optional.ofNullable(alert.getAlertGroupId()).orElse(0); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); if (CollectionUtils.isEmpty(alertInstanceList)) { logger.error("send alert msg fail,no bind plugin instance.");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
List<AlertResult> alertResults = Lists.newArrayList(new AlertResult("false", "no bind plugin instance")); alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, JSONUtils.toJsonString(alertResults), alertId); continue; } AlertData alertData = AlertData.builder() .id(alertId) .content(alert.getContent()) .log(alert.getLog()) .title(alert.getTitle()) .warnType(alert.getWarningType().getCode()) .alertType(alert.getAlertType().getCode()) .build(); int sendSuccessCount = 0; List<AlertSendStatus> alertSendStatuses = new ArrayList<>(); List<AlertResult> alertResults = new ArrayList<>(); for (AlertPluginInstance instance : alertInstanceList) { AlertResult alertResult = this.alertResultHandler(instance, alertData); if (alertResult != null) { AlertStatus sendStatus = Boolean.parseBoolean(alertResult.getStatus()) ? AlertStatus.EXECUTION_SUCCESS : AlertStatus.EXECUTION_FAILURE; AlertSendStatus alertSendStatus = AlertSendStatus.builder() .alertId(alertId) .alertPluginInstanceId(instance.getId()) .sendStatus(sendStatus) .log(JSONUtils.toJsonString(alertResult)) .createTime(new Date()) .build(); alertSendStatuses.add(alertSendStatus);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
if (AlertStatus.EXECUTION_SUCCESS.equals(sendStatus)) { sendSuccessCount++; AlertServerMetrics.incAlertSuccessCount(); } else { AlertServerMetrics.incAlertFailCount(); } alertResults.add(alertResult); } } AlertStatus alertStatus = AlertStatus.EXECUTION_SUCCESS; if (sendSuccessCount == 0) { alertStatus = AlertStatus.EXECUTION_FAILURE; } else if (sendSuccessCount < alertInstanceList.size()) { alertStatus = AlertStatus.EXECUTION_PARTIAL_SUCCESS; } alertDao.updateAlert(alertStatus, JSONUtils.toJsonString(alertResults), alertId); alertDao.insertAlertSendStatus(alertSendStatuses); } } /** * sync send alert handler * * @param alertGroupId alertGroupId * @param title title * @param content content * @return AlertSendResponseCommand */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
public AlertSendResponseCommand syncHandler(int alertGroupId, String title, String content, int warnType) { List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); AlertData alertData = AlertData.builder() .content(content) .title(title) .warnType(warnType) .build(); boolean sendResponseStatus = true; List<AlertSendResponseResult> sendResponseResults = new ArrayList<>(); if (CollectionUtils.isEmpty(alertInstanceList)) { AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(); String message = String.format("Alert GroupId %s send error : not found alert instance", alertGroupId); alertSendResponseResult.setSuccess(false); alertSendResponseResult.setMessage(message); sendResponseResults.add(alertSendResponseResult); logger.error("Alert GroupId {} send error : not found alert instance", alertGroupId); return new AlertSendResponseCommand(false, sendResponseResults); } for (AlertPluginInstance instance : alertInstanceList) { AlertResult alertResult = this.alertResultHandler(instance, alertData); if (alertResult != null) { AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult( Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage()); sendResponseStatus = sendResponseStatus && alertSendResponseResult.isSuccess(); sendResponseResults.add(alertSendResponseResult); } } return new AlertSendResponseCommand(sendResponseStatus, sendResponseResults); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
* alert result handler * * @param instance instance * @param alertData alertData * @return AlertResult */ private @Nullable AlertResult alertResultHandler(AlertPluginInstance instance, AlertData alertData) { String pluginInstanceName = instance.getInstanceName(); int pluginDefineId = instance.getPluginDefineId(); Optional<AlertChannel> alertChannelOptional = alertPluginManager.getAlertChannel(instance.getPluginDefineId()); if (!alertChannelOptional.isPresent()) { String message = String.format("Alert Plugin %s send error: the channel doesn't exist, pluginDefineId: %s", pluginInstanceName, pluginDefineId); logger.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, pluginDefineId); return new AlertResult("false", message); } AlertChannel alertChannel = alertChannelOptional.get(); Map<String, String> paramsMap = JSONUtils.toMap(instance.getPluginInstanceParams()); String instanceWarnType = WarningType.ALL.getDescp(); if (MapUtils.isNotEmpty(paramsMap)) { instanceWarnType = paramsMap.getOrDefault(AlertConstants.NAME_WARNING_TYPE, WarningType.ALL.getDescp()); } WarningType warningType = WarningType.of(instanceWarnType); if (warningType == null) { String message = String.format("Alert Plugin %s send error : plugin warnType is null", pluginInstanceName); logger.error("Alert Plugin {} send error : plugin warnType is null", pluginInstanceName); return new AlertResult("false", message); } boolean sendWarning = false;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
switch (warningType) { case ALL: sendWarning = true; break; case SUCCESS: if (alertData.getWarnType() == WarningType.SUCCESS.getCode()) { sendWarning = true; } break; case FAILURE: if (alertData.getWarnType() == WarningType.FAILURE.getCode()) { sendWarning = true; } break; default: } if (!sendWarning) { logger.info( "Alert Plugin {} send ignore warning type not match: plugin warning type is {}, alert data warning type is {}", pluginInstanceName, warningType.getCode(), alertData.getWarnType()); return null; } AlertInfo alertInfo = AlertInfo.builder() .alertData(alertData) .alertParams(paramsMap) .alertPluginInstanceId(instance.getId()) .build(); int waitTimeout = alertConfig.getWaitTimeout(); try { AlertResult alertResult;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,866
[Bug] [Alert] Ignore alert not write info to db
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Alert warning type does not match instance, will ignore this alert, but not write correct into the back to DB. ### What you expected to happen When the alert warning type does not match the instance, write the correct info to DB. ### How to reproduce ⬆️ ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12866
https://github.com/apache/dolphinscheduler/pull/12867
2dbc79693e99f7a10d8bddeef691d9321dc5f10c
d02991a2e6332609e6d745d769f5bebbe17ed78f
2022-11-11T07:30:13Z
java
2022-11-17T06:14:12Z
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/AlertSenderService.java
if (waitTimeout <= 0) { if (alertData.getAlertType() == AlertType.CLOSE_ALERT.getCode()) { alertResult = alertChannel.closeAlert(alertInfo); } else { alertResult = alertChannel.process(alertInfo); } } else { CompletableFuture<AlertResult> future; if (alertData.getAlertType() == AlertType.CLOSE_ALERT.getCode()) { future = CompletableFuture.supplyAsync(() -> alertChannel.closeAlert(alertInfo)); } else { future = CompletableFuture.supplyAsync(() -> alertChannel.process(alertInfo)); } alertResult = future.get(waitTimeout, TimeUnit.MILLISECONDS); } if (alertResult == null) { throw new RuntimeException("Alert result cannot be null"); } return alertResult; } catch (InterruptedException e) { logger.error("send alert error alert data id :{},", alertData.getId(), e); Thread.currentThread().interrupt(); return new AlertResult("false", e.getMessage()); } catch (Exception e) { logger.error("send alert error alert data id :{},", alertData.getId(), e); return new AlertResult("false", e.getMessage()); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
* 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.impl; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_UPDATE; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.JSONUtils; 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 org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.commons.collections4.CollectionUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
import org.apache.commons.lang3.StringUtils; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereo.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.node.ObjectNode; /** * data source service impl */ @Service public class DataSourceServiceImpl extends BaseServiceImpl implements DataSourceService { private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceImpl.class);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
@Autowired private DataSourceMapper dataSourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; private static final String TABLE = "TABLE"; private static final String VIEW = "VIEW"; private static final String[] TABLE_TYPES = new String[]{TABLE, VIEW}; private static final String TABLE_NAME = "TABLE_NAME"; private static final String COLUMN_NAME = "COLUMN_NAME"; /** * create data source * * @param loginUser login user * @param datasourceParam datasource parameters * @return create result code */ @Override @Transactional public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) { DataSourceUtils.checkDatasourceParam(datasourceParam); Result<Object> result = new Result<>(); if (!canOperatorPermissions(loginUser, null, AuthorizationType.DATASOURCE, ApiFuncIdentificationConstant.DATASOURCE_CREATE_DATASOURCE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (checkName(datasourceParam.getName())) { logger.warn("Datasource with the same name already exists, name:{}.", datasourceParam.getName()); putMsg(result, Status.DATASOURCE_EXIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
return result; } if (checkDescriptionLength(datasourceParam.getNote())) { logger.warn("Parameter description is too long, description:{}.", datasourceParam.getNote()); putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(datasourceParam); Result<Object> isConnection = checkConnection(datasourceParam.getType(), connectionParam); if (Status.SUCCESS.getCode() != isConnection.getCode()) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } DataSource dataSource = new DataSource(); Date now = new Date(); dataSource.setName(datasourceParam.getName().trim()); dataSource.setNote(datasourceParam.getNote()); dataSource.setUserId(loginUser.getId()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(datasourceParam.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setCreateTime(now); dataSource.setUpdateTime(now); dataSource.setTestFlag(datasourceParam.getTestFlag()); dataSource.setBindTestId(datasourceParam.getBindTestId()); try { dataSourceMapper.insert(dataSource); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
permissionPostHandle(AuthorizationType.DATASOURCE, loginUser.getId(), Collections.singletonList(dataSource.getId()), logger); logger.info("Datasource create complete, dbType:{}, datasourceName:{}.", dataSource.getType().getDescp(), dataSource.getName()); } catch (DuplicateKeyException ex) { logger.error("Datasource create error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result; } /** * updateProcessInstance datasource * * @param loginUser login user * @param id data source id * @return update result code */ @Override public Result<Object> updateDataSource(int id, User loginUser, BaseDataSourceParamDTO dataSourceParam) { DataSourceUtils.checkDatasourceParam(dataSourceParam); Result<Object> result = new Result<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { logger.error("Datasource does not exist, id:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!canOperatorPermissions(loginUser, new Object[]{dataSource.getId()}, AuthorizationType.DATASOURCE, DATASOURCE_UPDATE)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!dataSourceParam.getName().trim().equals(dataSource.getName()) && checkName(dataSourceParam.getName())) { logger.warn("Datasource with the same name already exists, name:{}.", dataSource.getName()); putMsg(result, Status.DATASOURCE_EXIST); return result; } if (checkDescriptionLength(dataSourceParam.getNote())) { logger.warn("Parameter description is too long, description:{}.", dataSourceParam.getNote()); putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR); return result; } BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams(dataSourceParam); String password = connectionParam.getPassword(); if (StringUtils.isBlank(password)) { String oldConnectionParams = dataSource.getConnectionParams(); ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams); connectionParam.setPassword(oldParams.path(Constants.PASSWORD).asText()); } Result<Object> isConnection = checkConnection(dataSource.getType(), connectionParam); if (isConnection.isFailed()) { return isConnection; } Date now = new Date(); dataSource.setName(dataSourceParam.getName().trim()); dataSource.setNote(dataSourceParam.getNote());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
dataSource.setUserName(loginUser.getUserName()); dataSource.setType(dataSource.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setUpdateTime(now); if (dataSource.getTestFlag() == 1 && dataSourceParam.getTestFlag() == 0) { clearBindTestId(id); } dataSource.setTestFlag(dataSourceParam.getTestFlag()); dataSource.setBindTestId(dataSourceParam.getBindTestId()); try { dataSourceMapper.updateById(dataSource); logger.info("Update datasource complete, datasourceId:{}, datasourceName:{}.", dataSource.getId(), dataSource.getName()); putMsg(result, Status.SUCCESS); } catch (DuplicateKeyException ex) { logger.error("Update datasource error, datasourceId:{}, datasourceName:{}.", dataSource.getId(), dataSource.getName()); putMsg(result, Status.DATASOURCE_EXIST); } return result; } private boolean checkName(String name) { List<DataSource> queryDataSource = dataSourceMapper.queryDataSourceByName(name.trim()); return queryDataSource != null && !queryDataSource.isEmpty(); } /** * updateProcessInstance datasource * * @param id datasource id * @return data source detail
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Map<String, Object> queryDataSource(int id) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { logger.error("Datasource does not exist, id:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } // BaseDataSourceParamDTO baseDataSourceParamDTO = DataSourceUtils.buildDatasourceParamDTO( dataSource.getType(), dataSource.getConnectionParams()); baseDataSourceParamDTO.setId(dataSource.getId()); baseDataSourceParamDTO.setName(dataSource.getName()); baseDataSourceParamDTO.setNote(dataSource.getNote()); baseDataSourceParamDTO.setTestFlag(dataSource.getTestFlag()); baseDataSourceParamDTO.setBindTestId(dataSource.getBindTestId()); result.put(Constants.DATA_LIST, baseDataSourceParamDTO); putMsg(result, Status.SUCCESS); return result; } /** * query datasource list by keyword * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ @Override public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); IPage<DataSource> dataSourceList = null; Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize); PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize); if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(), searchVal); } else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal); } List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>(); handlePasswd(dataSources); pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L)); pageInfo.setTotalList(dataSources); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * handle datasource connection password for safety
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,896
[Improvement][Datasource]It is unnecessary to check the validity when saving the data source
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description It is unnecessary to check the validity when saving the data source. Eg: The datasource is only open to the specified worker, but we cannot connect it from API-SERVER. ### Are you willing to submit a PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/12896
https://github.com/apache/dolphinscheduler/pull/12900
d02991a2e6332609e6d745d769f5bebbe17ed78f
528f45acc5a899d96dbe7caca1a05f8174648e2f
2022-11-14T11:33:54Z
java
2022-11-17T06:23:12Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
*/ private void handlePasswd(List<DataSource> dataSourceList) { for (DataSource dataSource : dataSourceList) { String connectionParams = dataSource.getConnectionParams(); ObjectNode object = JSONUtils.parseObject(connectionParams); object.put(Constants.PASSWORD, getHiddenPassword()); dataSource.setConnectionParams(object.toString()); } } /** * get hidden password (resolve the security hotspot) * * @return hidden password */ private String getHiddenPassword() { return Constants.XXXXXX; } /** * query data resource list * * @param loginUser login user * @param data source * @return data source list page */ @Override public Map<String, Object> queryDataSourceList(User loginUser, Integer , int testFlag) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList = null; if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { datasourceList = dataSourceMapper.queryDataSourceByType(0, , testFlag);