类 ProducerImpl<T>
- java.lang.Object
-
- org.apache.pulsar.client.impl.ProducerBase<T>
-
- org.apache.pulsar.client.impl.ProducerImpl<T>
-
- 所有已实现的接口:
io.netty.util.TimerTask
,java.io.Closeable
,java.lang.AutoCloseable
,org.apache.pulsar.client.api.Producer<T>
public class ProducerImpl<T> extends ProducerBase<T> implements io.netty.util.TimerTask
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static class
ProducerImpl.OpSendMsg
protected static class
ProducerImpl.OpSendMsgQueue
Queue implementation that is used as the pending messages queue.-
从类继承的嵌套类/接口 org.apache.pulsar.client.impl.ProducerBase
ProducerBase.MultiSchemaMode
-
-
字段概要
字段 修饰符和类型 字段 说明 protected PulsarClientImpl
client
protected long
lastSequenceIdPushed
protected long
producerId
protected java.lang.String
topic
-
从类继承的字段 org.apache.pulsar.client.impl.ProducerBase
conf, interceptors, multiSchemaMode, producerCreatedFuture, schema, schemaCache
-
-
构造器概要
构造器 构造器 说明 ProducerImpl(PulsarClientImpl client, java.lang.String topic, ProducerConfigurationData conf, java.util.concurrent.CompletableFuture<org.apache.pulsar.client.api.Producer<T>> producerCreatedFuture, int partitionIndex, org.apache.pulsar.client.api.Schema<T> schema, ProducerInterceptors interceptors)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 int
brokerChecksumSupportedVersion()
protected boolean
changeToConnecting()
protected boolean
changeToReadyState()
protected boolean
changeToRegisteringSchemaState()
java.util.concurrent.CompletableFuture<java.lang.Void>
closeAsync()
void
connectionFailed(org.apache.pulsar.client.api.PulsarClientException exception)
void
connectionOpened(ClientCnx cnx)
protected ProducerImpl.OpSendMsgQueue
createPendingMessagesQueue()
protected io.netty.buffer.ByteBuf
encryptMessage(org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload)
java.util.concurrent.CompletableFuture<java.lang.Void>
flushAsync()
protected org.apache.pulsar.client.impl.HandlerState.State
getAndUpdateState(java.util.function.UnaryOperator<org.apache.pulsar.client.impl.HandlerState.State> updater)
protected org.apache.pulsar.common.protocol.Commands.ChecksumType
getChecksumType()
PulsarClientImpl
getClient()
ClientCnx
getClientCnx()
protected ClientCnx
getCnxIfReady()
Hook method for testing.java.lang.String
getConnectedSince()
ConnectionHandler
getConnectionHandler()
java.lang.String
getConnectionId()
long
getDelayInMillis()
long
getLastDisconnectedTimestamp()
long
getLastSequenceId()
int
getPendingQueueSize()
java.lang.String
getProducerName()
protected org.apache.pulsar.client.impl.HandlerState.State
getState()
ProducerStatsRecorder
getStats()
boolean
isConnected()
boolean
isWritable()
protected void
processOpSendMsg(ProducerImpl.OpSendMsg op)
protected void
recoverChecksumError(ClientCnx cnx, long sequenceId)
Checks message checksum to retry if message was corrupted while sending to broker.protected void
recoverNotAllowedError(long sequenceId, java.lang.String errorMsg)
void
run(io.netty.util.Timeout timeout)
Process sendTimeout eventsprotected void
semaphoreRelease(int releaseCountRequest)
void
sendAsync(org.apache.pulsar.client.api.Message<?> message, SendCallback callback)
protected org.apache.pulsar.common.protocol.ByteBufPair
sendMessage(long producerId, long sequenceId, int numMessages, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload)
protected org.apache.pulsar.common.protocol.ByteBufPair
sendMessage(long producerId, long lowestSequenceId, long highestSequenceId, int numMessages, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload)
protected void
setState(org.apache.pulsar.client.impl.HandlerState.State s)
void
terminated(ClientCnx cnx)
protected void
triggerFlush()
protected boolean
verifyLocalBufferIsNotCorrupted(ProducerImpl.OpSendMsg op)
Computes checksum again and verifies it against existing checksum.-
从类继承的方法 org.apache.pulsar.client.impl.ProducerBase
beforeSend, close, flush, getConfiguration, getTopic, newMessage, newMessage, newMessage, onPartitionsChange, onSendAcknowledgement, producerCreatedFuture, send, send, sendAsync, sendAsync, toString
-
-
-
-
字段详细资料
-
producerId
protected final long producerId
-
lastSequenceIdPushed
protected volatile long lastSequenceIdPushed
-
client
protected final PulsarClientImpl client
-
topic
protected final java.lang.String topic
-
-
构造器详细资料
-
ProducerImpl
public ProducerImpl(PulsarClientImpl client, java.lang.String topic, ProducerConfigurationData conf, java.util.concurrent.CompletableFuture<org.apache.pulsar.client.api.Producer<T>> producerCreatedFuture, int partitionIndex, org.apache.pulsar.client.api.Schema<T> schema, ProducerInterceptors interceptors)
-
-
方法详细资料
-
semaphoreRelease
protected void semaphoreRelease(int releaseCountRequest)
-
createPendingMessagesQueue
protected ProducerImpl.OpSendMsgQueue createPendingMessagesQueue()
-
getConnectionHandler
public ConnectionHandler getConnectionHandler()
-
getLastSequenceId
public long getLastSequenceId()
- 指定者:
getLastSequenceId
在接口中org.apache.pulsar.client.api.Producer<T>
-
sendAsync
public void sendAsync(org.apache.pulsar.client.api.Message<?> message, SendCallback callback)
-
encryptMessage
protected io.netty.buffer.ByteBuf encryptMessage(org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload) throws org.apache.pulsar.client.api.PulsarClientException
- 抛出:
org.apache.pulsar.client.api.PulsarClientException
-
sendMessage
protected org.apache.pulsar.common.protocol.ByteBufPair sendMessage(long producerId, long sequenceId, int numMessages, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload)
-
sendMessage
protected org.apache.pulsar.common.protocol.ByteBufPair sendMessage(long producerId, long lowestSequenceId, long highestSequenceId, int numMessages, org.apache.pulsar.common.api.proto.MessageMetadata msgMetadata, io.netty.buffer.ByteBuf compressedPayload)
-
getChecksumType
protected org.apache.pulsar.common.protocol.Commands.ChecksumType getChecksumType()
-
closeAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> closeAsync()
- 指定者:
closeAsync
在接口中org.apache.pulsar.client.api.Producer<T>
- 指定者:
closeAsync
在类中ProducerBase<T>
-
isConnected
public boolean isConnected()
- 指定者:
isConnected
在接口中org.apache.pulsar.client.api.Producer<T>
-
getCnxIfReady
protected ClientCnx getCnxIfReady()
Hook method for testing. By returning null, it's possible to prevent messages being delivered to the broker.- 返回:
- cnx if OpSend messages should be written to open connection. Caller must verify that the returned cnx is not null before using reference.
-
getLastDisconnectedTimestamp
public long getLastDisconnectedTimestamp()
- 指定者:
getLastDisconnectedTimestamp
在接口中org.apache.pulsar.client.api.Producer<T>
-
isWritable
public boolean isWritable()
-
terminated
public void terminated(ClientCnx cnx)
-
recoverChecksumError
protected void recoverChecksumError(ClientCnx cnx, long sequenceId)
Checks message checksum to retry if message was corrupted while sending to broker. Recomputes checksum of the message header-payload again.- if matches with existing checksum: it means message was corrupt while sending to broker. So, resend message
- if doesn't match with existing checksum: it means message is already corrupt and can't retry again. So, fail send-message by failing callback
- 参数:
cnx
-sequenceId
-
-
recoverNotAllowedError
protected void recoverNotAllowedError(long sequenceId, java.lang.String errorMsg)
-
verifyLocalBufferIsNotCorrupted
protected boolean verifyLocalBufferIsNotCorrupted(ProducerImpl.OpSendMsg op)
Computes checksum again and verifies it against existing checksum. If checksum doesn't match it means that message is corrupt.- 参数:
op
-- 返回:
- returns true only if message is not modified and computed-checksum is same as previous checksum else return false that means that message is corrupted. Returns true if checksum is not present.
-
connectionOpened
public void connectionOpened(ClientCnx cnx)
-
connectionFailed
public void connectionFailed(org.apache.pulsar.client.api.PulsarClientException exception)
-
brokerChecksumSupportedVersion
public int brokerChecksumSupportedVersion()
-
run
public void run(io.netty.util.Timeout timeout) throws java.lang.Exception
Process sendTimeout events- 指定者:
run
在接口中io.netty.util.TimerTask
- 抛出:
java.lang.Exception
-
flushAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> flushAsync()
- 指定者:
flushAsync
在接口中org.apache.pulsar.client.api.Producer<T>
-
triggerFlush
protected void triggerFlush()
-
processOpSendMsg
protected void processOpSendMsg(ProducerImpl.OpSendMsg op)
-
getDelayInMillis
public long getDelayInMillis()
-
getConnectionId
public java.lang.String getConnectionId()
-
getConnectedSince
public java.lang.String getConnectedSince()
-
getPendingQueueSize
public int getPendingQueueSize()
-
getStats
public ProducerStatsRecorder getStats()
- 指定者:
getStats
在接口中org.apache.pulsar.client.api.Producer<T>
-
getProducerName
public java.lang.String getProducerName()
- 指定者:
getProducerName
在接口中org.apache.pulsar.client.api.Producer<T>
-
getClientCnx
public ClientCnx getClientCnx()
-
changeToReadyState
protected boolean changeToReadyState()
-
changeToRegisteringSchemaState
protected boolean changeToRegisteringSchemaState()
-
getState
protected org.apache.pulsar.client.impl.HandlerState.State getState()
-
changeToConnecting
protected boolean changeToConnecting()
-
setState
protected void setState(org.apache.pulsar.client.impl.HandlerState.State s)
-
getAndUpdateState
protected org.apache.pulsar.client.impl.HandlerState.State getAndUpdateState(java.util.function.UnaryOperator<org.apache.pulsar.client.impl.HandlerState.State> updater)
-
getClient
public PulsarClientImpl getClient()
-
-