Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pentaLiker
DolphinScheduler
提交
381ab72e
DolphinScheduler
项目概览
pentaLiker
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
381ab72e
编写于
4月 23, 2020
作者:
D
dailidong
提交者:
GitHub
4月 23, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into dev
上级
e4dad2ac
e837a73f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
12 deletion
+45
-12
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtilsTest.java
...lphinscheduler/alert/utils/EnterpriseWeChatUtilsTest.java
+12
-2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java
...rg/apache/dolphinscheduler/api/service/LoggerService.java
+23
-10
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
...n/java/org/apache/dolphinscheduler/remote/utils/Host.java
+10
-0
未找到文件。
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/EnterpriseWeChatUtilsTest.java
浏览文件 @
381ab72e
...
...
@@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.enums.AlertType;
import
org.apache.dolphinscheduler.common.enums.ShowType
;
import
org.apache.dolphinscheduler.dao.entity.Alert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -54,11 +55,19 @@ public class EnterpriseWeChatUtilsTest {
private
static
final
String
enterpriseWechatUsers
=
"LiGang,journey"
;
private
static
final
String
msg
=
"hello world"
;
private
static
final
String
enterpriseWechatTeamSendMsg
=
"{\\\"toparty\\\":\\\"$toParty\\\",\\\"agentid\\\":\\\"$agentId\\\",\\\"msgtype\\\":\\\"text\\\",\\\"text\\\":{\\\"content\\\":\\\"$msg\\\"},\\\"safe\\\":\\\"0\\\"}"
;
private
static
final
String
enterpriseWechatUserSendMsg
=
"{\\\"touser\\\":\\\"$toUser\\\",\\\"agentid\\\":\\\"$agentId\\\",\\\"msgtype\\\":\\\"markdown\\\",\\\"markdown\\\":{\\\"content\\\":\\\"$msg\\\"}}"
;
@
Test
public
void
testIsEnable
(){
@
Before
public
void
init
(){
PowerMockito
.
mockStatic
(
PropertyUtils
.
class
);
Mockito
.
when
(
PropertyUtils
.
getBoolean
(
Constants
.
ENTERPRISE_WECHAT_ENABLE
)).
thenReturn
(
true
);
Mockito
.
when
(
PropertyUtils
.
getString
(
Constants
.
ENTERPRISE_WECHAT_USER_SEND_MSG
)).
thenReturn
(
enterpriseWechatUserSendMsg
);
Mockito
.
when
(
PropertyUtils
.
getString
(
Constants
.
ENTERPRISE_WECHAT_TEAM_SEND_MSG
)).
thenReturn
(
enterpriseWechatTeamSendMsg
);
}
@Test
public
void
testIsEnable
(){
Boolean
weChartEnable
=
EnterpriseWeChatUtils
.
isEnable
();
Assert
.
assertTrue
(
weChartEnable
);
}
...
...
@@ -88,6 +97,7 @@ public class EnterpriseWeChatUtilsTest {
@Test
public
void
tesMakeUserSendMsg1
(){
String
sendMsg
=
EnterpriseWeChatUtils
.
makeUserSendMsg
(
enterpriseWechatUsers
,
enterpriseWechatAgentId
,
msg
);
Assert
.
assertTrue
(
sendMsg
.
contains
(
enterpriseWechatUsers
));
Assert
.
assertTrue
(
sendMsg
.
contains
(
enterpriseWechatAgentId
));
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/LoggerService.java
浏览文件 @
381ab72e
...
...
@@ -65,25 +65,24 @@ public class LoggerService {
TaskInstance
taskInstance
=
processService
.
findTaskInstanceById
(
taskInstId
);
if
(
taskInstance
==
null
){
return
new
Result
(
Status
.
TASK_INSTANCE_NOT_FOUND
.
getCode
(),
Status
.
TASK_INSTANCE_NOT_FOUND
.
getMsg
());
}
String
host
=
Host
.
of
(
taskInstance
.
getHost
()).
getIp
();
if
(
StringUtils
.
isEmpty
(
host
)){
if
(
taskInstance
==
null
||
StringUtils
.
isBlank
(
taskInstance
.
getHost
())){
return
new
Result
(
Status
.
TASK_INSTANCE_NOT_FOUND
.
getCode
(),
Status
.
TASK_INSTANCE_NOT_FOUND
.
getMsg
());
}
String
host
=
getHost
(
taskInstance
.
getHost
());
Result
result
=
new
Result
(
Status
.
SUCCESS
.
getCode
(),
Status
.
SUCCESS
.
getMsg
());
logger
.
info
(
"log host : {} , logPath : {} , logServer port : {}"
,
host
,
taskInstance
.
getLogPath
(),
Constants
.
RPC_PORT
);
String
log
=
logClient
.
rollViewLog
(
host
,
Constants
.
RPC_PORT
,
taskInstance
.
getLogPath
(),
skipLineNum
,
limit
);
result
.
setData
(
log
);
logger
.
info
(
log
);
return
result
;
}
/**
* get log size
*
...
...
@@ -92,10 +91,24 @@ public class LoggerService {
*/
public
byte
[]
getLogBytes
(
int
taskInstId
)
{
TaskInstance
taskInstance
=
processService
.
findTaskInstanceById
(
taskInstId
);
if
(
taskInstance
==
null
){
throw
new
RuntimeException
(
"task instance is null"
);
if
(
taskInstance
==
null
||
StringUtils
.
isBlank
(
taskInstance
.
getHost
())
){
throw
new
RuntimeException
(
"task instance is null
or host is null
"
);
}
String
host
=
Host
.
of
(
taskInstance
.
getHost
()).
getIp
();
String
host
=
getHost
(
taskInstance
.
getHost
());
return
logClient
.
getLogBytes
(
host
,
Constants
.
RPC_PORT
,
taskInstance
.
getLogPath
());
}
/**
* get host
* @param address address
* @return old version return true ,otherwise return false
*/
private
String
getHost
(
String
address
){
if
(
Host
.
isOldVersion
(
address
)){
return
address
;
}
return
Host
.
of
(
address
).
getIp
();
}
}
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
浏览文件 @
381ab72e
...
...
@@ -91,6 +91,16 @@ public class Host implements Serializable {
return
host
;
}
/**
* whether old version
* @param address address
* @return old version is true , otherwise is false
*/
public
static
Boolean
isOldVersion
(
String
address
){
String
[]
parts
=
address
.
split
(
":"
);
return
parts
.
length
!=
2
?
true
:
false
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录