All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.huaweicloud.dws.client.binlog.model.Slot Maven / Gradle / Ivy

/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

package com.huaweicloud.dws.client.binlog.model;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @ProjectName: dws-connector
 * @Description: slot相关信息
 * @Date: 2023-07-05 18:23
 * @Version: 1.0
 */
@Data
@NoArgsConstructor
public class Slot implements Serializable {
    // DN相关信息
    private int dnNodeId;

    // 同步点信息
    private long startCsn;

    private long endCsn;

    // 本次要读取开始的同步点
    private long currentStartCsn;

    private long xmin;

    public Slot slotDNNodeId(int dnNodeId) {
        this.dnNodeId = dnNodeId;
        return this;
    }

    public Slot startCsn(long startCsn) {
        this.startCsn = startCsn;
        return this;
    }

    public Slot endCsn(long endCsn) {
        this.endCsn = endCsn;
        return this;
    }

    public Slot currentStartCsn(long currentStartCsn) {
        this.currentStartCsn = currentStartCsn;
        return this;
    }

    public Slot xmin(long xmin) {
        this.xmin = xmin;
        return this;
    }

    public boolean isEnd() {
        return currentStartCsn >= endCsn;
    }

    public void finish() {
        currentStartCsn = endCsn;
    }

    public void start() {
        currentStartCsn = startCsn;
    }

    public long getConsumeEndScn(int binlogBatchReadSize) {
        return Math.min(currentStartCsn + binlogBatchReadSize, endCsn);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy