Package org.apache.pulsar.client.impl
Class AbstractBatchMessageContainer
- java.lang.Object
-
- org.apache.pulsar.client.impl.AbstractBatchMessageContainer
-
- All Implemented Interfaces:
org.apache.pulsar.client.api.BatchMessageContainer,BatchMessageContainerBase
public abstract class AbstractBatchMessageContainer extends java.lang.Object implements BatchMessageContainerBase
Batch message container framework.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.pulsar.common.api.proto.CompressionTypecompressionTypeprotected org.apache.pulsar.common.compression.CompressionCodeccompressorprotected longcurrentBatchSizeBytesprotected longcurrentTxnidLeastBitsprotected longcurrentTxnidMostBitsprotected static intINITIAL_BATCH_BUFFER_SIZEprotected intmaxBatchSizeprotected intmaxBytesInBatchprotected intmaxNumMessagesInBatchprotected intnumMessagesInBatchprotected ProducerImplproducerprotected java.lang.StringproducerNameprotected java.lang.StringtopicName
-
Constructor Summary
Constructors Constructor Description AbstractBatchMessageContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProducerImpl.OpSendMsgcreateOpSendMsg()Create OpSendMsg, producer use OpSendMsg to send to the broker.java.util.List<ProducerImpl.OpSendMsg>createOpSendMsgs()Create list of OpSendMsg, producer use OpSendMsg to send to the broker.longgetCurrentBatchSize()intgetNumMessagesInBatch()booleanhasSameTxn(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 booleanisBatchFull()voidsetProducer(ProducerImpl<?> producer)Set producer of the message batch container.-
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 Detail
-
compressionType
protected org.apache.pulsar.common.api.proto.CompressionType compressionType
-
compressor
protected org.apache.pulsar.common.compression.CompressionCodec compressor
-
topicName
protected java.lang.String topicName
-
producerName
protected java.lang.String producerName
-
producer
protected ProducerImpl producer
-
maxNumMessagesInBatch
protected int maxNumMessagesInBatch
-
maxBytesInBatch
protected int maxBytesInBatch
-
numMessagesInBatch
protected int numMessagesInBatch
-
currentBatchSizeBytes
protected long currentBatchSizeBytes
-
currentTxnidMostBits
protected long currentTxnidMostBits
-
currentTxnidLeastBits
protected long currentTxnidLeastBits
-
INITIAL_BATCH_BUFFER_SIZE
protected static final int INITIAL_BATCH_BUFFER_SIZE
- See Also:
- Constant Field Values
-
maxBatchSize
protected int maxBatchSize
-
-
Method Detail
-
haveEnoughSpace
public boolean haveEnoughSpace(MessageImpl<?> msg)
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.
-
isBatchFull
protected boolean isBatchFull()
-
getNumMessagesInBatch
public int getNumMessagesInBatch()
- Specified by:
getNumMessagesInBatchin interfaceorg.apache.pulsar.client.api.BatchMessageContainer
-
getCurrentBatchSize
public long getCurrentBatchSize()
- Specified by:
getCurrentBatchSizein interfaceorg.apache.pulsar.client.api.BatchMessageContainer
-
createOpSendMsgs
public java.util.List<ProducerImpl.OpSendMsg> createOpSendMsgs() throws java.io.IOException
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:
java.io.IOException
-
createOpSendMsg
public ProducerImpl.OpSendMsg createOpSendMsg() throws java.io.IOException
Description copied from interface:BatchMessageContainerBaseCreate OpSendMsg, producer use OpSendMsg to send to the broker.- Specified by:
createOpSendMsgin interfaceBatchMessageContainerBase- Returns:
- OpSendMsg
- Throws:
java.io.IOException
-
setProducer
public void setProducer(ProducerImpl<?> producer)
Description copied from interface:BatchMessageContainerBaseSet producer of the message batch container.- Specified by:
setProducerin interfaceBatchMessageContainerBase- Parameters:
producer- producer
-
hasSameTxn
public boolean hasSameTxn(MessageImpl<?> msg)
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
-
-