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>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pulsar.broker.service.Topic
Topic.PublishContext
-
Field Summary
Fields inherited from class org.apache.pulsar.broker.service.AbstractTopic
addEntryLatencyStatsUsec, brokerService, bytesOutFromRemovedSubscriptions, createFuture, entryFilters, hasBatchMessagePublished, isAllowAutoUpdateSchema, isEncryptionRequired, isFenced, lastActive, lock, msgOutFromRemovedSubscriptions, POLICY_UPDATE_FAILURE_RETRY_TIME_SECONDS, preciseTopicPublishRateLimitingEnable, producers, publishRateLimitedTimes, replicatorPrefix, resourceGroupPublishLimiter, resourceGroupRateLimitingEnabled, topic, topicEpoch, topicPolicies, topicPublishRateLimiter, userCreatedProducerCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletableFuture<Void>
addReplicationCluster
(String remoteCluster, NonPersistentTopic nonPersistentTopic, String localCluster) addSchemaIfIdleOrCheckCompatible
(org.apache.pulsar.common.protocol.schema.SchemaData schema) If the topic is idle (no producers, no entries, no subscribers and no existing schema), add the passed schema to the topic.CompletableFuture<org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl>
asyncGetStats
(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) void
Activate cursors those caught up backlog-threshold entries and deactivate slow cursors which are creating backlog.checkBacklogQuotaExceeded
(String producerName, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) void
void
void
checkGC()
checkIfTransactionBufferRecoverCompletely
(boolean isTxnEnabled) Wait TransactionBuffer Recovers completely.void
void
void
close
(boolean closeWithoutWaitingClientDisconnect) Close this topic - close all producers and subscriptions associated with this topic.createSubscription
(String subscriptionName, org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition initialPosition, boolean replicateSubscriptionState, Map<String, String> properties) delete()
Forcefully close all producers/consumers/replicators and deletes the topic.endTxn
(org.apache.pulsar.client.api.transaction.TxnID txnID, int txnAction, long lowWaterMark) End the transaction in this topic.org.apache.pulsar.common.policies.data.BacklogQuota
getBacklogQuota
(org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) long
Uses the best-effort (not necessarily up-to-date) information available to return the age.CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats>
getInternalStats
(boolean includeLedgerMetadata) CompletableFuture<org.apache.pulsar.client.api.MessageId>
int
int
getNumberOfSameAddressConsumers
(String clientAddress) getPersistentReplicator
(String remoteCluster) org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,
NonPersistentReplicator> org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,
? extends Replicator> org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl
getStats
(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) getSubscription
(String subscription) org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,
NonPersistentSubscription> protected CompletableFuture<Long>
incrementTopicEpoch
(Optional<Long> currentEpoch) boolean
isActive()
protected boolean
boolean
boolean
boolean
boolean
protected boolean
onPoliciesUpdate
(org.apache.pulsar.common.policies.data.Policies data) void
onUpdate
(org.apache.pulsar.common.policies.data.TopicPolicies data) void
publishMessage
(io.netty.buffer.ByteBuf data, Topic.PublishContext callback) void
publishTxnMessage
(org.apache.pulsar.client.api.transaction.TxnID txnID, io.netty.buffer.ByteBuf headersAndPayload, Topic.PublishContext publishContext) Publish Transaction message to this Topic's TransactionBuffer.protected CompletableFuture<Long>
setTopicEpoch
(long newEpoch) subscribe
(SubscriptionOption option) Subscribe a topic.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) truncate()
Truncate a topic.unsubscribe
(String subscriptionName) void
updateRates
(NamespaceStats nsStats, org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats bundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics replStats, String namespace, boolean hydratePublishers) Methods inherited from class org.apache.pulsar.broker.service.AbstractTopic
addConsumerToSubscription, addFilteredEntriesCount, addProducer, addSchema, checkSchemaCompatibleForConsumer, checkTopicFenced, checkTopicPublishThrottlingRate, currentUsageCount, decrementUsageCount, deletePartitionedTopicMetadataWhileInactive, deleteSchema, deleteTopicPolicies, disableCnxAutoRead, disableProducerRead, enableCnxAutoRead, enableProducerReadForPublishRateLimiting, getActiveConsumer, getBrokerPublishRateLimiter, getBrokerService, getBytesInCounter, getBytesOutCounter, getDispatchRate, getEntryFilters, getEntryFiltersPolicy, getFilteredEntriesCount, getHierarchyTopicPolicies, getInactiveTopicPolicies, getMigratedClusterUrl, getMigratedClusterUrl, getMigratedClusterUrlAsync, getMsgInCounter, getMsgOutCounter, getName, getNumberOfSameAddressConsumers, getNumberOfSameAddressProducers, getProducers, getReplicatorDispatchRate, getReplicatorPrefix, getSchemaCompatibilityStrategy, getSchemaId, getSchemaValidationEnforced, getSubscribeRate, getSubscriptionDispatchRate, getTopicPolicies, getTopicPublishRateLimiter, getWaitingProducersCount, handleConsumerAdded, handleProducerRemoved, hasLocalProducers, hasSchema, increasePublishLimitedTimes, incrementPublishCount, incrementTopicEpochIfNeeded, internalAddProducer, isBrokerPublishRateExceeded, isConsumersExceededOnTopic, isDeleteWhileInactive, isEncryptionRequired, isExceedMaximumMessageSize, isProducersExceeded, isProducersExceeded, isProducersExceeded, isPublishRateExceeded, isResourceGroupPublishRateExceeded, isResourceGroupRateLimitingEnabled, isSameAddressConsumersExceededOnTopic, isSameAddressProducersExceeded, isTopicPublishRateExceeded, markBatchMessagePublished, recordAddLatency, registerTopicPolicyListener, removeProducer, resetBrokerPublishCountAndEnableReadIfRequired, resetTopicPublishCountAndEnableReadIfRequired, toString, unregisterTopicPolicyListener, updateBrokerDispatchRate, updateBrokerPublishRate, updateBrokerReplicatorDispatchRate, updateBrokerSubscribeRate, updateBrokerSubscriptionDispatchRate, updateBrokerSubscriptionTypesEnabled, updateDispatchRateLimiter, updateEntryFilters, updatePublishRateLimiter, updateResourceGroupLimiter, updateResourceGroupLimiter, updateTopicPolicy, updateTopicPolicyByNamespacePolicy
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.pulsar.broker.service.Topic
addProducer, addSchema, checkSchemaCompatibleForConsumer, checkTopicPublishThrottlingRate, deleteSchema, disableCnxAutoRead, enableCnxAutoRead, getBrokerDispatchRateLimiter, getBrokerService, getDispatchRateLimiter, getEntryFilters, getEntryFiltersPolicy, getHierarchyTopicPolicies, getLastDispatchablePosition, getName, getProducers, getSchemaValidationEnforced, getSubscribeRateLimiter, hasSchema, increasePublishLimitedTimes, incrementPublishCount, isBrokerPublishRateExceeded, isDeduplicationEnabled, isEncryptionRequired, isPublishRateExceeded, isResourceGroupPublishRateExceeded, isResourceGroupRateLimitingEnabled, isSystemTopic, isTopicPublishRateExceeded, recordAddLatency, removeProducer, resetBrokerPublishCountAndEnableReadIfRequired, resetTopicPublishCountAndEnableReadIfRequired
-
Constructor Details
-
NonPersistentTopic
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceTopic
-
publishMessage
- Specified by:
publishMessage
in interfaceTopic
-
incrementTopicEpoch
- Specified by:
incrementTopicEpoch
in classAbstractTopic
-
setTopicEpoch
- Specified by:
setTopicEpoch
in classAbstractTopic
-
checkMessageDeduplicationInfo
public void checkMessageDeduplicationInfo()- Specified by:
checkMessageDeduplicationInfo
in interfaceTopic
-
isReplicationBacklogExist
public boolean isReplicationBacklogExist()- Specified by:
isReplicationBacklogExist
in interfaceTopic
-
checkIfTransactionBufferRecoverCompletely
Description copied from interface:Topic
Wait TransactionBuffer Recovers completely. Take snapshot after TB Recovers completely.- Specified by:
checkIfTransactionBufferRecoverCompletely
in interfaceTopic
- Parameters:
isTxnEnabled
- isTxnEnabled- Returns:
- a future which has completely if isTxn = false. Or a future return by takeSnapshot.
-
subscribe
Description copied from interface:Topic
Subscribe a 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 interfaceTopic
-
delete
-
deleteForcefully
Forcefully close all producers/consumers/replicators and deletes the topic.- Specified by:
deleteForcefully
in interfaceTopic
- Returns:
-
close
Close this topic - close all producers and subscriptions associated with this topic. -
stopReplProducers
-
checkReplication
- Specified by:
checkReplication
in interfaceTopic
-
addReplicationCluster
protected CompletableFuture<Void> addReplicationCluster(String remoteCluster, NonPersistentTopic nonPersistentTopic, String localCluster) -
checkMessageExpiry
public void checkMessageExpiry()- Specified by:
checkMessageExpiry
in interfaceTopic
-
getNumberOfConsumers
public int getNumberOfConsumers()- Specified by:
getNumberOfConsumers
in classAbstractTopic
-
getNumberOfSameAddressConsumers
- Specified by:
getNumberOfSameAddressConsumers
in classAbstractTopic
-
getSubscriptions
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentSubscription> getSubscriptions()- Specified by:
getSubscriptions
in interfaceTopic
-
getReplicators
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentReplicator> getReplicators()- Specified by:
getReplicators
in interfaceTopic
-
getShadowReplicators
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,? extends Replicator> getShadowReplicators()- Specified by:
getShadowReplicators
in interfaceTopic
-
getSubscription
- Specified by:
getSubscription
in interfaceTopic
-
getPersistentReplicator
-
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 interfaceTopic
-
getStats
public org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl getStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) -
asyncGetStats
public CompletableFuture<org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImpl> asyncGetStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) - Specified by:
asyncGetStats
in interfaceTopic
-
getInternalStats
public CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats> getInternalStats(boolean includeLedgerMetadata) - Specified by:
getInternalStats
in interfaceTopic
-
isActive
public boolean isActive() -
checkClusterMigration
- Specified by:
checkClusterMigration
in interfaceTopic
-
checkGC
public void checkGC() -
checkInactiveSubscriptions
public void checkInactiveSubscriptions()- Specified by:
checkInactiveSubscriptions
in interfaceTopic
-
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 interfaceTopic
-
checkCursorsToCacheEntries
public void checkCursorsToCacheEntries()- Specified by:
checkCursorsToCacheEntries
in interfaceTopic
-
checkDeduplicationSnapshot
public void checkDeduplicationSnapshot()- Specified by:
checkDeduplicationSnapshot
in interfaceTopic
-
onPoliciesUpdate
public CompletableFuture<Void> onPoliciesUpdate(org.apache.pulsar.common.policies.data.Policies data) - Specified by:
onPoliciesUpdate
in interfaceTopic
-
onUpdate
public void onUpdate(org.apache.pulsar.common.policies.data.TopicPolicies data) - Specified by:
onUpdate
in interfaceTopicPolicyListener<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 interfaceTopic
- 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 interfaceTopic
- Returns:
- quota exceeded status for blocking producer creation
-
isReplicated
public boolean isReplicated()- Specified by:
isReplicated
in interfaceTopic
-
isShadowReplicated
public boolean isShadowReplicated()- Specified by:
isShadowReplicated
in interfaceTopic
-
unsubscribe
- Specified by:
unsubscribe
in interfaceTopic
-
getLastPosition
- Specified by:
getLastPosition
in interfaceTopic
-
getLastMessageId
- Specified by:
getLastMessageId
in interfaceTopic
-
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 interfaceTopic
-
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 interfaceTopic
- Parameters:
txnID
- Transaction IdheadersAndPayload
- Message datapublishContext
- 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. -
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. -
isTerminated
protected boolean isTerminated()- Specified by:
isTerminated
in classAbstractTopic
-
isMigrated
protected boolean isMigrated()- Specified by:
isMigrated
in classAbstractTopic
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistent
in interfaceTopic
-
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 interfaceTopic
- Returns:
- The oldest unacknowledged message age in seconds, or -1 if not available
-