package com.fshark.overseas.advert.processor;

import com.fshark.overseas.advert.modle.AppsFlyerEvent;
import com.fshark.overseas.advert.modle.SinkMetricEvent;
import com.fshark.overseas.advert.modle.metrics.ServerActivationMetrics;
import com.fshark.overseas.advert.util.Constants;
import com.google.gson.Gson;
import org.apache.flink.api.common.functions.RichFlatMapFunction;
import org.apache.flink.util.Collector;

public class ServerMtricToStringProcessor extends RichFlatMapFunction<ServerActivationMetrics, String> {

    @Override
    public void flatMap(ServerActivationMetrics value, Collector<String> out) throws Exception {
        SinkMetricEvent sinkMetricEvent = new SinkMetricEvent();
        sinkMetricEvent.setEventType(Constants.TYPE_SINK_SERVER);
        sinkMetricEvent.setServerActivationMetrics(value);
        Gson gson = new Gson();
        out.collect(gson.toJson(sinkMetricEvent));
    }
}
