@@ -1284,34 +1284,16 @@ private void scheduleCleanup(String broker, long delayInSecs) {
1284
1284
}
1285
1285
1286
1286
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
-
1307
1287
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 ));
1315
1297
log .info ("Overriding ownership serviceUnit:{} from orphanData:{} to overrideData:{}" ,
1316
1298
serviceUnit , orphanData , override );
1317
1299
publishOverrideEventAsync (serviceUnit , orphanData , override )
0 commit comments