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
4fdf3519
Commit
4fdf3519
authored
Dec 09, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正NUM字段
parent
da85a076
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
ClientRpcUtil.java
...pc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
+16
-5
No files found.
byit-plugin-core/myth-plugin-rpc-client/src/main/java/com/byit/utils/ClientRpcUtil.java
View file @
4fdf3519
...
@@ -9,6 +9,7 @@ import com.byit.rpc.remoting.invoker.route.LoadBalance;
...
@@ -9,6 +9,7 @@ import com.byit.rpc.remoting.invoker.route.LoadBalance;
import
com.byit.rpc.util.RPCLogUtil
;
import
com.byit.rpc.util.RPCLogUtil
;
import
com.byit.rpc.util.RpcException
;
import
com.byit.rpc.util.RpcException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
...
@@ -31,7 +32,11 @@ public class ClientRpcUtil {
...
@@ -31,7 +32,11 @@ public class ClientRpcUtil {
for
(
String
ignored
:
address
)
{
for
(
String
ignored
:
address
)
{
String
routeHost
=
loadBalance
.
rpcInvokerRouter
.
route
(
pluginRpcRequestPacket
.
getJobName
(),
address
);
String
routeHost
=
loadBalance
.
rpcInvokerRouter
.
route
(
pluginRpcRequestPacket
.
getJobName
(),
address
);
String
extension
=
pluginRpcRequestPacket
.
getExtension
();
String
extension
=
pluginRpcRequestPacket
.
getExtension
();
String
runKey
=
KeyUtil
.
generateRunKey
(
Integer
.
parseInt
(
extension
));
String
runKey
=
null
;
if
(
StringUtils
.
isNoneBlank
(
extension
)){
runKey
=
KeyUtil
.
generateRunKey
(
Integer
.
parseInt
(
extension
));
}
boolean
retryRpcHost
=
retryRpcHost
(
client
,
routeHost
,
runKey
,
3
,
1
);
boolean
retryRpcHost
=
retryRpcHost
(
client
,
routeHost
,
runKey
,
3
,
1
);
if
(
retryRpcHost
)
{
if
(
retryRpcHost
)
{
return
routeHost
;
return
routeHost
;
...
@@ -57,7 +62,9 @@ public class ClientRpcUtil {
...
@@ -57,7 +62,9 @@ public class ClientRpcUtil {
client
.
send
(
host
,
PluginBeat
.
PLUGIN_RPC_REQUEST_PACKET
);
client
.
send
(
host
,
PluginBeat
.
PLUGIN_RPC_REQUEST_PACKET
);
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立成功,总共重试%s次!"
,
host
,
thisRetryCount
-
1
);
String
redisFormat
=
String
.
format
(
"与执行服务器[%s]建立成功,总共重试%s次!"
,
host
,
thisRetryCount
-
1
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
if
(
StringUtils
.
isNoneBlank
(
runKey
))
{
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
}
log
.
info
(
"------{}plugin-rpc通道建立成功,重试了{}次------"
,
host
,
thisRetryCount
-
1
);
log
.
info
(
"------{}plugin-rpc通道建立成功,重试了{}次------"
,
host
,
thisRetryCount
-
1
);
return
true
;
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -68,7 +75,10 @@ public class ClientRpcUtil {
...
@@ -68,7 +75,10 @@ public class ClientRpcUtil {
log
.
error
(
format
);
log
.
error
(
format
);
//redis模板
//redis模板
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
redisFormat
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
if
(
StringUtils
.
isNoneBlank
(
runKey
))
{
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
}
Thread
.
sleep
(
1000
*
thisRetryCount
);
Thread
.
sleep
(
1000
*
thisRetryCount
);
retryRpcHost
(
client
,
host
,
runKey
,
retryTotalCount
,
++
thisRetryCount
);
retryRpcHost
(
client
,
host
,
runKey
,
retryTotalCount
,
++
thisRetryCount
);
}
}
...
@@ -78,8 +88,9 @@ public class ClientRpcUtil {
...
@@ -78,8 +88,9 @@ public class ClientRpcUtil {
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
String
format
=
String
.
format
(
"与主机【%s】建立通道,总共【%s】次,全部失败,开始挑选下一个负载均衡方案重试,请稍后"
,
host
,
retryTotalCount
);
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
RunLog
runLog
=
RunLog
.
builder
().
runLog
(
format
).
isEnd
(
false
).
build
();
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
if
(
StringUtils
.
isNoneBlank
(
runKey
))
{
stringRedisTemplate
.
opsForList
().
rightPush
(
runKey
,
JSON
.
toJSONString
(
runLog
,
WriteClassName
));
}
log
.
error
(
format
);
log
.
error
(
format
);
}
}
return
false
;
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