Search in sources :

Example 1 with TunnelEvent

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

the class DistributedTunnelStore method deleteTunnel.

@Override
public void deleteTunnel(TunnelEndPoint src, TunnelEndPoint dst, ProviderId producerName) {
    TunnelKey key = TunnelKey.tunnelKey(src, dst);
    Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
    if (idSet == null) {
        return;
    }
    Tunnel deletedTunnel = null;
    TunnelEvent event = null;
    List<TunnelEvent> ls = new ArrayList<TunnelEvent>();
    for (TunnelId id : idSet) {
        deletedTunnel = tunnelIdAsKeyStore.get(id);
        if (producerName == null || producerName.equals(deletedTunnel.providerId())) {
            tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId());
            event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, deletedTunnel);
            ls.add(event);
        }
    }
    if (!ls.isEmpty()) {
        notifyDelegate(ls);
    }
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) ArrayList(java.util.ArrayList) TunnelEvent(org.onosproject.incubator.net.tunnel.TunnelEvent) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Example 2 with TunnelEvent

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

the class DistributedTunnelStore method deleteTunnel.

@Override
public void deleteTunnel(TunnelEndPoint src, TunnelEndPoint dst, Type type, ProviderId producerName) {
    TunnelKey key = TunnelKey.tunnelKey(src, dst);
    Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
    if (idSet == null) {
        return;
    }
    Tunnel deletedTunnel = null;
    TunnelEvent event = null;
    List<TunnelEvent> ls = new ArrayList<TunnelEvent>();
    for (TunnelId id : idSet) {
        deletedTunnel = tunnelIdAsKeyStore.get(id);
        if (type.equals(deletedTunnel.type()) && (producerName == null || producerName.equals(deletedTunnel.providerId()))) {
            tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId());
            event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, deletedTunnel);
            ls.add(event);
        }
    }
    if (!ls.isEmpty()) {
        notifyDelegate(ls);
    }
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) ArrayList(java.util.ArrayList) TunnelEvent(org.onosproject.incubator.net.tunnel.TunnelEvent) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Example 3 with TunnelEvent

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

the class DistributedTunnelStore method deleteTunnel.

@Override
public void deleteTunnel(TunnelId tunnelId) {
    Tunnel deletedTunnel = tunnelIdAsKeyStore.get(tunnelId);
    if (deletedTunnel == null) {
        return;
    }
    tunnelIdAsKeyStore.remove(tunnelId);
    TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, deletedTunnel);
    notifyDelegate(event);
}
Also used : Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) TunnelEvent(org.onosproject.incubator.net.tunnel.TunnelEvent)

Example 4 with TunnelEvent

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

the class DistributedTunnelStore method handleCreateOrUpdateTunnel.

private TunnelId handleCreateOrUpdateTunnel(Tunnel tunnel, State state) {
    // tunnelIdAsKeyStore.
    if (tunnel.tunnelId() != null && !"".equals(tunnel.tunnelId().toString())) {
        Tunnel old = tunnelIdAsKeyStore.get(tunnel.tunnelId());
        if (old == null) {
            log.info("This tunnel[" + tunnel.tunnelId() + "] is not available.");
            return tunnel.tunnelId();
        }
        DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations();
        SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations();
        State newTunnelState = (state != null) ? state : old.state();
        Tunnel newT = new DefaultTunnel(old.providerId(), old.src(), old.dst(), old.type(), newTunnelState, old.groupId(), old.tunnelId(), old.tunnelName(), old.path(), old.resource(), DefaultAnnotations.merge(oldAnno, newAnno));
        tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT);
        TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_UPDATED, tunnel);
        notifyDelegate(event);
        return tunnel.tunnelId();
    } else {
        TunnelId tunnelId = TunnelId.valueOf(String.valueOf(idGenerator.getNewId()));
        State tunnelState = (state != null) ? state : tunnel.state();
        Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(), tunnelState, tunnel.groupId(), tunnelId, tunnel.tunnelName(), tunnel.path(), tunnel.resource(), tunnel.annotations());
        tunnelIdAsKeyStore.put(tunnelId, newT);
        TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
        notifyDelegate(event);
        return tunnelId;
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) Tunnel(org.onosproject.incubator.net.tunnel.Tunnel) DefaultTunnel(org.onosproject.incubator.net.tunnel.DefaultTunnel) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) State(org.onosproject.incubator.net.tunnel.Tunnel.State) TunnelEvent(org.onosproject.incubator.net.tunnel.TunnelEvent) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId)

Aggregations

DefaultTunnel (org.onosproject.incubator.net.tunnel.DefaultTunnel)4 Tunnel (org.onosproject.incubator.net.tunnel.Tunnel)4 TunnelEvent (org.onosproject.incubator.net.tunnel.TunnelEvent)4 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)3 ArrayList (java.util.ArrayList)2 State (org.onosproject.incubator.net.tunnel.Tunnel.State)1 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)1 SparseAnnotations (org.onosproject.net.SparseAnnotations)1