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
abb490bc
Commit
abb490bc
authored
Aug 03, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
执行机结果发送回调重试
parent
86a64ec8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
ImperativeExecutionImpl.java
...c/main/java/com/byit/service/ImperativeExecutionImpl.java
+7
-1
RequestUtil.java
...utor-server/src/main/java/com/byit/utils/RequestUtil.java
+42
-0
No files found.
byit-myth-executor/myth-executor-server/src/main/java/com/byit/service/ImperativeExecutionImpl.java
View file @
abb490bc
...
...
@@ -15,6 +15,7 @@ import com.byit.node.impl.RunScriptProcessingMachine;
import
com.byit.pool.RunThreadPool
;
import
com.byit.rpc.remoting.provider.annotation.RpcService
;
import
com.byit.utils.ExecutorLogUtil
;
import
com.byit.utils.RequestUtil
;
import
com.byit.utils.ServiceInfoUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
...
...
@@ -106,7 +107,12 @@ public class ImperativeExecutionImpl implements ScriptExecutorService {
jobRunResultDto
.
setLogId
(
scriptDto
.
getLogId
());
//设置远程日志文件的路径
jobRunResultDto
.
setLogRemotelyPath
(
scriptDto
.
getLogRemotePath
());
cn
.
hutool
.
http
.
HttpUtil
.
post
(
scriptDto
.
getCallbackUrl
(),
JSON
.
toJSONString
(
jobRunResultDto
));
try
{
RequestUtil
.
retryPost
(
scriptDto
.
getCallbackUrl
(),
JSON
.
toJSONString
(
jobRunResultDto
),
3
,
1
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
log
.
error
(
"执行机异常:{}"
,
ExecutorLogUtil
.
getMessage
(
e
));
}
log
.
info
(
"--------------runPythonScript,脚本调用结束-----------"
);
}
}
byit-myth-executor/myth-executor-server/src/main/java/com/byit/utils/RequestUtil.java
0 → 100644
View file @
abb490bc
package
com
.
byit
.
utils
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 发送链接的工具类
* @author huangfu
*/
@Slf4j
public
class
RequestUtil
{
/**
* 默认的超时时间
*/
final
static
Integer
TIMEOUT_DEFAULT
=
30000
;
/**
* 带有重试的post请求
* @param requestUrl 请求的url
* @param body 请求的数据结果
* @param retryTotalCount 请求的总次数
* @param thisRetryCount 当前是第几次请求
* @throws InterruptedException 睡眠异常
*/
public
static
void
retryPost
(
String
requestUrl
,
String
body
,
int
retryTotalCount
,
int
thisRetryCount
)
throws
InterruptedException
{
try
{
log
.
info
(
"------当前的请求的地址为:{}-------"
,
requestUrl
);
HttpUtil
.
post
(
requestUrl
,
body
,
TIMEOUT_DEFAULT
);
}
catch
(
Exception
e
)
{
//当前重试次数 小于等于总共的重试次数时
if
(
thisRetryCount
<=
retryTotalCount
){
log
.
error
(
"{},出现异常,异常信息为:{},开始第{}次重试!"
,
body
,
ExecutorLogUtil
.
getMessage
(
e
),
thisRetryCount
);
Thread
.
sleep
(
1000
*
thisRetryCount
);
retryPost
(
requestUrl
,
body
,
retryTotalCount
,++
thisRetryCount
);
}
else
{
throw
new
RuntimeException
(
String
.
format
(
"执行机回调调度中心失败,失败原因是:%s,重试了%s次"
,
ExecutorLogUtil
.
getMessage
(
e
),
retryTotalCount
));
}
}
}
}
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