Skip to content

Commit 22a9023

Browse files
[cleanup][broker] Remove warn logs when changing the state from Owned to Free (Extensible LB) (apache#22708)
1 parent 361156e commit 22a9023

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

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

+9-27
Original file line numberDiff line numberDiff line change
@@ -1284,34 +1284,16 @@ private void scheduleCleanup(String broker, long delayInSecs) {
12841284
}
12851285

12861286

1287-
private ServiceUnitStateData getOverrideInactiveBrokerStateData(ServiceUnitStateData orphanData,
1288-
Optional<String> selectedBroker,
1289-
String inactiveBroker) {
1290-
1291-
1292-
if (selectedBroker.isEmpty()) {
1293-
return new ServiceUnitStateData(Free, null, inactiveBroker,
1294-
true, getNextVersionId(orphanData));
1295-
}
1296-
1297-
if (orphanData.state() == Splitting) {
1298-
return new ServiceUnitStateData(Splitting, orphanData.dstBroker(), selectedBroker.get(),
1299-
Map.copyOf(orphanData.splitServiceUnitToDestBroker()),
1300-
true, getNextVersionId(orphanData));
1301-
} else {
1302-
return new ServiceUnitStateData(Owned, selectedBroker.get(), inactiveBroker,
1303-
true, getNextVersionId(orphanData));
1304-
}
1305-
}
1306-
13071287
private void overrideOwnership(String serviceUnit, ServiceUnitStateData orphanData, String inactiveBroker) {
1308-
Optional<String> selectedBroker = selectBroker(serviceUnit, inactiveBroker);
1309-
if (selectedBroker.isEmpty()) {
1310-
log.warn("Empty selected broker for ownership serviceUnit:{} orphanData:{}."
1311-
+ "totalCleanupErrorCnt:{}",
1312-
serviceUnit, orphanData, totalCleanupErrorCnt.incrementAndGet());
1313-
}
1314-
var override = getOverrideInactiveBrokerStateData(orphanData, selectedBroker, inactiveBroker);
1288+
final var version = getNextVersionId(orphanData);
1289+
final var override = selectBroker(serviceUnit, inactiveBroker).map(selectedBroker -> {
1290+
if (orphanData.state() == Splitting) {
1291+
return new ServiceUnitStateData(Splitting, orphanData.dstBroker(), selectedBroker,
1292+
Map.copyOf(orphanData.splitServiceUnitToDestBroker()), true, version);
1293+
} else {
1294+
return new ServiceUnitStateData(Owned, selectedBroker, inactiveBroker, true, version);
1295+
}
1296+
}).orElseGet(() -> new ServiceUnitStateData(Free, null, inactiveBroker, true, version));
13151297
log.info("Overriding ownership serviceUnit:{} from orphanData:{} to overrideData:{}",
13161298
serviceUnit, orphanData, override);
13171299
publishOverrideEventAsync(serviceUnit, orphanData, override)

0 commit comments

Comments
 (0)