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);
}
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);
}
}
}
}
}
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;
}
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;
}
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;
}
Aggregations