类 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
    • 字段详细资料

      • producerId

        protected final long producerId
      • lastSequenceIdPushed

        protected volatile long lastSequenceIdPushed
      • 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)
      • 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()
      • 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)