Search in sources :

Example 1 with State

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);
}
Also used : Completable(rx.Completable) Collectors.partitioningBy(java.util.stream.Collectors.partitioningBy) LoadBalancerConnector(com.netflix.titus.api.connector.cloud.LoadBalancerConnector) JobLoadBalancerState(com.netflix.titus.api.loadbalancer.model.JobLoadBalancerState) LoadBalancerTargetState(com.netflix.titus.api.loadbalancer.model.LoadBalancerTargetState) CollectionsExt(com.netflix.titus.common.util.CollectionsExt) Counter(com.netflix.spectator.api.Counter) LoggerFactory(org.slf4j.LoggerFactory) ContinuousSubscriptionMetrics(com.netflix.titus.common.util.spectator.ContinuousSubscriptionMetrics) ReactorExt(com.netflix.titus.common.util.rx.ReactorExt) Supplier(java.util.function.Supplier) Id(com.netflix.spectator.api.Id) JobNotFound(com.netflix.titus.api.jobmanager.service.JobManagerException.ErrorCode.JobNotFound) ConcurrentMap(java.util.concurrent.ConcurrentMap) Observable(rx.Observable) SpectatorExt(com.netflix.titus.common.util.spectator.SpectatorExt) Duration(java.time.Duration) Map(java.util.Map) Collectors.mapping(java.util.stream.Collectors.mapping) Schedulers(rx.schedulers.Schedulers) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException) BasicTag(com.netflix.spectator.api.BasicTag) State(com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget.State) METRIC_LOADBALANCER(com.netflix.titus.master.MetricConstants.METRIC_LOADBALANCER) LoadBalancerTarget(com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget) LoadBalancerStore(com.netflix.titus.api.loadbalancer.store.LoadBalancerStore) Logger(org.slf4j.Logger) JobLoadBalancer(com.netflix.titus.api.loadbalancer.model.JobLoadBalancer) Priority(com.netflix.titus.common.util.rx.batch.Priority) Tag(com.netflix.spectator.api.Tag) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Instant(java.time.Instant) LoadBalancer(com.netflix.titus.api.connector.cloud.LoadBalancer) Scheduler(rx.Scheduler) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Registry(com.netflix.spectator.api.Registry) PolledMeter(com.netflix.spectator.api.patterns.PolledMeter) Collections(java.util.Collections) ObservableExt(com.netflix.titus.common.util.rx.ObservableExt) Set(java.util.Set) JobLoadBalancerState(com.netflix.titus.api.loadbalancer.model.JobLoadBalancerState) LoadBalancerTargetState(com.netflix.titus.api.loadbalancer.model.LoadBalancerTargetState) LoadBalancerTarget(com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget)

Aggregations

Sets (com.google.common.collect.Sets)1 BasicTag (com.netflix.spectator.api.BasicTag)1 Counter (com.netflix.spectator.api.Counter)1 Id (com.netflix.spectator.api.Id)1 Registry (com.netflix.spectator.api.Registry)1 Tag (com.netflix.spectator.api.Tag)1 PolledMeter (com.netflix.spectator.api.patterns.PolledMeter)1 LoadBalancer (com.netflix.titus.api.connector.cloud.LoadBalancer)1 LoadBalancerConnector (com.netflix.titus.api.connector.cloud.LoadBalancerConnector)1 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)1 JobNotFound (com.netflix.titus.api.jobmanager.service.JobManagerException.ErrorCode.JobNotFound)1 JobLoadBalancer (com.netflix.titus.api.loadbalancer.model.JobLoadBalancer)1 JobLoadBalancerState (com.netflix.titus.api.loadbalancer.model.JobLoadBalancerState)1 LoadBalancerTarget (com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget)1 State (com.netflix.titus.api.loadbalancer.model.LoadBalancerTarget.State)1 LoadBalancerTargetState (com.netflix.titus.api.loadbalancer.model.LoadBalancerTargetState)1 LoadBalancerStore (com.netflix.titus.api.loadbalancer.store.LoadBalancerStore)1 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)1 ObservableExt (com.netflix.titus.common.util.rx.ObservableExt)1 ReactorExt (com.netflix.titus.common.util.rx.ReactorExt)1