package com.lanyuanxiaoyao.service.executor.task.functions.pulsar;

import java.io.Serializable;
import org.apache.flink.api.connector.source.SourceSplit;

/**
 * @author lanyuanxiaoyao
 * @date 2024-01-18
 */
public class ReadPulsarSplit implements SourceSplit, Serializable {
    private String taskId;
    private String pulsarUrl;
    private String pulsarTopic;
    private String latestMessageId;
    private Long startTimestamp;
    private Long endTimestamp;

    public ReadPulsarSplit() {
    }

    public ReadPulsarSplit(String taskId, String pulsarUrl, String pulsarTopic, String latestMessageId, Long startTimestamp, Long endTimestamp) {
        this.taskId = taskId;
        this.pulsarUrl = pulsarUrl;
        this.pulsarTopic = pulsarTopic;
        this.latestMessageId = latestMessageId;
        this.startTimestamp = startTimestamp;
        this.endTimestamp = endTimestamp;
    }

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public String getPulsarUrl() {
        return pulsarUrl;
    }

    public void setPulsarUrl(String pulsarUrl) {
        this.pulsarUrl = pulsarUrl;
    }

    public String getPulsarTopic() {
        return pulsarTopic;
    }

    public void setPulsarTopic(String pulsarTopic) {
        this.pulsarTopic = pulsarTopic;
    }

    public String getLatestMessageId() {
        return latestMessageId;
    }

    public void setLatestMessageId(String latestMessageId) {
        this.latestMessageId = latestMessageId;
    }

    public Long getStartTimestamp() {
        return startTimestamp;
    }

    public void setStartTimestamp(Long startTimestamp) {
        this.startTimestamp = startTimestamp;
    }

    public Long getEndTimestamp() {
        return endTimestamp;
    }

    public void setEndTimestamp(Long endTimestamp) {
        this.endTimestamp = endTimestamp;
    }

    @Override
    public String splitId() {
        return taskId + pulsarUrl + pulsarTopic + startTimestamp + endTimestamp + latestMessageId;
    }

    @Override
    public String toString() {
        return "ReadPulsarSplit{" +
               "taskId='" + taskId + '\'' +
               ", pulsarUrl='" + pulsarUrl + '\'' +
               ", pulsarTopic='" + pulsarTopic + '\'' +
               ", latestMessageId='" + latestMessageId + '\'' +
               ", startTimestamp=" + startTimestamp +
               ", endTimestamp=" + endTimestamp +
               '}';
    }
}
