Search in sources :

Example 1 with XconnectLoadBalancerEndpoint

use of org.onosproject.segmentrouting.xconnect.api.XconnectLoadBalancerEndpoint in project trellis-control by opennetworkinglab.

the class XconnectManager method revokeNext.

/**
 * Revokes next objectives for given XConnect.
 *
 * @param key        XConnect store key
 * @param endpoints  XConnect endpoints
 * @param nextId     next objective id
 * @param nextFuture completable future for this next objective operation
 */
private void revokeNext(XconnectKey key, Set<XconnectEndpoint> endpoints, int nextId, CompletableFuture<ObjectiveError> nextFuture) {
    ObjectiveContext context = new ObjectiveContext() {

        @Override
        public void onSuccess(Objective objective) {
            log.debug("Previous NextObj for {} removed", key);
            if (nextFuture != null) {
                nextFuture.complete(null);
            }
        }

        @Override
        public void onError(Objective objective, ObjectiveError error) {
            log.warn("Failed to remove previous NextObj for {}: {}", key, error);
            if (nextFuture != null) {
                nextFuture.complete(error);
            }
            srService.invalidateNextObj(objective.id());
        }
    };
    NextObjective.Builder nextObjBuilder = nextObjBuilder(key, endpoints, nextId);
    if (nextObjBuilder == null) {
        log.warn("Fail to revokeNext {}: {}", key, ERROR_NEXT_OBJ_BUILDER);
        return;
    }
    // Release the port load balancer if present
    endpoints.stream().filter(endpoint -> endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER).forEach(endpoint -> {
        String portLoadBalancerKey = String.valueOf(((XconnectLoadBalancerEndpoint) endpoint).key());
        portLoadBalancerService.release(new PortLoadBalancerId(key.deviceId(), Integer.parseInt(portLoadBalancerKey)), appId);
    });
    flowObjectiveService.next(key.deviceId(), nextObjBuilder.remove(context));
    xconnectNextObjStore.remove(key);
}
Also used : DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) ConsistentMap(org.onosproject.store.service.ConsistentMap) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) XconnectService(org.onosproject.segmentrouting.xconnect.api.XconnectService) HostLocation(org.onosproject.net.HostLocation) CoreService(org.onosproject.core.CoreService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) XconnectKey(org.onosproject.segmentrouting.xconnect.api.XconnectKey) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) StorageService(org.onosproject.store.service.StorageService) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) Port(org.onosproject.net.Port) ApplicationId(org.onosproject.core.ApplicationId) NextObjective(org.onosproject.net.flowobjective.NextObjective) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) Serializer(org.onosproject.store.service.Serializer) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) XconnectDesc(org.onosproject.segmentrouting.xconnect.api.XconnectDesc) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) XconnectLoadBalancerEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectLoadBalancerEndpoint) Versioned(org.onosproject.store.service.Versioned) List(java.util.List) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) DeviceId(org.onosproject.net.DeviceId) NextTreatment(org.onosproject.net.flowobjective.NextTreatment) Host(org.onosproject.net.Host) DefaultNextTreatment(org.onosproject.net.flowobjective.DefaultNextTreatment) VlanNextObjectiveStoreKey(org.onosproject.segmentrouting.storekey.VlanNextObjectiveStoreKey) PortLoadBalancerService(org.onosproject.portloadbalancer.api.PortLoadBalancerService) SegmentRoutingDeviceConfig(org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig) CompletableFuture(java.util.concurrent.CompletableFuture) KryoNamespace(org.onlab.util.KryoNamespace) HostListener(org.onosproject.net.host.HostListener) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) MapEventListener(org.onosproject.store.service.MapEventListener) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) SegmentRoutingService(org.onosproject.segmentrouting.SegmentRoutingService) Component(org.osgi.service.component.annotations.Component) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BiConsumer(java.util.function.BiConsumer) HostEvent(org.onosproject.net.host.HostEvent) Activate(org.osgi.service.component.annotations.Activate) Criteria(org.onosproject.net.flow.criteria.Criteria) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ExecutorService(java.util.concurrent.ExecutorService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) RemovalNotification(com.google.common.cache.RemovalNotification) DeviceListener(org.onosproject.net.device.DeviceListener) XconnectEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectEndpoint) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PortLoadBalancerEvent(org.onosproject.portloadbalancer.api.PortLoadBalancerEvent) XconnectCodec(org.onosproject.segmentrouting.xconnect.api.XconnectCodec) VlanId(org.onlab.packet.VlanId) CodecService(org.onosproject.codec.CodecService) IdNextTreatment(org.onosproject.net.flowobjective.IdNextTreatment) XconnectPortEndpoint(org.onosproject.segmentrouting.xconnect.api.XconnectPortEndpoint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) PortLoadBalancerListener(org.onosproject.portloadbalancer.api.PortLoadBalancerListener) MapEvent(org.onosproject.store.service.MapEvent) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Cache(com.google.common.cache.Cache) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DefaultNextObjective(org.onosproject.net.flowobjective.DefaultNextObjective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) PortLoadBalancerId(org.onosproject.portloadbalancer.api.PortLoadBalancerId) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError)

Aggregations

Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Serializable (java.io.Serializable)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Executors.newScheduledThreadPool (java.util.concurrent.Executors.newScheduledThreadPool)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1