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 int
protected CompressionType
protected CompressionCodec
protected long
protected long
protected long
protected static final int
protected static final int
protected int
protected int
protected int
protected int
protected int
protected ProducerImpl
protected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Create OpSendMsg, producer use OpSendMsg to send to the broker.Create list of OpSendMsg, producer use OpSendMsg to send to the broker.int
long
long
Get the timestamp in nanoseconds when the 1st message is added into the batch container.int
int
boolean
hasSameTxn
(MessageImpl<?> msg) Check whether the added message belong to the same txn with batch message container.boolean
haveEnoughSpace
(MessageImpl<?> msg) Check the batch message container have enough space for the message want to add.protected boolean
void
setProducer
(ProducerImpl<?> producer) Set producer of the message batch container.protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.pulsar.client.api.BatchMessageContainer
clear, discard, isEmpty, isMultiBatches
Methods inherited from interface org.apache.pulsar.client.impl.BatchMessageContainerBase
add, hasSameSchema
-
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:BatchMessageContainerBase
Check the batch message container have enough space for the message want to add.- Specified by:
haveEnoughSpace
in interfaceBatchMessageContainerBase
- Parameters:
msg
- the message want to add- Returns:
- return true if the container have enough space for the specific message, otherwise return false.
-
isBatchFull
protected boolean isBatchFull() -
getNumMessagesInBatch
public int getNumMessagesInBatch()- Specified by:
getNumMessagesInBatch
in interfaceBatchMessageContainer
-
getMaxMessagesNum
public int getMaxMessagesNum() -
getCurrentBatchSize
public long getCurrentBatchSize()- Specified by:
getCurrentBatchSize
in interfaceBatchMessageContainer
-
getBatchAllocatedSizeBytes
public int getBatchAllocatedSizeBytes()- Specified by:
getBatchAllocatedSizeBytes
in interfaceBatchMessageContainer
-
createOpSendMsgs
Description copied from interface:BatchMessageContainerBase
Create list of OpSendMsg, producer use OpSendMsg to send to the broker.- Specified by:
createOpSendMsgs
in interfaceBatchMessageContainerBase
- Returns:
- list of OpSendMsg
- Throws:
IOException
-
createOpSendMsg
Description copied from interface:BatchMessageContainerBase
Create OpSendMsg, producer use OpSendMsg to send to the broker.- Specified by:
createOpSendMsg
in interfaceBatchMessageContainerBase
- Returns:
- OpSendMsg
- Throws:
IOException
-
setProducer
Description copied from interface:BatchMessageContainerBase
Set producer of the message batch container.- Specified by:
setProducer
in interfaceBatchMessageContainerBase
- Parameters:
producer
- producer
-
hasSameTxn
Description copied from interface:BatchMessageContainerBase
Check whether the added message belong to the same txn with batch message container.- Specified by:
hasSameTxn
in interfaceBatchMessageContainerBase
- Parameters:
msg
- added message- Returns:
- belong to the same txn or not
-
getFirstAddedTimestamp
public long getFirstAddedTimestamp()Description copied from interface:BatchMessageContainerBase
Get the timestamp in nanoseconds when the 1st message is added into the batch container.- Specified by:
getFirstAddedTimestamp
in interfaceBatchMessageContainerBase
- Returns:
- the timestamp in nanoseconds or 0L if the batch container is empty
-
tryUpdateTimestamp
protected void tryUpdateTimestamp() -
clearTimestamp
protected void clearTimestamp()
-