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
c9804f81
Commit
c9804f81
authored
Jan 07, 2019
by
303514581@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2019/1/7 backup 针对备用es调整读取策略
parent
953f2cdc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
3 deletions
+87
-3
README.md
+24
-0
src/main/java/com/zhiwei/messageflow/ES4RedisRunner.java
+1
-1
src/main/java/com/zhiwei/messageflow/ES4RedisStart.java
+62
-2
No files found.
README.md
0 → 100644
View file @
c9804f81
# messageflow-监测系统消息流模块
标签(空格分隔):readme
---
##介绍项目
监测系统消息流模块,主要功能:消息流、定向监测消息流、自动标注、事件采集
---
##项目文档地址
>参考监测系统文档
---
##项目运行的服务器及目录
> 项目地址:/home/zhiwei/jar/messageflow
服务器地址:
内网地址:192.168.0.2
外网地址:115.236.59.87
src/main/java/com/zhiwei/messageflow/ES4RedisRunner.java
View file @
c9804f81
...
@@ -61,7 +61,7 @@ public class ES4RedisRunner implements ApplicationRunner {
...
@@ -61,7 +61,7 @@ public class ES4RedisRunner implements ApplicationRunner {
log
.
error
(
"主定时器异常{}{}"
,
e
.
getMessage
(),
e
.
getStackTrace
());
log
.
error
(
"主定时器异常{}{}"
,
e
.
getMessage
(),
e
.
getStackTrace
());
}
}
}
}
},
60
*
10
00L
,
50
*
1000L
);
},
1
00L
,
50
*
1000L
);
...
...
src/main/java/com/zhiwei/messageflow/ES4RedisStart.java
View file @
c9804f81
...
@@ -2,7 +2,9 @@ package com.zhiwei.messageflow;
...
@@ -2,7 +2,9 @@ package com.zhiwei.messageflow;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
...
@@ -15,6 +17,7 @@ import com.zhiwei.messageflow.mongo.bean.PlatformNew;
...
@@ -15,6 +17,7 @@ import com.zhiwei.messageflow.mongo.bean.PlatformNew;
import
com.zhiwei.messageflow.mongo.bean.Project
;
import
com.zhiwei.messageflow.mongo.bean.Project
;
import
com.zhiwei.messageflow.mongo.dao.PlatformDao
;
import
com.zhiwei.messageflow.mongo.dao.PlatformDao
;
import
com.zhiwei.messageflow.mongo.dao.ProjectDao
;
import
com.zhiwei.messageflow.mongo.dao.ProjectDao
;
import
com.zhiwei.messageflow.util.Tools
;
@Component
@Component
public
class
ES4RedisStart
{
public
class
ES4RedisStart
{
...
@@ -33,15 +36,35 @@ public class ES4RedisStart {
...
@@ -33,15 +36,35 @@ public class ES4RedisStart {
@Autowired
@Autowired
private
ESGetCommonId
esGetCommonId
;
private
ESGetCommonId
esGetCommonId
;
private
Map
<
String
,
Boolean
>
PROJECTMAP
=
new
HashMap
<>();
private
static
final
int
PROJECTCOUNT
=
9
;
/**
/**
* 启动线程
* 启动线程
*/
*/
public
void
startThread
()
throws
JsonParseException
,
JsonMappingException
,
IOException
,
InterruptedException
{
public
void
startThread
()
throws
JsonParseException
,
JsonMappingException
,
IOException
,
InterruptedException
{
//更新commonid
//
更新commonid
esGetCommonId
.
getCommonId
();
esGetCommonId
.
getCommonId
();
// 项目列表
// 项目列表
List
<
Project
>
projects
=
projectDao
.
getAllProjects
();
List
<
Project
>
projects
=
projectDao
.
getAllProjects
();
// 本轮项目计数
int
pcount
=
0
;
//new Map
if
(
Tools
.
isEmpty
(
PROJECTMAP
.
keySet
())||
isProjectMapFull
())
{
projects
.
forEach
(
p
->
{
PROJECTMAP
.
put
(
p
.
getProjectName
(),
false
);
});
PROJECTMAP
.
keySet
().
forEach
(
p
->
{
System
.
out
.
println
(
p
+
"\t"
+
PROJECTMAP
.
get
(
p
));
});
}
else
{
PROJECTMAP
.
keySet
().
forEach
(
p
->
{
System
.
out
.
println
(
p
+
"\t"
+
PROJECTMAP
.
get
(
p
));
});
}
// 公共平台名列表
// 公共平台名列表
// List<String> platformNames = platformDao.getPublicPlatformName();
// List<String> platformNames = platformDao.getPublicPlatformName();
...
@@ -51,6 +74,15 @@ public class ES4RedisStart {
...
@@ -51,6 +74,15 @@ public class ES4RedisStart {
// if(!project.getProjectName().equals("测试")) {
// if(!project.getProjectName().equals("测试")) {
// continue;
// continue;
// }
// }
if
(
pcount
>=
PROJECTCOUNT
)
{
continue
;
}
if
(!
canProjectRead
(
project
))
{
continue
;
}
else
{
pcount
++;
}
/**
/**
* 项目全部平台(公共+私有)
* 项目全部平台(公共+私有)
...
@@ -62,7 +94,6 @@ public class ES4RedisStart {
...
@@ -62,7 +94,6 @@ public class ES4RedisStart {
// allplatformNames.addAll(platformNames);
// allplatformNames.addAll(platformNames);
// allplatformNames.addAll(project.getDataPt());
// allplatformNames.addAll(project.getDataPt());
// 获取线程
// 获取线程
ES4RedisThreadNew
es4RedisThread
=
ES4RedisThreadNew
.
getThread
(
project
.
getProjectName
(),
project
,
ES4RedisThreadNew
es4RedisThread
=
ES4RedisThreadNew
.
getThread
(
project
.
getProjectName
(),
project
,
allplatformNames
,
es4RedisTask
);
allplatformNames
,
es4RedisTask
);
...
@@ -80,4 +111,33 @@ public class ES4RedisStart {
...
@@ -80,4 +111,33 @@ public class ES4RedisStart {
es4RedisThread
.
start
();
es4RedisThread
.
start
();
}
}
}
}
/**
* 判断项目map是否一轮结束
* @param projects
* @Title: isProjectMapFull
* @Description: 判断项目map是否一轮结束
* @param @return 设定文件
* @return boolean 返回类型
*/
private
boolean
isProjectMapFull
()
{
return
PROJECTMAP
.
values
().
parallelStream
().
allMatch
(
v
->
v
);
}
/**
* 判断项目本轮内是否可以获取消息流
*
* @Title: canProjectRead
* @Description: 判断项目本轮内是否可以获取消息流
* @param @param project
* @param @return 设定文件
* @return boolean 返回类型
*/
private
boolean
canProjectRead
(
Project
project
)
{
if
(
PROJECTMAP
.
get
(
project
.
getProjectName
()))
{
return
false
;
}
else
{
PROJECTMAP
.
put
(
project
.
getProjectName
(),
true
);
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