Commit 9debd0a3 by 杨林龙

新增同步设备号接口

1 parent 8246255a
......@@ -46,7 +46,7 @@ public class BloomFilterService {
@PostConstruct
public void init() {
List<String> allSns = remoteDeviceLocationService.getAllSnInNewEshield();
log.info("缓存在布隆过滤器的设备号===" + JSON.toJSONString(allSns));
log.info("缓存在布隆过滤器的所有设备号===" + JSON.toJSONString(allSns));
allSns.forEach(this::putData);
}
......@@ -60,11 +60,35 @@ public class BloomFilterService {
* @param sn 设备号
*/
public void putData(String sn) {
boolean flag = bloomFilter.put(sn);
if (flag) {
log.info("向布隆过滤器中加入设备号===" + sn + "成功");
} else {
log.info("向布隆过滤器中加入设备号===" + sn + "失败");
// 查询布隆过滤器中是否存在该设备号 不存在就保存到布隆过滤器
boolean contain = bloomFilter.mightContain(sn);
if (!contain) {
boolean flag = bloomFilter.put(sn);
if (flag) {
log.info("向布隆过滤器中加入设备号===" + sn + "成功");
} else {
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 + "失败");
}
}
});
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!