use of com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget.State in project titus-control-plane by Netflix.
the class DefaultLoadBalancerReconciler method updatesForRemovedLoadBalancer.
private ReconciliationUpdates updatesForRemovedLoadBalancer(LoadBalancerWithKnownTargets loadBalancer, List<JobLoadBalancerState> associations) {
logger.warn("Load balancer is gone, ignoring its associations (marking them to be GCed later), and removing known state for its targets: {}", loadBalancer.current.getId());
for (JobLoadBalancerState association : associations) {
if (association.isStateAssociated()) {
logger.info("Marking association as orphan: {}", association.getJobLoadBalancer());
markedAsOrphan.add(association.getJobLoadBalancer());
}
}
// we will force deregistration of everything that was marked as REGISTERED to force its state to be updated
Map<Boolean, Set<LoadBalancerTarget>> registeredOrNot = loadBalancer.knownTargets.stream().collect(partitioningBy(target -> target.getState().equals(State.REGISTERED), mapping(LoadBalancerTargetState::getLoadBalancerTarget, Collectors.toSet())));
// all REGISTERED
Set<LoadBalancerTarget> toDeregister = registeredOrNot.get(true);
// all DEREGISTERED
Set<LoadBalancerTarget> toRemove = registeredOrNot.get(false);
return new ReconciliationUpdates(loadBalancer.current.getId(), Collections.emptySet(), toDeregister, toRemove);
}
Aggregations