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, hasBatchMessagePublished, isAllowAutoUpdateSchema, isEncryptionRequired, isFenced, lastActive, lock, msgOutFromRemovedSubscriptions, POLICY_UPDATE_FAILURE_RETRY_TIME_SECONDS, preciseTopicPublishRateLimitingEnable, producers, publishRateLimitedTimes, replicatorPrefix, resourceGroupPublishLimiter, resourceGroupRateLimitingEnabled, topic, topicEpoch, topicPolicies, topicPublishRateLimiter -
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) voidActivate 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) voidvoidvoidcheckGC()checkIfTransactionBufferRecoverCompletely(boolean isTxnEnabled) Wait TransactionBuffer Recovers completely.voidvoidvoidclose(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.BacklogQuotagetBacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats>getInternalStats(boolean includeLedgerMetadata) CompletableFuture<org.apache.pulsar.client.api.MessageId>org.apache.bookkeeper.mledger.PositionintintgetNumberOfSameAddressConsumers(String clientAddress) getPersistentReplicator(String remoteCluster) org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentReplicator> org.apache.pulsar.common.policies.data.stats.NonPersistentTopicStatsImplgetStats(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) booleanisActive()booleanbooleanprotected booleanonPoliciesUpdate(org.apache.pulsar.common.policies.data.Policies data) voidonUpdate(org.apache.pulsar.common.policies.data.TopicPolicies data) voidpublishMessage(io.netty.buffer.ByteBuf data, Topic.PublishContext callback) voidpublishTxnMessage(org.apache.pulsar.client.api.transaction.TxnID txnID, io.netty.buffer.ByteBuf headersAndPayload, Topic.PublishContext publishContext) Publish Transaction message to this Topic's TransactionBuffer.voidremoveProducer(Producer producer) 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) voidupdateRates(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, enableProducerReadForPublishBufferLimiting, enableProducerReadForPublishRateLimiting, getActiveConsumer, getBrokerPublishRateLimiter, getBrokerService, getBytesInCounter, getBytesOutCounter, getDispatchRate, getFilteredEntriesCount, getHierarchyTopicPolicies, getInactiveTopicPolicies, getMsgInCounter, getMsgOutCounter, getName, getNumberOfSameAddressConsumers, getNumberOfSameAddressProducers, getProducers, getReplicatorDispatchRate, getReplicatorPrefix, getSchemaCompatibilityStrategy, getSchemaValidationEnforced, getSubscribeRate, getSubscriptionDispatchRate, getTopicPolicies, getTopicPublishRateLimiter, getWaitingProducersCount, handleConsumerAdded, handleProducerRemoved, hasLocalProducers, hasSchema, increasePublishLimitedTimes, incrementPublishCount, incrementTopicEpochIfNeeded, internalAddProducer, isBrokerPublishRateExceeded, isConsumersExceededOnTopic, isDeleteWhileInactive, isEncryptionRequired, isExceedMaximumMessageSize, isProducersExceeded, isPublishRateExceeded, isResourceGroupPublishRateExceeded, isResourceGroupRateLimitingEnabled, isSameAddressConsumersExceededOnTopic, isSameAddressProducersExceeded, isTopicPublishRateExceeded, markBatchMessagePublished, recordAddLatency, registerTopicPolicyListener, resetBrokerPublishCountAndEnableReadIfRequired, resetTopicPublishCountAndEnableReadIfRequired, toString, unregisterTopicPolicyListener, updateBrokerDispatchRate, updateBrokerPublishRate, updateBrokerReplicatorDispatchRate, updateBrokerSubscribeRate, updateBrokerSubscriptionDispatchRate, updateBrokerSubscriptionTypesEnabled, updateDispatchRateLimiter, updatePublishDispatcher, updateResourceGroupLimiter, updateTopicPolicy, updateTopicPolicyByNamespacePolicyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.service.Topic
addProducer, addSchema, checkSchemaCompatibleForConsumer, checkTopicPublishThrottlingRate, deleteSchema, disableCnxAutoRead, enableCnxAutoRead, getBrokerDispatchRateLimiter, getBrokerService, getDispatchRateLimiter, getHierarchyTopicPolicies, getName, getProducers, getSchemaValidationEnforced, getSubscribeRateLimiter, hasSchema, increasePublishLimitedTimes, incrementPublishCount, isBrokerPublishRateExceeded, isEncryptionRequired, isPublishRateExceeded, isResourceGroupPublishRateExceeded, isResourceGroupRateLimitingEnabled, isSystemTopic, isTopicPublishRateExceeded, recordAddLatency, resetBrokerPublishCountAndEnableReadIfRequired, resetTopicPublishCountAndEnableReadIfRequired
-
Constructor Details
-
NonPersistentTopic
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceTopic
-
publishMessage
- Specified by:
publishMessagein interfaceTopic
-
incrementTopicEpoch
- Specified by:
incrementTopicEpochin classAbstractTopic
-
setTopicEpoch
- Specified by:
setTopicEpochin classAbstractTopic
-
checkMessageDeduplicationInfo
public void checkMessageDeduplicationInfo()- Specified by:
checkMessageDeduplicationInfoin interfaceTopic
-
removeProducer
- Specified by:
removeProducerin interfaceTopic- Overrides:
removeProducerin classAbstractTopic
-
checkIfTransactionBufferRecoverCompletely
Description copied from interface:TopicWait TransactionBuffer Recovers completely. Take snapshot after TB Recovers completely.- Specified by:
checkIfTransactionBufferRecoverCompletelyin interfaceTopic- Returns:
- a future which has completely if isTxn = false. Or a future return by takeSnapshot.
-
subscribe
Description copied from interface:TopicSubscribe 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:
createSubscriptionin interfaceTopic
-
delete
-
deleteForcefully
Forcefully close all producers/consumers/replicators and deletes the topic.- Specified by:
deleteForcefullyin interfaceTopic- Returns:
-
close
Close this topic - close all producers and subscriptions associated with this topic. -
stopReplProducers
-
checkReplication
- Specified by:
checkReplicationin interfaceTopic
-
addReplicationCluster
protected CompletableFuture<Void> addReplicationCluster(String remoteCluster, NonPersistentTopic nonPersistentTopic, String localCluster) -
checkMessageExpiry
public void checkMessageExpiry()- Specified by:
checkMessageExpiryin interfaceTopic
-
getNumberOfConsumers
public int getNumberOfConsumers()- Specified by:
getNumberOfConsumersin classAbstractTopic
-
getNumberOfSameAddressConsumers
- Specified by:
getNumberOfSameAddressConsumersin classAbstractTopic
-
getSubscriptions
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentSubscription> getSubscriptions()- Specified by:
getSubscriptionsin interfaceTopic
-
getReplicators
public org.apache.pulsar.common.util.collections.ConcurrentOpenHashMap<String,NonPersistentReplicator> getReplicators()- Specified by:
getReplicatorsin interfaceTopic
-
getSubscription
- Specified by:
getSubscriptionin 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:
updateRatesin 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:
asyncGetStatsin interfaceTopic
-
getInternalStats
public CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats> getInternalStats(boolean includeLedgerMetadata) - Specified by:
getInternalStatsin interfaceTopic
-
isActive
public boolean isActive() -
checkGC
public void checkGC() -
checkInactiveSubscriptions
public void checkInactiveSubscriptions()- Specified by:
checkInactiveSubscriptionsin interfaceTopic
-
checkBackloggedCursors
public void checkBackloggedCursors()Description copied from interface:TopicActivate cursors those caught up backlog-threshold entries and deactivate slow cursors which are creating backlog.- Specified by:
checkBackloggedCursorsin interfaceTopic
-
checkCursorsToCacheEntries
public void checkCursorsToCacheEntries()- Specified by:
checkCursorsToCacheEntriesin interfaceTopic
-
checkDeduplicationSnapshot
public void checkDeduplicationSnapshot()- Specified by:
checkDeduplicationSnapshotin interfaceTopic
-
onPoliciesUpdate
public CompletableFuture<Void> onPoliciesUpdate(org.apache.pulsar.common.policies.data.Policies data) - Specified by:
onPoliciesUpdatein interfaceTopic
-
onUpdate
public void onUpdate(org.apache.pulsar.common.policies.data.TopicPolicies data) - Specified by:
onUpdatein 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:
getBacklogQuotain interfaceTopic- Returns:
- Backlog quota for topic
-
checkBacklogQuotaExceeded
public CompletableFuture<Void> checkBacklogQuotaExceeded(String producerName, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) - Specified by:
checkBacklogQuotaExceededin interfaceTopic- Returns:
- quota exceeded status for blocking producer creation
-
isReplicated
public boolean isReplicated()- Specified by:
isReplicatedin interfaceTopic
-
unsubscribe
- Specified by:
unsubscribein interfaceTopic
-
getLastPosition
public org.apache.bookkeeper.mledger.Position getLastPosition()- Specified by:
getLastPositionin interfaceTopic
-
getLastMessageId
- Specified by:
getLastMessageIdin interfaceTopic
-
addSchemaIfIdleOrCheckCompatible
public CompletableFuture<Void> addSchemaIfIdleOrCheckCompatible(org.apache.pulsar.common.protocol.schema.SchemaData schema) Description copied from interface:TopicIf 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:
addSchemaIfIdleOrCheckCompatiblein 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:TopicPublish Transaction message to this Topic's TransactionBuffer.- Specified by:
publishTxnMessagein 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:TopicEnd the transaction in this topic. -
truncate
Description copied from interface:TopicTruncate 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:
isTerminatedin classAbstractTopic
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistentin interfaceTopic
-