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 { public class EmailManager {
/** /**
* email send * email send
* @param receviersList * @param receviersList the receiver list
* @param receviersCcList * @param receviersCcList the cc List
* @param title * @param title the title
* @param content * @param content the content
* @param showType * @param showType the showType
* @return * @return the send result
*/ */
public Map<String,Object> send(List<String> receviersList,List<String> receviersCcList,String title,String content,ShowType showType){ 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 * msg send
* @param receviersList * @param receviersList the receiver list
* @param title * @param title the title
* @param content * @param content the content
* @param showType * @param showType the showType
* @return * @return the send result
*/ */
public Map<String,Object> send(List<String> receviersList,String title,String content,ShowType showType){ 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); private static final Logger logger = LoggerFactory.getLogger(MsgManager.class);
/** /**
* Enterprise We Chat send * 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){ public Map<String,Object> send(Alert alert, String token){
Map<String,Object> retMap = new HashMap<>(); 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); private static final Logger logger = LoggerFactory.getLogger(MsgManager.class);
/** /**
* SMS send * SMS send
* @param alert * @param alert the alert
*/ */
public void send(Alert alert){ public void send(Alert alert){
logger.info("send message {}",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 * get Enterprise WeChat token info
* @return token string info * @return token string info
* @throws IOException * @throws IOException the IOException
*/ */
public static String getToken() throws IOException { public static String getToken() throws IOException {
String resp; String resp;
@ -104,9 +104,9 @@ public class EnterpriseWeChatUtils {
/** /**
* make team single Enterprise WeChat message * make team single Enterprise WeChat message
* @param toParty * @param toParty the toParty
* @param agentId * @param agentId the agentId
* @param msg * @param msg the msg
* @return Enterprise WeChat send message * @return Enterprise WeChat send message
*/ */
public static String makeTeamSendMsg(String toParty, String agentId, String msg) { public static String makeTeamSendMsg(String toParty, String agentId, String msg) {
@ -117,9 +117,9 @@ public class EnterpriseWeChatUtils {
/** /**
* make team multi Enterprise WeChat message * make team multi Enterprise WeChat message
* @param toParty * @param toParty the toParty
* @param agentId * @param agentId the agentId
* @param msg * @param msg the msg
* @return Enterprise WeChat send message * @return Enterprise WeChat send message
*/ */
public static String makeTeamSendMsg(Collection<String> toParty, String agentId, String msg) { public static String makeTeamSendMsg(Collection<String> toParty, String agentId, String msg) {
@ -131,9 +131,9 @@ public class EnterpriseWeChatUtils {
/** /**
* make team single user message * make team single user message
* @param toUser * @param toUser the toUser
* @param agentId * @param agentId the agentId
* @param msg * @param msg the msg
* @return Enterprise WeChat send message * @return Enterprise WeChat send message
*/ */
public static String makeUserSendMsg(String toUser, String agentId, String msg) { public static String makeUserSendMsg(String toUser, String agentId, String msg) {
@ -144,9 +144,9 @@ public class EnterpriseWeChatUtils {
/** /**
* make team multi user message * make team multi user message
* @param toUser * @param toUser the toUser
* @param agentId * @param agentId the agentId
* @param msg * @param msg the msg
* @return Enterprise WeChat send message * @return Enterprise WeChat send message
*/ */
public static String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) { public static String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) {
@ -158,11 +158,11 @@ public class EnterpriseWeChatUtils {
/** /**
* send Enterprise WeChat * send Enterprise WeChat
* @param charset * @param charset the charset
* @param data * @param data the data
* @param token * @param token the token
* @return Enterprise WeChat resp, demo: {"errcode":0,"errmsg":"ok","invaliduser":""} * @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 { public static String sendEnterpriseWeChat(String charset, String data, String token) throws IOException {
String enterpriseWeChatPushUrlReplace = enterpriseWeChatPushUrl.replaceAll("\\$token", token); String enterpriseWeChatPushUrlReplace = enterpriseWeChatPushUrl.replaceAll("\\$token", token);
@ -185,9 +185,9 @@ public class EnterpriseWeChatUtils {
/** /**
* convert table to markdown style * convert table to markdown style
* @param title * @param title the title
* @param content * @param content the content
* @return * @return markdown table content
*/ */
public static String markdownTable(String title,String content){ public static String markdownTable(String title,String content){
List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class); List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
@ -214,9 +214,9 @@ public class EnterpriseWeChatUtils {
/** /**
* convert text to markdown style * convert text to markdown style
* @param title * @param title the title
* @param content * @param content the content
* @return * @return markdown text
*/ */
public static String markdownText(String title,String content){ public static String markdownText(String title,String content){
if (StringUtils.isNotEmpty(content)){ if (StringUtils.isNotEmpty(content)){
@ -244,8 +244,8 @@ public class EnterpriseWeChatUtils {
/** /**
* Determine the mardown style based on the show type of the alert * Determine the mardown style based on the show type of the alert
* @param alert * @param alert the alert
* @return * @return the markdown alert table/text
*/ */
public static String markdownByAlert(Alert alert){ public static String markdownByAlert(Alert alert){
String result = ""; 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); private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
/** /**
* generate excel file * generate excel file
* @param content * @param content the content
* @param title * @param title the title
* @param xlsFilePath * @param xlsFilePath the xls path
* @return
* @throws Exception
*/ */
public static void genExcelFile(String content,String title,String xlsFilePath){ public static void genExcelFile(String content,String title,String xlsFilePath){
List<LinkedHashMap> itemsList; 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 * object to json string
* @param object * @param object the object to be converted to json
* @return json string * @return json string
*/ */
public static String toJsonString(Object object) { public static String toJsonString(Object object) {
@ -47,10 +47,10 @@ public class JSONUtils {
/** /**
* json to list * json to list
* *
* @param json * @param json the json
* @param clazz c * @param clazz c
* @param <T> * @param <T> the generic clazz
* @return * @return the result list
*/ */
public static <T> List<T> toList(String json, Class<T> clazz) { public static <T> List<T> toList(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json)) { 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 * send mail to receivers
* * @param receivers the receiver list
* @param receivers * @param title the title
* @param title * @param content the content
* @param content * @param showType the show type
* @return * @return the result map
*/ */
public static Map<String,Object> sendMails(Collection<String> receivers, String title, String content,ShowType showType) { public static Map<String,Object> sendMails(Collection<String> receivers, String title, String content,ShowType showType) {
return sendMails(receivers, null, title, content, showType); return sendMails(receivers, null, title, content, showType);
@ -104,12 +104,12 @@ public class MailUtils {
/** /**
* send mail * send mail
* @param receivers * @param receivers the receiver list
* @param receiversCc cc * @param receiversCc cc list
* @param title title * @param title the title
* @param content content * @param content the content
* @param showType mail type * @param showType the show type
* @return * @return the send result
*/ */
public static Map<String,Object> sendMails(Collection<String> receivers, Collection<String> receiversCc, String title, String content, ShowType showType) { public static Map<String,Object> sendMails(Collection<String> receivers, Collection<String> receiversCc, String title, String content, ShowType showType) {
Map<String,Object> retMap = new HashMap<>(); Map<String,Object> retMap = new HashMap<>();
@ -169,9 +169,9 @@ public class MailUtils {
/** /**
* html table content * html table content
* @param content * @param content the content
* @param showAll * @param showAll if show the whole content
* @return * @return the html table form
*/ */
private static String htmlTable(String content, boolean showAll){ private static String htmlTable(String content, boolean showAll){
if (StringUtils.isNotEmpty(content)){ if (StringUtils.isNotEmpty(content)){
@ -198,7 +198,7 @@ public class MailUtils {
Map.Entry<String, String> entry = iterator.next(); Map.Entry<String, String> entry = iterator.next();
t.append(Constants.TH).append(entry.getKey()).append(Constants.TH_END); 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); t.append(Constants.TR_END);
@ -218,8 +218,8 @@ public class MailUtils {
/** /**
* html table content * html table content
* @param content * @param content the content
* @return * @return the html table form
*/ */
private static String htmlTable(String content){ private static String htmlTable(String content){
return htmlTable(content,true); return htmlTable(content,true);
@ -227,8 +227,8 @@ public class MailUtils {
/** /**
* html text content * html text content
* @param content * @param content the content
* @return * @return text in html form
*/ */
private static String htmlText(String content){ private static String htmlText(String content){
@ -260,9 +260,8 @@ public class MailUtils {
/** /**
* send mail as Excel attachment * send mail as Excel attachment
* * @param receivers the receiver list
* @param receivers * @param title the title
* @param title
* @throws Exception * @throws Exception
*/ */
private static void attachment(Collection<String> receivers,Collection<String> receiversCc,String title,String content,String partContent)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 * get MimeMessage
* @param receivers * @param receivers
* @return * @return the MimeMessage
* @throws MessagingException * @throws MessagingException
*/ */
private static MimeMessage getMimeMessage(Collection<String> receivers) 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 // 1. The first step in creating mail: creating session
Session session = getSession(); Session session = getSession();
@ -299,7 +296,7 @@ public class MailUtils {
/** /**
* get session * get session
* @return * @return the new Session
*/ */
private static Session getSession() { private static Session getSession() {
Properties props = new Properties(); Properties props = new Properties();
@ -324,12 +321,12 @@ public class MailUtils {
} }
/** /**
* * attach content
* @param receiversCc * @param receiversCc the cc list
* @param title * @param title the title
* @param content * @param content the content
* @param partContent * @param partContent the partContent
* @param msg * @param msg the message
* @throws MessagingException * @throws MessagingException
* @throws IOException * @throws IOException
*/ */
@ -369,13 +366,13 @@ public class MailUtils {
} }
/** /**
* * the string object map
* @param title * @param title the title
* @param content * @param content the content
* @param showType * @param showType the showType
* @param retMap * @param retMap the result map
* @param email * @param email the email
* @return * @return the result map
* @throws EmailException * @throws EmailException
*/ */
private static Map<String, Object> getStringObjectMap(String title, String content, ShowType showType, Map<String, Object> retMap, HtmlEmail email) 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 * file delete
* @param file * @param file the file to delete
*/ */
public static void deleteFile(File file){ public static void deleteFile(File file){
if(file.exists()){ if(file.exists()){
@ -419,10 +416,10 @@ public class MailUtils {
/** /**
* * handle exception
* @param receivers * @param receivers the receiver list
* @param retMap * @param retMap the result map
* @param e * @param e the exception
*/ */
private static void handleException(Collection<String> receivers, Map<String, Object> retMap, Exception e) { private static void handleException(Collection<String> receivers, Map<String, Object> retMap, Exception e) {
logger.error("Send email to {} failed", StringUtils.join(",", receivers), e); logger.error("Send email to {} failed", StringUtils.join(",", receivers), e);
@ -430,10 +427,10 @@ public class MailUtils {
} }
/** /**
* * get the content of the template
* @param title * @param title the title
* @param content * @param content the content to retrieve
* @return * @return the content in the template or null if exception occurs
*/ */
private static String getTemplateContent(String title,String content){ private static String getTemplateContent(String title,String content){
StringWriter out = new StringWriter(); 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 * get property value
*
* @param key property name * @param key property name
* @return * @return the value
*/ */
public static String getString(String key) { public static String getString(String key) {
return properties.getProperty(key); return properties.getProperty(key);
@ -87,10 +86,10 @@ public class PropertyUtils {
} }
/** /**
* * get int value
* @param key * @param key the key
* @param defaultValue * @param defaultValue the default value
* @return * @return the value related the key or the default value if the key not existed
*/ */
public static int getInt(String key, int defaultValue) { public static int getInt(String key, int defaultValue) {
String value = getString(key); String value = getString(key);
@ -108,9 +107,8 @@ public class PropertyUtils {
/** /**
* get property value * get property value
*
* @param key property name * @param key property name
* @return * @return the boolean result value
*/ */
public static Boolean getBoolean(String key) { public static Boolean getBoolean(String key) {
String value = properties.getProperty(key.trim()); String value = properties.getProperty(key.trim());
@ -122,19 +120,19 @@ public class PropertyUtils {
} }
/** /**
* * get long value
* @param key * @param key the key
* @return * @return if the value not existed, return -1, or will return the related value
*/ */
public static long getLong(String key) { public static long getLong(String key) {
return getLong(key,-1); return getLong(key,-1);
} }
/** /**
* * get long value
* @param key * @param key the key
* @param defaultVal * @param defaultVal the default value
* @return * @return the value related the key or the default value if the key not existed
*/ */
public static long getLong(String key, long defaultVal) { public static long getLong(String key, long defaultVal) {
String val = getString(key); String val = getString(key);
@ -143,10 +141,10 @@ public class PropertyUtils {
/** /**
* * get double value
* @param key * @param key the key
* @param defaultVal * @param defaultVal the default value
* @return * @return the value related the key or the default value if the key not existed
*/ */
public double getDouble(String key, double defaultVal) { public double getDouble(String key, double defaultVal) {
String val = getString(key); String val = getString(key);
@ -158,7 +156,7 @@ public class PropertyUtils {
* get array * get array
* @param key property name * @param key property name
* @param splitStr separator * @param splitStr separator
* @return * @return the result array
*/ */
public static String[] getArray(String key, String splitStr) { public static String[] getArray(String key, String splitStr) {
String value = getString(key); String value = getString(key);
@ -175,11 +173,11 @@ public class PropertyUtils {
} }
/** /**
* * get enum
* @param key * @param key the key
* @param type * @param type the class type
* @param defaultValue * @param defaultValue the default value
* @param <T> * @param <T> the generic class type
* @return get enum value * @return get enum value
*/ */
public <T extends Enum<T>> T getEnum(String key, Class<T> type, public <T extends Enum<T>> T getEnum(String key, Class<T> type,

Loading…
Cancel
Save