Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
messageflow
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
虞诚毅
messageflow
Commits
0044078e
Commit
0044078e
authored
Oct 20, 2018
by
shentao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2018/10/20 预防消息流重启导致事件采集中断,加入自动恢复机制
parent
520c6fd1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletions
+33
-1
src/main/java/com/zhiwei/messageflow/ES4RedisRunner.java
+2
-1
src/main/java/com/zhiwei/messageflow/ESGetCommonId.java
+8
-0
src/main/java/com/zhiwei/messageflow/service/EventService.java
+8
-0
src/main/java/com/zhiwei/messageflow/service/impl/EventServiceImpl.java
+15
-0
No files found.
src/main/java/com/zhiwei/messageflow/ES4RedisRunner.java
View file @
0044078e
...
...
@@ -37,7 +37,8 @@ public class ES4RedisRunner implements ApplicationRunner {
esGetCommonId
.
getCommonId
();
//启动时更新事件等待采集列表中的前十个任务状态为采集完毕
boolean
isSuccess
=
esGetCommonId
.
updateTopTenCollection
();
log
.
info
(
"前十个任务状态更新为采集完毕是否成功:{}"
,
isSuccess
);
/**
* redis存入缓存
*/
...
...
src/main/java/com/zhiwei/messageflow/ESGetCommonId.java
View file @
0044078e
...
...
@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
com.zhiwei.messageflow.es.dao.ESDao
;
import
com.zhiwei.messageflow.service.EventService
;
@Component
public
class
ESGetCommonId
{
...
...
@@ -15,6 +16,9 @@ public class ESGetCommonId {
@Autowired
private
ESDao
esDao
;
@Autowired
private
EventService
eventService
;
public
static
int
START_COMMONID
;
public
static
long
TIME
;
...
...
@@ -56,4 +60,8 @@ public class ESGetCommonId {
return
commonid
;
}
public
boolean
updateTopTenCollection
()
{
return
eventService
.
updateTopTenCollection
();
}
}
src/main/java/com/zhiwei/messageflow/service/EventService.java
View file @
0044078e
...
...
@@ -64,5 +64,13 @@ public interface EventService {
* @throws JsonParseException
*/
boolean
autoMark
(
Event
eventCollection
)
throws
JsonParseException
,
JsonMappingException
,
IOException
;
/**
* 更新事件等待采集列表中的前十个任务状态为采集完毕
* @Title: updateTopTenCollection
* @Description: 更新事件等待采集列表中的前十个任务状态为采集完毕
* @param @return 设定文件
* @return boolean 返回类型
*/
boolean
updateTopTenCollection
();
}
src/main/java/com/zhiwei/messageflow/service/impl/EventServiceImpl.java
View file @
0044078e
...
...
@@ -171,4 +171,19 @@ public class EventServiceImpl implements EventService {
return
true
;
}
@Override
public
boolean
updateTopTenCollection
()
{
List
<
String
>
idList
=
redisService
.
getNeedAutoMark
();
List
<
Event
>
events
=
null
!=
findEventsbyIds
(
idList
)?
findEventsbyIds
(
idList
):
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
events
.
size
();
i
++)
{
Event
eventCollection
=
events
.
get
(
i
);
if
(!
eventCollection
.
getStatus
().
equals
(
"采集完毕"
))
{
Update
over
=
new
Update
();
over
.
update
(
"status"
,
"采集完毕"
);
primaryMongoTemplate
.
upsert
(
new
Query
(
Criteria
.
where
(
"_id"
).
is
(
eventCollection
.
getId
())),
over
,
Event
.
class
);
}
}
return
true
;
}
}
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