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

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

/**
 * @author lanyuanxiaoyao
 * @date 2023-05-04
 */
public final class FlinkCheckpointOverview {
    private Counts counts;
    private Summary summary;
    private FlinkCheckpoint latest;
    private ImmutableList<FlinkCheckpoint> history;

    public Counts getCounts() {
        return counts;
    }

    public Summary getSummary() {
        return summary;
    }

    public FlinkCheckpoint getLatest() {
        return latest;
    }

    public ImmutableList<FlinkCheckpoint> getHistory() {
        return history;
    }

    @Override
    public String toString() {
        return "FlinkCheckpointOverview{" +
                "counts=" + counts +
                ", summary=" + summary +
                ", latest=" + latest +
                ", history=" + history +
                '}';
    }

    public static final class Counts {
        private Long restored;
        private Long total;
        @JsonAlias("in_progress")
        private Long inProgress;
        private Long completed;
        private Long failed;

        public Long getRestored() {
            return restored;
        }

        public Long getTotal() {
            return total;
        }

        public Long getInProgress() {
            return inProgress;
        }

        public Long getCompleted() {
            return completed;
        }

        public Long getFailed() {
            return failed;
        }

        @Override
        public String toString() {
            return "Counts{" +
                    "restored=" + restored +
                    ", total=" + total +
                    ", inProgress=" + inProgress +
                    ", completed=" + completed +
                    ", failed=" + failed +
                    '}';
        }
    }

    public static final class Summary {
        @JsonAlias("state_size")
        private Metric stateSize;
        @JsonAlias("end_to_end_duration")
        private Metric endToEndDuration;
        @JsonAlias("alignment_buffered")
        private Metric alignmentBuffered;
        @JsonAlias("processed_data")
        private Metric processedData;
        @JsonAlias("persisted_data")
        private Metric persistedData;

        public Metric getStateSize() {
            return stateSize;
        }

        public Metric getEndToEndDuration() {
            return endToEndDuration;
        }

        public Metric getAlignmentBuffered() {
            return alignmentBuffered;
        }

        public Metric getProcessedData() {
            return processedData;
        }

        public Metric getPersistedData() {
            return persistedData;
        }

        @Override
        public String toString() {
            return "Summary{" +
                    "stateSize=" + stateSize +
                    ", endToEndDuration=" + endToEndDuration +
                    ", alignmentBuffered=" + alignmentBuffered +
                    ", processedData=" + processedData +
                    ", persistedData=" + persistedData +
                    '}';
        }

        public static final class Metric {
            private Long min;
            private Long max;
            private Long avg;

            public Long getMin() {
                return min;
            }

            public Long getMax() {
                return max;
            }

            public Long getAvg() {
                return avg;
            }

            @Override
            public String toString() {
                return "Metric{" +
                        "min=" + min +
                        ", max=" + max +
                        ", avg=" + avg +
                        '}';
            }
        }
    }
}
