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
8c155287
Commit
8c155287
authored
Nov 05, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决报错信息重复打印BUG
parent
c9f2ff97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
RequestUtil.java
...myth-rpc/src/main/java/com/byit/rpc/util/RequestUtil.java
+6
-2
ClientRpcUtil.java
...pc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
+6
-3
No files found.
byit-myth-rpc/src/main/java/com/byit/rpc/util/RequestUtil.java
View file @
8c155287
...
...
@@ -59,9 +59,14 @@ public class RequestUtil {
* @return 是否成功
*/
public
static
boolean
retryRpcHost
(
Client
client
,
String
host
,
String
runKey
,
int
retryTotalCount
,
int
thisRetryCount
)
throws
InterruptedException
{
StringRedisTemplate
stringRedisTemplate
=
RpcSpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
log
.
info
(
"------当前rpc的请求的地址为:{}-------"
,
host
);
try
{
client
.
asyncSend
(
host
,
Beat
.
BEAT_PING
);
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立成功,总共重试%s次!"
,
host
,
thisRetryCount
-
1
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
log
.
info
(
"------{}rpc通道建立成功,重试了{}次------"
,
host
,
thisRetryCount
-
1
);
return
true
;
}
catch
(
Exception
e
)
{
...
...
@@ -70,7 +75,6 @@ public class RequestUtil {
String
redisFormat
=
String
.
format
(
"rpc通道[%s]建立时出现异常,开始第%s次重试!"
,
host
,
thisRetryCount
);
log
.
error
(
"{},rpc通道建立时出现异常,异常信息为:{},开始第{}次重试!"
,
host
,
RPCLogUtil
.
getMessage
(
e
),
thisRetryCount
);
StringRedisTemplate
stringRedisTemplate
=
RpcSpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
...
...
@@ -80,7 +84,7 @@ public class RequestUtil {
if
(
thisRetryCount
==
retryTotalCount
)
{
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
StringRedisTemplate
stringRedisTemplate
=
RpcSpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
...
...
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
View file @
8c155287
...
...
@@ -51,9 +51,14 @@ public class ClientRpcUtil {
* @return 是否成功
*/
public
static
boolean
retryRpcHost
(
PluginClient
client
,
String
host
,
String
runKey
,
int
retryTotalCount
,
int
thisRetryCount
)
throws
InterruptedException
{
//redis模板
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
log
.
info
(
"------当前plugin-rpc的请求的地址为:{}-------"
,
host
);
try
{
client
.
send
(
host
,
PluginBeat
.
PLUGIN_RPC_REQUEST_PACKET
);
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立成功,总共重试%s次!"
,
host
,
thisRetryCount
-
1
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
log
.
info
(
"------{}plugin-rpc通道建立成功,重试了{}次------"
,
host
,
thisRetryCount
-
1
);
return
true
;
}
catch
(
Exception
e
)
{
...
...
@@ -63,7 +68,6 @@ public class ClientRpcUtil {
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立通道时出现异常,开始第%s次重试!"
,
host
,
thisRetryCount
);
log
.
error
(
format
);
//redis模板
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
Thread
.
sleep
(
1000
*
thisRetryCount
);
...
...
@@ -73,8 +77,7 @@ public class ClientRpcUtil {
if
(
thisRetryCount
==
retryTotalCount
){
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
//redis模板
StringRedisTemplate
stringRedisTemplate
=
SpringUtil
.
getBean
(
StringRedisTemplate
.
class
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
...
...
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