Package org.apache.pulsar.broker.service
Interface Topic
- All Known Implementing Classes:
AbstractTopic,NonPersistentTopic,PersistentTopic,SystemTopic
public interface Topic
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionaddProducer(Producer producer, CompletableFuture<Void> producerQueuedFuture) Tries to add a producer to the topic.CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion>addSchema(org.apache.pulsar.common.protocol.schema.SchemaData schema) Add a schema to the topic.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<? extends org.apache.pulsar.common.policies.data.stats.TopicStatsImpl>asyncGetStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) CompletableFuture<? extends org.apache.pulsar.common.policies.data.stats.TopicStatsImpl>asyncGetStats(GetStatsOptions getStatsOptions) 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()Wait TransactionBuffer recovers completely.voidvoidvoidcheckSchemaCompatibleForConsumer(org.apache.pulsar.common.protocol.schema.SchemaData schema) Check if schema is compatible with current topic schema.close(boolean closeWithoutWaitingClientDisconnect) close(boolean disconnectClients, boolean closeWithoutWaitingClientDisconnect) createSubscription(String subscriptionName, org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition initialPosition, boolean replicateSubscriptionState, Map<String, String> properties) delete()CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion>Delete the schema if this topic has a schema defined for it.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) longUses the best-effort (not necessarily up-to-date) information available to return the age.default Optional<DispatchRateLimiter>Get BrokerService.default Optional<DispatchRateLimiter>org.apache.pulsar.common.policies.data.EntryFiltersorg.apache.pulsar.common.policies.data.HierarchyTopicPoliciesGet HierarchyTopicPolicies.CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats>getInternalStats(boolean includeLedgerMetadata) default CompletableFuture<Position>Get the last message position that can be dispatch.CompletableFuture<org.apache.pulsar.client.api.MessageId>getName()Map<String,? extends Replicator> booleanMap<String,? extends Replicator> org.apache.pulsar.common.policies.data.stats.TopicStatsImplgetStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) org.apache.pulsar.common.policies.data.stats.TopicStatsImplgetStats(GetStatsOptions getStatsOptions) default Optional<SubscribeRateLimiter>getSubscription(String subscription) Map<String,? extends Subscription> Get OpenTelemetry attribute set.Whether a topic has had a schema defined for it.longincrease the publishing limited times.voidincrementPublishCount(Producer producer, int numOfMessages, long msgSizeInBytes) default booleanIndicate if the current topic enabled server side deduplication.booleanbooleanbooleanbooleanbooleandefault booleanbooleanonPoliciesUpdate(org.apache.pulsar.common.policies.data.Policies data) voidpublishMessage(io.netty.buffer.ByteBuf headersAndPayload, 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.voidrecordAddLatency(long latency, TimeUnit unit) record add-latency.voidremoveProducer(Producer producer) booleansubscribe(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 startMessageRollbackDurationSec, boolean replicateSubscriptionState, org.apache.pulsar.common.api.proto.KeySharedMeta keySharedMeta) Deprecated.truncate()Truncate a topic.unsubscribe(String subName) voidupdateRates(NamespaceStats nsStats, org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats currentBundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics clusterReplicationMetrics, String namespaceName, boolean hydratePublishers)
-
Method Details
-
initialize
CompletableFuture<Void> initialize() -
publishMessage
-
addProducer
CompletableFuture<Optional<Long>> addProducer(Producer producer, CompletableFuture<Void> producerQueuedFuture) Tries to add a producer to the topic. Several validations will be performed.- Parameters:
producer- Producer to addproducerQueuedFuture- 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
-
removeProducer
-
checkIfTransactionBufferRecoverCompletely
CompletableFuture<Void> checkIfTransactionBufferRecoverCompletely()Wait TransactionBuffer recovers completely.- Returns:
- a future that will be completed after the transaction buffer recover completely.
-
recordAddLatency
record add-latency. -
increasePublishLimitedTimes
long increasePublishLimitedTimes()increase the publishing limited times. -
subscribe
Subscribe a topic.- Parameters:
option-- Returns:
-
createSubscription
CompletableFuture<Subscription> createSubscription(String subscriptionName, org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition initialPosition, boolean replicateSubscriptionState, Map<String, String> properties) -
unsubscribe
-
getSubscriptions
Map<String,? extends Subscription> getSubscriptions() -
delete
CompletableFuture<Void> delete() -
getProducers
-
getName
String getName() -
checkReplication
CompletableFuture<Void> checkReplication() -
close
-
close
CompletableFuture<Void> close(boolean disconnectClients, boolean closeWithoutWaitingClientDisconnect) -
checkGC
void checkGC() -
checkClusterMigration
CompletableFuture<Void> checkClusterMigration() -
checkInactiveSubscriptions
void checkInactiveSubscriptions() -
checkBackloggedCursors
void checkBackloggedCursors()Activate cursors those caught up backlog-threshold entries and deactivate slow cursors which are creating backlog. -
checkCursorsToCacheEntries
void checkCursorsToCacheEntries() -
isDeduplicationEnabled
default boolean isDeduplicationEnabled()Indicate if the current topic enabled server side deduplication. This is a dynamic configuration, user may update it by namespace/topic policies.- Returns:
- whether enabled server side deduplication
-
checkDeduplicationSnapshot
void checkDeduplicationSnapshot() -
checkMessageExpiry
void checkMessageExpiry() -
checkMessageDeduplicationInfo
void checkMessageDeduplicationInfo() -
incrementPublishCount
-
shouldProducerMigrate
boolean shouldProducerMigrate() -
isReplicationBacklogExist
boolean isReplicationBacklogExist() -
onPoliciesUpdate
-
checkBacklogQuotaExceeded
CompletableFuture<Void> checkBacklogQuotaExceeded(String producerName, org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) -
isEncryptionRequired
boolean isEncryptionRequired() -
getSchemaValidationEnforced
boolean getSchemaValidationEnforced() -
isReplicated
boolean isReplicated() -
isShadowReplicated
boolean isShadowReplicated() -
getEntryFiltersPolicy
org.apache.pulsar.common.policies.data.EntryFilters getEntryFiltersPolicy() -
getEntryFilters
List<EntryFilter> getEntryFilters() -
getBacklogQuota
org.apache.pulsar.common.policies.data.BacklogQuota getBacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType backlogQuotaType) -
getBestEffortOldestUnacknowledgedMessageAgeSeconds
long getBestEffortOldestUnacknowledgedMessageAgeSeconds()Uses the best-effort (not necessarily up-to-date) information available to return the age.- Returns:
- The oldest unacknowledged message age in seconds, or -1 if not available
-
updateRates
void updateRates(NamespaceStats nsStats, org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats currentBundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics clusterReplicationMetrics, String namespaceName, boolean hydratePublishers) -
getSubscription
-
getReplicators
Map<String,? extends Replicator> getReplicators() -
getShadowReplicators
Map<String,? extends Replicator> getShadowReplicators() -
getStats
org.apache.pulsar.common.policies.data.stats.TopicStatsImpl getStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) -
getStats
org.apache.pulsar.common.policies.data.stats.TopicStatsImpl getStats(GetStatsOptions getStatsOptions) -
asyncGetStats
CompletableFuture<? extends org.apache.pulsar.common.policies.data.stats.TopicStatsImpl> asyncGetStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) -
asyncGetStats
CompletableFuture<? extends org.apache.pulsar.common.policies.data.stats.TopicStatsImpl> asyncGetStats(GetStatsOptions getStatsOptions) -
getInternalStats
CompletableFuture<org.apache.pulsar.common.policies.data.PersistentTopicInternalStats> getInternalStats(boolean includeLedgerMetadata) -
getLastPosition
Position getLastPosition() -
getLastDispatchablePosition
Get the last message position that can be dispatch. -
getLastMessageId
CompletableFuture<org.apache.pulsar.client.api.MessageId> getLastMessageId() -
hasSchema
CompletableFuture<Boolean> hasSchema()Whether a topic has had a schema defined for it. -
addSchema
CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> addSchema(org.apache.pulsar.common.protocol.schema.SchemaData schema) Add a schema to the topic. This will fail if the new schema is incompatible with the current schema. -
deleteSchema
CompletableFuture<org.apache.pulsar.common.protocol.schema.SchemaVersion> deleteSchema()Delete the schema if this topic has a schema defined for it. -
checkSchemaCompatibleForConsumer
CompletableFuture<Void> checkSchemaCompatibleForConsumer(org.apache.pulsar.common.protocol.schema.SchemaData schema) Check if schema is compatible with current topic schema. -
addSchemaIfIdleOrCheckCompatible
CompletableFuture<Void> 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. Otherwise, check that the passed schema is compatible with what the topic already has. -
deleteForcefully
CompletableFuture<Void> deleteForcefully() -
getDispatchRateLimiter
-
getSubscribeRateLimiter
-
getBrokerDispatchRateLimiter
-
isSystemTopic
default boolean isSystemTopic() -
isPersistent
boolean isPersistent() -
isTransferring
boolean isTransferring() -
publishTxnMessage
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.- Parameters:
txnID- Transaction IdheadersAndPayload- Message datapublishContext- Publish context
-
endTxn
CompletableFuture<Void> endTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, int txnAction, long lowWaterMark) End the transaction in this topic.- Parameters:
txnID- Transaction idtxnAction- Transaction action.lowWaterMark- low water mark of this tc- Returns:
-
truncate
CompletableFuture<Void> truncate()Truncate a topic. The truncate operation will move all cursors to the end of the topic and delete all inactive ledgers.- Returns:
-
getBrokerService
BrokerService getBrokerService()Get BrokerService.- Returns:
-
getHierarchyTopicPolicies
org.apache.pulsar.common.policies.data.HierarchyTopicPolicies getHierarchyTopicPolicies()Get HierarchyTopicPolicies.- Returns:
-
getTopicAttributes
TopicAttributes getTopicAttributes()Get OpenTelemetry attribute set.- Returns:
-