Search in sources :

Example 11 with Tunnel

use of org.onosproject.incubator.net.tunnel.Tunnel in project onos by opennetworkinglab.

the class TunnelManager method updateTunnelState.

@Override
public void updateTunnelState(Tunnel tunnel, State state) {
    Tunnel storedTunnel = store.queryTunnel(tunnel.tunnelId());
    store.createOrUpdateTunnel(storedTunnel, state);
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel)

Example 12 with Tunnel

use of org.onosproject.incubator.net.tunnel.Tunnel in project onos by opennetworkinglab.

the class TunnelManager method removeTunnels.

@Override
public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Type type, ProviderId producerName) {
    Collection<Tunnel> setTunnels = store.queryTunnel(src, dst);
    if (!setTunnels.isEmpty()) {
        store.deleteTunnel(src, dst, type, producerName);
        for (Tunnel tunnel : setTunnels) {
            if (producerName != null && !tunnel.providerId().equals(producerName) || !type.equals(tunnel.type())) {
                continue;
            }
            if (tunnel.providerId() != null) {
                TunnelProvider provider = getProvider(tunnel.providerId());
                if (provider != null) {
                    provider.releaseTunnel(tunnel);
                }
            } else {
                Set<ProviderId> ids = getProviders();
                for (ProviderId providerId : ids) {
                    TunnelProvider provider = getProvider(providerId);
                    provider.releaseTunnel(tunnel);
                }
            }
        }
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) TunnelProvider(org.onosproject.incubator.net.tunnel.TunnelProvider) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel)

Example 13 with Tunnel

use of org.onosproject.incubator.net.tunnel.Tunnel in project onos by opennetworkinglab.

the class DistributedTunnelStore method borrowTunnel.

@Override
public Tunnel borrowTunnel(ApplicationId appId, TunnelId tunnelId, Annotations... annotations) {
    Set<TunnelSubscription> orderSet = orderRelationship.get(appId);
    if (orderSet == null) {
        orderSet = new HashSet<TunnelSubscription>();
    }
    TunnelSubscription order = new TunnelSubscription(appId, null, null, tunnelId, null, null, annotations);
    Tunnel result = tunnelIdAsKeyStore.get(tunnelId);
    if (result == null || Tunnel.State.INACTIVE.equals(result.state())) {
        return null;
    }
    orderSet.add(order);
    orderRelationship.put(appId, orderSet);
    return result;
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) TunnelSubscription(org.onosproject.incubator.net.tunnel.TunnelSubscription)

Example 14 with Tunnel

use of org.onosproject.incubator.net.tunnel.Tunnel in project onos by opennetworkinglab.

the class DistributedTunnelStore method borrowTunnel.

@Override
public Collection<Tunnel> borrowTunnel(ApplicationId appId, TunnelEndPoint src, TunnelEndPoint dst, Type type, Annotations... annotations) {
    Set<TunnelSubscription> orderSet = orderRelationship.get(appId);
    if (orderSet == null) {
        orderSet = new HashSet<TunnelSubscription>();
    }
    TunnelSubscription order = new TunnelSubscription(appId, src, dst, null, type, null, annotations);
    boolean isExist = orderSet.contains(order);
    if (!isExist) {
        orderSet.add(order);
    }
    orderRelationship.put(appId, orderSet);
    TunnelKey key = TunnelKey.tunnelKey(src, dst);
    Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
    if (idSet == null || idSet.isEmpty()) {
        return Collections.emptySet();
    }
    Collection<Tunnel> tunnelSet = new HashSet<Tunnel>();
    for (TunnelId tunnelId : idSet) {
        Tunnel result = tunnelIdAsKeyStore.get(tunnelId);
        if (type.equals(result.type()) && Tunnel.State.ACTIVE.equals(result.state())) {
            tunnelSet.add(result);
        }
    }
    return tunnelSet;
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) TunnelSubscription(org.onosproject.incubator.net.tunnel.TunnelSubscription) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) HashSet(java.util.HashSet)

Example 15 with Tunnel

use of org.onosproject.incubator.net.tunnel.Tunnel in project onos by opennetworkinglab.

the class DistributedTunnelStore method borrowTunnel.

@Override
public Collection<Tunnel> borrowTunnel(ApplicationId appId, TunnelEndPoint src, TunnelEndPoint dst, Annotations... annotations) {
    Set<TunnelSubscription> orderSet = orderRelationship.get(appId);
    if (orderSet == null) {
        orderSet = new HashSet<TunnelSubscription>();
    }
    TunnelSubscription order = new TunnelSubscription(appId, src, dst, null, null, null, annotations);
    boolean isExist = orderSet.contains(order);
    if (!isExist) {
        orderSet.add(order);
    }
    orderRelationship.put(appId, orderSet);
    TunnelKey key = TunnelKey.tunnelKey(src, dst);
    Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
    if (idSet == null || idSet.isEmpty()) {
        return Collections.emptySet();
    }
    Collection<Tunnel> tunnelSet = new HashSet<Tunnel>();
    for (TunnelId tunnelId : idSet) {
        Tunnel result = tunnelIdAsKeyStore.get(tunnelId);
        if (Tunnel.State.ACTIVE.equals(result.state())) {
            tunnelSet.add(result);
        }
    }
    return tunnelSet;
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) TunnelSubscription(org.onosproject.incubator.net.tunnel.TunnelSubscription) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) HashSet(java.util.HashSet)

Aggregations

Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)23 DefaultTunnel (org.onosproject.incubator.net.tunnel.DefaultTunnel)18 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)15 ProviderId (org.onosproject.net.provider.ProviderId)12 TunnelProvider (org.onosproject.incubator.net.tunnel.TunnelProvider)9 HashSet (java.util.HashSet)5 DefaultOpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint)5 IpTunnelEndPoint (org.onosproject.incubator.net.tunnel.IpTunnelEndPoint)5 OpticalTunnelEndPoint (org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint)5 TunnelEndPoint (org.onosproject.incubator.net.tunnel.TunnelEndPoint)5 TunnelEvent (org.onosproject.incubator.net.tunnel.TunnelEvent)4 TunnelService (org.onosproject.incubator.net.tunnel.TunnelService)4 TunnelSubscription (org.onosproject.incubator.net.tunnel.TunnelSubscription)4 ArrayList (java.util.ArrayList)2 ApplicationId (org.onosproject.core.ApplicationId)2 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)2 DefaultTunnelDescription (org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)2 TunnelDescription (org.onosproject.incubator.net.tunnel.TunnelDescription)2 TunnelName (org.onosproject.incubator.net.tunnel.TunnelName)2 SparseAnnotations (org.onosproject.net.SparseAnnotations)2