首次提交,24.01版本

This commit is contained in:
houjinchuan
2024-01-22 17:33:39 +08:00
parent e08ac67b2c
commit e7fc4feb6f
23 changed files with 2577 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package com.zdjizhi.function;
import com.zdjizhi.pojo.FileChunk;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.metrics.Counter;
import org.apache.flink.metrics.MetricGroup;
public class SideOutputMapFunction extends RichMapFunction<FileChunk, FileChunk> {
private transient Counter pcapDelayedChunkCounter;
private transient Counter trafficDelayedChunkCounter;
@Override
public void open(Configuration parameters) throws Exception {
super.open(parameters);
MetricGroup metricGroup = getRuntimeContext().getMetricGroup();
pcapDelayedChunkCounter = metricGroup.counter("pcapDelayedChunkCount");
trafficDelayedChunkCounter = metricGroup.counter("trafficDelayedChunkCount");
}
@Override
public FileChunk map(FileChunk fileChunk) {
fileChunk.setChunkCount(1);
if ("seek".equals(fileChunk.getCombineMode())) {
trafficDelayedChunkCounter.inc();
} else {
fileChunk.setChunkNumbers(fileChunk.getTimestamp() + "-" + fileChunk.getChunk().length + ";");
pcapDelayedChunkCounter.inc();
}
return fileChunk;
}
}