Search in sources :

Example 1 with RawData

use of com.navercorp.pinpoint.flink.vo.RawData in project pinpoint by naver.

the class AgentStatHandler method handleSimple.

@Override
public void handleSimple(ServerRequest<TBase<?, ?>> serverRequest) {
    final TBase<?, ?> tBase = serverRequest.getData();
    final Map<String, String> metaInfo = new HashMap<>(serverRequest.getHeaderEntity().getEntityAll());
    final RawData rawData = new RawData(tBase, metaInfo);
    final SourceContext sourceContext = roundRobinSourceContext();
    if (sourceContext == null) {
        logger.warn("sourceContext is null.");
        return;
    }
    sourceContext.collect(rawData);
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) HashMap(java.util.HashMap) SourceContext(org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext)

Example 2 with RawData

use of com.navercorp.pinpoint.flink.vo.RawData in project pinpoint by naver.

the class TBaseFlatMapperTest method flatMap5Test.

@Test
public void flatMap5Test() throws Exception {
    ApplicationCache applicationCache = newMockApplicationCache();
    TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
    TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch5();
    ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
    ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
    RawData rawData = newRawData(tfAgentStatBatch);
    mapper.flatMap(rawData, collector);
    assertEquals(dataList.size(), 2);
    Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
    assertEquals(data1.f0, AGENT_ID);
    assertEquals(data1.f2.longValue(), 1491274143454L);
    JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
    assertEquals(joinAgentStatBo.getId(), AGENT_ID);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
    assertJoinDirectBufferBo(joinAgentStatBo.getJoinDirectBufferBoList());
    Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
    assertEquals(data2.f0, APPLICATION_ID);
    assertEquals(data2.f2.longValue(), 1491274140000L);
    JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
    assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
    assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
    assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
    assertJoinDirectBufferBo(joinApplicationStatBo.getJoinDirectBufferBoList());
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinApplicationStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) ListCollector(org.apache.flink.api.common.functions.util.ListCollector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Test(org.junit.Test)

Example 3 with RawData

use of com.navercorp.pinpoint.flink.vo.RawData in project pinpoint by naver.

the class TBaseFlatMapperTest method flatMap4Test.

@Test
public void flatMap4Test() throws Exception {
    ApplicationCache applicationCache = newMockApplicationCache();
    TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
    TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch4();
    ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
    ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
    RawData rawData = newRawData(tfAgentStatBatch);
    mapper.flatMap(rawData, collector);
    assertEquals(dataList.size(), 2);
    Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
    assertEquals(data1.f0, AGENT_ID);
    assertEquals(data1.f2.longValue(), 1491274143454L);
    JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
    assertEquals(joinAgentStatBo.getId(), AGENT_ID);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
    assertJoinFileDescriptorBo(joinAgentStatBo.getJoinFileDescriptorBoList());
    Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
    assertEquals(data2.f0, APPLICATION_ID);
    assertEquals(data2.f2.longValue(), 1491274140000L);
    JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
    assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
    assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
    assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
    assertJoinFileDescriptorBo(joinApplicationStatBo.getJoinFileDescriptorBoList());
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinApplicationStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) ListCollector(org.apache.flink.api.common.functions.util.ListCollector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Test(org.junit.Test)

Example 4 with RawData

use of com.navercorp.pinpoint.flink.vo.RawData in project pinpoint by naver.

the class TBaseFlatMapperTest method flatMap3Test.

@Test
public void flatMap3Test() throws Exception {
    ApplicationCache applicationCache = newMockApplicationCache();
    TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
    TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch3();
    ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
    ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
    RawData rawData = newRawData(tfAgentStatBatch);
    mapper.flatMap(rawData, collector);
    assertEquals(dataList.size(), 2);
    Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
    assertEquals(data1.f0, AGENT_ID);
    assertEquals(data1.f2.longValue(), 1491274143454L);
    JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
    assertEquals(joinAgentStatBo.getId(), AGENT_ID);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
    assertJoinTransactionBo(joinAgentStatBo.getJoinTransactionBoList());
    Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
    assertEquals(data2.f0, APPLICATION_ID);
    assertEquals(data2.f2.longValue(), 1491274140000L);
    JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
    assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
    assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
    assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
    assertJoinTransactionBo(joinApplicationStatBo.getJoinTransactionBoList());
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinApplicationStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) ListCollector(org.apache.flink.api.common.functions.util.ListCollector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Test(org.junit.Test)

Example 5 with RawData

use of com.navercorp.pinpoint.flink.vo.RawData 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");
}
Also used : TcpSourceFunction(com.navercorp.pinpoint.flink.receiver.TcpSourceFunction) RawData(com.navercorp.pinpoint.flink.vo.RawData) AgentStatTimestampAssigner(com.navercorp.pinpoint.flink.function.AgentStatTimestampAssigner) ApplicationStatBoWindow(com.navercorp.pinpoint.flink.function.ApplicationStatBoWindow) StatisticsDao(com.navercorp.pinpoint.flink.dao.hbase.StatisticsDao) ApplicationStatBoFilter(com.navercorp.pinpoint.flink.function.ApplicationStatBoFilter) ApplicationStatKeySelector(com.navercorp.pinpoint.flink.function.ApplicationStatKeySelector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

RawData (com.navercorp.pinpoint.flink.vo.RawData)7 Tuple3 (org.apache.flink.api.java.tuple.Tuple3)6 JoinAgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo)5 JoinApplicationStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo)5 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)5 JoinAgentStatBoMapper (com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper)5 TFAgentStatBatch (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch)5 ArrayList (java.util.ArrayList)5 ListCollector (org.apache.flink.api.common.functions.util.ListCollector)5 Test (org.junit.Test)5 StatisticsDao (com.navercorp.pinpoint.flink.dao.hbase.StatisticsDao)1 AgentStatTimestampAssigner (com.navercorp.pinpoint.flink.function.AgentStatTimestampAssigner)1 ApplicationStatBoFilter (com.navercorp.pinpoint.flink.function.ApplicationStatBoFilter)1 ApplicationStatBoWindow (com.navercorp.pinpoint.flink.function.ApplicationStatBoWindow)1 ApplicationStatKeySelector (com.navercorp.pinpoint.flink.function.ApplicationStatKeySelector)1 TcpSourceFunction (com.navercorp.pinpoint.flink.receiver.TcpSourceFunction)1 HashMap (java.util.HashMap)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 SourceContext (org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext)1