Class AbstractTopic

    • Field Detail

      • POLICY_UPDATE_FAILURE_RETRY_TIME_SECONDS

        protected static final long POLICY_UPDATE_FAILURE_RETRY_TIME_SECONDS
        See Also:
        Constant Field Values
      • topic

        protected final java.lang.String topic
      • producers

        protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,​Producer> producers
      • replicatorPrefix

        protected final java.lang.String replicatorPrefix
      • lock

        protected final java.util.concurrent.locks.ReentrantReadWriteLock lock
      • isFenced

        protected volatile boolean isFenced
      • inactiveTopicPolicies

        protected org.apache.pulsar.common.policies.data.InactiveTopicPolicies inactiveTopicPolicies
      • lastActive

        protected volatile long lastActive
      • hasBatchMessagePublished

        protected volatile boolean hasBatchMessagePublished
      • addEntryLatencyStatsUsec

        protected org.apache.bookkeeper.mledger.util.StatsBuckets addEntryLatencyStatsUsec
      • isEncryptionRequired

        protected volatile boolean isEncryptionRequired
      • schemaCompatibilityStrategy

        protected volatile org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy schemaCompatibilityStrategy
      • isAllowAutoUpdateSchema

        protected volatile java.lang.Boolean isAllowAutoUpdateSchema
      • schemaValidationEnforced

        protected volatile boolean schemaValidationEnforced
      • maxUnackedMessagesOnConsumerAppilied

        protected volatile int maxUnackedMessagesOnConsumerAppilied
      • maxSubscriptionsPerTopic

        protected volatile java.lang.Integer maxSubscriptionsPerTopic
      • preciseTopicPublishRateLimitingEnable

        protected boolean preciseTopicPublishRateLimitingEnable
      • resourceGroupRateLimitingEnabled

        protected boolean resourceGroupRateLimitingEnabled
      • publishRateLimitedTimes

        protected volatile long publishRateLimitedTimes
      • topicEpoch

        protected volatile java.util.Optional<java.lang.Long> topicEpoch
      • msgOutFromRemovedSubscriptions

        protected final java.util.concurrent.atomic.LongAdder msgOutFromRemovedSubscriptions
      • bytesOutFromRemovedSubscriptions

        protected final java.util.concurrent.atomic.LongAdder bytesOutFromRemovedSubscriptions
    • Constructor Detail

      • AbstractTopic

        public AbstractTopic​(java.lang.String topic,
                             BrokerService brokerService)
    • Method Detail

      • isProducersExceeded

        protected boolean isProducersExceeded​(Producer producer)
      • isSameAddressProducersExceeded

        protected boolean isSameAddressProducersExceeded​(Producer producer)
      • getNumberOfSameAddressProducers

        public int getNumberOfSameAddressProducers​(java.lang.String clientAddress)
      • isConsumersExceededOnTopic

        protected boolean isConsumersExceededOnTopic()
      • isSameAddressConsumersExceededOnTopic

        protected boolean isSameAddressConsumersExceededOnTopic​(Consumer consumer)
      • getNumberOfConsumers

        public abstract int getNumberOfConsumers()
      • getNumberOfSameAddressConsumers

        public abstract int getNumberOfSameAddressConsumers​(java.lang.String clientAddress)
      • getNumberOfSameAddressConsumers

        protected int getNumberOfSameAddressConsumers​(java.lang.String clientAddress,
                                                      java.util.List<? extends Subscription> subscriptions)
      • addConsumerToSubscription

        protected java.util.concurrent.CompletableFuture<java.lang.Void> addConsumerToSubscription​(Subscription subscription,
                                                                                                   Consumer consumer)
      • hasLocalProducers

        protected boolean hasLocalProducers()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getProducers

        public java.util.Map<java.lang.String,​Producer> getProducers()
        Specified by:
        getProducers in interface Topic
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Topic
      • markBatchMessagePublished

        public void markBatchMessagePublished()
      • getReplicatorPrefix

        public java.lang.String getReplicatorPrefix()
      • hasSchema

        public java.util.concurrent.CompletableFuture<java.lang.Boolean> hasSchema()
        Description copied from interface: Topic
        Whether a topic has had a schema defined for it.
        Specified by:
        hasSchema in interface Topic
      • addSchema

        public java.util.concurrent.CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> addSchema​(org.apache.pulsar.common.protocol.schema.SchemaData schema)
        Description copied from interface: Topic
        Add a schema to the topic. This will fail if the new schema is incompatible with the current schema.
        Specified by:
        addSchema in interface Topic
      • deleteSchema

        public java.util.concurrent.CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> deleteSchema()
        Description copied from interface: Topic
        Delete the schema if this topic has a schema defined for it.
        Specified by:
        deleteSchema in interface Topic
      • checkSchemaCompatibleForConsumer

        public java.util.concurrent.CompletableFuture<java.lang.Void> checkSchemaCompatibleForConsumer​(org.apache.pulsar.common.protocol.schema.SchemaData schema)
        Description copied from interface: Topic
        Check if schema is compatible with current topic schema.
        Specified by:
        checkSchemaCompatibleForConsumer in interface Topic
      • addProducer

        public java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.Long>> addProducer​(Producer producer,
                                                                                                      java.util.concurrent.CompletableFuture<java.lang.Void> producerQueuedFuture)
        Description copied from interface: Topic
        Tries to add a producer to the topic. Several validations will be performed.
        Specified by:
        addProducer in interface Topic
        producerQueuedFuture - a future that will be triggered if the producer is being queued up prior of getting established
        Returns:
        the "topic epoch" if there is one or empty
      • incrementTopicEpochIfNeeded

        protected java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.Long>> incrementTopicEpochIfNeeded​(Producer producer,
                                                                                                                         java.util.concurrent.CompletableFuture<java.lang.Void> producerQueuedFuture)
      • setTopicEpoch

        protected abstract java.util.concurrent.CompletableFuture<java.lang.Long> setTopicEpoch​(long newEpoch)
      • incrementTopicEpoch

        protected abstract java.util.concurrent.CompletableFuture<java.lang.Long> incrementTopicEpoch​(java.util.Optional<java.lang.Long> currentEpoch)
      • recordAddLatency

        public void recordAddLatency​(long latency,
                                     java.util.concurrent.TimeUnit unit)
        Description copied from interface: Topic
        record add-latency.
        Specified by:
        recordAddLatency in interface Topic
      • setSchemaCompatibilityStrategy

        protected void setSchemaCompatibilityStrategy​(org.apache.pulsar.common.policies.data.Policies policies)
      • incrementPublishCount

        public void incrementPublishCount​(int numOfMessages,
                                          long msgSizeInBytes)
        Specified by:
        incrementPublishCount in interface Topic
      • enableProducerReadForPublishRateLimiting

        protected void enableProducerReadForPublishRateLimiting()
        it sets cnx auto-readable if producer's cnx is disabled due to publish-throttling.
      • enableProducerReadForPublishBufferLimiting

        protected void enableProducerReadForPublishBufferLimiting()
      • disableProducerRead

        protected void disableProducerRead()
      • increasePublishLimitedTimes

        public long increasePublishLimitedTimes()
        Description copied from interface: Topic
        increase the publishing limited times.
        Specified by:
        increasePublishLimitedTimes in interface Topic
      • handleProducerRemoved

        protected void handleProducerRemoved​(Producer producer)
      • handleConsumerAdded

        public void handleConsumerAdded​(java.lang.String subscriptionName,
                                        java.lang.String consumerName)
      • decrementUsageCount

        public void decrementUsageCount()
      • currentUsageCount

        public long currentUsageCount()
      • isTopicPublishRateExceeded

        public boolean isTopicPublishRateExceeded​(int numberMessages,
                                                  int bytes)
        Specified by:
        isTopicPublishRateExceeded in interface Topic
      • updateMaxPublishRate

        public void updateMaxPublishRate​(org.apache.pulsar.common.policies.data.Policies policies)
      • getMsgInCounter

        public long getMsgInCounter()
      • getBytesInCounter

        public long getBytesInCounter()
      • getMsgOutCounter

        public long getMsgOutCounter()
      • getBytesOutCounter

        public long getBytesOutCounter()
      • isDeleteWhileInactive

        public boolean isDeleteWhileInactive()
      • deletePartitionedTopicMetadataWhileInactive

        public boolean deletePartitionedTopicMetadataWhileInactive()
      • setDeleteWhileInactive

        public void setDeleteWhileInactive​(boolean deleteWhileInactive)
      • isTerminated

        protected abstract boolean isTerminated()
      • getInactiveTopicPolicies

        public org.apache.pulsar.common.policies.data.InactiveTopicPolicies getInactiveTopicPolicies()
      • resetInactiveTopicPolicies

        public void resetInactiveTopicPolicies​(org.apache.pulsar.common.policies.data.InactiveTopicDeleteMode inactiveTopicDeleteMode,
                                               int maxInactiveDurationSeconds,
                                               boolean deleteWhileInactive)
      • getTopicPolicies

        public java.util.Optional<org.apache.pulsar.common.policies.data.TopicPolicies> getTopicPolicies()
        Get TopicPolicies for this topic.
        Returns:
        TopicPolicies, if they exist. Otherwise, the value will not be present.
      • deleteTopicPolicies

        public java.util.concurrent.CompletableFuture<java.lang.Void> deleteTopicPolicies()
      • getWaitingProducersCount

        protected int getWaitingProducersCount()
      • isExceedMaximumMessageSize

        protected boolean isExceedMaximumMessageSize​(int size)
      • updatePublishDispatcher

        protected void updatePublishDispatcher​(org.apache.pulsar.common.policies.data.PublishRate publishRate)
        update topic publish dispatcher for this topic.