Package org.apache.pulsar.client.impl
Class AbstractBatchMessageContainer
java.lang.Object
org.apache.pulsar.client.impl.AbstractBatchMessageContainer
- All Implemented Interfaces:
BatchMessageContainer,BatchMessageContainerBase
public abstract class AbstractBatchMessageContainer
extends Object
implements BatchMessageContainerBase
Batch message container framework.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected CompressionTypeprotected CompressionCodecprotected longprotected longprotected longprotected static final intprotected static final intprotected intprotected intprotected intprotected intprotected intprotected ProducerImplprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreate OpSendMsg, producer use OpSendMsg to send to the broker.Create list of OpSendMsg, producer use OpSendMsg to send to the broker.intlonglongGet the timestamp in nanoseconds when the 1st message is added into the batch container.protected intintintbooleanhasSameTxn(MessageImpl<?> msg) Check whether the added message belong to the same txn with batch message container.booleanhaveEnoughSpace(MessageImpl<?> msg) Check the batch message container have enough space for the message want to add.protected booleanvoidsetProducer(ProducerImpl<?> producer) Set producer of the message batch container.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.client.api.BatchMessageContainer
clear, discard, isEmpty, isMultiBatchesMethods inherited from interface org.apache.pulsar.client.impl.BatchMessageContainerBase
add, hasSameSchema, resetPayloadAfterFailedPublishing
-
Field Details
-
compressionType
-
compressor
-
topicName
-
producer
-
maxNumMessagesInBatch
protected int maxNumMessagesInBatch -
maxBytesInBatch
protected int maxBytesInBatch -
numMessagesInBatch
protected int numMessagesInBatch -
currentBatchSizeBytes
protected long currentBatchSizeBytes -
batchAllocatedSizeBytes
protected int batchAllocatedSizeBytes -
currentTxnidMostBits
protected long currentTxnidMostBits -
currentTxnidLeastBits
protected long currentTxnidLeastBits -
INITIAL_BATCH_BUFFER_SIZE
protected static final int INITIAL_BATCH_BUFFER_SIZE- See Also:
-
INITIAL_MESSAGES_NUM
protected static final int INITIAL_MESSAGES_NUM- See Also:
-
maxBatchSize
protected int maxBatchSize -
maxMessagesNum
protected int maxMessagesNum
-
-
Constructor Details
-
AbstractBatchMessageContainer
public AbstractBatchMessageContainer()
-
-
Method Details
-
haveEnoughSpace
Description copied from interface:BatchMessageContainerBaseCheck the batch message container have enough space for the message want to add.- Specified by:
haveEnoughSpacein interfaceBatchMessageContainerBase- Parameters:
msg- the message want to add- Returns:
- return true if the container have enough space for the specific message, otherwise return false.
-
getMaxMessageSize
protected int getMaxMessageSize() -
isBatchFull
protected boolean isBatchFull() -
getNumMessagesInBatch
public int getNumMessagesInBatch()- Specified by:
getNumMessagesInBatchin interfaceBatchMessageContainer
-
getMaxMessagesNum
public int getMaxMessagesNum() -
getCurrentBatchSize
public long getCurrentBatchSize()- Specified by:
getCurrentBatchSizein interfaceBatchMessageContainer
-
getBatchAllocatedSizeBytes
public int getBatchAllocatedSizeBytes()- Specified by:
getBatchAllocatedSizeBytesin interfaceBatchMessageContainer
-
createOpSendMsgs
Description copied from interface:BatchMessageContainerBaseCreate list of OpSendMsg, producer use OpSendMsg to send to the broker.- Specified by:
createOpSendMsgsin interfaceBatchMessageContainerBase- Returns:
- list of OpSendMsg
- Throws:
IOException
-
createOpSendMsg
Description copied from interface:BatchMessageContainerBaseCreate OpSendMsg, producer use OpSendMsg to send to the broker.- Specified by:
createOpSendMsgin interfaceBatchMessageContainerBase- Returns:
- OpSendMsg
- Throws:
IOException
-
setProducer
Description copied from interface:BatchMessageContainerBaseSet producer of the message batch container.- Specified by:
setProducerin interfaceBatchMessageContainerBase- Parameters:
producer- producer
-
hasSameTxn
Description copied from interface:BatchMessageContainerBaseCheck whether the added message belong to the same txn with batch message container.- Specified by:
hasSameTxnin interfaceBatchMessageContainerBase- Parameters:
msg- added message- Returns:
- belong to the same txn or not
-
getFirstAddedTimestamp
public long getFirstAddedTimestamp()Description copied from interface:BatchMessageContainerBaseGet the timestamp in nanoseconds when the 1st message is added into the batch container.- Specified by:
getFirstAddedTimestampin interfaceBatchMessageContainerBase- Returns:
- the timestamp in nanoseconds or 0L if the batch container is empty
-
tryUpdateTimestamp
protected void tryUpdateTimestamp() -
clearTimestamp
protected void clearTimestamp()
-