use of com.navercorp.pinpoint.flink.function.ApplicationStatBoFilter in project pinpoint by naver.
the class StatStreamingVer2Job method start.
public void start(ParameterTool parameters) throws Exception {
logger.info("start Aggregation Stat Data job with job parameter. : " + parameters.toMap());
final Bootstrap bootstrap = Bootstrap.getInstance(parameters.toMap());
// set data source
final TcpSourceFunction tcpSourceFunction = bootstrap.getTcpSourceFunction();
final StreamExecutionEnvironment env = bootstrap.createStreamExecutionEnvironment();
env.getConfig().setGlobalJobParameters(parameters);
DataStreamSource<RawData> rawData = env.addSource(tcpSourceFunction);
// 0. generation rawdata
final SingleOutputStreamOperator<Tuple3<String, JoinStatBo, Long>> statOperator = rawData.flatMap(bootstrap.getTbaseFlatMapper());
// 1-1 save data processing application stat raw data
final StatisticsDao statisticsDao = bootstrap.getStatisticsDao();
DataStream<Tuple3<String, JoinStatBo, Long>> applicationStatAggregationData = statOperator.filter(new ApplicationStatBoFilter()).assignTimestampsAndWatermarks(WatermarkStrategy.<Tuple3<String, JoinStatBo, Long>>forMonotonousTimestamps().withTimestampAssigner(new AgentStatTimestampAssigner())).keyBy(new ApplicationStatKeySelector()).window(TumblingEventTimeWindows.of(Time.milliseconds(ApplicationStatBoWindow.WINDOW_SIZE))).allowedLateness(Time.milliseconds(ApplicationStatBoWindow.ALLOWED_LATENESS)).apply(new ApplicationStatBoWindow());
applicationStatAggregationData.addSink(statisticsDao);
// 1-2. aggregate application stat data
// statOperator.filter(new FilterFunction<Tuple3<String, JoinStatBo, Long>>() {
// @Override
// public boolean filter(Tuple3<String, JoinStatBo, Long> value) throws Exception {
// if (value.f1 instanceof JoinApplicationStatBo) {
// logger.info("1-2 application stat aggre window function : " + value.f1);
// return true;
// }
//
// return false;
// }
// })
// .assignTimestampsAndWatermarks(new Timestamp())
// .keyBy(0)
// .window(TumblingEventTimeWindows.of(Time.seconds(120)))
// .apply(new WindowFunction<Tuple3<String, JoinStatBo, Long>, Tuple3<String, JoinStatBo, Long>, Tuple, TimeWindow>() {
// @Override
// public void apply(Tuple tuple, TimeWindow window, Iterable<Tuple3<String, JoinStatBo, Long>> values, Collector<Tuple3<String, JoinStatBo, Long>> out) throws Exception {
// try {
// JoinApplicationStatBo joinApplicationStatBo = join(values);
// logger.info("1-2 application stat aggre window function : " + joinApplicationStatBo);
// out.collect(new Tuple3<>(joinApplicationStatBo.getId(), joinApplicationStatBo, joinApplicationStatBo.getTimestamp()));
// } catch (Exception e) {
// logger.error("window function error", e);
// }
// }
//
// private JoinApplicationStatBo join(Iterable<Tuple3<String, JoinStatBo, Long>> values) {
// List<JoinApplicationStatBo> joinApplicaitonStatBoList = new ArrayList<JoinApplicationStatBo>();
// for (Tuple3<String, JoinStatBo, Long> value : values) {
// joinApplicaitonStatBoList.add((JoinApplicationStatBo) value.f1);
// }
// return JoinApplicationStatBo.joinApplicationStatBo(joinApplicaitonStatBoList);
//
// }
// }).writeUsingOutputFormat(statisticsDao);
// 2. agrregage agent stat
// statOperator.filter(new FilterFunction<Tuple3<String, JoinStatBo, Long>>() {
// @Override
// public boolean filter(Tuple3<String, JoinStatBo, Long> value) throws Exception {
// if (value.f1 instanceof JoinAgentStatBo) {
// logger.info("2 application stat aggre window function : " + value.f1);
// return true;
// }
//
// return false;
// }
// })
// .assignTimestampsAndWatermarks(new Timestamp())
// .keyBy(0)
// .window(TumblingEventTimeWindows.of(Time.seconds(120)))
//
// .apply(new WindowFunction<Tuple3<String, JoinStatBo, Long>, Tuple3<String, JoinStatBo, Long>, Tuple, TimeWindow>() {
//
// @Override
// public void apply(Tuple tuple, TimeWindow window, Iterable<Tuple3<String, JoinStatBo, Long>> values, Collector<Tuple3<String, JoinStatBo, Long>> out) throws Exception {
// try {
// JoinAgentStatBo joinAgentStatBo = join(values);
// logger.info("2 agent stat aggre window function : " + joinAgentStatBo);
// out.collect(new Tuple3<>(joinAgentStatBo.getId(), joinAgentStatBo, joinAgentStatBo.getTimestamp()));
// } catch (Exception e) {
// logger.error("window function error", e);
// }
// }
//
// private JoinAgentStatBo join(Iterable<Tuple3<String, JoinStatBo, Long>> values) {
// List<JoinAgentStatBo> joinAgentStatBoList = new ArrayList<JoinAgentStatBo>();
// for (Tuple3<String, JoinStatBo, Long> value : values) {
// joinAgentStatBoList.add((JoinAgentStatBo) value.f1);
// }
//
// return JoinAgentStatBo.joinAgentStatBo(joinAgentStatBoList);
// }
// })
// .writeUsingOutputFormat(statisticsDao);
env.execute("Aggregation Stat Data");
}
Aggregations