use of org.onosproject.incubator.net.tunnel.TunnelSubscription in project onos by opennetworkinglab.
the class DistributedTunnelStore method borrowTunnel.
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId appId, TunnelName tunnelName, Annotations... annotations) {
Set<TunnelSubscription> orderSet = orderRelationship.get(appId);
if (orderSet == null) {
orderSet = new HashSet<TunnelSubscription>();
}
TunnelSubscription order = new TunnelSubscription(appId, null, null, null, null, tunnelName, annotations);
boolean isExist = orderSet.contains(order);
Set<TunnelId> idSet = tunnelNameAsKeyMap.get(tunnelName);
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);
}
}
if (!tunnelSet.isEmpty() && !isExist) {
orderSet.add(order);
orderRelationship.put(appId, orderSet);
}
return tunnelSet;
}
use of org.onosproject.incubator.net.tunnel.TunnelSubscription in project onos by opennetworkinglab.
the class TunnelQuerySubscriptionCommand method doExecute.
@Override
protected void doExecute() {
TunnelService service = get(TunnelService.class);
ApplicationId applicationId = new DefaultApplicationId(1, consumerId);
Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId);
for (TunnelSubscription order : tunnelSet) {
print(FMT, order.consumerId(), order.src(), order.dst(), order.type(), order.tunnelId());
}
}
use of org.onosproject.incubator.net.tunnel.TunnelSubscription 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.TunnelSubscription in project onos by opennetworkinglab.
the class DistributedTunnelStore method activate.
@Activate
public void activate() {
KryoNamespace.Builder serializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(MultiValuedTimestamp.class);
tunnelIdAsKeyStore = storageService.<TunnelId, Tunnel>eventuallyConsistentMapBuilder().withName("all_tunnel").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
orderRelationship = storageService.<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder().withName("type_tunnel").withSerializer(serializer).withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
idGenerator = coreService.getIdGenerator(tunnelOpTopic);
tunnelIdAsKeyStore.addListener(tunnelUpdateListener);
log.info("Started");
}
use of org.onosproject.incubator.net.tunnel.TunnelSubscription 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;
}
Aggregations