Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
7df52bfa
Commit
7df52bfa
authored
Dec 23, 2019
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【优化Netty服务】修改调度Netty服务器时的回复对象
parent
1dcf47e2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
11 deletions
+32
-11
JavaBeanJobTask.java
...min-core/src/main/java/com/byit/task/JavaBeanJobTask.java
+12
-8
LogCallbackThread.java
...core/src/main/java/com/byit/thread/LogCallbackThread.java
+1
-2
DispatchResponseDto.java
...n/src/main/java/com/byit/job/dto/DispatchResponseDto.java
+16
-0
IpUtil.java
...-core-common/src/main/java/com/byit/job/utils/IpUtil.java
+3
-1
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/task/JavaBeanJobTask.java
View file @
7df52bfa
...
...
@@ -3,6 +3,7 @@ package com.byit.task;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.byit.job.dto.AdminSenPluginDto
;
import
com.byit.job.dto.DispatchResponseDto
;
import
com.byit.job.exceptions.plugin.PluginException
;
import
com.byit.job.utils.IpUtil
;
import
com.byit.model.MythJobTaskRunLog
;
...
...
@@ -47,31 +48,34 @@ public class JavaBeanJobTask implements TimerTask {
adminSenPluginDto
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
//这里获取的是调度结果
String
result
=
HttpUtil
.
post
(
url
,
JSON
.
toJSONString
(
adminSenPluginDto
),
10
*
1000
);
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
result
,
DispatchResponseDto
.
class
);
//修改调度结果
saveLog
(
mythJobTaskSchedule
,
url
,
result
);
log
.
debug
(
"---------------{}------------"
,
result
);
}
catch
(
PluginException
ignored
){
saveLog
(
mythJobTaskSchedule
,
""
,
ignored
.
getMessage
());
log
.
error
(
"-------------通讯异常:{},{}"
,
ignored
.
getIEnum
().
getCode
(),
ignored
.
getIEnum
().
getMsg
());
}
catch
(
Exception
e
){
saveLog
(
mythJobTaskSchedule
,
""
,
"未知错误!!"
);
e
.
printStackTrace
();
}
}
private
Integer
saveLog
(
MythJobTaskSchedule
mythJobTaskSchedule
,
String
url
,
String
result
){
MythJobTaskRunLog
mythJobTaskRunLog
=
new
MythJobTaskRunLog
();
private
void
saveLog
(
MythJobTaskSchedule
mythJobTaskSchedule
,
String
url
,
String
result
){
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
result
,
DispatchResponseDto
.
class
);
MythJobTaskRunLogServiceImpl
mythJobTaskRunLogService
=
SpringUtil
.
getBean
(
MythJobTaskRunLogServiceImpl
.
class
);
MythJobTaskRunLog
mythJobTaskRunLog
=
mythJobTaskRunLogService
.
findMythJobTaskRunLogById
(
mythJobTaskSchedule
.
getLogId
());
//版本id需要查验
//还需要携带版本的名字
mythJobTaskRunLog
.
setLogId
(
mythJobTaskSchedule
.
getLogId
());
mythJobTaskRunLog
.
setRunType
(
"2"
);
mythJobTaskRunLog
.
setLocalNodeHandlerName
(
mythJobTaskSchedule
.
getLocalNodeHandlerName
());
mythJobTaskRunLog
.
setTriggerTime
(
new
Date
());
mythJobTaskRunLog
.
setTriggerCode
(
result
);
mythJobTaskRunLog
.
setTriggerMsg
(
"SUCCESS"
);
MythJobTaskRunLogServiceImpl
mythJobTaskRunLogService
=
SpringUtil
.
getBean
(
MythJobTaskRunLogServiceImpl
.
class
);
MythJobTaskRunLog
mythJobTaskRunLogSave
=
mythJobTaskRunLogService
.
save
(
mythJobTaskRunLog
);
return
mythJobTaskRunLogSave
.
getLogId
();
mythJobTaskRunLog
.
setTriggerCode
(
dispatchResponseDto
.
getCode
());
mythJobTaskRunLog
.
setTriggerMsg
(
dispatchResponseDto
.
getMsg
());
mythJobTaskRunLogService
.
save
(
mythJobTaskRunLog
);
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/LogCallbackThread.java
View file @
7df52bfa
...
...
@@ -25,8 +25,7 @@ public class LogCallbackThread implements Runnable {
public
void
run
()
{
log
.
debug
(
"--------------------任务执行完成---------------------"
);
MythJobTaskRunLogServiceImpl
mythJobTaskRunLogService
=
SpringUtil
.
getBean
(
MythJobTaskRunLogServiceImpl
.
class
);
MythJobTaskRunLog
mythJobTaskRunLog
=
new
MythJobTaskRunLog
(
);
mythJobTaskRunLog
.
setLogId
(
jobRunResultDto
.
getLogId
());
MythJobTaskRunLog
mythJobTaskRunLog
=
mythJobTaskRunLogService
.
findMythJobTaskRunLogById
(
jobRunResultDto
.
getLogId
(
));
mythJobTaskRunLog
.
setRunTime
(
jobRunResultDto
.
getEndTime
());
mythJobTaskRunLog
.
setRunCode
(
jobRunResultDto
.
getReturnResult
().
getCode
());
mythJobTaskRunLog
.
setRunMsg
(
jobRunResultDto
.
getReturnResult
().
getMsg
());
...
...
byit-myth-core/myth-core-common/src/main/java/com/byit/job/dto/DispatchResponseDto.java
0 → 100644
View file @
7df52bfa
package
com
.
byit
.
job
.
dto
;
import
lombok.Data
;
/**
* @program: byit-myth-job->DispatchResponseDto
* @description: TODO
* @author: huangfu
* @date: 2019/12/23 11:12
**/
@Data
public
class
DispatchResponseDto
{
private
String
code
;
private
String
msg
;
private
String
content
;
}
byit-myth-core/myth-core-common/src/main/java/com/byit/job/utils/IpUtil.java
View file @
7df52bfa
...
...
@@ -5,6 +5,7 @@ import cn.hutool.http.HttpUtil;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.byit.job.dto.AdminSenPluginDto
;
import
com.byit.job.dto.DispatchResponseDto
;
import
com.byit.job.enums.plugin.PluginEnum
;
import
com.byit.job.exceptions.plugin.PluginException
;
import
com.byit.rpc.remoting.invoker.route.RpcLoadBalance
;
...
...
@@ -32,8 +33,9 @@ public class IpUtil {
AdminSenPluginDto
adminSenPluginDto
=
new
AdminSenPluginDto
(
);
adminSenPluginDto
.
setHeartbeat
(
"PENG"
);
String
heartbeatRes
=
HttpUtil
.
post
(
url
,
JSON
.
toJSONString
(
adminSenPluginDto
),
2
*
1000
);
DispatchResponseDto
dispatchResponseDto
=
JSON
.
parseObject
(
heartbeatRes
,
DispatchResponseDto
.
class
);
log
.
debug
(
"------------------接收心跳包--------------------"
);
return
"PONG"
.
equals
(
heartbeatRes
);
return
"PONG"
.
equals
(
(
dispatchResponseDto
!=
null
?
dispatchResponseDto
.
getContent
():
""
)
);
}
catch
(
Exception
e
){
log
.
error
(
"--------------------{},服务不可用------------------"
,
url
);
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment