Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
commons
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
commons
Commits
8a4e34ae
Commit
8a4e34ae
authored
Feb 05, 2020
by
杨锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决elastic job重复执行问题;
ElasticJobAspect 新增log;
parent
b6fa946b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
BraveAutoConfiguration.java
...roup/tech/brave/configuration/BraveAutoConfiguration.java
+3
-0
ElasticJobAutoConfiguration.java
...c/job/lite/autoconfigure/ElasticJobAutoConfiguration.java
+16
-15
No files found.
brave-spring-boot-starter/src/main/java/cn/quantgroup/tech/brave/configuration/BraveAutoConfiguration.java
View file @
8a4e34ae
...
...
@@ -425,11 +425,14 @@ public class BraveAutoConfiguration {
@Around
(
"target(com.dangdang.ddframe.job.api.ElasticJob)"
)
public
Object
dynamicTrace
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
log
.
info
(
"ElasticJobAspect dynamicTrace start."
);
Tracer
tracer
=
tracing
().
tracer
();
/* 防止应用层非法使用(上下文中存在span),不生成root span。 */
if
(
tracer
.
currentSpan
()
!=
null
)
{
log
.
info
(
"应用层上下文中存在span."
);
return
pjp
.
proceed
();
}
log
.
info
(
"应用层上下文中不存在span."
);
brave
.
Span
span
=
tracer
.
newTrace
();
try
(
Tracer
.
SpanInScope
ws
=
tracer
.
withSpanInScope
(
span
))
{
// note: try-with-resources closes the scope *before* the catch block
...
...
elastic-job-lite-spring-boot-starter/src/main/java/cn/quantgroup/tech/elastic/job/lite/autoconfigure/ElasticJobAutoConfiguration.java
View file @
8a4e34ae
...
...
@@ -47,25 +47,26 @@ public class ElasticJobAutoConfiguration {
for
(
Map
.
Entry
<
String
,
SimpleJob
>
entry
:
map
.
entrySet
())
{
SimpleJob
simpleJob
=
entry
.
getValue
();
ElasticSimpleJob
elasticSimpleJobAnnotation
=
AopUtils
.
getTargetClass
(
simpleJob
).
getAnnotation
(
ElasticSimpleJob
.
class
);
if
(
elasticSimpleJobAnnotation
!=
null
){
String
cron
=
StringUtils
.
defaultIfBlank
(
elasticSimpleJobAnnotation
.
cron
(),
elasticSimpleJobAnnotation
.
value
());
SimpleJobConfiguration
simpleJobConfiguration
=
new
SimpleJobConfiguration
(
JobCoreConfiguration
.
newBuilder
(
elasticSimpleJobAnnotation
.
jobName
(),
cron
,
elasticSimpleJobAnnotation
.
shardingTotalCount
()).
shardingItemParameters
(
elasticSimpleJobAnnotation
.
shardingItemParameters
()).
build
(),
elasticSimpleJobAnnotation
.
jobName
());
LiteJobConfiguration
liteJobConfiguration
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfiguration
).
overwrite
(
true
).
build
();
String
cron
=
StringUtils
.
defaultIfBlank
(
elasticSimpleJobAnnotation
.
cron
(),
elasticSimpleJobAnnotation
.
value
());
SimpleJobConfiguration
simpleJobConfiguration
=
new
SimpleJobConfiguration
(
JobCoreConfiguration
.
newBuilder
(
simpleJob
.
getClass
().
getName
(),
cron
,
elasticSimpleJobAnnotation
.
shardingTotalCount
()).
shardingItemParameters
(
elasticSimpleJobAnnotation
.
shardingItemParameters
()).
build
(),
simpleJob
.
getClass
().
getCanonicalName
());
LiteJobConfiguration
liteJobConfiguration
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfiguration
).
overwrite
(
true
).
build
();
String
dataSourceRef
=
elasticSimpleJobAnnotation
.
dataSource
();
if
(
StringUtils
.
isNotBlank
(
dataSourceRef
))
{
String
dataSourceRef
=
elasticSimpleJobAnnotation
.
dataSource
();
if
(
StringUtils
.
isNotBlank
(
dataSourceRef
))
{
if
(!
applicationContext
.
containsBean
(
dataSourceRef
))
{
throw
new
RuntimeException
(
"not exist datasource ["
+
dataSourceRef
+
"] !"
);
}
if
(!
applicationContext
.
containsBean
(
dataSourceRef
))
{
throw
new
RuntimeException
(
"not exist datasource ["
+
dataSourceRef
+
"] !"
);
DataSource
dataSource
=
(
DataSource
)
applicationContext
.
getBean
(
dataSourceRef
);
JobEventRdbConfiguration
jobEventRdbConfiguration
=
new
JobEventRdbConfiguration
(
dataSource
);
SpringJobScheduler
jobScheduler
=
new
SpringJobScheduler
(
simpleJob
,
regCenter
,
liteJobConfiguration
,
jobEventRdbConfiguration
);
jobScheduler
.
init
();
}
else
{
SpringJobScheduler
jobScheduler
=
new
SpringJobScheduler
(
simpleJob
,
regCenter
,
liteJobConfiguration
);
jobScheduler
.
init
();
}
DataSource
dataSource
=
(
DataSource
)
applicationContext
.
getBean
(
dataSourceRef
);
JobEventRdbConfiguration
jobEventRdbConfiguration
=
new
JobEventRdbConfiguration
(
dataSource
);
SpringJobScheduler
jobScheduler
=
new
SpringJobScheduler
(
simpleJob
,
regCenter
,
liteJobConfiguration
,
jobEventRdbConfiguration
);
jobScheduler
.
init
();
}
else
{
SpringJobScheduler
jobScheduler
=
new
SpringJobScheduler
(
simpleJob
,
regCenter
,
liteJobConfiguration
);
jobScheduler
.
init
();
}
}
}
...
...
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