* ONAP
* ================================================================================
* Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Any state in which events are being processed locally and forwarded, as appropriate.
*/
+@Setter
@Getter
public class ProcessingState extends State {
* Current known leader, never {@code null}.
*/
@NonNull
- @Setter
private String leader;
/**
* leader. Never {@code null}
* @throws IllegalArgumentException if an argument is invalid
*/
- public ProcessingState(PoolingManager mgr, String leader) {
+ public ProcessingState(PoolingManager mgr, @NonNull String leader) {
super(mgr);
- if (leader == null) {
- throw new IllegalArgumentException("null leader");
- }
-
BucketAssignments assignments = mgr.getAssignments();
if (assignments != null) {
for (Integer index : buckets) {
// add it to the host with the shortest bucket list
HostBucket newhb = assignments.pollFirst();
+ assert newhb != null;
newhb.add(index);
// put the item back into the queue, with its new count
HostBucket smaller = assignments.pollFirst();
HostBucket larger = assignments.pollLast();
+ assert larger != null && smaller != null;
if (larger.size() - smaller.size() <= 1) {
// it's as balanced as it will get
break;