package com.lanyuanxiaoyao.service.configuration.entity.flink;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.eclipse.collections.api.list.ImmutableList;

/**
 * Flink Vertices
 *
 * @author lanyuanxiaoyao
 * @date 2023-05-04
 */
public class FlinkVertex {
    @JsonAlias({"jid", "id"})
    private String jid;
    private String name;
    private String state;
    @JsonAlias("start-time")
    private Long startTime;
    @JsonAlias("end-time")
    private Long endTime;
    private Long duration;
    private Long lastModification;
    private Tasks tasks;
    @JsonAlias("maxParallelism")
    private Integer maxParallelism;
    private Integer parallelism;
    private Long now;
    private Timestamps timestamps;
    @JsonAlias("vertices")
    private ImmutableList<FlinkVertex> children;
    private Metrics metrics;

    public String getJid() {
        return jid;
    }

    public String getName() {
        return name;
    }

    public String getState() {
        return state;
    }

    public Long getStartTime() {
        return startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public Long getDuration() {
        return duration;
    }

    public Long getLastModification() {
        return lastModification;
    }

    public Tasks getTasks() {
        return tasks;
    }

    public Integer getMaxParallelism() {
        return maxParallelism;
    }

    public Long getNow() {
        return now;
    }

    public Timestamps getTimestamps() {
        return timestamps;
    }

    public ImmutableList<FlinkVertex> getChildren() {
        return children;
    }

    public Metrics getMetrics() {
        return metrics;
    }

    public static final class Tasks {
        private Integer total;
        private Integer created;
        private Integer scheduled;
        private Integer deploying;
        private Integer running;
        private Integer finished;
        private Integer canceling;
        private Integer canceled;
        private Integer failed;
        private Integer reconciling;
        private Integer initializing;

        public Integer getTotal() {
            return total;
        }

        public Integer getCreated() {
            return created;
        }

        public Integer getScheduled() {
            return scheduled;
        }

        public Integer getDeploying() {
            return deploying;
        }

        public Integer getRunning() {
            return running;
        }

        public Integer getFinished() {
            return finished;
        }

        public Integer getCanceling() {
            return canceling;
        }

        public Integer getCanceled() {
            return canceled;
        }

        public Integer getFailed() {
            return failed;
        }

        public Integer getReconciling() {
            return reconciling;
        }

        public Integer getInitializing() {
            return initializing;
        }

        @Override
        public String toString() {
            return "Tasks{" +
                    "total=" + total +
                    ", created=" + created +
                    ", scheduled=" + scheduled +
                    ", deploying=" + deploying +
                    ", running=" + running +
                    ", finished=" + finished +
                    ", canceling=" + canceling +
                    ", canceled=" + canceled +
                    ", failed=" + failed +
                    ", reconciling=" + reconciling +
                    ", initializing=" + initializing +
                    '}';
        }
    }

    public static final class Timestamps {
        @JsonAlias("RUNNING")
        private Long running;
        @JsonAlias("FAILING")
        private Long failing;
        @JsonAlias("FINISHED")
        private Long finished;
        @JsonAlias("RESTARTING")
        private Long restarting;
        @JsonAlias("RECONCILING")
        private Long reconciling;
        @JsonAlias("CREATED")
        private Long created;
        @JsonAlias("FAILED")
        private Long failed;
        @JsonAlias("INITIALIZING")
        private Long initializing;
        @JsonAlias("CANCELED")
        private Long canceled;
        @JsonAlias("CANCELLING")
        private Long canceling;
        @JsonAlias("SUSPENDED")
        private Long suspended;

        public Long getRunning() {
            return running;
        }

        public Long getFailing() {
            return failing;
        }

        public Long getFinished() {
            return finished;
        }

        public Long getRestarting() {
            return restarting;
        }

        public Long getReconciling() {
            return reconciling;
        }

        public Long getCreated() {
            return created;
        }

        public Long getFailed() {
            return failed;
        }

        public Long getInitializing() {
            return initializing;
        }

        public Long getCanceled() {
            return canceled;
        }

        public Long getCanceling() {
            return canceling;
        }

        public Long getSuspended() {
            return suspended;
        }

        @Override
        public String toString() {
            return "Timestamps{" +
                    "running=" + running +
                    ", failing=" + failing +
                    ", finished=" + finished +
                    ", restarting=" + restarting +
                    ", reconciling=" + reconciling +
                    ", created=" + created +
                    ", failed=" + failed +
                    ", initializing=" + initializing +
                    ", canceled=" + canceled +
                    ", canceling=" + canceling +
                    ", suspended=" + suspended +
                    '}';
        }
    }

    public static final class Metrics {
        @JsonAlias("read-bytes")
        private Long readBytes;
        @JsonAlias("read-bytes-complete")
        private Boolean readBytesComplete;
        @JsonAlias("write-bytes")
        private Long writeBytes;
        @JsonAlias("write-bytes-complete")
        private Boolean writeBytesComplete;
        @JsonAlias("read-records")
        private Long readRecords;
        @JsonAlias("read-records-complete")
        private Boolean readRecordsComplete;
        @JsonAlias("write-records")
        private Long writeRecords;
        @JsonAlias("write-records-complete")
        private Boolean writeRecordsComplete;

        public Long getReadBytes() {
            return readBytes;
        }

        public Boolean isReadBytesComplete() {
            return readBytesComplete;
        }

        public Long getWriteBytes() {
            return writeBytes;
        }

        public Boolean isWriteBytesComplete() {
            return writeBytesComplete;
        }

        public Long getReadRecords() {
            return readRecords;
        }

        public Boolean isReadRecordsComplete() {
            return readRecordsComplete;
        }

        public Long getWriteRecords() {
            return writeRecords;
        }

        public Boolean isWriteRecordsComplete() {
            return writeRecordsComplete;
        }

        @Override
        public String toString() {
            return "Metrics{" +
                    "readBytes=" + readBytes +
                    ", readBytesComplete=" + readBytesComplete +
                    ", writeBytes=" + writeBytes +
                    ", writeBytesComplete=" + writeBytesComplete +
                    ", readRecords=" + readRecords +
                    ", readRecordsComplete=" + readRecordsComplete +
                    ", writeRecords=" + writeRecords +
                    ", writeRecordsComplete=" + writeRecordsComplete +
                    '}';
        }
    }

    @Override
    public String toString() {
        return "FlinkVertex{" +
                "jid='" + jid + '\'' +
                ", name='" + name + '\'' +
                ", state='" + state + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", duration=" + duration +
                ", lastModification=" + lastModification +
                ", tasks=" + tasks +
                ", maxParallelism=" + maxParallelism +
                ", now=" + now +
                ", timestamps=" + timestamps +
                ", children=" + children +
                ", metrics=" + metrics +
                '}';
    }
}
