优化代码:去除无使用的类
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.zdjizhi.etl.connection;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import org.apache.flink.api.java.tuple.Tuple2;
|
||||
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction;
|
||||
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
|
||||
import org.apache.flink.util.Collector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 对ip去重
|
||||
*/
|
||||
public class Ip2IpGraphProcessFunction extends ProcessWindowFunction<Map<String, Object>, Map<String, Object>, Tuple2<String, String>, TimeWindow> {
|
||||
|
||||
private static final Log logger = LogFactory.get();
|
||||
|
||||
@Override
|
||||
public void process(Tuple2<String, String> keys, Context context, Iterable<Map<String, Object>> elements, Collector<Map<String, Object>> out) {
|
||||
|
||||
try {
|
||||
long lastFoundTime = DateUtil.currentSeconds();
|
||||
for (Map<String, Object> log : elements) {
|
||||
long connStartTimetime = Convert.toLong(log.get("start_time"));
|
||||
lastFoundTime = connStartTimetime > lastFoundTime ? connStartTimetime : lastFoundTime;
|
||||
}
|
||||
Map<String, Object> newLog = new HashMap<>();
|
||||
newLog.put("src_ip", keys.f0);
|
||||
newLog.put("dst_ip", keys.f1);
|
||||
newLog.put("last_found_time", lastFoundTime);
|
||||
out.collect(newLog);
|
||||
logger.debug("获取中间聚合结果:{}", newLog.toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("获取中间聚合结果失败,middleResult: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user