package com.sunwin.metro.constant;


import com.alibaba.fastjson.JSONObject;
import com.sunwin.metro.bean.*;
import com.sunwin.metro.governance.bean.Expression;
import com.sunwin.metro.governance.bean.Integrity;
import com.sunwin.metro.governance.bean.Timeliness;
import com.sunwin.metro.governance.bean.Uniformity;
import org.apache.flink.api.common.state.MapStateDescriptor;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple4;
import org.apache.flink.util.OutputTag;

import java.util.List;

/**
 * @author kane
 */
public class Descriptors {
    /**
     * 侧边流存储规则流
     */
    public static final MapStateDescriptor<String, RuleBase> RULE_STATE_DESCRIPTOR = new MapStateDescriptor<>(
            "rules-state",
            BasicTypeInfo.STRING_TYPE_INFO,
            TypeInformation.of(new TypeHint<RuleBase>() {
            }));
    public static final OutputTag<UpsXjyMes> ERROR_UPS_XYJ = new OutputTag<UpsXjyMes>(
            "warn-ups-xyj",
            TypeInformation.of(UpsXjyMes.class)) {
    };
    public static final OutputTag<String> DEMO_SINK_TAG = new OutputTag<String>(
            "demo-sink") {
    };
    public static final OutputTag<Event> LATENCY_SINK_TAG = new OutputTag<Event>(
            "latency-sink") {
    };
    public static final OutputTag<WindowRule> CURRENT_RULES_SINK_TAG = new OutputTag<WindowRule>(
            "current-rules-sink") {
    };
    public static final OutputTag<Timeliness> IN_TIME_RULE_1 = new OutputTag<Timeliness>(
            "IN_TIME_RULE_1") {
    };
    public static final OutputTag<Timeliness> OUT_TIME_RULE_1 = new OutputTag<Timeliness>(
            "OUT_TIME_RULE_1") {
    };
    public static final OutputTag<Integrity> COMPLETE_RULE_1 = new OutputTag<Integrity>(
            "COMPLETE_RULE_1") {
    };
    public static final OutputTag<Uniformity> UNIFORMITY_RULE_1 = new OutputTag<Uniformity>(
            "UNIFORMITY_RULE_1") {
    };
    public static final OutputTag<JSONObject> CURRENT_RULE_1 = new OutputTag<JSONObject>(
            "CURRENT_RULE_1") {
    };
    public static final MapStateDescriptor<Integer, WindowRule> RULES_DESCRIPTOR = new MapStateDescriptor<>(
            "rules",
            BasicTypeInfo.INT_TYPE_INFO,
            TypeInformation.of(WindowRule.class
            ));
    public static final MapStateDescriptor<String, List<String>> DESCRIPTOR = new MapStateDescriptor<>(
            "key-words",
            //Key类型
            BasicTypeInfo.STRING_TYPE_INFO,
            //Value类型
            TypeInformation.of(new TypeHint<List<String>>() {
            }));
    public static final MapStateDescriptor<String, List<Timeliness>> IN_TIME_RULE = new MapStateDescriptor<>(
            "IN_TIME_RULE",
            //Key类型
            BasicTypeInfo.STRING_TYPE_INFO,
            //Value类型
            TypeInformation.of(new TypeHint<List<Timeliness>>() {
            }));
    public static final MapStateDescriptor<String, List<Timeliness>> OUT_TIME_RULE = new MapStateDescriptor<>(
            "OUT_TIME_RULE",
            //Key类型
            BasicTypeInfo.STRING_TYPE_INFO,
            //Value类型
            TypeInformation.of(new TypeHint<List<Timeliness>>() {
            }));
    public static final MapStateDescriptor<String, List<Integrity>> COMPLETE_RULE = new MapStateDescriptor<>(
            "COMPLETE_RULE",
            //Key类型
            BasicTypeInfo.STRING_TYPE_INFO,
            //Value类型
            TypeInformation.of(new TypeHint<List<Integrity>>() {
            }));
    public static final MapStateDescriptor<String, List<Uniformity>> UNIFORMITY_RULE = new MapStateDescriptor<>(
            "UNIFORMITY_RULE",
            //Key类型
            BasicTypeInfo.STRING_TYPE_INFO,
            //Value类型
            TypeInformation.of(new TypeHint<List<Uniformity>>() {
            }));
    public static final OutputTag<Tuple2<String, String>> ERROR_METER = new OutputTag<Tuple2<String, String>>(
            "error_meter") {
    };
    public static final OutputTag<Tuple4<String, String, Integer, String>> COMPLETE_RULE_RESULT = new OutputTag<Tuple4<String, String, Integer, String>>(
            "COMPLETE_RULE_RESULT") {
    };
    public static final OutputTag<Tuple4<String, String, Integer, String>> UNIFORMITY_RULE_RESULT = new OutputTag<Tuple4<String, String, Integer, String>>(
            "UNIFORMITY_RULE_RESULT") {
    };
    public static final OutputTag<Tuple4<String, String, Integer, String>> TIME_RULE_RESULT = new OutputTag<Tuple4<String, String, Integer, String>>(
            "TIME_RULE_RESULT") {
    };
    public static final OutputTag<Tuple4<String, String, Integer, String>> CURRENT_RULE_RESULT = new OutputTag<Tuple4<String, String, Integer, String>>(
            "CURRENT_RULE_RESULT") {
    };

    public static final String RULE_ADDRESS = "C:\\Users\\daoda\\Desktop\\地铁项目\\test_prometheus\\src\\main\\resources\\rule.stg";
    //public static final String RULE_ADDRESS = "/home/flink-1.13.3/conf/rule.stg";


}
