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

tech.ydb.topic.write.impl.EnqueuedMessage Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package tech.ydb.topic.write.impl;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;

import tech.ydb.common.transaction.YdbTransaction;
import tech.ydb.topic.settings.SendSettings;
import tech.ydb.topic.write.Message;
import tech.ydb.topic.write.WriteAck;

public class EnqueuedMessage {
    private final Message message;
    private final CompletableFuture future = new CompletableFuture<>();
    private final AtomicBoolean isCompressed = new AtomicBoolean();
    private final AtomicBoolean isProcessingFailed = new AtomicBoolean();
    private final long uncompressedSizeBytes;
    private final YdbTransaction transaction;
    private long compressedSizeBytes;
    private Long seqNo;

    public EnqueuedMessage(Message message, SendSettings sendSettings) {
        this.message = message;
        this.uncompressedSizeBytes = message.getData().length;
        this.transaction = sendSettings != null ? sendSettings.getTransaction() : null;
    }

    public Message getMessage() {
        return message;
    }

    public CompletableFuture getFuture() {
        return future;
    }

    public boolean isCompressed() {
        return isCompressed.get();
    }

    public void setCompressed(boolean compressed) {
        this.isCompressed.set(compressed);
    }

    public boolean isProcessingFailed() {
        return isProcessingFailed.get();
    }

     public void setProcessingFailed(boolean procesingFailed) {
        isProcessingFailed.set(procesingFailed);
     }

    public long getUncompressedSizeBytes() {
        return uncompressedSizeBytes;
    }

    public long getCompressedSizeBytes() {
        return compressedSizeBytes;
    }

    public void setCompressedSizeBytes(long compressedSizeBytes) {
        this.compressedSizeBytes = compressedSizeBytes;
    }

    public long getSizeBytes() {
        return isCompressed() ? getCompressedSizeBytes() : getUncompressedSizeBytes();
    }

    public Long getSeqNo() {
        return seqNo;
    }

    public void setSeqNo(long seqNo) {
        this.seqNo = seqNo;
    }

    public YdbTransaction getTransaction() {
        return transaction;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy