Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1b15569
authored
Sep 23, 2018
by
xuxueli
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
分片任务失败重试优化,仅重试当前失败的分片;
parent
54fce811
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
16 deletions
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java
View file @
b1b15569
...
@@ -45,32 +45,44 @@ public class XxlJobTrigger {
...
@@ -45,32 +45,44 @@ public class XxlJobTrigger {
int
finalFailRetryCount
=
failRetryCount
>=
0
?
failRetryCount:
jobInfo
.
getExecutorFailRetryCount
();
int
finalFailRetryCount
=
failRetryCount
>=
0
?
failRetryCount:
jobInfo
.
getExecutorFailRetryCount
();
XxlJobGroup
group
=
XxlJobDynamicScheduler
.
xxlJobGroupDao
.
load
(
jobInfo
.
getJobGroup
());
XxlJobGroup
group
=
XxlJobDynamicScheduler
.
xxlJobGroupDao
.
load
(
jobInfo
.
getJobGroup
());
// process trigger
// sharding param
if
(
triggerType
==
TriggerTypeEnum
.
RETRY
&&
executorShardingParam
!=
null
)
{
int
[]
shardingParam
=
null
;
if
(
executorShardingParam
!=
null
){
String
[]
shardingArr
=
executorShardingParam
.
split
(
"/"
);
String
[]
shardingArr
=
executorShardingParam
.
split
(
"/"
);
if
(
shardingArr
.
length
==
2
&&
StringUtils
.
isNumeric
(
shardingArr
[
0
])
&&
StringUtils
.
isNumeric
(
shardingArr
[
1
]));
{
if
(
shardingArr
.
length
==
2
&&
StringUtils
.
isNumeric
(
shardingArr
[
0
])
&&
StringUtils
.
isNumeric
(
shardingArr
[
1
]))
{
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
Integer
.
valueOf
(
shardingArr
[
0
]),
Integer
.
valueOf
(
shardingArr
[
1
]));
shardingParam
=
new
int
[
2
];
shardingParam
[
0
]
=
Integer
.
valueOf
(
shardingArr
[
0
]);
shardingParam
[
1
]
=
Integer
.
valueOf
(
shardingArr
[
1
]);
}
}
if
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
ExecutorRouteStrategyEnum
.
match
(
jobInfo
.
getExecutorRouteStrategy
(),
null
)
&&
CollectionUtils
.
isNotEmpty
(
group
.
getRegistryList
())
&&
shardingParam
==
null
)
{
for
(
int
i
=
0
;
i
<
group
.
getRegistryList
().
size
();
i
++)
{
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
i
,
group
.
getRegistryList
().
size
());
}
}
}
else
{
}
else
{
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getRegistryList
()))
{
if
(
shardingParam
==
null
)
{
if
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
ExecutorRouteStrategyEnum
.
match
(
jobInfo
.
getExecutorRouteStrategy
(),
null
))
{
shardingParam
=
new
int
[]{
0
,
1
};
for
(
int
i
=
0
;
i
<
group
.
getRegistryList
().
size
();
i
++)
{
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
i
,
group
.
getRegistryList
().
size
());
}
}
else
{
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
0
,
1
);
}
}
else
{
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
0
,
0
);
}
}
processTrigger
(
group
,
jobInfo
,
finalFailRetryCount
,
triggerType
,
shardingParam
[
0
],
shardingParam
[
1
]);
}
}
}
}
/**
* @param group job group, registry list may be empty
* @param jobInfo
* @param finalFailRetryCount
* @param triggerType
* @param index sharding index
* @param total sharding index
*/
private
static
void
processTrigger
(
XxlJobGroup
group
,
XxlJobInfo
jobInfo
,
int
finalFailRetryCount
,
TriggerTypeEnum
triggerType
,
int
index
,
int
total
){
private
static
void
processTrigger
(
XxlJobGroup
group
,
XxlJobInfo
jobInfo
,
int
finalFailRetryCount
,
TriggerTypeEnum
triggerType
,
int
index
,
int
total
){
// param
// param
ExecutorBlockStrategyEnum
blockStrategy
=
ExecutorBlockStrategyEnum
.
match
(
jobInfo
.
getExecutorBlockStrategy
(),
ExecutorBlockStrategyEnum
.
SERIAL_EXECUTION
);
// block strategy
ExecutorBlockStrategyEnum
blockStrategy
=
ExecutorBlockStrategyEnum
.
match
(
jobInfo
.
getExecutorBlockStrategy
(),
ExecutorBlockStrategyEnum
.
SERIAL_EXECUTION
);
// block strategy
ExecutorRouteStrategyEnum
executorRouteStrategyEnum
=
ExecutorRouteStrategyEnum
.
match
(
jobInfo
.
getExecutorRouteStrategy
(),
null
);
// route strategy
ExecutorRouteStrategyEnum
executorRouteStrategyEnum
=
ExecutorRouteStrategyEnum
.
match
(
jobInfo
.
getExecutorRouteStrategy
(),
null
);
// route strategy
String
shardingParam
=
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
executorRouteStrategyEnum
)?
String
.
valueOf
(
index
).
concat
(
"/"
).
concat
(
String
.
valueOf
(
total
)):
null
;
// 1、save log-id
// 1、save log-id
XxlJobLog
jobLog
=
new
XxlJobLog
();
XxlJobLog
jobLog
=
new
XxlJobLog
();
...
@@ -98,10 +110,13 @@ public class XxlJobTrigger {
...
@@ -98,10 +110,13 @@ public class XxlJobTrigger {
// 3、init address
// 3、init address
String
address
=
null
;
String
address
=
null
;
ReturnT
<
String
>
routeAddressResult
=
null
;
ReturnT
<
String
>
routeAddressResult
=
null
;
String
shardingParam
=
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
executorRouteStrategyEnum
&&
total
>
0
)?
String
.
valueOf
(
triggerParam
.
getBroadcastIndex
()).
concat
(
"/"
).
concat
(
String
.
valueOf
(
triggerParam
.
getBroadcastTotal
())):
null
;
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getRegistryList
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
group
.
getRegistryList
()))
{
if
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
executorRouteStrategyEnum
)
{
if
(
ExecutorRouteStrategyEnum
.
SHARDING_BROADCAST
==
executorRouteStrategyEnum
)
{
address
=
group
.
getRegistryList
().
get
(
index
);
if
(
index
<
group
.
getRegistryList
().
size
())
{
address
=
group
.
getRegistryList
().
get
(
index
);
}
else
{
address
=
group
.
getRegistryList
().
get
(
0
);
}
}
else
{
}
else
{
routeAddressResult
=
executorRouteStrategyEnum
.
getRouter
().
route
(
triggerParam
,
group
.
getRegistryList
());
routeAddressResult
=
executorRouteStrategyEnum
.
getRouter
().
route
(
triggerParam
,
group
.
getRegistryList
());
if
(
routeAddressResult
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
)
{
if
(
routeAddressResult
.
getCode
()
==
ReturnT
.
SUCCESS_CODE
)
{
...
...
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