Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-kafkaconsumer-gpsbs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9debd0a3
authored
Dec 20, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增同步设备号接口
1 parent
8246255a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletions
src/main/java/cn/com/glsx/kafka/service/BloomFilterService.java
src/main/java/cn/com/glsx/kafka/service/BloomFilterService.java
View file @
9debd0a
...
@@ -46,7 +46,7 @@ public class BloomFilterService {
...
@@ -46,7 +46,7 @@ public class BloomFilterService {
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
List
<
String
>
allSns
=
remoteDeviceLocationService
.
getAllSnInNewEshield
();
List
<
String
>
allSns
=
remoteDeviceLocationService
.
getAllSnInNewEshield
();
log
.
info
(
"缓存在布隆过滤器的设备号==="
+
JSON
.
toJSONString
(
allSns
));
log
.
info
(
"缓存在布隆过滤器的
所有
设备号==="
+
JSON
.
toJSONString
(
allSns
));
allSns
.
forEach
(
this
::
putData
);
allSns
.
forEach
(
this
::
putData
);
}
}
...
@@ -60,6 +60,9 @@ public class BloomFilterService {
...
@@ -60,6 +60,9 @@ public class BloomFilterService {
* @param sn 设备号
* @param sn 设备号
*/
*/
public
void
putData
(
String
sn
)
{
public
void
putData
(
String
sn
)
{
// 查询布隆过滤器中是否存在该设备号 不存在就保存到布隆过滤器
boolean
contain
=
bloomFilter
.
mightContain
(
sn
);
if
(!
contain
)
{
boolean
flag
=
bloomFilter
.
put
(
sn
);
boolean
flag
=
bloomFilter
.
put
(
sn
);
if
(
flag
)
{
if
(
flag
)
{
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"成功"
);
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"成功"
);
...
@@ -67,4 +70,25 @@ public class BloomFilterService {
...
@@ -67,4 +70,25 @@ public class BloomFilterService {
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"失败"
);
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"失败"
);
}
}
}
}
}
/**
* 手动同步所有设备号
*/
public
void
syncAllData
()
{
List
<
String
>
allSns
=
remoteDeviceLocationService
.
getAllSnInNewEshield
();
log
.
info
(
"缓存在布隆过滤器的所有设备号==="
+
JSON
.
toJSONString
(
allSns
));
allSns
.
forEach
(
sn
->
{
// 查询布隆过滤器中是否存在该设备号 不存在就保存到布隆过滤器
boolean
contain
=
bloomFilter
.
mightContain
(
sn
);
if
(!
contain
)
{
boolean
flag
=
bloomFilter
.
put
(
sn
);
if
(
flag
)
{
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"成功"
);
}
else
{
log
.
info
(
"向布隆过滤器中加入设备号==="
+
sn
+
"失败"
);
}
}
});
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment