tech.ydb.topic.write.impl.EnqueuedMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-topic Show documentation
Show all versions of ydb-sdk-topic Show documentation
Topic client implementation
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;
}
}