Browse Source

add more message for java-doc (#1209)

* move updateTaskState into try/catch block in case of exception

* fix NPE

* using conf.getInt instead of getString

* for AbstractZKClient, remove the log, for it will print the same log message in createZNodePath.
for AlertDao, correct the spelling.

* duplicate

* refactor getTaskWorkerGroupId

* add friendly log

* update hearbeat thread num = 1

* fix the bug when worker execute task using queue. and remove checking Tenant user anymore in TaskScheduleThread

* 1. move verifyTaskInstanceIsNull after taskInstance
2. keep verifyTenantIsNull/verifyTaskInstanceIsNull clean and readable

* fix the message

* delete before check to avoid KeeperException$NoNodeException

* fix the message

* check processInstance state before delete tenant

* check processInstance state before delete worker group

* refactor

* merge api constants into common constatns

* update the resource perm

* update the dataSource perm

* fix CheckUtils.checkUserParams method

* update AlertGroupService, extends from BaseService, remove duplicate methods

* refactor

* modify method name

* add hasProjectAndPerm method

* using checkProject instead of getResultStatus

* delete checkAuth method, using hasProjectAndPerm instead.

* correct spelling

* add transactional for deleteWorkerGroupById

* add Transactional for deleteProcessInstanceById method

* change sqlSessionTemplate singleton

* change sqlSessionTemplate singleton and reformat code

* fix unsuitable error message

* update shutdownhook methods

* fix worker log bug

* fix api server debug mode bug

* upgrade zk version

* delete this line ,for zkClient.close() will do the whole thing

* fix master server shutdown error

* degrade zk version and add FourLetterWordMain class

* fix PathChildrenCache not close

* add Transactional for createSession method

* add more message for java-doc
pull/2/head
Tboy 5 years ago committed by qiaozhanwei
parent
commit
501a4006f7
  1. 22
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EmailManager.java
  2. 4
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EnterpriseWeChatManager.java
  3. 2
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/MsgManager.java
  4. 50
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java
  5. 8
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java
  6. 8
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java
  7. 93
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java
  8. 48
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java

22
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EmailManager.java

@ -28,12 +28,12 @@ import java.util.Map;
public class EmailManager {
/**
* email send
* @param receviersList
* @param receviersCcList
* @param title
* @param content
* @param showType
* @return
* @param receviersList the receiver list
* @param receviersCcList the cc List
* @param title the title
* @param content the content
* @param showType the showType
* @return the send result
*/
public Map<String,Object> send(List<String> receviersList,List<String> receviersCcList,String title,String content,ShowType showType){
@ -42,11 +42,11 @@ public class EmailManager {
/**
* msg send
* @param receviersList
* @param title
* @param content
* @param showType
* @return
* @param receviersList the receiver list
* @param title the title
* @param content the content
* @param showType the showType
* @return the send result
*/
public Map<String,Object> send(List<String> receviersList,String title,String content,ShowType showType){

4
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EnterpriseWeChatManager.java

@ -35,7 +35,9 @@ public class EnterpriseWeChatManager {
private static final Logger logger = LoggerFactory.getLogger(MsgManager.class);
/**
* Enterprise We Chat send
* @param alert
* @param alert the alert
* @param token the token
* @return the send result
*/
public Map<String,Object> send(Alert alert, String token){
Map<String,Object> retMap = new HashMap<>();

2
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/MsgManager.java

@ -28,7 +28,7 @@ public class MsgManager {
private static final Logger logger = LoggerFactory.getLogger(MsgManager.class);
/**
* SMS send
* @param alert
* @param alert the alert
*/
public void send(Alert alert){
logger.info("send message {}",alert);

50
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtils.java

@ -80,7 +80,7 @@ public class EnterpriseWeChatUtils {
/**
* get Enterprise WeChat token info
* @return token string info
* @throws IOException
* @throws IOException the IOException
*/
public static String getToken() throws IOException {
String resp;
@ -104,9 +104,9 @@ public class EnterpriseWeChatUtils {
/**
* make team single Enterprise WeChat message
* @param toParty
* @param agentId
* @param msg
* @param toParty the toParty
* @param agentId the agentId
* @param msg the msg
* @return Enterprise WeChat send message
*/
public static String makeTeamSendMsg(String toParty, String agentId, String msg) {
@ -117,9 +117,9 @@ public class EnterpriseWeChatUtils {
/**
* make team multi Enterprise WeChat message
* @param toParty
* @param agentId
* @param msg
* @param toParty the toParty
* @param agentId the agentId
* @param msg the msg
* @return Enterprise WeChat send message
*/
public static String makeTeamSendMsg(Collection<String> toParty, String agentId, String msg) {
@ -131,9 +131,9 @@ public class EnterpriseWeChatUtils {
/**
* make team single user message
* @param toUser
* @param agentId
* @param msg
* @param toUser the toUser
* @param agentId the agentId
* @param msg the msg
* @return Enterprise WeChat send message
*/
public static String makeUserSendMsg(String toUser, String agentId, String msg) {
@ -144,9 +144,9 @@ public class EnterpriseWeChatUtils {
/**
* make team multi user message
* @param toUser
* @param agentId
* @param msg
* @param toUser the toUser
* @param agentId the agentId
* @param msg the msg
* @return Enterprise WeChat send message
*/
public static String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) {
@ -158,11 +158,11 @@ public class EnterpriseWeChatUtils {
/**
* send Enterprise WeChat
* @param charset
* @param data
* @param token
* @param charset the charset
* @param data the data
* @param token the token
* @return Enterprise WeChat resp, demo: {"errcode":0,"errmsg":"ok","invaliduser":""}
* @throws IOException
* @throws IOException the IOException
*/
public static String sendEnterpriseWeChat(String charset, String data, String token) throws IOException {
String enterpriseWeChatPushUrlReplace = enterpriseWeChatPushUrl.replaceAll("\\$token", token);
@ -185,9 +185,9 @@ public class EnterpriseWeChatUtils {
/**
* convert table to markdown style
* @param title
* @param content
* @return
* @param title the title
* @param content the content
* @return markdown table content
*/
public static String markdownTable(String title,String content){
List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
@ -214,9 +214,9 @@ public class EnterpriseWeChatUtils {
/**
* convert text to markdown style
* @param title
* @param content
* @return
* @param title the title
* @param content the content
* @return markdown text
*/
public static String markdownText(String title,String content){
if (StringUtils.isNotEmpty(content)){
@ -244,8 +244,8 @@ public class EnterpriseWeChatUtils {
/**
* Determine the mardown style based on the show type of the alert
* @param alert
* @return
* @param alert the alert
* @return the markdown alert table/text
*/
public static String markdownByAlert(Alert alert){
String result = "";

8
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java

@ -35,11 +35,9 @@ public class ExcelUtils {
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
/**
* generate excel file
* @param content
* @param title
* @param xlsFilePath
* @return
* @throws Exception
* @param content the content
* @param title the title
* @param xlsFilePath the xls path
*/
public static void genExcelFile(String content,String title,String xlsFilePath){
List<LinkedHashMap> itemsList;

8
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/JSONUtils.java

@ -33,7 +33,7 @@ public class JSONUtils {
/**
* object to json string
* @param object
* @param object the object to be converted to json
* @return json string
*/
public static String toJsonString(Object object) {
@ -47,10 +47,10 @@ public class JSONUtils {
/**
* json to list
*
* @param json
* @param json the json
* @param clazz c
* @param <T>
* @return
* @param <T> the generic clazz
* @return the result list
*/
public static <T> List<T> toList(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) {

93
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/MailUtils.java

@ -92,11 +92,11 @@ public class MailUtils {
/**
* send mail to receivers
*
* @param receivers
* @param title
* @param content
* @return
* @param receivers the receiver list
* @param title the title
* @param content the content
* @param showType the show type
* @return the result map
*/
public static Map<String,Object> sendMails(Collection<String> receivers, String title, String content,ShowType showType) {
return sendMails(receivers, null, title, content, showType);
@ -104,12 +104,12 @@ public class MailUtils {
/**
* send mail
* @param receivers
* @param receiversCc cc
* @param title title
* @param content content
* @param showType mail type
* @return
* @param receivers the receiver list
* @param receiversCc cc list
* @param title the title
* @param content the content
* @param showType the show type
* @return the send result
*/
public static Map<String,Object> sendMails(Collection<String> receivers, Collection<String> receiversCc, String title, String content, ShowType showType) {
Map<String,Object> retMap = new HashMap<>();
@ -169,9 +169,9 @@ public class MailUtils {
/**
* html table content
* @param content
* @param showAll
* @return
* @param content the content
* @param showAll if show the whole content
* @return the html table form
*/
private static String htmlTable(String content, boolean showAll){
if (StringUtils.isNotEmpty(content)){
@ -198,7 +198,7 @@ public class MailUtils {
Map.Entry<String, String> entry = iterator.next();
t.append(Constants.TH).append(entry.getKey()).append(Constants.TH_END);
cs.append(Constants.TD).append(String.valueOf(entry.getValue())).append(Constants.TD_END);
cs.append(Constants.TD).append(entry.getValue()).append(Constants.TD_END);
}
t.append(Constants.TR_END);
@ -218,8 +218,8 @@ public class MailUtils {
/**
* html table content
* @param content
* @return
* @param content the content
* @return the html table form
*/
private static String htmlTable(String content){
return htmlTable(content,true);
@ -227,8 +227,8 @@ public class MailUtils {
/**
* html text content
* @param content
* @return
* @param content the content
* @return text in html form
*/
private static String htmlText(String content){
@ -260,9 +260,8 @@ public class MailUtils {
/**
* send mail as Excel attachment
*
* @param receivers
* @param title
* @param receivers the receiver list
* @param title the title
* @throws Exception
*/
private static void attachment(Collection<String> receivers,Collection<String> receiversCc,String title,String content,String partContent)throws Exception{
@ -274,12 +273,10 @@ public class MailUtils {
/**
* get MimeMessage
* @param receivers
* @return
* @return the MimeMessage
* @throws MessagingException
*/
private static MimeMessage getMimeMessage(Collection<String> receivers) throws MessagingException {
// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
// final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
// 1. The first step in creating mail: creating session
Session session = getSession();
@ -299,7 +296,7 @@ public class MailUtils {
/**
* get session
* @return
* @return the new Session
*/
private static Session getSession() {
Properties props = new Properties();
@ -324,12 +321,12 @@ public class MailUtils {
}
/**
*
* @param receiversCc
* @param title
* @param content
* @param partContent
* @param msg
* attach content
* @param receiversCc the cc list
* @param title the title
* @param content the content
* @param partContent the partContent
* @param msg the message
* @throws MessagingException
* @throws IOException
*/
@ -369,13 +366,13 @@ public class MailUtils {
}
/**
*
* @param title
* @param content
* @param showType
* @param retMap
* @param email
* @return
* the string object map
* @param title the title
* @param content the content
* @param showType the showType
* @param retMap the result map
* @param email the email
* @return the result map
* @throws EmailException
*/
private static Map<String, Object> getStringObjectMap(String title, String content, ShowType showType, Map<String, Object> retMap, HtmlEmail email) throws EmailException {
@ -403,7 +400,7 @@ public class MailUtils {
/**
* file delete
* @param file
* @param file the file to delete
*/
public static void deleteFile(File file){
if(file.exists()){
@ -419,10 +416,10 @@ public class MailUtils {
/**
*
* @param receivers
* @param retMap
* @param e
* handle exception
* @param receivers the receiver list
* @param retMap the result map
* @param e the exception
*/
private static void handleException(Collection<String> receivers, Map<String, Object> retMap, Exception e) {
logger.error("Send email to {} failed", StringUtils.join(",", receivers), e);
@ -430,10 +427,10 @@ public class MailUtils {
}
/**
*
* @param title
* @param content
* @return
* get the content of the template
* @param title the title
* @param content the content to retrieve
* @return the content in the template or null if exception occurs
*/
private static String getTemplateContent(String title,String content){
StringWriter out = new StringWriter();

48
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/PropertyUtils.java

@ -68,9 +68,8 @@ public class PropertyUtils {
/**
* get property value
*
* @param key property name
* @return
* @return the value
*/
public static String getString(String key) {
return properties.getProperty(key);
@ -87,10 +86,10 @@ public class PropertyUtils {
}
/**
*
* @param key
* @param defaultValue
* @return
* 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);
@ -108,9 +107,8 @@ public class PropertyUtils {
/**
* get property value
*
* @param key property name
* @return
* @return the boolean result value
*/
public static Boolean getBoolean(String key) {
String value = properties.getProperty(key.trim());
@ -122,19 +120,19 @@ public class PropertyUtils {
}
/**
*
* @param key
* @return
* 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);
}
/**
*
* @param key
* @param defaultVal
* @return
* 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);
@ -143,10 +141,10 @@ public class PropertyUtils {
/**
*
* @param key
* @param defaultVal
* @return
* get double 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 double getDouble(String key, double defaultVal) {
String val = getString(key);
@ -158,7 +156,7 @@ public class PropertyUtils {
* get array
* @param key property name
* @param splitStr separator
* @return
* @return the result array
*/
public static String[] getArray(String key, String splitStr) {
String value = getString(key);
@ -175,11 +173,11 @@ public class PropertyUtils {
}
/**
*
* @param key
* @param type
* @param defaultValue
* @param <T>
* 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 <T extends Enum<T>> T getEnum(String key, Class<T> type,

Loading…
Cancel
Save