package com.lanyuanxiaoyao.service.command.commands.jobs;

import cn.hutool.core.util.StrUtil;
import com.lanyuanxiaoyao.service.command.commands.jobs.AbstractAdder;
import com.lanyuanxiaoyao.service.common.entity.FlinkJob;
import com.lanyuanxiaoyao.service.forest.service.InfoService;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ImmutableList;

/**
 * @date 2022-06-29
 */
public class BigTableAdder extends AbstractAdder implements TableGetter {
    public BigTableAdder(InfoService infoService, String database, String type, String schema, String table, String pulsarAddress, String hdfs) {
        super(infoService, database, type, schema, table, pulsarAddress, hdfs);
    }

    @Override
    public ImmutableList<Table> getTables() {
        return Lists.immutable.of(
                new Table(
                        snowflake.nextId(),
                        StrUtil.format("{}_{}", schema, table),
                        2L,
                        2L,
                        4L,
                        database,
                        type,
                        schema,
                        table,
                        pulsarAddress,
                        StrUtil.format("persistent://odcp/{}/{}", schema, table),
                        StrUtil.format("dws_{}", schema),
                        StrUtil.format("dws_{}", table),
                        StrUtil.format("{}/dws_{}/external_table_hudi/dws_{}", hdfs, schema, table),
                        "CITY_ID",
                        "200,755,757,769",
                        "EXCLUDE", 20L
                ),
                new Table(
                        snowflake.nextId(),
                        StrUtil.format("{}_{}_b", schema, table),
                        3L,
                        3L,
                        4L,
                        database,
                        type,
                        schema,
                        table,
                        pulsarAddress,
                        StrUtil.format("persistent://odcp/{}/{}", schema, table),
                        StrUtil.format("dws_{}", schema),
                        StrUtil.format("dws_{}", table),
                        StrUtil.format("{}/dws_{}/external_table_hudi/dws_{}_b", hdfs, schema, table),
                        "CITY_ID",
                        "200,755,757,769",
                        "INCLUDE",
                        50L)
        );
    }

    @Override
    protected ImmutableList<Job> getJobs() {
        return Lists.immutable.of(new Job(snowflake.nextId(), StrUtil.format("{} {}", schema, table), FlinkJob.RunMode.ONE_IN_ONE.name(), getTables(), false));
    }
}
