package com.lanyuanxiaoyao.service.common.entity;

import java.io.Serializable;

/**
 * Flink Job
 *
 * @author ZhangJiacheng
 * @version 0.0.1
 * @date 2021-12-08
 */
public class FlinkJob implements Serializable {
    private Long id;
    private String name;
    private RunMode runMode;
    private TableMeta.YarnMeta oneInOneSyncYarn;

    public FlinkJob() {
    }

    public FlinkJob(Builder builder) {
        this.id = builder.id;
        this.name = builder.name;
        this.runMode = builder.runMode;
        this.oneInOneSyncYarn = builder.oneInOneSyncYarn;
    }

    public static Builder builder() {
        return new Builder();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public RunMode getRunMode() {
        return runMode;
    }

    public void setRunMode(RunMode runMode) {
        this.runMode = runMode;
    }

    public TableMeta.YarnMeta getOneInOneSyncYarn() {
        return oneInOneSyncYarn;
    }

    public void setOneInOneSyncYarn(TableMeta.YarnMeta oneInOneSyncYarn) {
        this.oneInOneSyncYarn = oneInOneSyncYarn;
    }

    @Override
    public String toString() {
        return "FlinkJob{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", runMode=" + runMode +
                ", oneInOneSyncYarn=" + oneInOneSyncYarn +
                '}';
    }

    public enum RunMode {
        /**
         * 所有表放在同一个任务中
         */
        ALL_IN_ONE,
        /**
         * 每个表放在单独的任务中
         */
        ONE_IN_ONE,
        /**
         * 针对 ACCT 小表，将同一个表放在同一个子任务中
         */
        ALL_IN_ONE_BY_TABLE,
        ALL_IN_ONE_BY_SCHEMA,
    }

    public static final class Builder {
        private Long id;
        private String name;
        private RunMode runMode;
        private TableMeta.YarnMeta oneInOneSyncYarn;

        private Builder() {}

        public Builder id(Long id) {
            this.id = id;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder runMode(RunMode runMode) {
            this.runMode = runMode;
            return this;
        }

        public Builder oneInOneSyncYarn(TableMeta.YarnMeta oneInOneSyncYarn) {
            this.oneInOneSyncYarn = oneInOneSyncYarn;
            return this;
        }

        public FlinkJob build() {
            return new FlinkJob(this);
        }
    }

}
