-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Avoid split non-existent bundle #25031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c08ff26
d582d6b
eeaaf73
ef61623
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1130,4 +1130,50 @@ public void testRemoveNonExistBundleData() | |
| assertFalse(bundlesAfterSplit.contains(bundleWillBeSplit.getBundleRange())); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRepeatSplitBundle() throws Exception { | ||
| final String cluster = "use"; | ||
| final String tenant = "my-tenant"; | ||
| final String namespace = "repeat-split-bundle"; | ||
| final String topicName = tenant + "/" + namespace + "/" + "topic"; | ||
| int bundleNumbers = 8; | ||
|
|
||
| admin1.clusters().createCluster(cluster, ClusterData.builder() | ||
| .serviceUrl(pulsar1.getWebServiceAddress()).build()); | ||
| admin1.tenants().createTenant(tenant, | ||
| new TenantInfoImpl(Sets.newHashSet("appid1", "appid2"), Sets.newHashSet(cluster))); | ||
| admin1.namespaces().createNamespace(tenant + "/" + namespace, bundleNumbers); | ||
|
|
||
| LoadData loadData = (LoadData) getField(primaryLoadManager, "loadData"); | ||
| LocalBrokerData localData = (LocalBrokerData) getField(primaryLoadManager, "localData"); | ||
|
|
||
| @Cleanup | ||
| PulsarClient pulsarClient = PulsarClient.builder().serviceUrl(pulsar1.getBrokerServiceUrl()).build(); | ||
|
|
||
| // create a lot of topic to fully distributed among bundles. | ||
| for (int i = 0; i < 10; i++) { | ||
| String topicNameI = topicName + i; | ||
| admin1.topics().createPartitionedTopic(topicNameI, 20); | ||
| // trigger bundle assignment | ||
|
|
||
| pulsarClient.newConsumer().topic(topicNameI) | ||
| .subscriptionName("my-subscriber-name2").subscribe(); | ||
|
Comment on lines
+1159
to
+1160
|
||
| } | ||
|
|
||
| String topicToFindBundle = topicName + 0; | ||
| NamespaceBundle realBundle = pulsar1.getNamespaceService().getBundle(TopicName.get(topicToFindBundle)); | ||
| String bundleKey = realBundle.toString(); | ||
| log.info("Before bundle={}", bundleKey); | ||
|
|
||
| NamespaceBundleStats stats = new NamespaceBundleStats(); | ||
| stats.msgRateIn = 100000.0; | ||
| localData.getLastStats().put(bundleKey, stats); | ||
| pulsar1.getBrokerService().updateRates(); | ||
|
|
||
| primaryLoadManager.updateAll(); | ||
|
|
||
| primaryLoadManager.updateAll(); | ||
| Assert.assertFalse(loadData.getBundleData().containsKey(bundleKey)); | ||
|
Comment on lines
+1173
to
+1176
|
||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be modified. Small problem.