Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5077bf7

Browse files
committedMar 15, 2023
Address comments
1 parent 7080399 commit 5077bf7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
 

‎pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateData.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public ServiceUnitStateData(ServiceUnitState state, String dstBroker, String sou
4646
}
4747

4848
public ServiceUnitStateData(ServiceUnitState state, String dstBroker, String sourceBroker, long versionId) {
49-
this(state, dstBroker, sourceBroker, Map.of(), false, System.currentTimeMillis(), versionId);
49+
this(state, dstBroker, sourceBroker, null, false, System.currentTimeMillis(), versionId);
5050
}
5151

5252
public ServiceUnitStateData(ServiceUnitState state, String dstBroker, long versionId) {
53-
this(state, dstBroker, null, Map.of(), false, System.currentTimeMillis(), versionId);
53+
this(state, dstBroker, null, null, false, System.currentTimeMillis(), versionId);
5454
}
5555

5656
public ServiceUnitStateData(ServiceUnitState state, String dstBroker, boolean force, long versionId) {
57-
this(state, dstBroker, null, Map.of(), force, System.currentTimeMillis(), versionId);
57+
this(state, dstBroker, null, null, force, System.currentTimeMillis(), versionId);
5858
}
5959

6060
public static ServiceUnitState state(ServiceUnitStateData data) {

‎pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,22 @@ public void testSplitBundleAdminAPI() throws Exception {
385385
admin.topics().createPartitionedTopic(topic, 10);
386386
BundlesData bundles = admin.namespaces().getBundles(namespace);
387387
int numBundles = bundles.getNumBundles();
388+
var bundleRanges = bundles.getBoundaries().stream().map(Long::decode).sorted().toList();
389+
390+
String firstBundle = bundleRanges.get(0) + "_" + bundleRanges.get(1);
388391

389-
String firstBundle = bundles.getBoundaries().get(0) + "_" + bundles.getBoundaries().get(1);
392+
long mid = bundleRanges.get(0) + (bundleRanges.get(1) - bundleRanges.get(0)) / 2;
390393

391394
admin.namespaces().splitNamespaceBundle(namespace, firstBundle, true, null);
392395

393-
assertEquals(admin.namespaces().getBundles(namespace).getNumBundles(), numBundles + 1);
396+
BundlesData bundlesData = admin.namespaces().getBundles(namespace);
397+
assertEquals(bundlesData.getNumBundles(), numBundles + 1);
398+
String lowBundle = String.format("0x%08x", bundleRanges.get(0));
399+
String midBundle = String.format("0x%08x", mid);
400+
String highBundle = String.format("0x%08x", bundleRanges.get(1));
401+
assertTrue(bundlesData.getBoundaries().contains(lowBundle));
402+
assertTrue(bundlesData.getBoundaries().contains(midBundle));
403+
assertTrue(bundlesData.getBoundaries().contains(highBundle));
394404

395405
// Test split bundle with invalid bundle range.
396406
try {

0 commit comments

Comments
 (0)
Please sign in to comment.