Interface ScalableTopics
Scalable topics (topic:// domain) are composed of a DAG of hash-range segments that can be dynamically split and merged.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclearBacklog(String topic, String subscription) Skip every undelivered message on the subscription, across every segment in the DAG (advance each per-segment cursor to the end).clearBacklogAsync(String topic, String subscription) Skip every undelivered message on the subscription, asynchronously.clearSegmentSubscriptionBacklogAsync(String segmentTopic, String subscription) Skip every undelivered message on the segment topic's subscription — advance the cursor to the end of the segment.voidcreateScalableTopic(String topic, int numInitialSegments) Create a new scalable topic.voidcreateScalableTopic(String topic, int numInitialSegments, Map<String, String> properties) Create a new scalable topic with properties.createScalableTopicAsync(String topic, int numInitialSegments) Create a new scalable topic asynchronously.createScalableTopicAsync(String topic, int numInitialSegments, Map<String, String> properties) Create a new scalable topic with properties asynchronously.voidcreateSegment(String segmentTopic, List<String> subscriptions) Create a segment topic on the broker that owns its namespace bundle.createSegmentAsync(String segmentTopic, List<String> subscriptions) Create a segment topic asynchronously.createSegmentSubscriptionAsync(String segmentTopic, String subscription) Create a subscription cursor on the given segment topic at the earliest position.voidcreateSubscription(String topic, String subscription, ScalableSubscriptionType type) Create a subscription on a scalable topic.createSubscriptionAsync(String topic, String subscription, ScalableSubscriptionType type) Create a subscription on a scalable topic asynchronously.default voiddeleteScalableTopic(String topic) Delete a scalable topic and all its underlying segment topics.voiddeleteScalableTopic(String topic, boolean force) Delete a scalable topic and all its underlying segment topics.default CompletableFuture<Void> deleteScalableTopicAsync(String topic) Delete a scalable topic and all its underlying segment topics asynchronously.deleteScalableTopicAsync(String topic, boolean force) Delete a scalable topic and all its underlying segment topics asynchronously.voiddeleteSegment(String segmentTopic, boolean force) Delete a segment topic.deleteSegmentAsync(String segmentTopic, boolean force) Delete a segment topic asynchronously.deleteSegmentSubscriptionAsync(String segmentTopic, String subscription) Delete a subscription cursor on the given segment topic.voiddeleteSubscription(String topic, String subscription) Delete a subscription from a scalable topic.deleteSubscriptionAsync(String topic, String subscription) Delete a subscription from a scalable topic asynchronously.getAutoScalePolicy(String topic) Get the per-topic auto split/merge policy override.getAutoScalePolicyAsync(String topic) Get the per-topic auto split/merge policy override asynchronously.getMetadata(String topic) Get scalable topic metadata.getMetadataAsync(String topic) Get scalable topic metadata asynchronously.getSegmentSubscriptionBacklogAsync(String segmentTopic, String subscription) Returns the number of unconsumed entries in the given subscription's cursor on the segment topic — i.e.Get aggregated stats for a scalable topic.getStatsAsync(String topic) Get aggregated stats for a scalable topic asynchronously.listScalableTopics(String namespace) Get the list of scalable topics under a namespace.listScalableTopicsAsync(String namespace) Get the list of scalable topics under a namespace asynchronously.listScalableTopicsByProperties(String namespace, Map<String, String> propertyFilters) Get the list of scalable topics under a namespace whose properties contain every key/value pair inpropertyFilters(AND semantics).listScalableTopicsByPropertiesAsync(String namespace, Map<String, String> propertyFilters) Async variant oflistScalableTopicsByProperties(String, Map).voidmergeSegments(String topic, long segmentId1, long segmentId2) Merge two adjacent segments into one.mergeSegmentsAsync(String topic, long segmentId1, long segmentId2) Merge two adjacent segments into one asynchronously.voidmigrateToScalable(String topic, boolean force) Migrate an existing regular (partitioned or non-partitioned) topic to a scalable topic.migrateToScalableAsync(String topic, boolean force) Migrate an existing regular topic to a scalable topic asynchronously.voidremoveAutoScalePolicy(String topic) Remove the per-topic auto split/merge policy override, letting the namespace policy and broker defaults apply.removeAutoScalePolicyAsync(String topic) Remove the per-topic auto split/merge policy override asynchronously.seekSegmentSubscriptionAsync(String segmentTopic, String subscription, long timestampMs) Reset the segment topic's subscription cursor to the given wall-clock timestamp.voidseekSubscription(String topic, String subscription, long timestampMs) Reset a subscription's cursor across every segment to the given wall-clock timestamp.seekSubscriptionAsync(String topic, String subscription, long timestampMs) Reset a subscription's cursor across every segment, asynchronously.voidsetAutoScalePolicy(String topic, AutoScalePolicyOverride override) Set the per-topic auto split/merge policy override (PIP-483).setAutoScalePolicyAsync(String topic, AutoScalePolicyOverride override) Set the per-topic auto split/merge policy override asynchronously.voidsplitSegment(String topic, long segmentId) Split a segment into two halves.splitSegmentAsync(String topic, long segmentId) Split a segment into two halves asynchronously.voidterminateSegment(String segmentTopic) Terminate a segment topic so that no more messages can be published to it.terminateSegmentAsync(String segmentTopic) Terminate a segment topic asynchronously.
-
Method Details
-
listScalableTopics
Get the list of scalable topics under a namespace.- Parameters:
namespace- Namespace name in the format "tenant/namespace"- Returns:
- list of scalable topic names
- Throws:
PulsarAdminException
-
listScalableTopicsAsync
Get the list of scalable topics under a namespace asynchronously.- Parameters:
namespace- Namespace name in the format "tenant/namespace"- Returns:
- list of scalable topic names
-
listScalableTopicsByProperties
List<String> listScalableTopicsByProperties(String namespace, Map<String, String> propertyFilters) throws PulsarAdminExceptionGet the list of scalable topics under a namespace whose properties contain every key/value pair inpropertyFilters(AND semantics).Backed by the secondary index registered on the topic properties at create/update time. On stores with native index support the lookup uses one filter to narrow the candidate set and verifies the rest on the loaded record; stores without index support fall back to a per-record check.
- Parameters:
namespace- Namespace name in the format "tenant/namespace"propertyFilters- Property names and exact values that all must match- Returns:
- list of matching scalable topic names; an empty filter returns the full namespace listing
- Throws:
PulsarAdminException
-
listScalableTopicsByPropertiesAsync
CompletableFuture<List<String>> listScalableTopicsByPropertiesAsync(String namespace, Map<String, String> propertyFilters) Async variant oflistScalableTopicsByProperties(String, Map). -
createScalableTopic
Create a new scalable topic.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"numInitialSegments- Number of initial segments (must be >= 1)- Throws:
PulsarAdminException
-
createScalableTopicAsync
Create a new scalable topic asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"numInitialSegments- Number of initial segments (must be >= 1)
-
createScalableTopic
void createScalableTopic(String topic, int numInitialSegments, Map<String, String> properties) throws PulsarAdminExceptionCreate a new scalable topic with properties.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"numInitialSegments- Number of initial segments (must be >= 1)properties- Key-value properties for the topic metadata- Throws:
PulsarAdminException
-
createScalableTopicAsync
CompletableFuture<Void> createScalableTopicAsync(String topic, int numInitialSegments, Map<String, String> properties) Create a new scalable topic with properties asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"numInitialSegments- Number of initial segments (must be >= 1)properties- Key-value properties for the topic metadata
-
migrateToScalable
Migrate an existing regular (partitioned or non-partitioned) topic to a scalable topic.The old partitions become sealed parent segments of the new scalable topic and the old topics are terminated; new active segments take over. Fails if the topic is already scalable, if it doesn't exist, or if any legacy v4 client is still connected (unless
forceis set).- Parameters:
topic- Topic name in the format "tenant/namespace/topic"force- Migrate even if legacy v4 clients are still connected- Throws:
PulsarAdminException
-
migrateToScalableAsync
Migrate an existing regular topic to a scalable topic asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"force- Migrate even if legacy v4 clients are still connected
-
getMetadata
Get scalable topic metadata.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Returns:
- the scalable topic metadata including segment DAG
- Throws:
PulsarAdminException
-
getMetadataAsync
Get scalable topic metadata asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Returns:
- the scalable topic metadata including segment DAG
-
setAutoScalePolicy
Set the per-topic auto split/merge policy override (PIP-483). Overrides the namespace policy and the broker defaults for this topic; unset fields fall through.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"override- the override to apply- Throws:
PulsarAdminException
-
setAutoScalePolicyAsync
Set the per-topic auto split/merge policy override asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"override- the override to apply
-
getAutoScalePolicy
Get the per-topic auto split/merge policy override.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Returns:
- the override, or
nullif none is set - Throws:
PulsarAdminException
-
getAutoScalePolicyAsync
Get the per-topic auto split/merge policy override asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Returns:
- the override, or
nullif none is set
-
removeAutoScalePolicy
Remove the per-topic auto split/merge policy override, letting the namespace policy and broker defaults apply.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Throws:
PulsarAdminException
-
removeAutoScalePolicyAsync
Remove the per-topic auto split/merge policy override asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"
-
deleteScalableTopic
Delete a scalable topic and all its underlying segment topics.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"force- Force deletion even if topic has active subscriptions- Throws:
PulsarAdminException
-
deleteScalableTopicAsync
Delete a scalable topic and all its underlying segment topics asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"force- Force deletion even if topic has active subscriptions
-
deleteScalableTopic
Delete a scalable topic and all its underlying segment topics.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Throws:
PulsarAdminException
-
deleteScalableTopicAsync
Delete a scalable topic and all its underlying segment topics asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"
-
getStats
Get aggregated stats for a scalable topic.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"- Returns:
- stats including segment counts, per-segment layout info, and per-subscription consumer counts
- Throws:
PulsarAdminException
-
getStatsAsync
Get aggregated stats for a scalable topic asynchronously. -
createSubscription
void createSubscription(String topic, String subscription, ScalableSubscriptionType type) throws PulsarAdminException Create a subscription on a scalable topic. The controller leader propagates the subscription to all active segment topics.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"subscription- Name of the subscription to createtype- Subscription type:ScalableSubscriptionType.STREAMfor controller-managed ordered subscriptions, orScalableSubscriptionType.QUEUEfor unordered per-segment fan-out.- Throws:
PulsarAdminException
-
createSubscriptionAsync
CompletableFuture<Void> createSubscriptionAsync(String topic, String subscription, ScalableSubscriptionType type) Create a subscription on a scalable topic asynchronously. -
deleteSubscription
Delete a subscription from a scalable topic. Unregisters all consumers and removes the subscription from every segment topic.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"subscription- Name of the subscription to delete- Throws:
PulsarAdminException
-
deleteSubscriptionAsync
Delete a subscription from a scalable topic asynchronously. -
seekSubscription
void seekSubscription(String topic, String subscription, long timestampMs) throws PulsarAdminException Reset a subscription's cursor across every segment to the given wall-clock timestamp. The controller uses each segment's recorded sealed-time window to dispatch the cheapest per-segment op.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"subscription- Subscription nametimestampMs- Wall-clock millis since the unix epoch- Throws:
PulsarAdminException
-
seekSubscriptionAsync
Reset a subscription's cursor across every segment, asynchronously. -
clearBacklog
Skip every undelivered message on the subscription, across every segment in the DAG (advance each per-segment cursor to the end).- Parameters:
topic- Topic name in the format "tenant/namespace/topic"subscription- Subscription name- Throws:
PulsarAdminException
-
clearBacklogAsync
Skip every undelivered message on the subscription, asynchronously. -
splitSegment
Split a segment into two halves.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"segmentId- ID of the segment to split- Throws:
PulsarAdminException
-
splitSegmentAsync
Split a segment into two halves asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"segmentId- ID of the segment to split
-
mergeSegments
Merge two adjacent segments into one.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"segmentId1- First segment ID to mergesegmentId2- Second segment ID to merge- Throws:
PulsarAdminException
-
mergeSegmentsAsync
Merge two adjacent segments into one asynchronously.- Parameters:
topic- Topic name in the format "tenant/namespace/topic"segmentId1- First segment ID to mergesegmentId2- Second segment ID to merge
-
createSegment
Create a segment topic on the broker that owns its namespace bundle. Optionally creates subscriptions on the new segment.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscriptions- Optional list of subscription names to create at earliest position- Throws:
PulsarAdminException
-
createSegmentAsync
Create a segment topic asynchronously. -
terminateSegment
Terminate a segment topic so that no more messages can be published to it.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)- Throws:
PulsarAdminException
-
terminateSegmentAsync
Terminate a segment topic asynchronously. -
deleteSegment
Delete a segment topic.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)force- Force deletion even if topic has active producers/subscriptions- Throws:
PulsarAdminException
-
deleteSegmentAsync
Delete a segment topic asynchronously. -
createSegmentSubscriptionAsync
Create a subscription cursor on the given segment topic at the earliest position. The call routes to the broker that owns the segment.Used internally by
to fan a new scalable-topic subscription out across every active segment so a future consumer doesn't drop the backlog.invalid reference
ScalableTopicController- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscription- Subscription name
-
deleteSegmentSubscriptionAsync
Delete a subscription cursor on the given segment topic. The call routes to the broker that owns the segment.Used internally by
when a scalable-topic subscription is deleted, so no orphan cursors remain on any segment in the DAG.invalid reference
ScalableTopicController- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscription- Subscription name
-
getSegmentSubscriptionBacklogAsync
CompletableFuture<Long> getSegmentSubscriptionBacklogAsync(String segmentTopic, String subscription) Returns the number of unconsumed entries in the given subscription's cursor on the segment topic — i.e. the per-subscription backlog. The call routes to the broker that owns the segment topic, so it works whether the caller is colocated with the segment or not.Used internally by the
to detect when a sealed parent has been drained and its children can be unblocked. Callers can also use it for diagnostics; a returnedinvalid reference
SubscriptionCoordinator0on a sealed segment indicates the subscription has nothing left to consume there.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscription- Subscription name
-
seekSegmentSubscriptionAsync
CompletableFuture<Void> seekSegmentSubscriptionAsync(String segmentTopic, String subscription, long timestampMs) Reset the segment topic's subscription cursor to the given wall-clock timestamp. Routes to the broker that owns the segment topic.Used internally by the parent-topic seek operation in
: the controller classifies each segment by itsinvalid reference
ScalableTopicController[createdAtMs, sealedAtMs)window against the requested timestamp and dispatches per-segment seek / skip-all calls.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscription- Subscription nametimestampMs- Wall-clock millis since the unix epoch
-
clearSegmentSubscriptionBacklogAsync
CompletableFuture<Void> clearSegmentSubscriptionBacklogAsync(String segmentTopic, String subscription) Skip every undelivered message on the segment topic's subscription — advance the cursor to the end of the segment.- Parameters:
segmentTopic- Full segment topic name (segment://tenant/namespace/topic/descriptor)subscription- Subscription name
-