status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @throws IOException errors
*/
public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws IOException {
return FileUtil.copy(fs, new Path(srcPath), fs, new Path(dstPath), deleteSource, overwrite, fs.getConf());
}
/**
* the src file is on the local disk. Add it to FS at
* the given dst name.
*
* @param srcFile local file
* @param dstHdfsPath destination hdfs path
* @param deleteSource whether to delete the src
* @param overwrite whether to overwrite an existing file
* @return if success or not
* @throws IOException errors
*/
public boolean copyLocalToHdfs(String srcFile, String dstHdfsPath, boolean deleteSource, boolean overwrite) throws IOException {
Path srcPath = new Path(srcFile);
Path dstPath = new Path(dstHdfsPath);
fs.copyFromLocalFile(deleteSource, overwrite, srcPath, dstPath);
return true;
}
/**
* copy hdfs file to local
*
* @param srcHdfsFilePath source hdfs file path
* @param dstFile destination file
* @param deleteSource delete source
* @param overwrite overwrite
* @return result of copy hdfs file to local |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @throws IOException errors
*/
public boolean copyHdfsToLocal(String srcHdfsFilePath, String dstFile, boolean deleteSource, boolean overwrite) throws IOException {
Path srcPath = new Path(srcHdfsFilePath);
File dstPath = new File(dstFile);
if (dstPath.exists()) {
if (dstPath.isFile()) {
if (overwrite) {
Files.delete(dstPath.toPath());
}
} else {
logger.error("destination file must be a file");
}
}
if (!dstPath.getParentFile().exists()) {
dstPath.getParentFile().mkdirs();
}
return FileUtil.copy(fs, srcPath, dstPath, deleteSource, fs.getConf());
}
/**
* delete a file
*
* @param hdfsFilePath the path to delete.
* @param recursive if path is a directory and set to
* true, the directory is deleted else throws an exception. In
* case of a file the recursive can be set to either true or false.
* @return true if delete is successful else false.
* @throws IOException errors
*/
public boolean delete(String hdfsFilePath, boolean recursive) throws IOException { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | return fs.delete(new Path(hdfsFilePath), recursive);
}
/**
* check if exists
*
* @param hdfsFilePath source file path
* @return result of exists or not
* @throws IOException errors
*/
public boolean exists(String hdfsFilePath) throws IOException {
return fs.exists(new Path(hdfsFilePath));
}
/**
* Gets a list of files in the directory
*
* @param filePath file path
* @return {@link FileStatus} file status
* @throws Exception errors
*/
public FileStatus[] listFileStatus(String filePath) throws Exception {
try {
return fs.listStatus(new Path(filePath));
} catch (IOException e) {
logger.error("Get file list exception", e);
throw new Exception("Get file list exception", e);
}
}
/**
* Renames Path src to Path dst. Can take place on local fs
* or remote DFS. |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | *
* @param src path to be renamed
* @param dst new path after rename
* @return true if rename is successful
* @throws IOException on failure
*/
public boolean rename(String src, String dst) throws IOException {
return fs.rename(new Path(src), new Path(dst));
}
/**
* hadoop resourcemanager enabled or not
*
* @return result
*/
public boolean isYarnEnabled() {
return yarnEnabled;
}
/**
* get the state of an application
*
* @param applicationId application id
* @return the return may be null or there may be other parse exceptions
*/
public ExecutionStatus getApplicationStatus(String applicationId) throws Exception {
if (StringUtils.isEmpty(applicationId)) {
return null;
}
String result = Constants.FAILED;
String applicationUrl = getApplicationUrl(applicationId);
logger.info("applicationUrl={}", applicationUrl); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | String responseContent = PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false) ? KerberosHttpClient.get(applicationUrl) : HttpUtils.get(applicationUrl);
if (responseContent != null) {
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
if (!jsonObject.has("app")) {
return ExecutionStatus.FAILURE;
}
result = jsonObject.path("app").path("finalStatus").asText();
} else {
String jobHistoryUrl = getJobHistoryUrl(applicationId);
logger.info("jobHistoryUrl={}", jobHistoryUrl);
responseContent = PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false) ? KerberosHttpClient.get(jobHistoryUrl) : HttpUtils.get(jobHistoryUrl);
if (null != responseContent) {
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
if (!jsonObject.has("job")) {
return ExecutionStatus.FAILURE;
}
result = jsonObject.path("job").path("state").asText();
} else {
return ExecutionStatus.FAILURE;
}
}
switch (result) {
case Constants.ACCEPTED:
return ExecutionStatus.SUBMITTED_SUCCESS;
case Constants.SUCCEEDED:
return ExecutionStatus.SUCCESS;
case Constants.NEW:
case Constants.NEW_SAVING:
case Constants.SUBMITTED: |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | case Constants.FAILED:
return ExecutionStatus.FAILURE;
case Constants.KILLED:
return ExecutionStatus.KILL;
case Constants.RUNNING:
default:
return ExecutionStatus.RUNNING_EXECUTION;
}
}
/**
* get data hdfs path
*
* @return data hdfs path
*/
public static String getHdfsDataBasePath() {
if ("/".equals(resourceUploadPath)) {
return "";
} else {
return resourceUploadPath;
}
}
/**
* hdfs resource dir
*
* @param tenantCode tenant code
* @param resourceType resource type
* @return hdfs resource dir
*/
public static String getHdfsDir(ResourceType resourceType, String tenantCode) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | String hdfsDir = "";
if (resourceType.equals(ResourceType.FILE)) {
hdfsDir = getHdfsResDir(tenantCode);
} else if (resourceType.equals(ResourceType.UDF)) {
hdfsDir = getHdfsUdfDir(tenantCode);
}
return hdfsDir;
}
/**
* hdfs resource dir
*
* @param tenantCode tenant code
* @return hdfs resource dir
*/
public static String getHdfsResDir(String tenantCode) {
return String.format("%s/resources", getHdfsTenantDir(tenantCode));
}
/**
* hdfs user dir
*
* @param tenantCode tenant code
* @param userId user id
* @return hdfs resource dir
*/
public static String getHdfsUserDir(String tenantCode, int userId) {
return String.format("%s/home/%d", getHdfsTenantDir(tenantCode), userId);
}
/**
* hdfs udf dir
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | * @param tenantCode tenant code
* @return get udf dir on hdfs
*/
public static String getHdfsUdfDir(String tenantCode) {
return String.format("%s/udfs", getHdfsTenantDir(tenantCode));
}
/**
* get hdfs file name
*
* @param resourceType resource type
* @param tenantCode tenant code
* @param fileName file name
* @return hdfs file name
*/
public static String getHdfsFileName(ResourceType resourceType, String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", "");
}
return String.format("%s/%s", getHdfsDir(resourceType, tenantCode), fileName);
}
/**
* get absolute path and name for resource file on hdfs
*
* @param tenantCode tenant code
* @param fileName file name
* @return get absolute path and name for file on hdfs
*/
public static String getHdfsResourceFileName(String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", ""); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | }
return String.format("%s/%s", getHdfsResDir(tenantCode), fileName);
}
/**
* get absolute path and name for udf file on hdfs
*
* @param tenantCode tenant code
* @param fileName file name
* @return get absolute path and name for udf file on hdfs
*/
public static String getHdfsUdfFileName(String tenantCode, String fileName) {
if (fileName.startsWith("/")) {
fileName = fileName.replaceFirst("/", "");
}
return String.format("%s/%s", getHdfsUdfDir(tenantCode), fileName);
}
/**
* @param tenantCode tenant code
* @return file directory of tenants on hdfs
*/
public static String getHdfsTenantDir(String tenantCode) {
return String.format("%s/%s", getHdfsDataBasePath(), tenantCode);
}
/**
* getAppAddress
*
* @param appAddress app address
* @param rmHa resource manager ha
* @return app address
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | public static String getAppAddress(String appAddress, String rmHa) {
String activeRM = YarnHAAdminUtils.getAcitveRMName(rmHa);
String[] split1 = appAddress.split(Constants.DOUBLE_SLASH);
if (split1.length != 2) {
return null;
}
String start = split1[0] + Constants.DOUBLE_SLASH;
String[] split2 = split1[1].split(Constants.COLON);
if (split2.length != 2) {
return null;
}
String end = Constants.COLON + split2[1];
return start + activeRM + end;
}
@Override
public void close() throws IOException {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
logger.error("Close HadoopUtils instance failed", e);
throw new IOException("Close HadoopUtils instance failed", e);
}
}
}
/**
* yarn ha admin utils
*/
private static final class YarnHAAdminUtils extends RMAdminCLI { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | /**
* get active resourcemanager
*
* @param rmIds
* @return
*/
public static String getAcitveRMName(String rmIds) {
String[] rmIdArr = rmIds.split(Constants.COMMA);
int activeResourceManagerPort = PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
String yarnUrl = "http://%s:" + activeResourceManagerPort + "/ws/v1/cluster/info";
try {
/**
* send http get request to rm
*/
for (String rmId : rmIdArr) {
String state = getRMState(String.format(yarnUrl, rmId));
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
return rmId;
}
}
} catch (Exception e) {
for (int i = 1; i < rmIdArr.length; i++) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java | String state = getRMState(String.format(yarnUrl, rmIdArr[i]));
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
return rmIdArr[i];
}
}
}
return null;
}
/**
* get ResourceManager state
*
* @param url
* @return
*/
public static String getRMState(String url) {
String retStr = PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false) ? KerberosHttpClient.get(url) : HttpUtils.get(url);
if (StringUtils.isEmpty(retStr)) {
return null;
}
ObjectNode jsonObject = JSONUtils.parseObject(retStr);
if (!jsonObject.has("clusterInfo")) {
return null;
}
return jsonObject.get("clusterInfo").path("haState").asText();
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.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.common.utils;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.hadoop.conf.Configuration;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@RunWith(MockitoJUnitRunner.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | public class HadoopUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(HadoopUtilsTest.class);
private HadoopUtils hadoopUtils = HadoopUtils.getInstance();
@Test
public void getActiveRMTest() {
try{
hadoopUtils.getAppAddress("http://ark1:8088/ws/v1/cluster/apps/%s","192.168.xx.xx,192.168.xx.xx");
} catch (Exception e) {
logger.error(e.getMessage(),e);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | }
@Test
public void rename() {
boolean result = false;
try {
result = hadoopUtils.rename("/dolphinscheduler/hdfs1","/dolphinscheduler/hdfs2");
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
Assert.assertEquals(false, result);
}
@Test
public void getConfiguration(){
Configuration conf = hadoopUtils.getConfiguration();
}
@Test
public void mkdir() {
boolean result = false;
try {
result = hadoopUtils.mkdir("/dolphinscheduler/hdfs");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
Assert.assertEquals(false, result);
}
@Test
public void delete() {
boolean result = false;
try {
result = hadoopUtils.delete("/dolphinscheduler/hdfs",true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | } catch (Exception e) {
logger.error(e.getMessage(), e);
}
Assert.assertEquals(false, result);
}
@Test
public void exists() {
boolean result = false;
try {
result = hadoopUtils.exists("/dolphinscheduler/hdfs");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
Assert.assertEquals(false, result);
}
@Test
public void getHdfsDataBasePath() {
String result = hadoopUtils.getHdfsDataBasePath();
Assert.assertEquals("/dolphinscheduler", result);
}
@Test
public void getHdfsResDir() {
String result = hadoopUtils.getHdfsResDir("11000");
Assert.assertEquals("/dolphinscheduler/11000/resources", result);
}
@Test
public void getHdfsUserDir() {
String result = hadoopUtils.getHdfsUserDir("11000",1000);
Assert.assertEquals("/dolphinscheduler/11000/home/1000", result);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | @Test
public void getHdfsUdfDir() {
String result = hadoopUtils.getHdfsUdfDir("11000");
Assert.assertEquals("/dolphinscheduler/11000/udfs", result);
}
@Test
public void getHdfsFileName() {
String result = hadoopUtils.getHdfsFileName(ResourceType.FILE,"11000","aa.txt");
Assert.assertEquals("/dolphinscheduler/11000/resources/aa.txt", result);
}
@Test
public void getHdfsResourceFileName() {
String result = hadoopUtils.getHdfsResourceFileName("11000","aa.txt");
Assert.assertEquals("/dolphinscheduler/11000/resources/aa.txt", result);
}
@Test
public void getHdfsUdfFileName() {
String result = hadoopUtils.getHdfsFileName(ResourceType.UDF,"11000","aa.txt");
Assert.assertEquals("/dolphinscheduler/11000/udfs/aa.txt", result);
}
@Test
public void isYarnEnabled() {
boolean result = hadoopUtils.isYarnEnabled();
Assert.assertEquals(true, result);
}
@Test
public void test() {
try {
hadoopUtils.copyLocalToHdfs("/root/teamviewer_13.1.8286.x86_64.rpm", "/journey", true, true);
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | logger.error(e.getMessage(), e);
}
}
@Test
public void readFileTest(){
try {
byte[] bytes = hadoopUtils.catFile("/dolphinscheduler/hdfs/resources/35435.sh");
logger.info(new String(bytes));
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
}
@Test
public void testMove(){
try {
hadoopUtils.copy("/opt/apptest/test.dat","/opt/apptest/test.dat.back",true,true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Test
public void getApplicationStatus() {
try {
logger.info(hadoopUtils.getApplicationStatus("application_1542010131334_0029").toString());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Test
public void getApplicationUrl() throws Exception { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,884 | [Improvement][Common] a concatenation URL problem occurred when the address of the ACITVE ResourceManager in YARN HA mode failed to be obtained | **Describe the question**
Acitve ReSourceManager IP = null when obtaining Acitve ReSourceManager address in YARN HA mode fails,
the program will return splicing application url = http://null:8088/ws/v1/cluster/apps/%s
**What are the current deficiencies and the benefits of improvement**
The yarn application URL generation failed exception should be thrown here
**Which version of DolphinScheduler:**
-[dev]
| https://github.com/apache/dolphinscheduler/issues/4884 | https://github.com/apache/dolphinscheduler/pull/4885 | ea6b1de120cd438b7611b966d396164dec421cbb | c8e31ad58e15936174e773172d12337a8cf26d69 | "2021-02-26T04:31:57Z" | java | "2021-03-11T14:14:52Z" | dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HadoopUtilsTest.java | String application_1516778421218_0042 = hadoopUtils.getApplicationUrl("application_1529051418016_0167");
logger.info(application_1516778421218_0042);
}
@Test
public void getJobHistoryUrl(){
String application_1516778421218_0042 = hadoopUtils.getJobHistoryUrl("application_1529051418016_0167");
logger.info(application_1516778421218_0042);
}
@Test
public void catFileWithLimitTest() {
List<String> stringList = new ArrayList<>();
try {
stringList = hadoopUtils.catFile("/dolphinscheduler/hdfs/resources/WCSparkPython.py", 0, 1000);
logger.info(String.join(",",stringList));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
@Test
public void catFileTest() {
byte[] content = new byte[0];
try {
content = hadoopUtils.catFile("/dolphinscheduler/hdfs/resources/WCSparkPython.py");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
logger.info(Arrays.toString(content));
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.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.zk;
import static org.apache.dolphinscheduler.common.Constants.SLEEP_TIME_MILLIS;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | import org.apache.dolphinscheduler.common.enums.ZKNodeType;
import org.apache.dolphinscheduler.common.model.Server;
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
import org.apache.dolphinscheduler.common.utils.NetUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.apache.dolphinscheduler.server.builder.TaskExecutionContextBuilder;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.server.master.MasterServer;
import org.apache.dolphinscheduler.server.master.registry.MasterRegistry;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.zk.AbstractZKClient;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* zookeeper master client
* <p>
* single instance
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | public class ZKMasterClient extends AbstractZKClient {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(ZKMasterClient.class);
/**
* process service
*/
@Autowired
private ProcessService processService;
/**
* master registry
*/
@Autowired |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | private MasterRegistry masterRegistry;
public void start(MasterServer masterServer) {
InterProcessMutex mutex = null;
try {
String znodeLock = getMasterStartUpLockPath();
mutex = new InterProcessMutex(getZkClient(), znodeLock);
mutex.acquire();
masterRegistry.registry();
masterRegistry.getZookeeperRegistryCenter().setStoppable(masterServer);
String registPath = this.masterRegistry.getMasterPath();
masterRegistry.getZookeeperRegistryCenter().getRegisterOperator().handleDeadServer(registPath, ZKNodeType.MASTER, Constants.DELETE_ZK_OP);
this.initSystemZNode();
while (!checkZKNodeExists(NetUtils.getHost(), ZKNodeType.MASTER)) {
ThreadUtils.sleep(SLEEP_TIME_MILLIS);
}
if (getActiveMasterNum() == 1) {
removeZKNodePath(null, ZKNodeType.MASTER, true);
removeZKNodePath(null, ZKNodeType.WORKER, true);
}
registerListener();
} catch (Exception e) {
logger.error("master start up exception", e);
} finally {
releaseMutex(mutex);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | @Override
public void close() {
masterRegistry.unRegistry();
super.close();
}
/**
* handle path events that this class cares about
*
* @param client zkClient
* @param event path event
* @param path zk path
*/
@Override
protected void dataChanged(CuratorFramework client, TreeCacheEvent event, String path) {
if (path.startsWith(getZNodeParentPath(ZKNodeType.MASTER) + Constants.SINGLE_SLASH)) {
handleMasterEvent(event, path);
} else if (path.startsWith(getZNodeParentPath(ZKNodeType.WORKER) + Constants.SINGLE_SLASH)) {
handleWorkerEvent(event, path);
}
}
/**
* remove zookeeper node path
*
* @param path zookeeper node path
* @param zkNodeType zookeeper node type
* @param failover is failover
*/
private void removeZKNodePath(String path, ZKNodeType zkNodeType, boolean failover) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | logger.info("{} node deleted : {}", zkNodeType.toString(), path);
InterProcessMutex mutex = null;
try {
String failoverPath = getFailoverLockPath(zkNodeType);
mutex = new InterProcessMutex(getZkClient(), failoverPath);
mutex.acquire();
String serverHost = null;
if (StringUtils.isNotEmpty(path)) {
serverHost = getHostByEventDataPath(path);
if (StringUtils.isEmpty(serverHost)) {
logger.error("server down error: unknown path: {}", path);
return;
}
handleDeadServer(path, zkNodeType, Constants.ADD_ZK_OP);
}
if (failover) {
failoverServerWhenDown(serverHost, zkNodeType);
}
} catch (Exception e) {
logger.error("{} server failover failed.", zkNodeType.toString());
logger.error("failover exception ", e);
} finally {
releaseMutex(mutex);
}
}
/**
* failover server when server down |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | *
* @param serverHost server host
* @param zkNodeType zookeeper node type
* @throws Exception exception
*/
private void failoverServerWhenDown(String serverHost, ZKNodeType zkNodeType) throws Exception {
if (StringUtils.isEmpty(serverHost)) {
return;
}
switch (zkNodeType) {
case MASTER:
failoverMaster(serverHost);
break;
case WORKER:
failoverWorker(serverHost, true);
break;
default:
break;
}
}
/**
* get failover lock path
*
* @param zkNodeType zookeeper node type
* @return fail over lock path
*/
private String getFailoverLockPath(ZKNodeType zkNodeType) {
switch (zkNodeType) {
case MASTER:
return getMasterFailoverLockPath(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | case WORKER:
return getWorkerFailoverLockPath();
default:
return "";
}
}
/**
* monitor master
*
* @param event event
* @param path path
*/
public void handleMasterEvent(TreeCacheEvent event, String path) {
switch (event.getType()) {
case NODE_ADDED:
logger.info("master node added : {}", path);
break;
case NODE_REMOVED:
removeZKNodePath(path, ZKNodeType.MASTER, true);
break;
default:
break;
}
}
/**
* monitor worker
*
* @param event event
* @param path path
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | public void handleWorkerEvent(TreeCacheEvent event, String path) {
switch (event.getType()) {
case NODE_ADDED:
logger.info("worker node added : {}", path);
break;
case NODE_REMOVED:
logger.info("worker node deleted : {}", path);
removeZKNodePath(path, ZKNodeType.WORKER, true);
break;
default:
break;
}
}
/**
* task needs failover if task start before worker starts
*
* @param taskInstance task instance
* @return true if task instance need fail over
*/
private boolean checkTaskInstanceNeedFailover(TaskInstance taskInstance) throws Exception {
boolean taskNeedFailover = true;
if (taskInstance.getHost() == null) {
return false;
}
if (checkZKNodeExists(taskInstance.getHost(), ZKNodeType.WORKER)) {
if (checkTaskAfterWorkerStart(taskInstance)) {
taskNeedFailover = false; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | }
}
return taskNeedFailover;
}
/**
* check task start after the worker server starts.
*
* @param taskInstance task instance
* @return true if task instance start time after worker server start date
*/
private boolean checkTaskAfterWorkerStart(TaskInstance taskInstance) {
if (StringUtils.isEmpty(taskInstance.getHost())) {
return false;
}
Date workerServerStartDate = null;
List<Server> workerServers = getServersList(ZKNodeType.WORKER);
for (Server workerServer : workerServers) {
if (taskInstance.getHost().equals(workerServer.getHost() + Constants.COLON + workerServer.getPort())) {
workerServerStartDate = workerServer.getCreateTime();
break;
}
}
if (workerServerStartDate != null) {
return taskInstance.getStartTime().after(workerServerStartDate);
}
return false;
}
/**
* failover worker tasks
* <p> |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | * 1. kill yarn job if there are yarn jobs in tasks.
* 2. change task state from running to need failover.
* 3. failover all tasks when workerHost is null
*
* @param workerHost worker host
* @param needCheckWorkerAlive need check worker alive
* @throws Exception exception
*/
private void failoverWorker(String workerHost, boolean needCheckWorkerAlive) throws Exception {
workerHost = Host.of(workerHost).getAddress();
logger.info("start worker[{}] failover ...", workerHost);
List<TaskInstance> needFailoverTaskInstanceList = processService.queryNeedFailoverTaskInstances(workerHost);
for (TaskInstance taskInstance : needFailoverTaskInstanceList) {
if (needCheckWorkerAlive) {
if (!checkTaskInstanceNeedFailover(taskInstance)) {
continue;
}
}
ProcessInstance processInstance = processService.findProcessInstanceDetailById(taskInstance.getProcessInstanceId());
if (processInstance != null) {
taskInstance.setProcessInstance(processInstance);
}
TaskExecutionContext taskExecutionContext = TaskExecutionContextBuilder.get()
.buildTaskInstanceRelatedInfo(taskInstance)
.buildProcessInstanceRelatedInfo(processInstance)
.create();
ProcessUtils.killYarnJob(taskExecutionContext);
taskInstance.setState(ExecutionStatus.NEED_FAULT_TOLERANCE);
processService.saveTaskInstance(taskInstance); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,044 | [Bug][Master] Fix First master fault tolerance when startup | **For better global communication, Please describe it in English. If you feel the description in English is not clear, then you can append description in Chinese(just for Mandarin(CN)), thx! **
**Describe the bug**
Filtering an empty Host results in failure to perform Master startup fault tolerance
过滤空Host导致未执行Master启动容错


**Which version of Dolphin Scheduler:**
-[1.3.6-prerelease]
| https://github.com/apache/dolphinscheduler/issues/5044 | https://github.com/apache/dolphinscheduler/pull/5045 | cc2a94a9735099b0a453624ce1c9f3be7a375a9d | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | "2021-03-12T15:02:48Z" | java | "2021-03-12T16:01:18Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/zk/ZKMasterClient.java | }
logger.info("end worker[{}] failover ...", workerHost);
}
/**
* failover master tasks
*
* @param masterHost master host
*/
private void failoverMaster(String masterHost) {
logger.info("start master failover ...");
List<ProcessInstance> needFailoverProcessInstanceList = processService.queryNeedFailoverProcessInstances(masterHost);
logger.info("failover process list size:{} ", needFailoverProcessInstanceList.size());
for (ProcessInstance processInstance : needFailoverProcessInstanceList) {
logger.info("failover process instance id: {} host:{}",
processInstance.getId(), processInstance.getHost());
if (Constants.NULL.equals(processInstance.getHost())) {
continue;
}
processService.processNeedFailoverProcessInstances(processInstance);
}
logger.info("master failover end");
}
public InterProcessMutex blockAcquireMutex() throws Exception {
InterProcessMutex mutex = new InterProcessMutex(getZkClient(), getMasterLockPath());
mutex.acquire();
return mutex;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.server.worker.task;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.function.Consumer;
/**
* python command executor
*/
public class PythonCommandExecutor extends AbstractCommandExecutor { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | /**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(PythonCommandExecutor.class);
/**
* python
*/
public static final String PYTHON = "python";
/**
* constructor
* @param logHandler log handler
* @param taskExecutionContext taskExecutionContext
* @param logger logger
*/
public PythonCommandExecutor(Consumer<List<String>> logHandler,
TaskExecutionContext taskExecutionContext,
Logger logger) {
super(logHandler,taskExecutionContext,logger);
}
/**
* build command file path
*
* @return command file path
*/
@Override
protected String buildCommandFilePath() {
return String.format("%s/py_%s.command", taskExecutionContext.getExecutePath(), taskExecutionContext.getTaskAppId());
}
/**
* create command file if not exists |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | * @param execCommand exec command
* @param commandFile command file
* @throws IOException io exception
*/
@Override
protected void createCommandFileIfNotExists(String execCommand, String commandFile) throws IOException {
logger.info("tenantCode :{}, task dir:{}", taskExecutionContext.getTenantCode(), taskExecutionContext.getExecutePath());
if (!Files.exists(Paths.get(commandFile))) {
logger.info("generate command file:{}", commandFile);
StringBuilder sb = new StringBuilder();
sb.append("#-*- encoding=utf8 -*-\n");
sb.append("\n\n");
sb.append(execCommand);
logger.info(sb.toString());
FileUtils.writeStringToFile(new File(commandFile),
sb.toString(),
StandardCharsets.UTF_8);
}
}
/**
* get command options
* @return command options list
*/
@Override
protected List<String> commandOptions() {
return Collections.singletonList("-u");
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | * get python home
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)){
return PYTHON;
}
return pythonHome;
}
/**
* get the absolute path of the Python command
* note :
* common.properties
* PYTHON_HOME configured under common.properties is Python absolute path, not PYTHON_HOME itself
*
* for example :
* your PYTHON_HOM is /opt/python3.7/
* you must set PYTHON_HOME is /opt/python3.7/python under nder common.properties
* dolphinscheduler.env.path file.
*
* @param envPath env path
* @return python home
*/
private static String getPythonHome(String envPath){
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(envPath))); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/PythonCommandExecutor.java | String line;
while ((line = br.readLine()) != null){
if (line.contains(Constants.PYTHON_HOME)){
sb.append(line);
break;
}
}
String result = sb.toString();
if (org.apache.commons.lang.StringUtils.isEmpty(result)){
return null;
}
String[] arrs = result.split(Constants.EQUAL_SIGN);
if (arrs.length == 2){
return arrs[1];
}
}catch (IOException e){
logger.error("read file failure",e);
}finally {
try {
if (br != null){
br.close();
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
}
return null;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/EnvFileTest.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;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnvFileTest { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/EnvFileTest.java | private static final Logger logger = LoggerFactory.getLogger(EnvFileTest.class);
@Test
public void test() {
String path = System.getProperty("user.dir")+"/script/env/dolphinscheduler_env.sh";
String pythonHome = getPythonHome(path);
logger.info(pythonHome);
}
/**
* get python home
* @param path
* @return
*/
private static String getPythonHome(String path){
BufferedReader br = null;
String line = null;
StringBuilder sb = new StringBuilder();
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,024 | [Improvement][Worker] Python Command | In general, the home is the directory where the software is installed,but the commandInterpreter method use the Python home directory in PythonCommandExecutor.java, which is in the environment variable configuration file needs to be configured PYTHON_HOME to PYTHON_HOME/bin/Python. Obviously, this is unreasonable and misleading
**Describe alternatives you've considered**
```java
/**
* get python home
*
* @return python home
*/
@Override
protected String commandInterpreter() {
String pythonHome = getPythonHome(taskExecutionContext.getEnvFile());
if (StringUtils.isEmpty(pythonHome)) {
return PYTHON;
}
-- return pythonHome
++ return pythonHome + "/bin/python";
}
```
[dev] | https://github.com/apache/dolphinscheduler/issues/5024 | https://github.com/apache/dolphinscheduler/pull/5036 | a3153b5e44d40cceea6e705f2406c4a4ec5f99c9 | 2d8c4ec86bdc8d00baee4066f40699078735c5dc | "2021-03-10T02:12:24Z" | java | "2021-03-15T02:22:13Z" | dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/EnvFileTest.java | br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
while ((line = br.readLine()) != null){
if (line.contains("PYTHON_HOME")){
sb.append(line);
break;
}
}
String result = sb.toString();
if (StringUtils.isEmpty(result)){
return null;
}
String[] arrs = result.split("=");
if (arrs.length == 2){
return arrs[1];
}
}catch (IOException e){
logger.error("read file failed",e);
}finally {
try {
if (br != null){
br.close();
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
}
return null;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.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.shell;
import static java.util.Calendar.DAY_OF_MONTH;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.Direct;
import org.apache.dolphinscheduler.common.process.Property;
import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.task.shell.ShellParameters;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.java | import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext;
import org.apache.dolphinscheduler.server.utils.ParamUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
import org.apache.dolphinscheduler.server.worker.task.CommandExecuteResult;
import org.apache.dolphinscheduler.server.worker.task.ShellCommandExecutor;
import org.slf4j.Logger;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* shell task
*/
public class ShellTask extends AbstractTask {
/**
* shell parameters
*/
private ShellParameters shellParameters;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.java | * shell command executor
*/
private ShellCommandExecutor shellCommandExecutor;
/**
* taskExecutionContext
*/
private TaskExecutionContext taskExecutionContext;
/**
* constructor
*
* @param taskExecutionContext taskExecutionContext
* @param logger logger
*/
public ShellTask(TaskExecutionContext taskExecutionContext, Logger logger) {
super(taskExecutionContext, logger);
this.taskExecutionContext = taskExecutionContext;
this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
taskExecutionContext,
logger);
}
@Override
public void init() {
logger.info("shell task params {}", taskExecutionContext.getTaskParams());
shellParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), ShellParameters.class);
if (!shellParameters.checkParameters()) {
throw new RuntimeException("shell task params is not valid");
}
}
@Override
public void handle() throws Exception { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.java | try {
CommandExecuteResult commandExecuteResult = shellCommandExecutor.run(buildCommand());
setExitStatusCode(commandExecuteResult.getExitStatusCode());
setAppIds(commandExecuteResult.getAppIds());
setProcessId(commandExecuteResult.getProcessId());
setResult(shellCommandExecutor.getTaskResultString());
} catch (Exception e) {
logger.error("shell task error", e);
setExitStatusCode(Constants.EXIT_CODE_FAILURE);
throw e;
}
}
@Override
public void cancelApplication(boolean cancelApplication) throws Exception {
shellCommandExecutor.cancelApplication();
}
/**
* create command
*
* @return file name
* @throws Exception exception
*/
private String buildCommand() throws Exception {
String fileName = String.format("%s/%s_node.%s",
taskExecutionContext.getExecutePath(),
taskExecutionContext.getTaskAppId(), OSUtils.isWindows() ? "bat" : "sh");
Path path = new File(fileName).toPath(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.java | if (Files.exists(path)) {
return fileName;
}
String script = shellParameters.getRawScript().replaceAll("\\r\\n", "\n");
script = parseScript(script);
shellParameters.setRawScript(script);
logger.info("raw script : {}", shellParameters.getRawScript());
logger.info("task execute path : {}", taskExecutionContext.getExecutePath());
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(Constants.RWXR_XR_X);
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
if (OSUtils.isWindows()) {
Files.createFile(path);
} else {
Files.createFile(path, attr);
}
Files.write(path, shellParameters.getRawScript().getBytes(), StandardOpenOption.APPEND);
return fileName;
}
@Override
public AbstractParameters getParameters() {
return shellParameters;
}
private String parseScript(String script) {
Map<String, Property> paramsMap = ParamUtils.convert(ParamUtils.getUserDefParamsMap(taskExecutionContext.getDefinedParams()),
taskExecutionContext.getDefinedParams(),
shellParameters.getLocalParametersMap(),
CommandType.of(taskExecutionContext.getCmdTypeIfComplement()),
taskExecutionContext.getScheduleTime()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,071 | [Bug][Server] When setting value on shell script, it not working on the next task node. |
**When setting value on shell script, it not working on the next task node.**
If using `${setValue(key, value)}` function in the shell task, it needs to share the `key` to the process instance. but now, it's not working.
**Which version of Dolphin Scheduler:**
- [current dev branch]
| https://github.com/apache/dolphinscheduler/issues/5071 | https://github.com/apache/dolphinscheduler/pull/5067 | 6bf5031f455a930488ab58bb15c108cab80425a4 | 0ba120e8ab80d4687685837f6aa52460e7201813 | "2021-03-16T13:51:01Z" | java | "2021-03-16T13:56:05Z" | dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/shell/ShellTask.java | if (taskExecutionContext.getScheduleTime() != null) {
if (paramsMap == null) {
paramsMap = new HashMap<>();
}
Date date = taskExecutionContext.getScheduleTime();
if (CommandType.COMPLEMENT_DATA.getCode() == taskExecutionContext.getCmdTypeIfComplement()) {
date = DateUtils.add(taskExecutionContext.getScheduleTime(), DAY_OF_MONTH, 1);
}
String dateTime = DateUtils.format(date, Constants.PARAMETER_FORMAT_TIME);
Property p = new Property();
p.setValue(dateTime);
p.setProp(Constants.PARAMETER_DATETIME);
paramsMap.put(Constants.PARAMETER_DATETIME, p);
}
return ParameterUtils.convertParameterPlaceholders(script, ParamUtils.convert(paramsMap));
}
public void setResult(String result) {
Map<String, Property> localParams = shellParameters.getLocalParametersMap();
List<Map<String, String>> outProperties = new ArrayList<>();
Map<String, String> p = new HashMap<>();
localParams.forEach((k,v) -> {
if (v.getDirect() == Direct.OUT) {
p.put(k, result);
}
});
outProperties.add(p);
resultString = JSONUtils.toJsonString(outProperties);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert;
import static org.apache.dolphinscheduler.common.Constants.ALERT_RPC_PORT;
import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginLoader;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginManagerConfig;
import org.apache.dolphinscheduler.alert.processor.AlertRequestProcessor;
import org.apache.dolphinscheduler.alert.runner.AlertSender;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.DaoFactory; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java | import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
/**
* alert of start
*/
public class AlertServer {
private static final Logger logger = LoggerFactory.getLogger(AlertServer.class);
/**
* Alert Dao
*/
private AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class);
private AlertSender alertSender;
private static AlertServer instance;
private AlertPluginManager alertPluginManager;
private DolphinPluginManagerConfig alertPluginManagerConfig;
public static final String ALERT_PLUGIN_BINDING = "alert.plugin.binding";
public static final String ALERT_PLUGIN_DIR = "alert.plugin.dir";
public static final String MAVEN_LOCAL_REPOSITORY = "maven.local.repository";
/**
* netty server
*/
private NettyRemotingServer server;
private static class AlertServerHolder { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java | private static final AlertServer INSTANCE = new AlertServer();
}
public static final AlertServer getInstance() {
return AlertServerHolder.INSTANCE;
}
private AlertServer() {
}
private void initPlugin() {
alertPluginManager = new AlertPluginManager();
alertPluginManagerConfig = new DolphinPluginManagerConfig();
alertPluginManagerConfig.setPlugins(PropertyUtils.getString(ALERT_PLUGIN_BINDING));
if (StringUtils.isNotBlank(PropertyUtils.getString(ALERT_PLUGIN_DIR))) {
alertPluginManagerConfig.setInstalledPluginsDir(PropertyUtils.getString(ALERT_PLUGIN_DIR, Constants.ALERT_PLUGIN_PATH).trim());
}
if (StringUtils.isNotBlank(PropertyUtils.getString(MAVEN_LOCAL_REPOSITORY))) {
alertPluginManagerConfig.setMavenLocalRepository(PropertyUtils.getString(MAVEN_LOCAL_REPOSITORY).trim());
}
DolphinPluginLoader alertPluginLoader = new DolphinPluginLoader(alertPluginManagerConfig, ImmutableList.of(alertPluginManager));
try {
alertPluginLoader.loadPlugins();
} catch (Exception e) {
throw new RuntimeException("load Alert Plugin Failed !", e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java | }
}
/**
* init netty remoting server
*/
private void initRemoteServer() {
NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(ALERT_RPC_PORT);
this.server = new NettyRemotingServer(serverConfig);
this.server.registerProcessor(CommandType.ALERT_SEND_REQUEST, new AlertRequestProcessor(alertDao, alertPluginManager));
this.server.start();
}
/**
* Cyclic alert info sending alert
*/
private void runSender() {
while (Stopper.isRunning()) {
try {
Thread.sleep(Constants.ALERT_SCAN_INTERVAL);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
Thread.currentThread().interrupt();
}
if (alertPluginManager == null || alertPluginManager.getAlertChannelMap().size() == 0) {
logger.warn("No Alert Plugin . Can not send alert info. ");
} else {
List<Alert> alerts = alertDao.listWaitExecutionAlert();
alertSender = new AlertSender(alerts, alertDao, alertPluginManager);
alertSender.run();
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java | }
}
/**
* start
*/
public void start() {
initPlugin();
initRemoteServer();
logger.info("alert server ready start ");
runSender();
}
/**
* stop
*/
public void stop() {
this.server.close();
logger.info("alert server shut down");
}
public static void main(String[] args) {
AlertServer alertServer = AlertServer.getInstance();
alertServer.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
alertServer.stop();
}
});
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert.utils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | import static org.apache.dolphinscheduler.alert.utils.Constants.ALERT_PROPERTIES_PATH;
import org.apache.dolphinscheduler.common.utils.IOUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.regex.PatternSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* property utils
* single instance
*/
public class PropertyUtils {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(PropertyUtils.class);
private static final Properties properties = new Properties();
/**
* init properties
*/
private static final PropertyUtils propertyUtils = new PropertyUtils();
private PropertyUtils() {
init();
}
private void init() {
String[] propertyFiles = new String[]{ALERT_PROPERTIES_PATH};
for (String fileName : propertyFiles) {
InputStream fis = null; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | try {
fis = PropertyUtils.class.getResourceAsStream(fileName);
properties.load(fis);
} catch (IOException e) {
logger.error(e.getMessage(), e);
if (fis != null) {
IOUtils.closeQuietly(fis);
}
System.exit(1);
} finally {
IOUtils.closeQuietly(fis);
}
}
}
/**
* get property value
*
* @param key property name
* @return the value
*/
public static String getString(String key) {
if (StringUtils.isEmpty(key)) {
return null;
}
return properties.getProperty(key.trim());
}
/**
* get property value
*
* @param key property name |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | * @param defaultVal default value
* @return property value
*/
public static String getString(String key, String defaultVal) {
String val = properties.getProperty(key.trim());
return val == null ? defaultVal : val;
}
/**
* get property value
*
* @param key property name
* @return get property int value , if key == null, then return -1
*/
public static int getInt(String key) {
return getInt(key, -1);
}
/**
* get int value
*
* @param key the key
* @param defaultValue the default value
* @return the value related the key or the default value if the key not existed
*/
public static int getInt(String key, int defaultValue) {
String value = getString(key);
if (value == null) {
return defaultValue;
}
try {
return Integer.parseInt(value); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | } catch (NumberFormatException e) {
logger.info(e.getMessage(), e);
}
return defaultValue;
}
/**
* get property value
*
* @param key property name
* @return the boolean result value
*/
public static Boolean getBoolean(String key) {
if (StringUtils.isEmpty(key)) {
return false;
}
String value = properties.getProperty(key.trim());
if (null != value) {
return Boolean.parseBoolean(value);
}
return false;
}
/**
* get long value
*
* @param key the key
* @return if the value not existed, return -1, or will return the related value
*/
public static long getLong(String key) {
return getLong(key, -1);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | /**
* get long value
*
* @param key the key
* @param defaultVal the default value
* @return the value related the key or the default value if the key not existed
*/
public static long getLong(String key, long defaultVal) {
String val = getString(key);
if (val == null) {
return defaultVal;
}
try {
return Long.parseLong(val);
} catch (NumberFormatException e) {
logger.info(e.getMessage(), e);
}
return defaultVal;
}
/**
* get double value
*
* @param key the key
* @return if the value not existed, return -1.0, or will return the related value
*/
public static double getDouble(String key) {
return getDouble(key, -1.0);
}
/**
* get double value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | *
* @param key the key
* @param defaultVal the default value
* @return the value related the key or the default value if the key not existed
*/
public static double getDouble(String key, double defaultVal) {
String val = getString(key);
if (val == null) {
return defaultVal;
}
try {
return Double.parseDouble(val);
} catch (NumberFormatException e) {
logger.info(e.getMessage(), e);
}
return defaultVal;
}
/**
* get array
*
* @param key property name
* @param splitStr separator
* @return the result array
*/
public static String[] getArray(String key, String splitStr) {
String value = getString(key);
if (value == null || StringUtils.isEmpty(splitStr)) {
return null;
}
try { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java | return value.split(splitStr);
} catch (PatternSyntaxException e) {
logger.info(e.getMessage(), e);
}
return null;
}
/**
* get enum
*
* @param key the key
* @param type the class type
* @param defaultValue the default value
* @param <T> the generic class type
* @return get enum value
*/
public static <T extends Enum<T>> T getEnum(String key, Class<T> type,
T defaultValue) {
String val = getString(key);
if (val == null) {
return defaultValue;
}
try {
return Enum.valueOf(type, val);
} catch (IllegalArgumentException e) {
logger.info(e.getMessage(), e);
}
return defaultValue;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManagerTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert.plugin;
import org.apache.dolphinscheduler.alert.AlertServer;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginLoader;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginManagerConfig;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import java.util.Objects;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManagerTest.java | import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
/**
* AlertPluginManager Tester.
*/
public class AlertPluginManagerTest {
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManagerTest.class);
@Test
public void testLoadPlugins() {
logger.info("begin test AlertPluginManagerTest");
AlertPluginManager alertPluginManager = new AlertPluginManager();
DolphinPluginManagerConfig alertPluginManagerConfig = new DolphinPluginManagerConfig();
String path = Objects.requireNonNull(DolphinPluginLoader.class.getClassLoader().getResource("")).getPath();
alertPluginManagerConfig.setPlugins(path + "../../../dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/pom.xml");
if (StringUtils.isNotBlank(PropertyUtils.getString(AlertServer.ALERT_PLUGIN_DIR))) {
alertPluginManagerConfig.setInstalledPluginsDir(org.apache.dolphinscheduler.alert.utils.PropertyUtils.getString(AlertServer.ALERT_PLUGIN_DIR, Constants.ALERT_PLUGIN_PATH).trim());
}
if (StringUtils.isNotBlank(PropertyUtils.getString(AlertServer.MAVEN_LOCAL_REPOSITORY))) {
alertPluginManagerConfig.setMavenLocalRepository(Objects.requireNonNull(PropertyUtils.getString(AlertServer.MAVEN_LOCAL_REPOSITORY)).trim());
}
DolphinPluginLoader alertPluginLoader = new DolphinPluginLoader(alertPluginManagerConfig, ImmutableList.of(alertPluginManager));
try {
alertPluginLoader.loadPlugins();
} catch (Exception e) {
throw new RuntimeException("load Alert Plugin Failed !", e);
}
Assert.assertNotNull(alertPluginManager.getAlertChannelFactoryMap().get("Email"));
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert.plugin;
import org.apache.dolphinscheduler.alert.AlertServer;
import org.apache.dolphinscheduler.alert.runner.AlertSender;
import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginLoader;
import org.apache.dolphinscheduler.common.plugin.DolphinPluginManagerConfig; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.DaoFactory;
import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.spi.alert.AlertConstants;
import org.apache.dolphinscheduler.spi.alert.ShowType;
import org.apache.dolphinscheduler.spi.params.InputParam;
import org.apache.dolphinscheduler.spi.params.PasswordParam;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.RadioParam;
import org.apache.dolphinscheduler.spi.params.base.DataType;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
/**
* test load and use alert plugin
*/
public class EmailAlertPluginTest { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | private AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class);
private PluginDao pluginDao = DaoFactory.getDaoInstance(PluginDao.class);
@Test
public void testRunSend() {
AlertGroup alertGroup = new AlertGroup();
alertGroup.setDescription("test alert group 1");
alertGroup.setGroupName("testalertg1");
alertDao.getAlertGroupMapper().insert(alertGroup);
Alert alert1 = new Alert();
alert1.setTitle("test alert");
LinkedHashMap<String, Object> map1 = new LinkedHashMap<>();
map1.put("mysql service name", "mysql200");
map1.put("mysql address", "192.168.xx.xx");
map1.put("port", "3306");
map1.put(AlertConstants.SHOW_TYPE, ShowType.TEXT.getDescp());
map1.put("no index of number", "80");
map1.put("database client connections", "190");
LinkedHashMap<String, Object> map2 = new LinkedHashMap<>();
map2.put("mysql service name", "mysql210");
map2.put("mysql address", "192.168.xx.xx");
map2.put("port", "3306");
map2.put("no index of number", "10");
map1.put(AlertConstants.SHOW_TYPE, ShowType.TABLE.getDescp());
map2.put("database client connections", "90");
List<LinkedHashMap<String, Object>> maps = new ArrayList<>();
maps.add(0, map1);
maps.add(1, map2);
String mapjson = JSONUtils.toJsonString(maps); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | alert1.setContent(mapjson);
alert1.setLog("log log");
alert1.setAlertGroupId(alertGroup.getId());
alertDao.addAlert(alert1);
List<Alert> alertList = new ArrayList<>();
alertList.add(alert1);
AlertPluginManager alertPluginManager = new AlertPluginManager();
DolphinPluginManagerConfig alertPluginManagerConfig = new DolphinPluginManagerConfig();
String path = DolphinPluginLoader.class.getClassLoader().getResource("").getPath();
alertPluginManagerConfig.setPlugins(path + "../../../dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/pom.xml");
if (StringUtils.isNotBlank(PropertyUtils.getString(AlertServer.ALERT_PLUGIN_DIR))) {
alertPluginManagerConfig.setInstalledPluginsDir(PropertyUtils.getString(AlertServer.ALERT_PLUGIN_DIR, Constants.ALERT_PLUGIN_PATH).trim());
}
if (StringUtils.isNotBlank(PropertyUtils.getString(AlertServer.MAVEN_LOCAL_REPOSITORY))) {
alertPluginManagerConfig.setMavenLocalRepository(PropertyUtils.getString(AlertServer.MAVEN_LOCAL_REPOSITORY).trim());
}
DolphinPluginLoader alertPluginLoader = new DolphinPluginLoader(alertPluginManagerConfig, ImmutableList.of(alertPluginManager));
try {
alertPluginLoader.loadPlugins();
} catch (Exception e) {
throw new RuntimeException("load Alert Plugin Failed !", e);
}
AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
alertPluginInstance.setCreateTime(new Date());
alertPluginInstance.setInstanceName("test email alert");
List<PluginDefine> pluginDefineList = pluginDao.getPluginDefineMapper().queryByNameAndType("Email", "alert");
if (pluginDefineList == null || pluginDefineList.size() == 0) {
throw new RuntimeException("no alert plugin be load"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | }
PluginDefine pluginDefine = pluginDefineList.get(0);
alertPluginInstance.setPluginDefineId(pluginDefine.getId());
alertPluginInstance.setPluginInstanceParams(getEmailAlertParams());
alertDao.getAlertPluginInstanceMapper().insert(alertPluginInstance);
AlertSender alertSender = new AlertSender(alertList, alertDao, alertPluginManager);
alertSender.run();
Alert alertResult = alertDao.getAlertMapper().selectById(alert1.getId());
Assert.assertNotNull(alertResult);
Assert.assertEquals(alertResult.getAlertStatus(), AlertStatus.EXECUTION_FAILURE);
alertDao.getAlertGroupMapper().deleteById(alertGroup.getId());
alertDao.getAlertPluginInstanceMapper().deleteById(alertPluginInstance.getId());
alertDao.getAlertMapper().deleteById(alert1.getId());
}
public String getEmailAlertParams() {
List<PluginParams> paramsList = new ArrayList<>();
InputParam receivesParam = InputParam.newBuilder("receivers", "receivers")
.setValue("[email protected]")
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
InputParam mailSmtpHost = InputParam.newBuilder("mailServerHost", "mail.smtp.host")
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("smtp.exmail.qq.com")
.build();
InputParam mailSmtpPort = InputParam.newBuilder("mailServerPort", "mail.smtp.port")
.addValidate(Validate.newBuilder()
.setRequired(true)
.setType(DataType.NUMBER.getDataType())
.build())
.setValue(25) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | .build();
InputParam mailSender = InputParam.newBuilder("mailSender", "mail.sender")
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("[email protected]")
.build();
RadioParam enableSmtpAuth = RadioParam.newBuilder("enableSmtpAuth", "mail.smtp.auth")
.addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(true)
.build();
InputParam mailUser = InputParam.newBuilder("mailUser", "mail.user")
.setPlaceholder("if enable use authentication, you need input user")
.setValue("[email protected]")
.build();
PasswordParam mailPassword = PasswordParam.newBuilder("mailPasswd", "mail.passwd")
.setPlaceholder("if enable use authentication, you need input password")
.setValue("xxxxxxx")
.build();
RadioParam enableTls = RadioParam.newBuilder("starttlsEnable", "mail.smtp.starttls.enable")
.addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(true)
.build();
RadioParam enableSsl = RadioParam.newBuilder("sslEnable", "mail.smtp.ssl.enable")
.addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(false) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java | .build();
InputParam sslTrust = InputParam.newBuilder("mailSmtpSslTrust", "mail.smtp.ssl.trust")
.addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("smtp.exmail.qq.com")
.build();
List<ParamsOptions> emailShowTypeList = new ArrayList<>();
emailShowTypeList.add(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false));
emailShowTypeList.add(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false));
emailShowTypeList.add(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false));
emailShowTypeList.add(new ParamsOptions(ShowType.TABLEATTACHMENT.getDescp(), ShowType.TABLEATTACHMENT.getDescp(), false));
RadioParam showType = RadioParam.newBuilder(AlertConstants.SHOW_TYPE, "showType")
.setParamsOptionsList(emailShowTypeList)
.setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
paramsList.add(receivesParam);
paramsList.add(mailSmtpHost);
paramsList.add(mailSmtpPort);
paramsList.add(mailSender);
paramsList.add(enableSmtpAuth);
paramsList.add(mailUser);
paramsList.add(mailPassword);
paramsList.add(enableTls);
paramsList.add(enableSsl);
paramsList.add(sslTrust);
paramsList.add(showType);
return PluginParamsTransfer.transferParamsToJson(paramsList);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.alert.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import org.apache.dolphinscheduler.common.enums.ZKNodeType;
import org.junit.Test; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Test PropertyUtils
* and the resource path is src/test/resources/alert.properties.
*/
public class PropertyUtilsTest {
private static final Logger logger = LoggerFactory.getLogger(PropertyUtilsTest.class);
/**
* Test getString
*/
@Test
public void testGetString() {
String result = PropertyUtils.getString("alert.type");
logger.info(result);
assertEquals("EMAIL", result);
result = PropertyUtils.getString("mail.server.host");
assertEquals("xxx.xxx.test", result);
result = PropertyUtils.getString("abc");
assertNull(result);
result = PropertyUtils.getString(null);
assertNull(result);
}
/**
* Test getBoolean
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | @Test
public void testGetBoolean() {
Boolean result = PropertyUtils.getBoolean("mail.smtp.starttls.enable");
assertTrue(result);
result = PropertyUtils.getBoolean("mail.smtp.ssl.enable");
assertFalse(result);
result = PropertyUtils.getBoolean("abc");
assertFalse(result);
result = PropertyUtils.getBoolean(null);
assertFalse(result);
}
/**
* Test getLong
*/
@Test
public void testGetLong() {
long result = PropertyUtils.getLong("mail.server.port");
assertSame(25L, result);
result = PropertyUtils.getLong(null);
assertSame(-1L, result);
result = PropertyUtils.getLong("abc");
assertSame(-1L, result); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | result = PropertyUtils.getLong("abc", 200);
assertEquals(200L, result);
result = PropertyUtils.getLong("test.server.testnumber");
assertSame(-1L, result);
}
/**
* Test getDouble
*/
@Test
public void testGetDouble() {
double result = PropertyUtils.getDouble("test.server.factor");
assertEquals(3.0, result, 0);
result = PropertyUtils.getDouble(null);
assertEquals(-1.0, result, 0);
result = PropertyUtils.getDouble("abc");
assertEquals(-1.0, result, 0);
result = PropertyUtils.getDouble("abc", 5.0);
assertEquals(5.0, result, 0);
result = PropertyUtils.getDouble("test.server.testnumber");
assertEquals(-1.0, result, 0);
}
/**
* Test getArray
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | @Test
public void testGetArray() {
String[] result = PropertyUtils.getArray("test.server.list", ",");
assertEquals(result.length, 3);
assertEquals("xxx.xxx.test1", result[0]);
assertEquals("xxx.xxx.test2", result[1]);
assertEquals("xxx.xxx.test3", result[2]);
result = PropertyUtils.getArray(null, ",");
assertNull(result);
result = PropertyUtils.getArray("abc", ",");
assertNull(result);
result = PropertyUtils.getArray("test.server.list", null);
assertNull(result);
}
/**
* test getInt
*/
@Test
public void testGetInt() {
int result = PropertyUtils.getInt("mail.server.port");
assertSame(25, result);
result = PropertyUtils.getInt(null);
assertSame(-1, result); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/PropertyUtilsTest.java | result = PropertyUtils.getInt("abc");
assertSame(-1, result);
result = PropertyUtils.getInt("abc", 300);
assertEquals(300, result);
result = PropertyUtils.getInt("test.server.testnumber");
assertSame(-1, result);
}
/**
* Test getEnum
*/
@Test
public void testGetEnum() {
ZKNodeType zkNodeType = PropertyUtils.getEnum("test.server.enum1", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(ZKNodeType.MASTER, zkNodeType);
zkNodeType = PropertyUtils.getEnum("test.server.enum2", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(ZKNodeType.DEAD_SERVER, zkNodeType);
zkNodeType = PropertyUtils.getEnum(null, ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(ZKNodeType.WORKER, zkNodeType);
zkNodeType = PropertyUtils.getEnum("test.server.enum3", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(ZKNodeType.WORKER, zkNodeType);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.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.common.utils;
import static org.apache.dolphinscheduler.common.Constants.COMMON_PROPERTIES_PATH;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ResUploadType;
import org.apache.commons.io.IOUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* property utils
* single instance
*/
public class PropertyUtils {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(PropertyUtils.class);
private static final Properties properties = new Properties();
private PropertyUtils() {
throw new UnsupportedOperationException("Construct PropertyUtils");
}
static {
String[] propertyFiles = new String[]{COMMON_PROPERTIES_PATH};
for (String fileName : propertyFiles) {
InputStream fis = null;
try {
fis = PropertyUtils.class.getResourceAsStream(fileName);
properties.load(fis);
} catch (IOException e) {
logger.error(e.getMessage(), e);
if (fis != null) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | IOUtils.closeQuietly(fis);
}
System.exit(1);
} finally {
IOUtils.closeQuietly(fis);
}
}
}
/**
* @return judge whether resource upload startup
*/
public static boolean getResUploadStartupState() {
String resUploadStartupType = PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE);
ResUploadType resUploadType = ResUploadType.valueOf(resUploadStartupType);
return resUploadType == ResUploadType.HDFS || resUploadType == ResUploadType.S3;
}
/**
* get property value
*
* @param key property name
* @return property value
*/
public static String getString(String key) {
return properties.getProperty(key.trim());
}
/**
* get property value with upper case
*
* @param key property name
* @return property value with upper case |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | */
public static String getUpperCaseString(String key) {
return properties.getProperty(key.trim()).toUpperCase();
}
/**
* get property value
*
* @param key property name
* @param defaultVal default value
* @return property value
*/
public static String getString(String key, String defaultVal) {
String val = properties.getProperty(key.trim());
return val == null ? defaultVal : val;
}
/**
* get property value
*
* @param key property name
* @return get property int value , if key == null, then return -1
*/
public static int getInt(String key) {
return getInt(key, -1);
}
/**
* @param key key
* @param defaultValue default value
* @return property value
*/
public static int getInt(String key, int defaultValue) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | String value = getString(key);
if (value == null) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
logger.info(e.getMessage(), e);
}
return defaultValue;
}
/**
* get property value
*
* @param key property name
* @return property value
*/
public static boolean getBoolean(String key) {
String value = properties.getProperty(key.trim());
if (null != value) {
return Boolean.parseBoolean(value);
}
return false;
}
/**
* get property value
*
* @param key property name
* @param defaultValue default value
* @return property value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | */
public static Boolean getBoolean(String key, boolean defaultValue) {
String value = properties.getProperty(key.trim());
if (null != value) {
return Boolean.parseBoolean(value);
}
return defaultValue;
}
/**
* get property long value
*
* @param key key
* @param defaultVal default value
* @return property value
*/
public static long getLong(String key, long defaultVal) {
String val = getString(key);
return val == null ? defaultVal : Long.parseLong(val);
}
/**
* @param key key
* @return property value
*/
public static long getLong(String key) {
return getLong(key, -1);
}
/**
* @param key key
* @param defaultVal default value
* @return property value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | */
public double getDouble(String key, double defaultVal) {
String val = getString(key);
return val == null ? defaultVal : Double.parseDouble(val);
}
/**
* get array
*
* @param key property name
* @param splitStr separator
* @return property value through array
*/
public static String[] getArray(String key, String splitStr) {
String value = getString(key);
if (value == null) {
return new String[0];
}
try {
String[] propertyArray = value.split(splitStr);
return propertyArray;
} catch (NumberFormatException e) {
logger.info(e.getMessage(), e);
}
return new String[0];
}
/**
* @param key key
* @param type type
* @param defaultValue default value
* @param <T> T |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java | * @return get enum value
*/
public <T extends Enum<T>> T getEnum(String key, Class<T> type,
T defaultValue) {
String val = getString(key);
return val == null ? defaultValue : Enum.valueOf(type, val);
}
/**
* get all properties with specified prefix, like: fs.
*
* @param prefix prefix to search
* @return all properties with specified prefix
*/
public static Map<String, String> getPrefixedProperties(String prefix) {
Map<String, String> matchedProperties = new HashMap<>();
for (String propName : properties.stringPropertyNames()) {
if (propName.startsWith(prefix)) {
matchedProperties.put(propName, properties.getProperty(propName));
}
}
return matchedProperties;
}
/**
*
*/
public static void setValue(String key, String value) {
properties.setProperty(key, value);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.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 | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | * See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.TaskRecordStatus;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.ConnectionUtils;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.TaskRecord;
import org.apache.dolphinscheduler.dao.utils.PropertyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* task record dao
*/
public class TaskRecordDao {
private static Logger logger = LoggerFactory.getLogger(TaskRecordDao.class.getName());
/**
* get task record flag
* @return whether startup taskrecord
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | public static boolean getTaskRecordFlag(){
return PropertyUtils.getBoolean(Constants.TASK_RECORD_FLAG,false);
}
/**
* create connection
*
* @return connection
*/
private static Connection getConn() {
if (!getTaskRecordFlag()) {
return null;
}
String driver = "com.mysql.jdbc.Driver";
String url = PropertyUtils.getString(Constants.TASK_RECORD_URL);
String username = PropertyUtils.getString(Constants.TASK_RECORD_USER);
String password = PropertyUtils.getString(Constants.TASK_RECORD_PWD);
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
logger.error("Class not found Exception ", e);
} catch (SQLException e) {
logger.error("SQL Exception ", e);
}
return conn;
}
/**
* generate where sql string |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | *
* @param filterMap filterMap
* @return sql string
*/
private static String getWhereString(Map<String, String> filterMap) {
if (filterMap.size() == 0) {
return "";
}
String result = " where 1=1 ";
Object taskName = filterMap.get("taskName");
if (taskName != null && StringUtils.isNotEmpty(taskName.toString())) {
result += " and PROC_NAME like concat('%', '" + taskName.toString() + "', '%') ";
}
Object taskDate = filterMap.get("taskDate");
if (taskDate != null && StringUtils.isNotEmpty(taskDate.toString())) {
result += " and PROC_DATE='" + taskDate.toString() + "'";
}
Object state = filterMap.get("state");
if (state != null && StringUtils.isNotEmpty(state.toString())) {
result += " and NOTE='" + state.toString() + "'";
}
Object sourceTable = filterMap.get("sourceTable");
if (sourceTable != null && StringUtils.isNotEmpty(sourceTable.toString())) {
result += " and SOURCE_TAB like concat('%', '" + sourceTable.toString() + "', '%')";
}
Object targetTable = filterMap.get("targetTable");
if (sourceTable != null && StringUtils.isNotEmpty(targetTable.toString())) {
result += " and TARGET_TAB like concat('%', '" + targetTable.toString() + "', '%') ";
}
Object start = filterMap.get("startTime"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | if (start != null && StringUtils.isNotEmpty(start.toString())) {
result += " and STARTDATE>='" + start.toString() + "'";
}
Object end = filterMap.get("endTime");
if (end != null && StringUtils.isNotEmpty(end.toString())) {
result += " and ENDDATE>='" + end.toString() + "'";
}
return result;
}
/**
* count task record
*
* @param filterMap filterMap
* @param table table
* @return task record count
*/
public static int countTaskRecord(Map<String, String> filterMap, String table) {
int count = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = getConn();
if (conn == null) {
return count;
}
String sql = String.format("select count(1) as count from %s", table);
sql += getWhereString(filterMap);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | while (rs.next()){
count = rs.getInt("count");
break;
}
} catch (SQLException e) {
logger.error("Exception ", e);
}finally {
ConnectionUtils.releaseResource(rs, pstmt, conn);
}
return count;
}
/**
* query task record by filter map paging
*
* @param filterMap filterMap
* @param table table
* @return task record list
*/
public static List<TaskRecord> queryAllTaskRecord(Map<String, String> filterMap, String table) {
String sql = String.format("select * from %s", table);
sql += getWhereString(filterMap);
int offset = Integer.parseInt(filterMap.get("offset"));
int pageSize = Integer.parseInt(filterMap.get("pageSize"));
sql += String.format(" order by STARTDATE desc limit %d,%d", offset, pageSize);
List<TaskRecord> recordList = new ArrayList<>();
try {
recordList = getQueryResult(sql);
} catch (Exception e) {
logger.error("Exception ", e);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | return recordList;
}
/**
* convert result set to task record
*
* @param resultSet resultSet
* @return task record
* @throws SQLException if error throws SQLException
*/
private static TaskRecord convertToTaskRecord(ResultSet resultSet) throws SQLException {
TaskRecord taskRecord = new TaskRecord();
taskRecord.setId(resultSet.getInt("ID"));
taskRecord.setProcId(resultSet.getInt("PROC_ID"));
taskRecord.setProcName(resultSet.getString("PROC_NAME"));
taskRecord.setProcDate(resultSet.getString("PROC_DATE"));
taskRecord.setStartTime(DateUtils.stringToDate(resultSet.getString("STARTDATE")));
taskRecord.setEndTime(DateUtils.stringToDate(resultSet.getString("ENDDATE")));
taskRecord.setResult(resultSet.getString("RESULT"));
taskRecord.setDuration(resultSet.getInt("DURATION"));
taskRecord.setNote(resultSet.getString("NOTE"));
taskRecord.setSchema(resultSet.getString("SCHEMA"));
taskRecord.setJobId(resultSet.getString("JOB_ID"));
taskRecord.setSourceTab(resultSet.getString("SOURCE_TAB"));
taskRecord.setSourceRowCount(resultSet.getLong("SOURCE_ROW_COUNT"));
taskRecord.setTargetTab(resultSet.getString("TARGET_TAB"));
taskRecord.setTargetRowCount(resultSet.getLong("TARGET_ROW_COUNT"));
taskRecord.setErrorCode(resultSet.getString("ERROR_CODE"));
return taskRecord;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | * query task list by select sql
*
* @param selectSql select sql
* @return task record list
*/
private static List<TaskRecord> getQueryResult(String selectSql) {
List<TaskRecord> recordList = new ArrayList<>();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = getConn();
if (conn == null) {
return recordList;
}
pstmt = conn.prepareStatement(selectSql);
rs = pstmt.executeQuery();
while (rs.next()) {
TaskRecord taskRecord = convertToTaskRecord(rs);
recordList.add(taskRecord);
}
} catch (SQLException e) {
logger.error("Exception ", e);
}finally {
ConnectionUtils.releaseResource(rs, pstmt, conn);
}
return recordList;
}
/**
* according to procname and procdate query task record |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/TaskRecordDao.java | *
* @param procName procName
* @param procDate procDate
* @return task record status
*/
public static TaskRecordStatus getTaskRecordState(String procName, String procDate) {
String sql = String.format("SELECT * FROM eamp_hive_log_hd WHERE PROC_NAME='%s' and PROC_DATE like '%s'"
, procName, procDate + "%");
List<TaskRecord> taskRecordList = getQueryResult(sql);
//
if (CollectionUtils.isEmpty(taskRecordList)) {
//
return TaskRecordStatus.EXCEPTION;
} else if (taskRecordList.size() > 1) {
return TaskRecordStatus.EXCEPTION;
} else {
TaskRecord taskRecord = taskRecordList.get(0);
if (taskRecord == null) {
return TaskRecordStatus.EXCEPTION;
}
Long targetRowCount = taskRecord.getTargetRowCount();
if (targetRowCount <= 0) {
return TaskRecordStatus.FAILURE;
} else {
return TaskRecordStatus.SUCCESS;
}
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.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.dao.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java | import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.utils.PropertyUtils;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import java.util.Properties;
/**
* data source connection factory
*/
@Configuration
@MapperScan("org.apache.dolphinscheduler.*.mapper")
public class SpringConnectionFactory {
private static final Logger logger = LoggerFactory.getLogger(SpringConnectionFactory.class);
/**
* pagination interceptor
* @return pagination interceptor
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java | @Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* get the data source
* @return druid dataSource
*/
@Bean(destroyMethod="")
public DruidDataSource dataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(PropertyUtils.getString(Constants.SPRING_DATASOURCE_DRIVER_CLASS_NAME));
druidDataSource.setUrl(PropertyUtils.getString(Constants.SPRING_DATASOURCE_URL));
druidDataSource.setUsername(PropertyUtils.getString(Constants.SPRING_DATASOURCE_USERNAME));
druidDataSource.setPassword(PropertyUtils.getString(Constants.SPRING_DATASOURCE_PASSWORD));
druidDataSource.setValidationQuery(PropertyUtils.getString(Constants.SPRING_DATASOURCE_VALIDATION_QUERY,"SELECT 1"));
druidDataSource.setPoolPreparedStatements(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_POOL_PREPARED_STATEMENTS,true));
druidDataSource.setTestWhileIdle(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_TEST_WHILE_IDLE,true));
druidDataSource.setTestOnBorrow(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_TEST_ON_BORROW,true));
druidDataSource.setTestOnReturn(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_TEST_ON_RETURN,true));
druidDataSource.setKeepAlive(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_KEEP_ALIVE,true));
druidDataSource.setMinIdle(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MIN_IDLE,5));
druidDataSource.setMaxActive(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE,50));
druidDataSource.setMaxWait(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_WAIT,60000));
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_POOL_PREPARED_STATEMENT_PER_CONNECTION_SIZE,20));
druidDataSource.setInitialSize(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_INITIAL_SIZE,5));
druidDataSource.setTimeBetweenEvictionRunsMillis(PropertyUtils.getLong(Constants.SPRING_DATASOURCE_TIME_BETWEEN_EVICTION_RUNS_MILLIS,60000));
druidDataSource.setTimeBetweenConnectErrorMillis(PropertyUtils.getLong(Constants.SPRING_DATASOURCE_TIME_BETWEEN_CONNECT_ERROR_MILLIS,60000));
druidDataSource.setMinEvictableIdleTimeMillis(PropertyUtils.getLong(Constants.SPRING_DATASOURCE_MIN_EVICTABLE_IDLE_TIME_MILLIS,300000));
druidDataSource.setValidationQueryTimeout(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_VALIDATION_QUERY_TIMEOUT,3)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java | druidDataSource.setDefaultAutoCommit(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT,true));
return druidDataSource;
}
/**
* * get transaction manager
* @return DataSourceTransactionManager
*/
@Bean
public DataSourceTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
/**
* * get sql session factory
* @return sqlSessionFactory
* @throws Exception sqlSessionFactory exception
*/
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
MybatisConfiguration configuration = new MybatisConfiguration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setCacheEnabled(false);
configuration.setCallSettersOnNulls(true);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.addInterceptor(paginationInterceptor());
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setConfiguration(configuration);
sqlSessionFactoryBean.setDataSource(dataSource());
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
dbConfig.setIdType(IdType.AUTO); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java | GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setDbConfig(dbConfig);
sqlSessionFactoryBean.setGlobalConfig(globalConfig);
sqlSessionFactoryBean.setTypeAliasesPackage("org.apache.dolphinscheduler.dao.entity");
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("org/apache/dolphinscheduler/dao/mapper/*Mapper.xml"));
sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.*.enums");
sqlSessionFactoryBean.setDatabaseIdProvider(databaseIdProvider());
return sqlSessionFactoryBean.getObject();
}
/**
* get sql session
* @return SqlSession
* @throws Exception
*/
@Bean
public SqlSession sqlSession() throws Exception{
return new SqlSessionTemplate(sqlSessionFactory());
}
@Bean
public DatabaseIdProvider databaseIdProvider(){
DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
Properties properties = new Properties();
properties.setProperty("MySQL", "mysql");
properties.setProperty("PostgreSQL", "pg");
databaseIdProvider.setProperties(properties);
return databaseIdProvider;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PropertyUtils.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.dao.utils;
import org.apache.dolphinscheduler.common.Constants;
import com.baomidou.mybatisplus.core.toolkit.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* property utils
* single instance
*/
public class PropertyUtils { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PropertyUtils.java | /**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(PropertyUtils.class);
private static final Properties properties = new Properties();
private static final PropertyUtils propertyUtils = new PropertyUtils();
private PropertyUtils(){
init();
}
/**
* init
*/
private void init(){
String[] propertyFiles = new String[]{Constants.DATASOURCE_PROPERTIES};
for (String fileName : propertyFiles) {
InputStream fis = null;
try {
fis = PropertyUtils.class.getResourceAsStream(fileName);
properties.load(fis);
} catch (IOException e) {
logger.error(e.getMessage(), e);
if (fis != null) {
IOUtils.closeQuietly(fis);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PropertyUtils.java | System.exit(1);
} finally {
IOUtils.closeQuietly(fis);
}
}
}
/**
* get property value
* @param key property name
* @return get string value
*/
public static String getString(String key) {
return properties.getProperty(key);
}
/**
* get property value
*
* @param key property name
* @param defaultVal default value
* @return property value
*/
public static String getString(String key, String defaultVal) {
String val = properties.getProperty(key.trim());
return val == null ? defaultVal : val;
}
/**
* get property value
* @param key property name
* @return get property int value , if key == null, then return -1
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 4,971 | [Improvement][common] Remove redundant PropertyUtils.class | We are flooded with too many PropertyUtils.class, in my opinion, there is no need, therefore, it is best to keep only the common-model. | https://github.com/apache/dolphinscheduler/issues/4971 | https://github.com/apache/dolphinscheduler/pull/5020 | 1cd62b4a5e6d5e8ac3adf8b7e2ffd61a8e87f71b | 6216817861c64d9a170686c4c5aa6f3b9b0da110 | "2021-03-05T13:58:44Z" | java | "2021-03-17T07:28:07Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/PropertyUtils.java | public static int getInt(String key) {
return getInt(key, -1);
}
/**
* get property value
* @param key key
* @param defaultValue defaultValue
* @return get property int value,if key == null ,then return defaultValue
*/
public static int getInt(String key, int defaultValue) {
String value = getString(key);
if (value == null) {
return defaultValue;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
logger.info(e.getMessage(),e);
}
return defaultValue;
}
/**
* get property value
*
* @param key property name
* @return property value
*/
public static Boolean getBoolean(String key) {
String value = properties.getProperty(key.trim());
if(null != value){ |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.