|
@@ -45,28 +45,6 @@ public class FlowPoolService {
|
|
|
SHORT_VIDEO.getCode(), H5.getCode(), APP_SPEED.getCode(), WAN_NENG_VIDEO.getCode(),
|
|
|
LAO_HAO_KAN_VIDEO.getCode(), ZUI_JING_QI.getCode(), PIAO_QUAN_VIDEO_PLUS.getCode(), JOURNEY.getCode()};
|
|
|
|
|
|
-
|
|
|
- public Map<Long, Integer> getDistributeCountWithLevel(Map<Long, String> videoFlowPoolMap) {
|
|
|
- if (MapUtils.isEmpty(videoFlowPoolMap)) {
|
|
|
- return Collections.emptyMap();
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, Integer> result = getDistributeCount(videoFlowPoolMap);
|
|
|
-
|
|
|
-
|
|
|
- // 处理脏数据:分发数<0
|
|
|
- Map<Long, String> dirties = videoFlowPoolMap.entrySet().stream()
|
|
|
- .filter(e -> result.get(e.getKey()) <= 0)
|
|
|
- .collect(Collectors.toMap(
|
|
|
- e -> e.getKey(),
|
|
|
- e -> e.getValue()
|
|
|
- ));
|
|
|
- log.info("dirties size:{}", dirties.size());
|
|
|
- asyncDelDistributeCountWithLevel(dirties);
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
public void updateDistributeCountWithLevel(List<Video> videos) {
|
|
|
if (CollectionUtils.isEmpty(videos)) {
|
|
|
return;
|
|
@@ -92,23 +70,6 @@ public class FlowPoolService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Map<Long, Integer> getDistributeCount(Map<Long, String> videoFlowPoolMap) {
|
|
|
- // 为了保证有序
|
|
|
- List<Map.Entry<Long, String>> entries = videoFlowPoolMap.entrySet().stream()
|
|
|
- .sorted(Comparator.comparingLong(e -> e.getKey()))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- List<String> keys = entries.stream()
|
|
|
- .map(v -> String.format(localDistributeCountFormat, v.getKey(), v.getValue()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- List<String> counts = redisTemplate.opsForValue().multiGet(keys);
|
|
|
- Map<Long, Integer> result = new HashMap<>();
|
|
|
- for (int i = 0; i < entries.size(); i++) {
|
|
|
- result.put(entries.get(i).getKey(), NumberUtils.toInt(counts.get(i), 0));
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
private Map<Long, String> updateDistributeCount(List<Video> videos) {
|
|
|
// TODO 异步更新
|
|
|
Map<Long, String> removeMap = new HashMap<>();
|