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,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
} else { Set<Integer> ids = resourcePermissionCheckService .userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.put(Constants.DATA_LIST, Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } datasourceList = dataSourceMapper.selectBatchIds(ids).stream() .filter(dataSource -> dataSource.getType().getCode() == ) .filter(dataSource -> dataSource.getTestFlag() == testFlag).collect(Collectors.toList()); } result.put(Constants.DATA_LIST, datasourceList); putMsg(result, Status.SUCCESS); return result; } /** * verify datasource exists * * @param name datasource name * @return true if data datasource not exists, otherwise return false */ @Override public Result<Object> verifyDataSourceName(String name) { Result<Object> result = new Result<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name); if (dataSourceList != null && !dataSourceList.isEmpty()) { logger.warn("Datasource with the same name already exists, dataSourceName:{}.", dataSourceList.get(0).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
} else { putMsg(result, Status.SUCCESS); } return result; } /** * check connection * * @param data source * @param connectionParam connectionParam * @return true if connect successfully, otherwise false * @return true if connect successfully, otherwise false */ @Override public Result<Object> checkConnection(DbType , ConnectionParam connectionParam) { Result<Object> result = new Result<>(); try (Connection connection = DataSourceClientProvider.getInstance().getConnection(, connectionParam)) { if (connection == null) { logger.error("Connection test to {} datasource failed, connectionParam:{}.", .getDescp(), connectionParam); putMsg(result, Status.CONNECTION_TEST_FAILURE); return result; } logger.info("Connection test to {} datasource success, connectionParam:{}", .getDescp(), connectionParam); putMsg(result, Status.SUCCESS); return result; } catch (Exception e) { String message = Optional.of(e).map(Throwable::getCause) .map(Throwable::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
.orElse(e.getMessage()); logger.error("Datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", , connectionParam, message); return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), message); } } /** * test connection * * @param id datasource id * @return connect result code */ @Override public Result<Object> connectionTest(int id) { DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { Result<Object> result = new Result<>(); logger.error("Datasource does not exist, datasourceId:{}.", id); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } return checkConnection(dataSource.getType(), DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams())); } /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code
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 @Transactional public Result<Object> delete(User loginUser, int datasourceId) { Result<Object> result = new Result<>(); try { // DataSource dataSource = dataSourceMapper.selectById(datasourceId); if (dataSource == null) { logger.warn("Datasource does not exist, datasourceId:{}.", datasourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!canOperatorPermissions(loginUser, new Object[]{dataSource.getId()}, AuthorizationType.DATASOURCE, DATASOURCE_DELETE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } dataSourceMapper.deleteById(datasourceId); datasourceUserMapper.deleteByDatasourceId(datasourceId); clearBindTestId(datasourceId); logger.info("Delete datasource complete, datasourceId:{}.", datasourceId); putMsg(result, Status.SUCCESS); } catch (Exception e) { logger.error("Delete datasource complete, datasourceId:{}.", datasourceId, e); throw new ServiceException(Status.DELETE_DATA_SOURCE_FAILURE); } return result; } /**
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
* unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ @Override public Map<String, Object> unauthDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList; if (canOperatorPermissions(loginUser, null, AuthorizationType.DATASOURCE, null)) { // datasourceList = dataSourceMapper.queryDatasourceExceptUserId(userId); } else { // datasourceList = dataSourceMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<DataSource> resultList = new ArrayList<>(); Set<DataSource> datasourceSet; if (datasourceList != null && !datasourceList.isEmpty()) { datasourceSet = new HashSet<>(datasourceList); List<DataSource> authedDataSourceList = dataSourceMapper.queryAuthedDatasource(userId); Set<DataSource> authedDataSourceSet; if (authedDataSourceList != null && !authedDataSourceList.isEmpty()) { authedDataSourceSet = new HashSet<>(authedDataSourceList); datasourceSet.removeAll(authedDataSourceSet); } resultList = new ArrayList<>(datasourceSet); } result.put(Constants.DATA_LIST, resultList);
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.SUCCESS); return result; } /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authedDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> authedDatasourceList = dataSourceMapper.queryAuthedDatasource(userId); result.put(Constants.DATA_LIST, authedDatasourceList); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTables(Integer datasourceId) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); List<String> tableList = null; BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(), dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result;
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
} Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam); ResultSet tables = null; try { if (null == connection) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } DatabaseMetaData metaData = connection.getMetaData(); String schema = null; try { schema = metaData.getConnection().getSchema(); } catch (SQLException e) { logger.error("Cant not get the schema, datasourceId:{}.", datasourceId, e); } tables = metaData.getTables( connectionParam.getDatabase(), getDbSchemaPattern(dataSource.getType(), schema, connectionParam), "%", TABLE_TYPES); if (null == tables) { logger.error("Get datasource tables error, datasourceId:{}.", datasourceId); putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } tableList = new ArrayList<>(); while (tables.next()) { String name = tables.getString(TABLE_NAME); tableList.add(name); }
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
} catch (Exception e) { logger.error("Get datasource tables error, datasourceId:{}.", datasourceId, e); putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } finally { closeResult(tables); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(tableList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTableColumns(Integer datasourceId, String tableName) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(), dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam); List<String> columnList = new ArrayList<>(); ResultSet rs = null; try {
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
String database = connectionParam.getDatabase(); if (null == connection) { return result; } DatabaseMetaData metaData = connection.getMetaData(); if (dataSource.getType() == DbType.ORACLE) { database = null; } rs = metaData.getColumns(database, null, tableName, "%"); if (rs == null) { return result; } while (rs.next()) { columnList.add(rs.getString(COLUMN_NAME)); } } catch (Exception e) { logger.error("Get datasource table columns error, datasourceId:{}.", dataSource.getId(), e); } finally { closeResult(rs); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(columnList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } private List<ParamsOptions> getParamsOptions(List<String> columnList) { List<ParamsOptions> options = null; if (CollectionUtils.isNotEmpty(columnList)) { options = new ArrayList<>();
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
for (String column : columnList) { ParamsOptions childrenOption = new ParamsOptions(column, column, false); options.add(childrenOption); } } return options; } private String getDbSchemaPattern(DbType dbType, String schema, BaseConnectionParam connectionParam) { if (dbType == null) { return null; } String schemaPattern = null; switch (dbType) { case HIVE: schemaPattern = connectionParam.getDatabase(); break; case ORACLE: schemaPattern = connectionParam.getUser(); if (null != schemaPattern) { schemaPattern = schemaPattern.toUpperCase(); } break; case SQLSERVER: schemaPattern = "dbo"; break; case CLICKHOUSE: case PRESTO: if (!StringUtils.isEmpty(schema)) { schemaPattern = schema;
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
} break; default: break; } return schemaPattern; } private static void releaseConnection(Connection connection) { if (null != connection) { try { connection.close(); } catch (Exception e) { logger.error("Connection release error", e); } } } private static void closeResult(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (Exception e) { logger.error("ResultSet close error", e); } } } private void clearBindTestId(Integer bindTestId) { dataSourceMapper.clearBindTestId(bindTestId); } }
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.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 org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl; import org.apache.dolphinscheduler.api.service.impl.DataSourceServiceImpl; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.DataSourceConstants; 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.common.utils.PropertyUtils; 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.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.plugin.datasource.hive.param.HiveDataSourceParamDTO;
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
import org.apache.dolphinscheduler.plugin.datasource.mysql.param.MySQLDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.oracle.param.OracleDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.postgresql.param.PostgreSQLDataSourceParamDTO; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbConnectType; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.commons.collections.CollectionUtils; import java.sql.Connection; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; 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.MockedStatic; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * data source service test */ @ExtendWith(MockitoExtension.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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
public class DataSourceServiceTest { private static final Logger baseServiceLogger = LoggerFactory.getLogger(BaseServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceTest.class); private static final Logger dataSourceServiceLogger = LoggerFactory.getLogger(DataSourceServiceImpl.class); @InjectMocks private DataSourceServiceImpl dataSourceService; @Mock private DataSourceMapper dataSourceMapper; @Mock private DataSourceUserMapper datasourceUserMapper; @Mock private ResourcePermissionCheckService resourcePermissionCheckService; private void passResourcePermissionCheckService() { Mockito.when(resourcePermissionCheckService.operationPermissionCheck(Mockito.any(), Mockito.anyInt(), Mockito.anyString(), Mockito.any())).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(Mockito.any(), Mockito.any(), Mockito.anyInt(), Mockito.any())).thenReturn(true); } @Test public void createDataSourceTest() throws ExecutionException { User loginUser = getAdminUser(); 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);
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
postgreSqlDatasourceParam.setDatabase("dolphinscheduler"); postgreSqlDatasourceParam.setUserName("postgres"); postgreSqlDatasourceParam.setPassword(""); postgreSqlDatasourceParam.setName(dataSourceName); Result result = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), result.getCode().intValue()); List<DataSource> dataSourceList = new ArrayList<>(); DataSource dataSource = new DataSource(); dataSource.setName(dataSourceName); dataSourceList.add(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(dataSourceList); passResourcePermissionCheckService(); Result dataSourceExitsResult = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceExitsResult.getCode().intValue()); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); Mockito.when(dataSourceMapper.queryDataSourceByName(dataSourceName.trim())).thenReturn(null); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(null); Result connectFailedResult = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_CONNECT_FAILED.getCode(), connectFailedResult.getCode().intValue()); Connection connection = Mockito.mock(Connection.class); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(connection);
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Result success = dataSourceService.createDataSource(loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.SUCCESS.getCode(), success.getCode().intValue()); } } @Test public void updateDataSourceTest() throws ExecutionException { User loginUser = getAdminUser(); int dataSourceId = 12; String dataSourceName = "dataSource01"; String dataSourceDesc = "test dataSource"; String dataSourceUpdateName = "dataSource01-update"; 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(""); postgreSqlDatasourceParam.setName(dataSourceUpdateName); 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(); dataSource.setUserId(0); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Result userNoOperationPerm =
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), userNoOperationPerm.getCode().intValue()); dataSource.setName(dataSourceName); dataSource.setType(DbType.POSTGRESQL); dataSource.setConnectionParams( JSONUtils.toJsonString(DataSourceUtils.buildConnectionParams(postgreSqlDatasourceParam))); DataSource anotherDataSource = new DataSource(); anotherDataSource.setName(dataSourceUpdateName); List<DataSource> dataSourceList = new ArrayList<>(); dataSourceList.add(anotherDataSource); Mockito.when(dataSourceMapper.selectById(dataSourceId)).thenReturn(dataSource); Mockito.when(dataSourceMapper.queryDataSourceByName(postgreSqlDatasourceParam.getName())) .thenReturn(dataSourceList); passResourcePermissionCheckService(); Result dataSourceNameExist = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.DATASOURCE_EXIST.getCode(), dataSourceNameExist.getCode().intValue()); try ( MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = Mockito.mockStatic(DataSourceClientProvider.class)) { DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(null); Mockito.when(dataSourceMapper.queryDataSourceByName(postgreSqlDatasourceParam.getName())).thenReturn(null); Result connectFailed = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); Assertions.assertEquals(Status.CONNECTION_TEST_FAILURE.getCode(), connectFailed.getCode().intValue());
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Connection connection = Mockito.mock(Connection.class); Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(connection); Result success = dataSourceService.updateDataSource(dataSourceId, loginUser, postgreSqlDatasourceParam); 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);
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Assertions.assertEquals(result.getCode(), dataSourceService.delete(loginUser, dataSourceId).getCode()); dataSourceService.putMsg(result, Status.USER_NO_OPERATION_PERM); DataSource dataSource = new DataSource(); 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); passResourcePermissionCheckService(); 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());
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Map<String, Object> result = dataSourceService.unauthDatasource(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); 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);
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
logger.info(result.toString()); 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);
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
Map<String, Object> result = dataSourceService.queryDataSource(Mockito.anyInt()); 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");
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
dataSource.setNote("Note"); dataSource.setType(DbType.ORACLE); dataSource.setConnectionParams( "{\"connectType\":\"ORACLE_SID\",\"address\":\"jdbc:oracle:thin:@192.168.xx.xx:49161\",\"database\":\"XE\"," + "\"jdbcUrl\":\"jdbc:oracle:thin:@192.168.xx.xx:49161/XE\",\"user\":\"system\",\"password\":\"oracle\"}"); return dataSource; } @Test public void buildParameter() { 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");
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
hiveDataSourceParamDTO.setJavaSecurityKrb5Conf("/opt/krb5.conf"); 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 =
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/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
"{\"user\":\"test\",\"password\":\"bnVsbE1USXpORFUy\",\"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\",\"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,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/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); 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
12,853
[Improvement][UT] Improve the ut of ResourcePermissionCheckServiceTest
### 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 ResourcePermissionCheckServiceTest ### 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/12853
https://github.com/apache/dolphinscheduler/pull/12854
27c37b882840e4e373d966858e27793686bdc94c
20518682bbc1970f3250ece24c35bddf35241a98
2022-11-10T06:24:27Z
java
2022-11-19T07:12:12Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.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.permission; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.User;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,853
[Improvement][UT] Improve the ut of ResourcePermissionCheckServiceTest
### 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 ResourcePermissionCheckServiceTest ### 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/12853
https://github.com/apache/dolphinscheduler/pull/12854
27c37b882840e4e373d966858e27793686bdc94c
20518682bbc1970f3250ece24c35bddf35241a98
2022-11-10T06:24:27Z
java
2022-11-19T07:12:12Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; 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.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; /** * permission service test */ @ExtendWith(MockitoExtension.class) public class ResourcePermissionCheckServiceTest { private static final Logger logger = LoggerFactory.getLogger(ResourcePermissionCheckServiceTest.class); @Mock private ProcessService processService; @Mock private ProjectMapper projectMapper; @Mock private ApplicationContext context; @Mock private ResourcePermissionCheckService<Object> resourcePermissionCheckService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,853
[Improvement][UT] Improve the ut of ResourcePermissionCheckServiceTest
### 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 ResourcePermissionCheckServiceTest ### 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/12853
https://github.com/apache/dolphinscheduler/pull/12854
27c37b882840e4e373d966858e27793686bdc94c
20518682bbc1970f3250ece24c35bddf35241a98
2022-11-10T06:24:27Z
java
2022-11-19T07:12:12Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java
@InjectMocks ResourcePermissionCheckServiceImpl resourcePermissionCheckServices; protected static final Map<AuthorizationType, ResourcePermissionCheckServiceImpl.ResourceAcquisitionAndPermissionCheck<?>> RESOURCE_LIST_MAP = new ConcurrentHashMap<>(); @Test public void testResourcePermissionCheck() { User user = new User(); user.setId(1); Object[] obj = new Object[]{1, 2}; boolean result = this.resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, obj, user.getId(), logger); Assertions.assertFalse(result); } @Test public void testOperationPermissionCheck() { User user = new User(); user.setId(1); resourcePermissionCheckServices.setApplicationContext(context); Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, user.getId(), null, logger)); String sourceUrl = "/tmp/"; Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, user.getId(), sourceUrl, logger)); } @Test public void testUserOwnedResourceIdsAcquisition() { User user = new User(); user.setId(1); user.setUserType(UserType.ADMIN_USER);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,853
[Improvement][UT] Improve the ut of ResourcePermissionCheckServiceTest
### 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 ResourcePermissionCheckServiceTest ### 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/12853
https://github.com/apache/dolphinscheduler/pull/12854
27c37b882840e4e373d966858e27793686bdc94c
20518682bbc1970f3250ece24c35bddf35241a98
2022-11-10T06:24:27Z
java
2022-11-19T07:12:12Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java
Set result = resourcePermissionCheckServices.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, user.getId(), logger); Assertions.assertNotNull(result); } @Test public void testSetApplication() { resourcePermissionCheckServices.setApplicationContext(context); } /** * create entity */ private Project getEntity() { Project project = new Project(); project.setId(1); project.setUserId(1); project.setName("permissionsTest"); project.setUserName("permissionTest"); return project; } /** * entity list */ private List<Project> getList() { List<Project> list = new ArrayList<>(); list.add(getEntity()); return list; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,804
[Improvement][UT] Remove the unused method in DataAnalysisControllerTest
### 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 Remove the unused method in DataAnalysisControllerTest ### 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/12804
https://github.com/apache/dolphinscheduler/pull/12805
27c00ed3772113e4eb7c53035360d3e3dbf55e66
d09e02e5a92f0f6a70d053128e280be1143a567b
2022-11-08T02:20:11Z
java
2022-11-21T12:59:30Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.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.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,804
[Improvement][UT] Remove the unused method in DataAnalysisControllerTest
### 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 Remove the unused method in DataAnalysisControllerTest ### 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/12804
https://github.com/apache/dolphinscheduler/pull/12805
27c00ed3772113e4eb7c53035360d3e3dbf55e66
d09e02e5a92f0f6a70d053128e280be1143a567b
2022-11-08T02:20:11Z
java
2022-11-21T12:59:30Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
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.utils.Result; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import java.util.Date; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; /** * data analysis controller test */ public class DataAnalysisControllerTest extends AbstractControllerTest { private static final Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class); @Autowired private ProjectMapper projectMapper; private int createProject() { Project project = new Project(); project.setCode(16L); project.setName("ut project"); project.setUserId(1); project.setCreateTime(new Date()); projectMapper.insert(project);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,804
[Improvement][UT] Remove the unused method in DataAnalysisControllerTest
### 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 Remove the unused method in DataAnalysisControllerTest ### 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/12804
https://github.com/apache/dolphinscheduler/pull/12805
27c00ed3772113e4eb7c53035360d3e3dbf55e66
d09e02e5a92f0f6a70d053128e280be1143a567b
2022-11-08T02:20:11Z
java
2022-11-21T12:59:30Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
return project.getId(); } @Test public void testCountTaskState() throws Exception { int projectId = createProject(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("startDate", "2019-12-01 00:00:00"); paramsMap.add("endDate", "2019-12-28 00:00:00"); paramsMap.add("projectCode", "16"); MvcResult mvcResult = mockMvc.perform(get("/projects/analysis/task-state-count") .header("sessionId", sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); assertThat(result.getCode().intValue()).isEqualTo(Status.SUCCESS.getCode()); logger.info(mvcResult.getResponse().getContentAsString()); projectMapper.deleteById(projectId); } @Test public void testCountProcessInstanceState() throws Exception { int projectId = createProject(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("startDate", "2019-12-01 00:00:00"); paramsMap.add("endDate", "2019-12-28 00:00:00"); paramsMap.add("projectCode", "16"); MvcResult mvcResult = mockMvc.perform(get("/projects/analysis/process-state-count") .header("sessionId", sessionId) .params(paramsMap))
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,804
[Improvement][UT] Remove the unused method in DataAnalysisControllerTest
### 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 Remove the unused method in DataAnalysisControllerTest ### 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/12804
https://github.com/apache/dolphinscheduler/pull/12805
27c00ed3772113e4eb7c53035360d3e3dbf55e66
d09e02e5a92f0f6a70d053128e280be1143a567b
2022-11-08T02:20:11Z
java
2022-11-21T12:59:30Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
.andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); assertThat(result.getCode().intValue()).isEqualTo(Status.SUCCESS.getCode()); logger.info(mvcResult.getResponse().getContentAsString()); projectMapper.deleteById(projectId); } @Test public void testCountDefinitionByUser() throws Exception { MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("projectId", "16"); MvcResult mvcResult = mockMvc.perform(get("/projects/analysis/define-user-count") .header("sessionId", sessionId) .params(paramsMap)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); assertThat(result.getCode().intValue()).isEqualTo(Status.SUCCESS.getCode()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testCountCommandState() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/projects/analysis/command-state-count") .header("sessionId", sessionId)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,804
[Improvement][UT] Remove the unused method in DataAnalysisControllerTest
### 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 Remove the unused method in DataAnalysisControllerTest ### 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/12804
https://github.com/apache/dolphinscheduler/pull/12805
27c00ed3772113e4eb7c53035360d3e3dbf55e66
d09e02e5a92f0f6a70d053128e280be1143a567b
2022-11-08T02:20:11Z
java
2022-11-21T12:59:30Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
assertThat(result.getCode().intValue()).isEqualTo(Status.SUCCESS.getCode()); logger.info(mvcResult.getResponse().getContentAsString()); } @Test public void testCountQueueState() throws Exception { MvcResult mvcResult = mockMvc.perform(get("/projects/analysis/queue-count") .header("sessionId", sessionId)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); assertThat(result.getCode().intValue()).isEqualTo(Status.SUCCESS.getCode()); logger.info(mvcResult.getResponse().getContentAsString()); } /** * get mock Project * * @param projectName projectName * @return Project */ private Project getProject(String projectName) { Project project = new Project(); project.setCode(11L); project.setId(1); project.setName(projectName); project.setUserId(1); return project; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.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.server.master.runner; import org.apache.dolphinscheduler.common.enums.Flag;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
import org.apache.dolphinscheduler.common.enums.StateEventType; import org.apache.dolphinscheduler.common.utils.NetUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.remote.command.WorkflowStateEventChangeCommand; import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.event.StateEvent; import org.apache.dolphinscheduler.server.master.event.TaskStateEvent; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.utils.LoggerUtils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.PostConstruct; import lombok.NonNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Component; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureCallback; import com.google.common.base.Strings; /** * Used to execute {@link WorkflowExecuteRunnable}. */ @Component
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
public class WorkflowExecuteThreadPool extends ThreadPoolTaskExecutor { private static final Logger logger = LoggerFactory.getLogger(WorkflowExecuteThreadPool.class); @Autowired private MasterConfig masterConfig; @Autowired private ProcessService processService; @Autowired private ProcessInstanceExecCacheManager processInstanceExecCacheManager; @Autowired private StateEventCallbackService stateEventCallbackService; @Autowired private StateWheelExecuteThread stateWheelExecuteThread; /** * multi-thread filter, avoid handling workflow at the same time */ private ConcurrentHashMap<String, WorkflowExecuteRunnable> multiThreadFilterMap = new ConcurrentHashMap<>(); @PostConstruct private void init() { this.setDaemon(true); this.setThreadNamePrefix("WorkflowExecuteThread-"); this.setMaxPoolSize(masterConfig.getExecThreads()); this.setCorePoolSize(masterConfig.getExecThreads()); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
* submit state event */ public void submitStateEvent(StateEvent stateEvent) { WorkflowExecuteRunnable workflowExecuteThread = processInstanceExecCacheManager.getByProcessInstanceId(stateEvent.getProcessInstanceId()); if (workflowExecuteThread == null) { logger.warn("Submit state event error, cannot from workflowExecuteThread from cache manager, stateEvent:{}", stateEvent); return; } workflowExecuteThread.addStateEvent(stateEvent); logger.info("Submit state event success, stateEvent: {}", stateEvent); } /** * Handle the events belong to the given workflow. */ public void executeEvent(final WorkflowExecuteRunnable workflowExecuteThread) { if (!workflowExecuteThread.isStart() || workflowExecuteThread.eventSize() == 0) { return; } if (multiThreadFilterMap.containsKey(workflowExecuteThread.getKey())) { logger.warn("The workflow has been executed by another thread"); return; } multiThreadFilterMap.put(workflowExecuteThread.getKey(), workflowExecuteThread); int processInstanceId = workflowExecuteThread.getProcessInstance().getId(); ListenableFuture<?> future = this.submitListenable(workflowExecuteThread::handleEvents); future.addCallback(new ListenableFutureCallback() { @Override public void onFailure(Throwable ex) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
LoggerUtils.setWorkflowInstanceIdMDC(processInstanceId); try { logger.error("Workflow instance events handle failed", ex); multiThreadFilterMap.remove(workflowExecuteThread.getKey()); } finally { LoggerUtils.removeWorkflowInstanceIdMDC(); } } @Override public void onSuccess(Object result) { try { LoggerUtils.setWorkflowInstanceIdMDC(workflowExecuteThread.getProcessInstance().getId()); if (workflowExecuteThread.workFlowFinish()) { stateWheelExecuteThread .removeProcess4TimeoutCheck(workflowExecuteThread.getProcessInstance().getId()); processInstanceExecCacheManager.removeByProcessInstanceId(processInstanceId); notifyProcessChanged(workflowExecuteThread.getProcessInstance()); logger.info("Workflow instance is finished."); } } catch (Exception e) { logger.error("Workflow instance is finished, but notify changed error", e); } finally { multiThreadFilterMap.remove(workflowExecuteThread.getKey()); LoggerUtils.removeWorkflowInstanceIdMDC(); } } }); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
* notify process change */ private void notifyProcessChanged(ProcessInstance finishProcessInstance) { if (Flag.NO == finishProcessInstance.getIsSubProcess()) { return; } Map<ProcessInstance, TaskInstance> fatherMaps = processService.notifyProcessList(finishProcessInstance.getId()); for (Map.Entry<ProcessInstance, TaskInstance> entry : fatherMaps.entrySet()) { ProcessInstance processInstance = entry.getKey(); TaskInstance taskInstance = entry.getValue(); String address = NetUtils.getAddr(masterConfig.getListenPort()); try { LoggerUtils.setWorkflowAndTaskInstanceIDMDC(processInstance.getId(), taskInstance.getId()); if (processInstance.getHost().equalsIgnoreCase(address)) { logger.info("Process host is local master, will notify it"); this.notifyMyself(processInstance, taskInstance); } else { logger.info("Process host is remote master, will notify it"); this.notifyProcess(finishProcessInstance, processInstance, taskInstance); } } finally { LoggerUtils.removeWorkflowAndTaskInstanceIdMDC(); } } } /** * notify myself */ private void notifyMyself(@NonNull ProcessInstance processInstance, @NonNull TaskInstance taskInstance) { if (!processInstanceExecCacheManager.contains(processInstance.getId())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,932
[Bug] [Master] when subprocess's processInstance is fail,not notify parent processInstance
### 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 when subprocess's process Instance 's state changed to fail, match the task instance‘s state is still SUBMITTED_SUCCESS in the parent process instance ### What you expected to happen notify master to change state in parent process instance ### How to reproduce notify master to change state in parent process instance ### 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/12932
https://github.com/apache/dolphinscheduler/pull/12933
d09e02e5a92f0f6a70d053128e280be1143a567b
3747029cc06cef2c3dd5063b3dc303585627400b
2022-11-18T06:02:43Z
java
2022-11-22T07:07:50Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThreadPool.java
logger.warn("The execute cache manager doesn't contains this workflow instance"); return; } TaskStateEvent stateEvent = TaskStateEvent.builder() .processInstanceId(processInstance.getId()) .taskInstanceId(taskInstance.getId()) .type(StateEventType.TASK_STATE_CHANGE) .status(TaskExecutionStatus.RUNNING_EXECUTION) .build(); this.submitStateEvent(stateEvent); } /** * notify process's master */ private void notifyProcess(ProcessInstance finishProcessInstance, ProcessInstance processInstance, TaskInstance taskInstance) { String processInstanceHost = processInstance.getHost(); if (Strings.isNullOrEmpty(processInstanceHost)) { logger.error("Process {} host is empty, cannot notify task {} now, taskId: {}", processInstance.getName(), taskInstance.getName(), taskInstance.getId()); return; } WorkflowStateEventChangeCommand workflowStateEventChangeCommand = new WorkflowStateEventChangeCommand( finishProcessInstance.getId(), 0, finishProcessInstance.getState(), processInstance.getId(), taskInstance.getId()); Host host = new Host(processInstanceHost); stateEventCallbackService.sendResult(host, workflowStateEventChangeCommand.convert2Command()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,954
[Bug] [Schedule] When timing triggers execution, the configured workflow-level environment information does not take effect
### 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 When timing triggers execution, the configured workflow-level environment information does not take effect. ### What you expected to happen When timing triggers execution, the workflow configuration environment information is effective. ### How to reproduce When timing triggers execution, the configured workflow-level environment information does not take effect. ### Anything else _No response_ ### Version 3.1.x ### 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/12954
https://github.com/apache/dolphinscheduler/pull/12955
3747029cc06cef2c3dd5063b3dc303585627400b
2f8f0952fb6e45b84437e9f651096858d856bd96
2022-11-22T01:42:51Z
java
2022-11-22T07:35:29Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.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.
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,954
[Bug] [Schedule] When timing triggers execution, the configured workflow-level environment information does not take effect
### 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 When timing triggers execution, the configured workflow-level environment information does not take effect. ### What you expected to happen When timing triggers execution, the workflow configuration environment information is effective. ### How to reproduce When timing triggers execution, the configured workflow-level environment information does not take effect. ### Anything else _No response_ ### Version 3.1.x ### 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/12954
https://github.com/apache/dolphinscheduler/pull/12955
3747029cc06cef2c3dd5063b3dc303585627400b
2f8f0952fb6e45b84437e9f651096858d856bd96
2022-11-22T01:42:51Z
java
2022-11-22T07:35:29Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
* See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.scheduler.quartz; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.dao.entity.Command; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Schedule; import org.apache.dolphinscheduler.scheduler.quartz.utils.QuartzTaskUtils; import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.commons.lang3.StringUtils; import java.util.Date; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobKey; import org.quartz.Scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.quartz.QuartzJobBean; import io.micrometer.core.annotation.Counted; import io.micrometer.core.annotation.Timed; public class ProcessScheduleTask extends QuartzJobBean { private static final Logger logger = LoggerFactory.getLogger(ProcessScheduleTask.class); @Autowired private ProcessService processService; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,954
[Bug] [Schedule] When timing triggers execution, the configured workflow-level environment information does not take effect
### 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 When timing triggers execution, the configured workflow-level environment information does not take effect. ### What you expected to happen When timing triggers execution, the workflow configuration environment information is effective. ### How to reproduce When timing triggers execution, the configured workflow-level environment information does not take effect. ### Anything else _No response_ ### Version 3.1.x ### 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/12954
https://github.com/apache/dolphinscheduler/pull/12955
3747029cc06cef2c3dd5063b3dc303585627400b
2f8f0952fb6e45b84437e9f651096858d856bd96
2022-11-22T01:42:51Z
java
2022-11-22T07:35:29Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
private CommandService commandService; @Counted(value = "ds.master.quartz.job.executed") @Timed(value = "ds.master.quartz.job.execution.time", percentiles = {0.5, 0.75, 0.95, 0.99}, histogram = true) @Override protected void executeInternal(JobExecutionContext context) { JobDataMap dataMap = context.getJobDetail().getJobDataMap(); int projectId = dataMap.getInt(QuartzTaskUtils.PROJECT_ID); int scheduleId = dataMap.getInt(QuartzTaskUtils.SCHEDULE_ID); Date scheduledFireTime = context.getScheduledFireTime(); Date fireTime = context.getFireTime(); logger.info("scheduled fire time :{}, fire time :{}, scheduleId :{}", scheduledFireTime, fireTime, scheduleId); Schedule schedule = processService.querySchedule(scheduleId); if (schedule == null || ReleaseState.OFFLINE == schedule.getReleaseState()) { logger.warn( "process schedule does not exist in db or process schedule offline,delete schedule job in quartz, projectId:{}, scheduleId:{}", projectId, scheduleId); deleteJob(context, projectId, scheduleId); return; } ProcessDefinition processDefinition = processService.findProcessDefinitionByCode(schedule.getProcessDefinitionCode()); // ReleaseState releaseState = processDefinition.getReleaseState(); if (releaseState == ReleaseState.OFFLINE) { logger.warn( "process definition does not exist in db or offline,need not to create command, projectId:{}, processDefinitionId:{}", projectId, processDefinition.getId()); return; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,954
[Bug] [Schedule] When timing triggers execution, the configured workflow-level environment information does not take effect
### 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 When timing triggers execution, the configured workflow-level environment information does not take effect. ### What you expected to happen When timing triggers execution, the workflow configuration environment information is effective. ### How to reproduce When timing triggers execution, the configured workflow-level environment information does not take effect. ### Anything else _No response_ ### Version 3.1.x ### 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/12954
https://github.com/apache/dolphinscheduler/pull/12955
3747029cc06cef2c3dd5063b3dc303585627400b
2f8f0952fb6e45b84437e9f651096858d856bd96
2022-11-22T01:42:51Z
java
2022-11-22T07:35:29Z
dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
Command command = new Command(); command.setCommandType(CommandType.SCHEDULER); command.setExecutorId(schedule.getUserId()); command.setFailureStrategy(schedule.getFailureStrategy()); command.setProcessDefinitionCode(schedule.getProcessDefinitionCode()); command.setScheduleTime(scheduledFireTime); command.setStartTime(fireTime); command.setWarningGroupId(schedule.getWarningGroupId()); String workerGroup = StringUtils.isEmpty(schedule.getWorkerGroup()) ? Constants.DEFAULT_WORKER_GROUP : schedule.getWorkerGroup(); command.setWorkerGroup(workerGroup); command.setWarningType(schedule.getWarningType()); command.setProcessInstancePriority(schedule.getProcessInstancePriority()); command.setProcessDefinitionVersion(processDefinition.getVersion()); commandService.createCommand(command); } private void deleteJob(JobExecutionContext context, int projectId, int scheduleId) { final Scheduler scheduler = context.getScheduler(); JobKey jobKey = QuartzTaskUtils.getJobKey(scheduleId, projectId); try { if (scheduler.checkExists(jobKey)) { logger.info("Try to delete job: {}, projectId: {}, schedulerId", projectId, scheduleId); scheduler.deleteJob(jobKey); } } catch (Exception e) { logger.error("Failed to delete job: {}", jobKey); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.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.plugin.task.python; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor; import org.apache.dolphinscheduler.plugin.task.api.TaskCallBack;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskException; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; import org.apache.dolphinscheduler.plugin.task.api.model.Property; import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils; import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Map; import com.google.common.base.Preconditions; /** * python task */ public class PythonTask extends AbstractTask { /** * python parameters */ protected PythonParameters pythonParameters; /** * shell command executor */ private ShellCommandExecutor shellCommandExecutor; protected TaskExecutionContext taskRequest; protected static final String PYTHON_HOME = "PYTHON_HOME";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
private static final String DEFAULT_PYTHON_VERSION = "python"; /** * constructor * * @param taskRequest taskRequest */ public PythonTask(TaskExecutionContext taskRequest) { super(taskRequest); this.taskRequest = taskRequest; this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle, taskRequest, logger); } @Override public void init() { logger.info("python task params {}", taskRequest.getTaskParams()); pythonParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), PythonParameters.class); if (!pythonParameters.checkParameters()) { throw new TaskException("python task params is not valid"); } } @Override public String getPreScript() { String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); try { rawPythonScript = convertPythonScriptPlaceholders(rawPythonScript); } catch (StringIndexOutOfBoundsException e) { logger.error("setShareVar field format error, raw python script : {}", rawPythonScript); } return rawPythonScript;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
} @Override public void handle(TaskCallBack taskCallBack) throws TaskException { try { String pythonScriptContent = buildPythonScriptContent(); String pythonScriptFile = buildPythonCommandFilePath(); createPythonCommandFileIfNotExists(pythonScriptContent, pythonScriptFile); String command = buildPythonExecuteCommand(pythonScriptFile); TaskResponse taskResponse = shellCommandExecutor.run(command); setExitStatusCode(taskResponse.getExitStatusCode()); setProcessId(taskResponse.getProcessId()); setVarPool(shellCommandExecutor.getVarPool()); } catch (Exception e) { logger.error("python task failure", e); setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE); throw new TaskException("run python task error", e); } } @Override public void cancel() throws TaskException { try { shellCommandExecutor.cancelApplication(); } catch (Exception e) { throw new TaskException("cancel application error", e); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
@Override public AbstractParameters getParameters() { return pythonParameters; } /** * convertPythonScriptPlaceholders * * @param rawScript rawScript * @return String * @throws StringIndexOutOfBoundsException if substring index is out of bounds */ private static String convertPythonScriptPlaceholders(String rawScript) throws StringIndexOutOfBoundsException { int len = "${setShareVar(${".length(); int scriptStart = 0; while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) { int start = -1; int end = rawScript.indexOf('}', scriptStart + len); String prop = rawScript.substring(scriptStart + len, end); start = rawScript.indexOf(',', end); end = rawScript.indexOf(')', start); String value = rawScript.substring(start + 1, end); start = rawScript.indexOf('}', start) + 1; end = rawScript.length(); String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value); rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end); scriptStart += replaceScript.length(); } return rawScript; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
* create python command file if not exists * * @param pythonScript exec python script * @param pythonScriptFile python script file * @throws IOException io exception */ protected void createPythonCommandFileIfNotExists(String pythonScript, String pythonScriptFile) throws IOException { logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath()); if (!Files.exists(Paths.get(pythonScriptFile))) { logger.info("generate python script file:{}", pythonScriptFile); StringBuilder sb = new StringBuilder(); sb.append("#-*- encoding=utf8 -*-").append(System.lineSeparator()); sb.append(System.lineSeparator()); sb.append(pythonScript); logger.info(sb.toString()); FileUtils.writeStringToFile(new File(pythonScriptFile), sb.toString(), StandardCharsets.UTF_8); } } /** * build python command file path * * @return python command file path */ protected String buildPythonCommandFilePath() { return String.format("%s/py_%s.py", taskRequest.getExecutePath(), taskRequest.getTaskAppId()); } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,958
[Bug] [Task Plugin] Python task can not pass the parameters to downstream task.
### 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 ![image](https://user-images.githubusercontent.com/31528124/203241406-b6625b78-a1d7-410a-9db2-38dbd7e977b2.png) Can’t work ### What you expected to happen empty ### How to reproduce empty ### Anything else _No response_ ### Version 3.1.x ### 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/12958
https://github.com/apache/dolphinscheduler/pull/12961
bd1efccc9a4f451c30e0c74c9bd5d279167ffef6
6e224d08a22b0d9e67059bae69087038f7ba7394
2022-11-22T06:34:57Z
java
2022-11-22T08:11:45Z
dolphinscheduler-task-plugin/dolphinscheduler-task-python/src/main/java/org/apache/dolphinscheduler/plugin/task/python/PythonTask.java
* build python script content * * @return raw python script * @throws Exception exception */ protected String buildPythonScriptContent() throws Exception { logger.info("raw python script : {}", pythonParameters.getRawScript()); String rawPythonScript = pythonParameters.getRawScript().replaceAll("\\r\\n", System.lineSeparator()); Map<String, Property> paramsMap = mergeParamsWithContext(pythonParameters); return ParameterUtils.convertParameterPlaceholders(rawPythonScript, ParamUtils.convert(paramsMap)); } protected Map<String, Property> mergeParamsWithContext(AbstractParameters parameters) { return taskRequest.getPrepareParamsMap(); } /** * Build the python task command. * If user have set the 'PYTHON_HOME' environment, we will use the 'PYTHON_HOME', * if not, we will default use python. * * @param pythonFile Python file, cannot be empty. * @return Python execute command, e.g. 'python test.py'. */ protected String buildPythonExecuteCommand(String pythonFile) { Preconditions.checkNotNull(pythonFile, "Python file cannot be null"); String pythonHome = String.format("${%s}", PYTHON_HOME); return pythonHome + " " + pythonFile; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.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 *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.server.master.utils; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao; import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult; import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; import org.apache.dolphinscheduler.plugin.task.api.model.DateInterval; import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; import org.apache.dolphinscheduler.plugin.task.api.utils.DependentUtils; import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; import org.apache.dolphinscheduler.service.process.ProcessService; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * dependent item execute */ public class DependentExecute {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
/** * process service */ private final ProcessService processService = SpringApplicationContext.getBean(ProcessService.class); private final TaskInstanceDao taskInstanceDao = SpringApplicationContext.getBean(TaskInstanceDao.class); /** * depend item list */ private List<DependentItem> dependItemList; /** * dependent relation */ private DependentRelation relation; /** * depend result */ private DependResult modelDependResult = DependResult.WAITING; /** * depend result map */ private Map<String, DependResult> dependResultMap = new HashMap<>(); /** * logger */ private Logger logger = LoggerFactory.getLogger(DependentExecute.class); /** * constructor * * @param itemList item list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
* @param relation relation */ public DependentExecute(List<DependentItem> itemList, DependentRelation relation) { this.dependItemList = itemList; this.relation = relation; } /** * get dependent item for one dependent item * * @param dependentItem dependent item * @param currentTime current time * @return DependResult */ private DependResult getDependentResultForItem(DependentItem dependentItem, Date currentTime, int testFlag) { List<DateInterval> dateIntervals = DependentUtils.getDateIntervalList(currentTime, dependentItem.getDateValue()); return calculateResultForTasks(dependentItem, dateIntervals, testFlag); } /** * calculate dependent result for one dependent item. * * @param dependentItem dependent item * @param dateIntervals date intervals * @return dateIntervals */ private DependResult calculateResultForTasks(DependentItem dependentItem, List<DateInterval> dateIntervals, int testFlag) { DependResult result = DependResult.FAILED; for (DateInterval dateInterval : dateIntervals) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
ProcessInstance processInstance = findLastProcessInterval(dependentItem.getDefinitionCode(), dateInterval, testFlag); if (processInstance == null) { return DependResult.WAITING; } if (dependentItem.getDepTaskCode() == Constants.DEPENDENT_ALL_TASK_CODE) { result = dependResultByProcessInstance(processInstance); } else { result = getDependTaskResult(dependentItem.getDepTaskCode(), processInstance, testFlag); } if (result != DependResult.SUCCESS) { break; } } return result; } /** * depend type = depend_all * * @return */ private DependResult dependResultByProcessInstance(ProcessInstance processInstance) { if (!processInstance.getState().isFinished()) { return DependResult.WAITING; } if (processInstance.getState().isSuccess()) { return DependResult.SUCCESS; } return DependResult.FAILED;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
} /** * get depend task result * * @param taskCode * @param processInstance * @return */ private DependResult getDependTaskResult(long taskCode, ProcessInstance processInstance, int testFlag) { DependResult result; TaskInstance taskInstance = null; List<TaskInstance> taskInstanceList = taskInstanceDao.findValidTaskListByProcessId(processInstance.getId(), testFlag); for (TaskInstance task : taskInstanceList) { if (task.getTaskCode() == taskCode) { taskInstance = task; break; } } if (taskInstance == null) { if (processInstance.getState().isFinished()) { result = DependResult.FAILED; } else { return DependResult.WAITING; } } else { result = getDependResultByState(taskInstance.getState()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
return result; } /** * find the last one process instance that : * 1. manual run and finish between the interval * 2. schedule run and schedule time between the interval * * @param definitionCode definition code * @param dateInterval date interval * @return ProcessInstance */ private ProcessInstance findLastProcessInterval(Long definitionCode, DateInterval dateInterval, int testFlag) { ProcessInstance lastSchedulerProcess = processService.findLastSchedulerProcessInterval(definitionCode, dateInterval, testFlag); ProcessInstance lastManualProcess = processService.findLastManualProcessInterval(definitionCode, dateInterval, testFlag); if (lastManualProcess == null) { return lastSchedulerProcess; } if (lastSchedulerProcess == null) { return lastManualProcess; } return (lastManualProcess.getEndTime().after(lastSchedulerProcess.getEndTime())) ? lastManualProcess : lastSchedulerProcess; } /** * get dependent result by task/process instance state * * @param state state * @return DependResult
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
*/ private DependResult getDependResultByState(TaskExecutionStatus state) { if (!state.isFinished()) { return DependResult.WAITING; } else if (state.isSuccess()) { return DependResult.SUCCESS; } else { return DependResult.FAILED; } } /** * judge depend item finished * * @param currentTime current time * @return boolean */ public boolean finish(Date currentTime, int testFlag) { if (modelDependResult == DependResult.WAITING) { modelDependResult = getModelDependResult(currentTime, testFlag); return false; } return true; } /** * get model depend result * * @param currentTime current time * @return DependResult */ public DependResult getModelDependResult(Date currentTime, int testFlag) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,963
[Bug] [Master] Dependent task node null pointer exception
### 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 <img width="1395" alt="image" src="https://user-images.githubusercontent.com/37063904/203247835-598e1825-93f8-4eab-832e-374b0b77014b.png"> ### What you expected to happen Dependent task node to check that the status of the upstream task is normal ### How to reproduce There are two workflow definitions: w1, w2. In the workflow definition w2, use the dependent task node to select the workflow definition w1, and the time is today. Trigger w1 regularly to generate a w1-1 workflow instance to keep the task running; manually generate a w1-2 workflow instance to keep the task running. A workflow instance of w2 is generated regularly, and a null pointer exception will be reported if the dependent task node. ### Anything else _No response_ ### Version 3.1.x ### 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/12963
https://github.com/apache/dolphinscheduler/pull/12965
31021730ec78d8de1b55a3471ca713995052105b
50779ea1e6acdbca721dcc3d6331e13687ac9544
2022-11-22T07:22:04Z
java
2022-11-24T11:00:46Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/utils/DependentExecute.java
List<DependResult> dependResultList = new ArrayList<>(); for (DependentItem dependentItem : dependItemList) { DependResult dependResult = getDependResultForItem(dependentItem, currentTime, testFlag); if (dependResult != DependResult.WAITING) { dependResultMap.put(dependentItem.getKey(), dependResult); } dependResultList.add(dependResult); } modelDependResult = DependentUtils.getDependResultForRelation(this.relation, dependResultList); return modelDependResult; } /** * get dependent item result * * @param item item * @param currentTime current time * @return DependResult */ private DependResult getDependResultForItem(DependentItem item, Date currentTime, int testFlag) { String key = item.getKey(); if (dependResultMap.containsKey(key)) { return dependResultMap.get(key); } return getDependentResultForItem(item, currentTime, testFlag); } public Map<String, DependResult> getDependResultMap() { return dependResultMap; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.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,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.java
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.dolphinscheduler.server.master.dispatch.host; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.model.WorkerHeartBeat; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; import org.apache.dolphinscheduler.server.master.dispatch.host.assign.HostWeight; import org.apache.dolphinscheduler.server.master.dispatch.host.assign.HostWorker; import org.apache.dolphinscheduler.server.master.dispatch.host.assign.LowerWeightRoundRobin; import org.apache.dolphinscheduler.server.master.registry.WorkerInfoChangeListener; import org.apache.commons.collections.CollectionUtils; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import javax.annotation.PostConstruct; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * lower weight host manager */ public class LowerWeightHostManager extends CommonHostManager {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.java
private final Logger logger = LoggerFactory.getLogger(LowerWeightHostManager.class); /** * selector */ private LowerWeightRoundRobin selector; /** * worker host weights */ private ConcurrentHashMap<String, Set<HostWeight>> workerHostWeightsMap; /** * worker group host lock */ private Lock lock; @PostConstruct public void init() { this.selector = new LowerWeightRoundRobin(); this.workerHostWeightsMap = new ConcurrentHashMap<>(); this.lock = new ReentrantLock(); serverNodeManager.addWorkerInfoChangeListener(new WorkerWeightListener()); } /** * select host * * @param context context * @return host
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.java
*/ @Override public Host select(ExecutionContext context) { Set<HostWeight> workerHostWeights = getWorkerHostWeights(context.getWorkerGroup()); if (CollectionUtils.isNotEmpty(workerHostWeights)) { return selector.select(workerHostWeights).getHost(); } return new Host(); } @Override public HostWorker select(Collection<HostWorker> nodes) { throw new UnsupportedOperationException("not support"); } private class WorkerWeightListener implements WorkerInfoChangeListener { @Override public void notify(Map<String, Set<String>> workerGroups, Map<String, WorkerHeartBeat> workerNodeInfo) { syncWorkerResources(workerGroups, workerNodeInfo); } } /** * Sync worker resource. * * @param workerGroupNodes worker group nodes, key is worker group, value is worker group nodes. * @param workerNodeInfoMap worker node info map, key is worker node, value is worker info. */ private void syncWorkerResources(final Map<String, Set<String>> workerGroupNodes, final Map<String, WorkerHeartBeat> workerNodeInfoMap) { try { Map<String, Set<HostWeight>> workerHostWeights = new HashMap<>(); for (Map.Entry<String, Set<String>> entry : workerGroupNodes.entrySet()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.java
String workerGroup = entry.getKey(); Set<String> nodes = entry.getValue(); Set<HostWeight> hostWeights = new HashSet<>(nodes.size()); for (String node : nodes) { WorkerHeartBeat heartbeat = workerNodeInfoMap.getOrDefault(node, null); Optional<HostWeight> hostWeightOpt = getHostWeight(node, workerGroup, heartbeat); hostWeightOpt.ifPresent(hostWeights::add); } if (!hostWeights.isEmpty()) { workerHostWeights.put(workerGroup, hostWeights); } } syncWorkerHostWeight(workerHostWeights); } catch (Throwable ex) { logger.error("Sync worker resource error", ex); } } public Optional<HostWeight> getHostWeight(String addr, String workerGroup, WorkerHeartBeat heartBeat) { if (heartBeat == null) { logger.warn("worker {} in work group {} have not received the heartbeat", addr, workerGroup); return Optional.empty(); } if (Constants.ABNORMAL_NODE_STATUS == heartBeat.getServerStatus()) { logger.warn("worker {} current cpu load average {} is too high or available memory {}G is too low", addr, heartBeat.getLoadAverage(), heartBeat.getAvailablePhysicalMemorySize()); return Optional.empty(); } if (Constants.BUSY_NODE_STATUE == heartBeat.getServerStatus()) { logger.warn("worker {} is busy, current waiting task count {} is large than worker thread count {}", addr, heartBeat.getWorkerWaitingTaskCount(), heartBeat.getWorkerExecThreadCount());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/LowerWeightHostManager.java
return Optional.empty(); } return Optional.of( new HostWeight( HostWorker.of(addr, heartBeat.getWorkerHostWeight(), workerGroup), heartBeat.getCpuUsage(), heartBeat.getMemoryUsage(), heartBeat.getLoadAverage(), heartBeat.getWorkerWaitingTaskCount(), heartBeat.getStartupTime())); } private void syncWorkerHostWeight(Map<String, Set<HostWeight>> workerHostWeights) { lock.lock(); try { workerHostWeightsMap.clear(); workerHostWeightsMap.putAll(workerHostWeights); } finally { lock.unlock(); } } private Set<HostWeight> getWorkerHostWeights(String workerGroup) { lock.lock(); try { return workerHostWeightsMap.get(workerGroup); } finally { lock.unlock(); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.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.server.master.registry; import static org.apache.dolphinscheduler.common.constants.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS; import static org.apache.dolphinscheduler.common.constants.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.enums.NodeType; import org.apache.dolphinscheduler.common.model.Server; import org.apache.dolphinscheduler.common.model.WorkerHeartBeat; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.entity.WorkerGroup; import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper; import org.apache.dolphinscheduler.registry.api.Event; import org.apache.dolphinscheduler.registry.api.Event.Type;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
import org.apache.dolphinscheduler.registry.api.SubscribeListener; import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.queue.MasterPriorityQueue; import org.apache.dolphinscheduler.service.registry.RegistryClient; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; 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.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.stream.Collectors; import javax.annotation.PreDestroy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class ServerNodeManager implements InitializingBean { private final Logger logger = LoggerFactory.getLogger(ServerNodeManager.class); private final Lock masterLock = new ReentrantLock(); private final ReentrantReadWriteLock workerGroupLock = new ReentrantReadWriteLock(); private final ReentrantReadWriteLock.ReadLock workerGroupReadLock = workerGroupLock.readLock(); private final ReentrantReadWriteLock.WriteLock workerGroupWriteLock = workerGroupLock.writeLock(); private final ReentrantReadWriteLock workerNodeInfoLock = new ReentrantReadWriteLock(); private final ReentrantReadWriteLock.ReadLock workerNodeInfoReadLock = workerNodeInfoLock.readLock(); private final ReentrantReadWriteLock.WriteLock workerNodeInfoWriteLock = workerNodeInfoLock.writeLock(); /** * worker group nodes, workerGroup -> ips, combining registryWorkerGroupNodes and dbWorkerGroupNodes */ private final ConcurrentHashMap<String, Set<String>> workerGroupNodes = new ConcurrentHashMap<>(); private final Set<String> masterNodes = new HashSet<>(); private final Map<String, WorkerHeartBeat> workerNodeInfo = new HashMap<>(); /** * executor service */ private ScheduledExecutorService executorService; @Autowired private RegistryClient registryClient; @Autowired private WorkerGroupMapper workerGroupMapper; private final MasterPriorityQueue masterPriorityQueue = new MasterPriorityQueue(); @Autowired private AlertDao alertDao; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
private MasterConfig masterConfig; private final List<WorkerInfoChangeListener> workerInfoChangeListeners = new ArrayList<>(); private volatile int currentSlot = 0; private volatile int totalSlot = 0; public int getSlot() { return currentSlot; } public int getMasterSize() { return totalSlot; } @Override public void afterPropertiesSet() { updateMasterNodes(); updateWorkerNodes(); updateWorkerGroupMappings(); executorService = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("ServerNodeManagerExecutor")); executorService.scheduleWithFixedDelay( new WorkerNodeInfoAndGroupDbSyncTask(), 0, masterConfig.getWorkerGroupRefreshInterval().getSeconds(), TimeUnit.SECONDS); registryClient.subscribe(REGISTRY_DOLPHINSCHEDULER_MASTERS, new MasterDataListener()); registryClient.subscribe(REGISTRY_DOLPHINSCHEDULER_WORKERS, new WorkerDataListener()); } class WorkerNodeInfoAndGroupDbSyncTask implements Runnable {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
@Override public void run() { try { updateWorkerNodes(); updateWorkerGroupMappings(); notifyWorkerInfoChangeListeners(); } catch (Exception e) { logger.error("WorkerNodeInfoAndGroupDbSyncTask error:", e); } } } protected Set<String> getWorkerAddressByWorkerGroup(Map<String, String> newWorkerNodeInfo, WorkerGroup wg) { Set<String> nodes = new HashSet<>(); String[] addrs = wg.getAddrList().split(Constants.COMMA); for (String addr : addrs) { if (newWorkerNodeInfo.containsKey(addr)) { nodes.add(addr); } } return nodes; } /** * worker group node listener */ class WorkerDataListener implements SubscribeListener {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
@Override public void notify(Event event) { final String path = event.path(); final Type type = event.type(); final String data = event.data(); if (registryClient.isWorkerPath(path)) { try { String[] parts = path.split("/"); final String workerAddress = parts[parts.length - 1]; logger.debug("received subscribe event : {}", event); if (type == Type.ADD) { logger.info("Worker: {} added, currentNode : {}", path, workerAddress); } else if (type == Type.REMOVE) { logger.info("Worker node : {} down.", path); alertDao.sendServerStoppedAlert(1, path, "WORKER"); } else if (type == Type.UPDATE) { syncSingleWorkerNodeInfo(workerAddress, JSONUtils.parseObject(data, WorkerHeartBeat.class)); } } catch (Exception ex) { logger.error("WorkerGroupListener capture data change and get data failed", ex); } } } } class MasterDataListener implements SubscribeListener {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
@Override public void notify(Event event) { final String path = event.path(); final Type type = event.type(); if (registryClient.isMasterPath(path)) { try { if (type.equals(Type.ADD)) { logger.info("master node : {} added.", path); updateMasterNodes(); } if (type.equals(Type.REMOVE)) { logger.info("master node : {} down.", path); updateMasterNodes(); alertDao.sendServerStoppedAlert(1, path, "MASTER"); } } catch (Exception ex) { logger.error("MasterNodeListener capture data change and get data failed.", ex); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
} private void updateMasterNodes() { currentSlot = 0; totalSlot = 0; this.masterNodes.clear(); String nodeLock = Constants.REGISTRY_DOLPHINSCHEDULER_LOCK_MASTERS; try { registryClient.getLock(nodeLock); Collection<String> currentNodes = registryClient.getMasterNodesDirectly(); List<Server> masterNodes = registryClient.getServerList(NodeType.MASTER); syncMasterNodes(currentNodes, masterNodes); } catch (Exception e) { logger.error("update master nodes error", e); } finally { registryClient.releaseLock(nodeLock); } } private void updateWorkerNodes() { workerGroupWriteLock.lock(); try { Map<String, String> workerNodeMaps = registryClient.getServerMaps(NodeType.WORKER); for (Map.Entry<String, String> entry : workerNodeMaps.entrySet()) { workerNodeInfo.put(entry.getKey(), JSONUtils.parseObject(entry.getValue(), WorkerHeartBeat.class)); } } finally { workerGroupWriteLock.unlock(); } } private void updateWorkerGroupMappings() { List<WorkerGroup> workerGroups = workerGroupMapper.queryAllWorkerGroup();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
Map<String, Set<String>> tmpWorkerGroupMappings = new HashMap<>(); try { workerNodeInfoReadLock.lock(); for (WorkerGroup workerGroup : workerGroups) { String workerGroupName = workerGroup.getName(); String[] workerAddresses = workerGroup.getAddrList().split(Constants.COMMA); if (ArrayUtils.isEmpty(workerAddresses)) { continue; } Set<String> activeWorkerNodes = Arrays.stream(workerAddresses) .filter(workerNodeInfo::containsKey).collect(Collectors.toSet()); tmpWorkerGroupMappings.put(workerGroupName, activeWorkerNodes); } if (!tmpWorkerGroupMappings.containsKey(Constants.DEFAULT_WORKER_GROUP)) { tmpWorkerGroupMappings.put(Constants.DEFAULT_WORKER_GROUP, workerNodeInfo.keySet()); } } finally { workerNodeInfoReadLock.unlock(); } workerGroupWriteLock.lock(); try { workerGroupNodes.clear(); workerGroupNodes.putAll(tmpWorkerGroupMappings); notifyWorkerInfoChangeListeners(); } finally { workerGroupWriteLock.unlock(); } } /** * sync master nodes
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
* * @param nodes master nodes */ private void syncMasterNodes(Collection<String> nodes, List<Server> masterNodes) { masterLock.lock(); try { this.masterNodes.addAll(nodes); this.masterPriorityQueue.clear(); this.masterPriorityQueue.putList(masterNodes); int index = masterPriorityQueue.getIndex(masterConfig.getMasterAddress()); if (index >= 0) { totalSlot = nodes.size(); currentSlot = index; } else { logger.warn("Current master is not in active master list"); } logger.info("Update master nodes, total master size: {}, current slot: {}", totalSlot, currentSlot); } finally { masterLock.unlock(); } } public Map<String, Set<String>> getWorkerGroupNodes() { workerGroupReadLock.lock(); try { return Collections.unmodifiableMap(workerGroupNodes); } finally { workerGroupReadLock.unlock(); } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
* get worker group nodes * * @param workerGroup workerGroup * @return worker nodes */ public Set<String> getWorkerGroupNodes(String workerGroup) { workerGroupReadLock.lock(); try { if (StringUtils.isEmpty(workerGroup)) { workerGroup = Constants.DEFAULT_WORKER_GROUP; } Set<String> nodes = workerGroupNodes.get(workerGroup); if (CollectionUtils.isEmpty(nodes)) { return Collections.emptySet(); } return Collections.unmodifiableSet(nodes); } finally { workerGroupReadLock.unlock(); } } public Map<String, WorkerHeartBeat> getWorkerNodeInfo() { return Collections.unmodifiableMap(workerNodeInfo); } public Optional<WorkerHeartBeat> getWorkerNodeInfo(String workerServerAddress) { workerNodeInfoReadLock.lock(); try { return Optional.ofNullable(workerNodeInfo.getOrDefault(workerServerAddress, null)); } finally { workerNodeInfoReadLock.unlock(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java
} private void syncSingleWorkerNodeInfo(String workerAddress, WorkerHeartBeat info) { workerNodeInfoWriteLock.lock(); try { workerNodeInfo.put(workerAddress, info); } finally { workerNodeInfoWriteLock.unlock(); } } /** * Add the resource change listener, when the resource changed, the listener will be notified. * * @param listener will be trigger, when the worker node info changed. */ public synchronized void addWorkerInfoChangeListener(WorkerInfoChangeListener listener) { workerInfoChangeListeners.add(listener); } private void notifyWorkerInfoChangeListeners() { Map<String, Set<String>> workerGroupNodes = getWorkerGroupNodes(); Map<String, WorkerHeartBeat> workerNodeInfo = getWorkerNodeInfo(); for (WorkerInfoChangeListener listener : workerInfoChangeListeners) { listener.notify(workerGroupNodes, workerNodeInfo); } } @PreDestroy public void destroy() { executorService.shutdownNow(); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/task/MasterHeartBeatTask.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.server.master.task; import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager; import org.apache.dolphinscheduler.common.model.BaseHeartBeatTask; import org.apache.dolphinscheduler.common.model.MasterHeartBeat; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.service.registry.RegistryClient; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @Slf4j
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/task/MasterHeartBeatTask.java
public class MasterHeartBeatTask extends BaseHeartBeatTask<MasterHeartBeat> { private final MasterConfig masterConfig; private final RegistryClient registryClient; private final String heartBeatPath; private final int processId; public MasterHeartBeatTask(@NonNull MasterConfig masterConfig, @NonNull RegistryClient registryClient) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/task/MasterHeartBeatTask.java
super("MasterHeartBeatTask", masterConfig.getHeartbeatInterval().toMillis()); this.masterConfig = masterConfig; this.registryClient = registryClient; this.heartBeatPath = masterConfig.getMasterRegistryPath(); this.processId = OSUtils.getProcessID(); } @Override public MasterHeartBeat getHeartBeat() { return MasterHeartBeat.builder() .startupTime(ServerLifeCycleManager.getServerStartupTime()) .reportTime(System.currentTimeMillis()) .cpuUsage(OSUtils.cpuUsage()) .loadAverage(OSUtils.loadAverage()) .availablePhysicalMemorySize(OSUtils.availablePhysicalMemorySize()) .maxCpuloadAvg(masterConfig.getMaxCpuLoadAvg()) .reservedMemory(masterConfig.getReservedMemory()) .memoryUsage(OSUtils.memoryUsage()) .diskAvailable(OSUtils.diskAvailable()) .processId(processId) .build(); } @Override public void writeHeartBeat(MasterHeartBeat masterHeartBeat) { String masterHeartBeatJson = JSONUtils.toJsonString(masterHeartBeat); registryClient.persistEphemeral(heartBeatPath, masterHeartBeatJson); log.info("Success write master heartBeatInfo into registry, masterRegistryPath: {}, heartBeatInfo: {}", heartBeatPath, masterHeartBeatJson); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/task/WorkerHeartBeatTask.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.server.worker.task; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager; import org.apache.dolphinscheduler.common.model.BaseHeartBeatTask; import org.apache.dolphinscheduler.common.model.WorkerHeartBeat; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.OSUtils; import org.apache.dolphinscheduler.server.worker.config.WorkerConfig; import org.apache.dolphinscheduler.service.registry.RegistryClient; import java.util.function.Supplier; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; @Slf4j
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/task/WorkerHeartBeatTask.java
public class WorkerHeartBeatTask extends BaseHeartBeatTask<WorkerHeartBeat> { private final WorkerConfig workerConfig; private final RegistryClient registryClient; private final Supplier<Integer> workerWaitingTaskCount; private final int processId; public WorkerHeartBeatTask(@NonNull WorkerConfig workerConfig, @NonNull RegistryClient registryClient, @NonNull Supplier<Integer> workerWaitingTaskCount) { super("WorkerHeartBeatTask", workerConfig.getHeartbeatInterval().toMillis()); this.workerConfig = workerConfig; this.registryClient = registryClient; this.workerWaitingTaskCount = workerWaitingTaskCount;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/task/WorkerHeartBeatTask.java
this.processId = OSUtils.getProcessID(); } @Override public WorkerHeartBeat getHeartBeat() { double loadAverage = OSUtils.loadAverage(); double cpuUsage = OSUtils.cpuUsage(); int maxCpuLoadAvg = workerConfig.getMaxCpuLoadAvg(); double reservedMemory = workerConfig.getReservedMemory(); double availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize(); int execThreads = workerConfig.getExecThreads(); int workerWaitingTaskCount = this.workerWaitingTaskCount.get(); int serverStatus = getServerStatus(loadAverage, maxCpuLoadAvg, availablePhysicalMemorySize, reservedMemory, execThreads, workerWaitingTaskCount); return WorkerHeartBeat.builder() .startupTime(ServerLifeCycleManager.getServerStartupTime()) .reportTime(System.currentTimeMillis()) .cpuUsage(cpuUsage) .loadAverage(loadAverage) .availablePhysicalMemorySize(availablePhysicalMemorySize) .maxCpuloadAvg(maxCpuLoadAvg) .memoryUsage(OSUtils.memoryUsage()) .reservedMemory(reservedMemory) .diskAvailable(OSUtils.diskAvailable()) .processId(processId) .workerHostWeight(workerConfig.getHostWeight()) .workerWaitingTaskCount(this.workerWaitingTaskCount.get()) .workerExecThreadCount(workerConfig.getExecThreads()) .serverStatus(serverStatus) .build(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,907
[Improvement][Log] Adjust WorkerHeartBeatTask log level.
### 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 Please check the following screenshot, i think these heartbeat log should be `debug`, not `info`. Frequent normal heartbeat logs will interfere with user focus ![image](https://user-images.githubusercontent.com/20518339/201924625-89239c8e-e359-4d8e-8710-c14a864198fe.png) ![image](https://user-images.githubusercontent.com/20518339/201924687-1511a204-064b-4166-899c-b51bec36393f.png) ### 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/12907
https://github.com/apache/dolphinscheduler/pull/12980
a2ff140f43a19eb0e9661ce6b1dbffe14fcdd11e
3106054ea78a0036069d1860a228723519efab38
2022-11-15T12:56:38Z
java
2022-11-25T09:37:30Z
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/task/WorkerHeartBeatTask.java
@Override public void writeHeartBeat(WorkerHeartBeat workerHeartBeat) { String workerHeartBeatJson = JSONUtils.toJsonString(workerHeartBeat); String workerRegistryPath = workerConfig.getWorkerRegistryPath(); registryClient.persistEphemeral(workerRegistryPath, workerHeartBeatJson); log.info( "Success write worker group heartBeatInfo into registry, workerRegistryPath: {} workerHeartBeatInfo: {}", workerRegistryPath, workerHeartBeatJson); } public int getServerStatus(double loadAverage, double maxCpuloadAvg, double availablePhysicalMemorySize, double reservedMemory, int workerExecThreadCount, int workerWaitingTaskCount) { if (loadAverage > maxCpuloadAvg || availablePhysicalMemorySize < reservedMemory) { log.warn( "current cpu load average {} is too high or available memory {}G is too low, under max.cpuload.avg={} and reserved.memory={}G", loadAverage, availablePhysicalMemorySize, maxCpuloadAvg, reservedMemory); return Constants.ABNORMAL_NODE_STATUS; } else if (workerWaitingTaskCount > workerExecThreadCount) { log.warn("current waiting task count {} is large than worker thread count {}, worker is busy", workerWaitingTaskCount, workerExecThreadCount); return Constants.BUSY_NODE_STATUE; } else { return Constants.NORMAL_NODE_STATUS; } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.java
import static org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_INSTANCE_LOG_ERROR; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.service.LoggerService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.dao.entity.ResponseTaskLog; import org.apache.dolphinscheduler.dao.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; 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.ResponseBody; 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; /** * logger controller */ @Tag(name = "LOGGER_TAG")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.java
@RestController @RequestMapping("/log") public class LoggerController extends BaseController { @Autowired private LoggerService loggerService; /** * query task log * * @param loginUser login user * @param taskInstanceId task instance id * @param skipNum skip number * @param limit limit * @return task log content */ @Operation(summary = "queryLog", description = "QUERY_TASK_INSTANCE_LOG_NOTES") @Parameters({ @Parameter(name = "taskInstanceId", description = "TASK_ID", required = true, schema = @Schema(implementation = int.class, example = "100")), @Parameter(name = "skipLineNum", description = "SKIP_LINE_NUM", required = true, schema = @Schema(implementation = int.class, example = "100")), @Parameter(name = "limit", description = "LIMIT", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/detail")
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.java
@ResponseStatus(HttpStatus.OK) @ApiException(QUERY_TASK_INSTANCE_LOG_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result<ResponseTaskLog> queryLog(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskInstanceId") int taskInstanceId, @RequestParam(value = "skipLineNum") int skipNum, @RequestParam(value = "limit") int limit) { return loggerService.queryLog(taskInstanceId, skipNum, limit); } /** * download log file * * @param loginUser login user * @param taskInstanceId task instance id * @return log file content */ @Operation(summary = "downloadTaskLog", description = "DOWNLOAD_TASK_INSTANCE_LOG_NOTES") @Parameters({ @Parameter(name = "taskInstanceId", description = "TASK_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/download-log") @ResponseBody @ApiException(DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public ResponseEntity downloadTaskLog(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @RequestParam(value = "taskInstanceId") int taskInstanceId) { byte[] logBytes = loggerService.getLogBytes(taskInstanceId); return ResponseEntity .ok() .header(HttpHeaders.CONTENT_DISPOSITION,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.java
"attachment; filename=\"" + System.currentTimeMillis() + ".log" + "\"") .body(logBytes); } /** * query task log in specified project * * @param loginUser login user * @param projectCode project code * @param taskInstanceId task instance id * @param skipNum skip number * @param limit limit * @return task log content */ @Operation(summary = "queryLogInSpecifiedProject", description = "QUERY_TASK_INSTANCE_LOG_IN_SPECIFIED_PROJECT_NOTES") @Parameters({ @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true, schema = @Schema(implementation = long.class)), @Parameter(name = "taskInstanceId", description = "TASK_ID", required = true, schema = @Schema(implementation = int.class, example = "100")), @Parameter(name = "skipLineNum", description = "SKIP_LINE_NUM", required = true, schema = @Schema(implementation = int.class, example = "100")), @Parameter(name = "limit", description = "LIMIT", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/{projectCode}/detail") @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_TASK_INSTANCE_LOG_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result<String> queryLog(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam(value = "taskInstanceId") int taskInstanceId, @RequestParam(value = "skipLineNum") int skipNum, @RequestParam(value = "limit") int limit) { return returnDataList(loggerService.queryLog(loginUser, projectCode, taskInstanceId, skipNum, limit));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/LoggerController.java
} /** * download log file * * @param loginUser login user * @param projectCode project code * @param taskInstanceId task instance id * @return log file content */ @Operation(summary = "downloadTaskLogInSpecifiedProject", description = "DOWNLOAD_TASK_INSTANCE_LOG_IN_SPECIFIED_PROJECT_NOTES") @Parameters({ @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true, schema = @Schema(implementation = long.class)), @Parameter(name = "taskInstanceId", description = "TASK_ID", required = true, schema = @Schema(implementation = int.class, example = "100")) }) @GetMapping(value = "/{projectCode}/download-log") @ResponseBody @ApiException(DOWNLOAD_TASK_INSTANCE_LOG_FILE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public ResponseEntity downloadTaskLog(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam(value = "taskInstanceId") int taskInstanceId) { byte[] logBytes = loggerService.getLogBytes(loginUser, projectCode, taskInstanceId); return ResponseEntity .ok() .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + System.currentTimeMillis() + ".log" + "\"") .body(logBytes); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.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.dao.entity.ResponseTaskLog; import org.apache.dolphinscheduler.dao.entity.User; import java.util.Map; /** * logger service */ public interface LoggerService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java
/** * view log * * @param taskInstId task instance id * @param skipLineNum skip line number * @param limit limit * @return log string data */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java
Result<ResponseTaskLog> queryLog(int taskInstId, int skipLineNum, int limit); /** * get log size * * @param taskInstId task instance id * @return log byte array */ byte[] getLogBytes(int taskInstId); /** * query log * * @param loginUser login user * @param projectCode project code * @param taskInstId task instance id * @param skipLineNum skip line number * @param limit limit * @return log string data */ Map<String, Object> queryLog(User loginUser, long projectCode, int taskInstId, int skipLineNum, int limit); /** * get log bytes * * @param loginUser login user * @param projectCode project code * @param taskInstId task instance id * @return log byte array */ byte[] getLogBytes(User loginUser, long projectCode, int taskInstId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.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.DOWNLOAD_LOG; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.VIEW_LOG; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.LoggerService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ResponseTaskLog; 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.repository.TaskInstanceDao; import org.apache.dolphinscheduler.remote.utils.Host; import org.apache.dolphinscheduler.service.log.LogClient; import org.apache.commons.lang3.StringUtils; import java.nio.charset.StandardCharsets; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.google.common.primitives.Bytes; /** * logger service impl */ @Service public class LoggerServiceImpl extends BaseServiceImpl implements LoggerService { private static final Logger logger = LoggerFactory.getLogger(LoggerServiceImpl.class); private static final String LOG_HEAD_FORMAT = "[LOG-PATH]: %s, [HOST]: %s%s"; @Autowired private TaskInstanceDao taskInstanceDao;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
12,916
[Bug] [Log] User can query or download other user's log
### 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 User can query or download other user's log ### What you expected to happen There's permission control in loggerService. ### How to reproduce User (not admin) query the log of a task instance which is created by other user. <img width="1386" alt="截屏2022-11-16 09 55 30" src="https://user-images.githubusercontent.com/38122586/202098814-7afaea49-0a57-43be-8476-ea56da0a28d2.png"> ### 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/12916
https://github.com/apache/dolphinscheduler/pull/12917
3106054ea78a0036069d1860a228723519efab38
7336afaa65e3c4bb4596081cf0049b5166506a0c
2022-11-16T06:14:30Z
java
2022-11-25T09:59:28Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java
@Autowired private LogClient logClient; @Autowired ProjectMapper projectMapper; @Autowired ProjectService projectService; @Autowired TaskDefinitionMapper taskDefinitionMapper; /** * view log * * @param taskInstId task instance id * @param skipLineNum skip line number * @param limit limit * @return log string data */ @Override @SuppressWarnings("unchecked") public Result<ResponseTaskLog> queryLog(int taskInstId, int skipLineNum, int limit) { TaskInstance taskInstance = taskInstanceDao.findTaskInstanceById(taskInstId); if (taskInstance == null) { logger.error("Task instance does not exist, taskInstanceId:{}.", taskInstId); return Result.error(Status.TASK_INSTANCE_NOT_FOUND); } if (StringUtils.isBlank(taskInstance.getHost())) { logger.error("Host of task instance is null, taskInstanceId:{}.", taskInstId); return Result.error(Status.TASK_INSTANCE_HOST_IS_NULL); } Result<ResponseTaskLog> result = new Result<>(Status.SUCCESS.getCode(), Status.SUCCESS.getMsg()); String log = queryLog(taskInstance, skipLineNum, limit);