Class NonPersistentTopic

java.lang.Object
org.apache.pulsar.broker.service.AbstractTopic
org.apache.pulsar.broker.service.nonpersistent.NonPersistentTopic
All Implemented Interfaces:
Topic, TopicPolicyListener<org.apache.pulsar.common.policies.data.TopicPolicies>

public class NonPersistentTopic extends AbstractTopic implements Topic, TopicPolicyListener<org.apache.pulsar.common.policies.data.TopicPolicies>
  • Constructor Details

  • Method Details

    • initialize

      public CompletableFuture<Void> initialize()
      Specified by:
      initialize in interface Topic
    • publishMessage

      public void publishMessage(io.netty.buffer.ByteBuf data, Topic.PublishContext callback)
      Specified by:
      publishMessage in interface Topic
    • incrementTopicEpoch

      protected CompletableFuture<Long> incrementTopicEpoch(Optional<Long> currentEpoch)
      Specified by:
      incrementTopicEpoch in class AbstractTopic
    • setTopicEpoch

      protected CompletableFuture<Long> setTopicEpoch(long newEpoch)
      Specified by:
      setTopicEpoch in class AbstractTopic
    • checkMessageDeduplicationInfo

      public void checkMessageDeduplicationInfo()
      Specified by:
      checkMessageDeduplicationInfo in interface Topic
    • isReplicationBacklogExist

      public boolean isReplicationBacklogExist()
      Specified by:
      isReplicationBacklogExist in interface Topic
    • checkIfTransactionBufferRecoverCompletely

      public CompletableFuture<Void> checkIfTransactionBufferRecoverCompletely(boolean isTxnEnabled)
      Description copied from interface: Topic
      Wait TransactionBuffer Recovers completely. Take snapshot after TB Recovers completely.
      Specified by:
      checkIfTransactionBufferRecoverCompletely in interface Topic
      Parameters:
      isTxnEnabled - isTxnEnabled
      Returns:
      a future which has completely if isTxn = false. Or a future return by takeSnapshot.
    • subscribe

      public CompletableFuture<Consumer> subscribe(SubscriptionOption option)
      Description copied from interface: Topic
      Subscribe a topic.
      Specified by:
      subscribe in interface Topic
      Returns:
    • subscribe

      public CompletableFuture<Consumer> subscribe(TransportCnx cnx, String subscriptionName, long consumerId, org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subType, int priorityLevel, String consumerName, boolean isDurable, org.apache.pulsar.client.api.MessageId startMessageId, Map<String,String> metadata, boolean readCompacted, org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition initialPosition, long resetStartMessageBackInSec, boolean replicateSubscriptionState, org.apache.pulsar.common.api.proto.KeySharedMeta keySharedMeta)
      Specified by:
      subscribe in interface Topic
    • createSubscription

      public CompletableFuture<Subscription> createSubscription(String subscriptionName, org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition initialPosition, boolean replicateSubscriptionState, Map<String,String> properties)
      Specified by:
      createSubscription in interface Topic
    • delete

      public CompletableFuture<Void> delete()
      Specified by:
      delete in interface Topic
    • deleteForcefully

      public CompletableFuture<Void> deleteForcefully()
      Forcefully close all producers/consumers/replicators and deletes the topic.
      Specified by:
      deleteForcefully in interface Topic
      Returns:
    • close

      public CompletableFuture<Void> close(boolean closeWithoutWaitingClientDisconnect)
      Close this topic - close all producers and subscriptions associated with this topic.
      Specified by:
      close in interface Topic
      Parameters:
      closeWithoutWaitingClientDisconnect - don't wait for client disconnect and forcefully close managed-ledger
      Returns:
      Completable future indicating completion of close operation
    • stopReplProducers

      public CompletableFuture<Void> stopReplProducers()
    • checkReplication

      public CompletableFuture<Void> checkReplication()
      Specified by:
      checkReplication in interface Topic
    • addReplicationCluster

      protected CompletableFuture<Void> addReplicationCluster(String remoteCluster, NonPersistentTopic nonPersistentTopic, String localCluster)
    • checkMessageExpiry

      public void checkMessageExpiry()
      Specified by:
      checkMessageExpiry in interface Topic
    • getNumberOfConsumers

      public int getNumberOfConsumers()
      Specified by:
      getNumberOfConsumers in class AbstractTopic
    • getNumberOfSameAddressConsumers

      public int getNumberOfSameAddressConsumers(String clientAddress)
      Specified by:
      getNumberOfSameAddressConsumers in class AbstractTopic
    • getSubscriptions

      public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentSubscription> getSubscriptions()
      Specified by:
      getSubscriptions in interface Topic
    • getReplicators

      public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentReplicator> getReplicators()
      Specified by:
      getReplicators in interface Topic
    • getShadowReplicators

      public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,? extends Replicator> getShadowReplicators()
      Specified by:
      getShadowReplicators in interface Topic
    • getSubscription

      public Subscription getSubscription(String subscription)
      Specified by:
      getSubscription in interface Topic
    • getPersistentReplicator

      public Replicator getPersistentReplicator(String remoteCluster)
    • updateRates

      public void updateRates(NamespaceStats nsStats, org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats bundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics replStats, String namespace, boolean hydratePublishers)
      Specified by:
      updateRates in interface Topic
    • getStats

      public org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl getStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog)
      Specified by:
      getStats in interface Topic
    • asyncGetStats

      public CompletableFuture<org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl> asyncGetStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog)
      Specified by:
      asyncGetStats in interface Topic
    • getInternalStats

      public CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats> getInternalStats(boolean includeLedgerMetadata)
      Specified by:
      getInternalStats in interface Topic
    • isActive

      public boolean isActive()
    • checkClusterMigration

      public CompletableFuture<Void> checkClusterMigration()
      Specified by:
      checkClusterMigration in interface Topic
    • checkGC

      public void checkGC()
      Specified by:
      checkGC in interface Topic
    • checkInactiveSubscriptions

      public void checkInactiveSubscriptions()
      Specified by:
      checkInactiveSubscriptions in interface Topic
    • checkBackloggedCursors

      public void checkBackloggedCursors()
      Description copied from interface: Topic
      Activate cursors those caught up backlog-threshold entries and deactivate slow cursors which are creating backlog.
      Specified by:
      checkBackloggedCursors in interface Topic
    • checkCursorsToCacheEntries

      public void checkCursorsToCacheEntries()
      Specified by:
      checkCursorsToCacheEntries in interface Topic
    • checkDeduplicationSnapshot

      public void checkDeduplicationSnapshot()
      Specified by:
      checkDeduplicationSnapshot in interface Topic
    • onPoliciesUpdate

      public CompletableFuture<Void> onPoliciesUpdate(org.apache.pulsar.common.policies.data.Policies data)
      Specified by:
      onPoliciesUpdate in interface Topic
    • onUpdate

      public void onUpdate(org.apache.pulsar.common.policies.data.TopicPolicies data)
      Specified by:
      onUpdate in interface TopicPolicyListener<org.apache.pulsar.common.policies.data.TopicPolicies>
    • getBacklogQuota

      public org.apache.pulsar.common.policies.data.BacklogQuota getBacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType)
      Specified by:
      getBacklogQuota in interface Topic
      Returns:
      Backlog quota for topic
    • checkBacklogQuotaExceeded

      public CompletableFuture<Void> checkBacklogQuotaExceeded(String producerName, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType)
      Specified by:
      checkBacklogQuotaExceeded in interface Topic
      Returns:
      quota exceeded status for blocking producer creation
    • isReplicated

      public boolean isReplicated()
      Specified by:
      isReplicated in interface Topic
    • isShadowReplicated

      public boolean isShadowReplicated()
      Specified by:
      isShadowReplicated in interface Topic
    • unsubscribe

      public CompletableFuture<Void> unsubscribe(String subscriptionName)
      Specified by:
      unsubscribe in interface Topic
    • getLastPosition

      public Position getLastPosition()
      Specified by:
      getLastPosition in interface Topic
    • getLastMessageId

      public CompletableFuture<org.apache.pulsar.client.api.MessageId> getLastMessageId()
      Specified by:
      getLastMessageId in interface Topic
    • addSchemaIfIdleOrCheckCompatible

      public CompletableFuture<Void> addSchemaIfIdleOrCheckCompatible(org.apache.pulsar.common.protocol.schema.SchemaData schema)
      Description copied from interface: Topic
      If the topic is idle (no producers, no entries, no subscribers and no existing schema), add the passed schema to the topic. Otherwise, check that the passed schema is compatible with what the topic already has.
      Specified by:
      addSchemaIfIdleOrCheckCompatible in interface Topic
    • publishTxnMessage

      public void publishTxnMessage(org.apache.pulsar.client.api.transaction.TxnID txnID, io.netty.buffer.ByteBuf headersAndPayload, Topic.PublishContext publishContext)
      Description copied from interface: Topic
      Publish Transaction message to this Topic's TransactionBuffer.
      Specified by:
      publishTxnMessage in interface Topic
      Parameters:
      txnID - Transaction Id
      headersAndPayload - Message data
      publishContext - Publish context
    • endTxn

      public CompletableFuture<Void> endTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, int txnAction, long lowWaterMark)
      Description copied from interface: Topic
      End the transaction in this topic.
      Specified by:
      endTxn in interface Topic
      Parameters:
      txnID - Transaction id
      txnAction - Transaction action.
      lowWaterMark - low water mark of this tc
      Returns:
    • truncate

      public CompletableFuture<Void> truncate()
      Description copied from interface: Topic
      Truncate a topic. The truncate operation will move all cursors to the end of the topic and delete all inactive ledgers.
      Specified by:
      truncate in interface Topic
      Returns:
    • isTerminated

      protected boolean isTerminated()
      Specified by:
      isTerminated in class AbstractTopic
    • isMigrated

      protected boolean isMigrated()
      Specified by:
      isMigrated in class AbstractTopic
    • isPersistent

      public boolean isPersistent()
      Specified by:
      isPersistent in interface Topic
    • getBestEffortOldestUnacknowledgedMessageAgeSeconds

      public long getBestEffortOldestUnacknowledgedMessageAgeSeconds()
      Description copied from interface: Topic
      Uses the best-effort (not necessarily up-to-date) information available to return the age.
      Specified by:
      getBestEffortOldestUnacknowledgedMessageAgeSeconds in interface Topic
      Returns:
      The oldest unacknowledged message age in seconds, or -1 if not available